Skip to content

Commit 9c44b30

Browse files
committed
simplify logic #10517
1 parent d865521 commit 9c44b30

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,13 @@ public Dataset parseDataset(JsonObject obj) throws JsonParseException {
332332
}else {
333333
throw new JsonParseException("Specified metadatalanguage not allowed.");
334334
}
335-
DatasetType defaultDatasetType = datasetTypeService.getByName(DatasetType.DEFAULT_DATASET_TYPE);
336-
String datasetTypeIn = obj.getString("datasetType", null);
335+
String datasetTypeIn = obj.getString("datasetType", DatasetType.DEFAULT_DATASET_TYPE);
337336
logger.fine("datasetTypeIn: " + datasetTypeIn);
338-
if (datasetTypeIn == null) {
339-
dataset.setDatasetType(defaultDatasetType);
337+
DatasetType datasetType = datasetTypeService.getByName(datasetTypeIn);
338+
if (datasetType != null) {
339+
dataset.setDatasetType(datasetType);
340340
} else {
341-
DatasetType datasetType = datasetTypeService.getByName(datasetTypeIn);
342-
if (datasetType != null) {
343-
dataset.setDatasetType(datasetType);
344-
} else {
345-
throw new JsonParseException("Invalid dataset type: " + datasetTypeIn);
346-
}
341+
throw new JsonParseException("Invalid dataset type: " + datasetTypeIn);
347342
}
348343

349344
DatasetVersion dsv = new DatasetVersion();

0 commit comments

Comments
 (0)