Updated approved site API for error handling
parent
435fff3b1c
commit
218fe9328c
|
@ -59,10 +59,14 @@ public class ApprovedSiteAPI {
|
|||
if (approvedSite == null) {
|
||||
logger.error("deleteApprovedSite failed; no approved site found for id: " + id);
|
||||
m.put("code", HttpStatus.NOT_FOUND);
|
||||
m.put("entity", "An error occurred while processing your request - no approved site found for id: " + id);
|
||||
return "jsonEntityView";
|
||||
} else if (!approvedSite.getUserId().equals(p.getName())) {
|
||||
logger.error("deleteApprovedSite failed; principal "
|
||||
+ p.getName() + " does not own approved site" + id);
|
||||
m.put("code", HttpStatus.FORBIDDEN);
|
||||
m.put("entity", "An error occurred while processing your request - you do not have permission to delete this approved site");
|
||||
return "jsonEntityView";
|
||||
} else {
|
||||
m.put("code", HttpStatus.OK);
|
||||
approvedSiteService.remove(approvedSite);
|
||||
|
|
|
@ -129,7 +129,22 @@ var ApprovedSiteView = Backbone.View.extend({
|
|||
app.approvedSiteListView.togglePlaceholder();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
error:function (error, response) {
|
||||
|
||||
//Pull out the response text.
|
||||
var responseText = JSON.parse(response.responseText);
|
||||
|
||||
//Display an alert with an error message
|
||||
$('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>");
|
||||
|
||||
$("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog
|
||||
"backdrop" : "static",
|
||||
"keyboard" : true,
|
||||
"show" : true // ensure the modal is shown immediately
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
app.approvedSiteListView.delegateEvents();
|
||||
|
|
Loading…
Reference in New Issue