Skip to content

Commit

Permalink
#3599 use String builder for parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jun 22, 2018
1 parent 63ffdae commit 882566c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,20 +670,20 @@ private Response processDatasetUpdate(String jsonBody, String id, DataverseReque
}
}

private void validateDatasetFieldValues(List<DatasetField> fields) throws JsonParseException {
String errors = "";
private void validateDatasetFieldValues(List<DatasetField> fields) throws JsonParseException {
StringBuilder error = new StringBuilder();

for (DatasetField dsf : fields) {
if (dsf.getDatasetFieldType().isAllowMultiples() && dsf.getControlledVocabularyValues().isEmpty()
&& dsf.getDatasetFieldCompoundValues().isEmpty() && dsf.getDatasetFieldValues().isEmpty()) {
errors += "Empty multiple value for field " + dsf.getDatasetFieldType().getDisplayName() + " ";
error.append("Empty multiple value for field ").append(dsf.getDatasetFieldType().getDisplayName()).append(" ");
} else if (!dsf.getDatasetFieldType().isAllowMultiples() && dsf.getSingleValue().getValue().isEmpty()) {
errors += "Empty value for field " + dsf.getDatasetFieldType().getDisplayName() + " ";
error.append("Empty value for field ").append(dsf.getDatasetFieldType().getDisplayName()).append(" ");
}
}

if (!errors.isEmpty()) {
throw new JsonParseException(errors);
if (!error.toString().isEmpty()) {
throw new JsonParseException(error.toString());
}
}

Expand Down

0 comments on commit 882566c

Please sign in to comment.