Skip to content

Commit

Permalink
#3599 Post update/delete errors to log
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jun 29, 2018
1 parent dc979d1 commit 48ed4e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ private Response processDatasetFieldDataDelete(String jsonBody, String id, Datav
}
}
if (!found) {
logger.log(Level.SEVERE, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + cvv.getStrValue() + " not found.");
return error(Response.Status.BAD_REQUEST, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + cvv.getStrValue() + " not found.");
}
}
Expand All @@ -486,6 +487,7 @@ private Response processDatasetFieldDataDelete(String jsonBody, String id, Datav
}
}
if (!found) {
logger.log(Level.SEVERE, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + dfv.getDisplayValue() + " not found.");
return error(Response.Status.BAD_REQUEST, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + dfv.getDisplayValue() + " not found.");
}
}
Expand Down Expand Up @@ -513,7 +515,8 @@ private Response processDatasetFieldDataDelete(String jsonBody, String id, Datav
datasetFieldCompoundValueItemsToRemove.forEach((remove) -> {
dsf.getDatasetFieldCompoundValues().remove(remove);
});
if (!found) {
if (!found) {
logger.log(Level.SEVERE, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + deleteVal + " not found.");
return error(Response.Status.BAD_REQUEST, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + deleteVal + " not found.");
}
}
Expand All @@ -529,6 +532,7 @@ private Response processDatasetFieldDataDelete(String jsonBody, String id, Datav
}
if (!found){
String displayValue = !updateField.getDisplayValue().isEmpty() ? updateField.getDisplayValue() : updateField.getCompoundDisplayValue();
logger.log(Level.SEVERE, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + displayValue + " not found." );
return error(Response.Status.BAD_REQUEST, "Delete metadata failed: " + updateField.getDatasetFieldType().getDisplayName() + ": " + displayValue + " not found." );
}
}
Expand All @@ -546,6 +550,7 @@ private Response processDatasetFieldDataDelete(String jsonBody, String id, Datav
return error(Response.Status.BAD_REQUEST, "Error processing metadata delete: " + ex.getMessage());

} catch (WrappedResponse ex) {
logger.log(Level.SEVERE, "Delete metadata error: " + ex.getMessage(), ex);
return ex.getResponse();

}
Expand Down Expand Up @@ -677,6 +682,7 @@ private Response processDatasetUpdate(String jsonBody, String id, DataverseReque
return error(Response.Status.BAD_REQUEST, "Error parsing dataset update: " + ex.getMessage());

} catch (WrappedResponse ex) {
logger.log(Level.SEVERE, "Update metdata error: " + ex.getMessage(), ex);
return ex.getResponse();

}
Expand Down

0 comments on commit 48ed4e3

Please sign in to comment.