Skip to content

Commit

Permalink
simplify logic #10517
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Aug 22, 2024
1 parent d865521 commit 9c44b30
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,13 @@ public Dataset parseDataset(JsonObject obj) throws JsonParseException {
}else {
throw new JsonParseException("Specified metadatalanguage not allowed.");
}
DatasetType defaultDatasetType = datasetTypeService.getByName(DatasetType.DEFAULT_DATASET_TYPE);
String datasetTypeIn = obj.getString("datasetType", null);
String datasetTypeIn = obj.getString("datasetType", DatasetType.DEFAULT_DATASET_TYPE);
logger.fine("datasetTypeIn: " + datasetTypeIn);
if (datasetTypeIn == null) {
dataset.setDatasetType(defaultDatasetType);
DatasetType datasetType = datasetTypeService.getByName(datasetTypeIn);
if (datasetType != null) {
dataset.setDatasetType(datasetType);
} else {
DatasetType datasetType = datasetTypeService.getByName(datasetTypeIn);
if (datasetType != null) {
dataset.setDatasetType(datasetType);
} else {
throw new JsonParseException("Invalid dataset type: " + datasetTypeIn);
}
throw new JsonParseException("Invalid dataset type: " + datasetTypeIn);
}

DatasetVersion dsv = new DatasetVersion();
Expand Down

0 comments on commit 9c44b30

Please sign in to comment.