use of org.alfresco.service.cmr.repository.DeleteLinksStatusReport in project alfresco-remote-api by Alfresco.
the class DocLinksDelete method executeImpl.
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
NodeRef destinationNodeRef = null;
/* Parse the template vars */
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
destinationNodeRef = parseNodeRefFromTemplateArgs(templateVars);
/* Delete links */
DeleteLinksStatusReport report;
try {
report = documentLinkService.deleteLinksToDocument(destinationNodeRef);
} catch (IllegalArgumentException ex) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid Arguments: " + ex.getMessage());
} catch (AccessDeniedException e) {
throw new WebScriptException(Status.STATUS_FORBIDDEN, "You don't have permission to perform this operation");
}
/* Build response */
Map<String, Object> model = new HashMap<String, Object>();
model.put("total_count", report.getTotalLinksFoundCount());
model.put("deleted_count", report.getDeletedLinksCount());
Map<String, String> errorDetails = new HashMap<String, String>();
Iterator<Entry<NodeRef, Throwable>> it = report.getErrorDetails().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<NodeRef, Throwable> pair = it.next();
Throwable th = pair.getValue();
errorDetails.put(pair.getKey().toString(), th.getMessage());
}
model.put("error_details", errorDetails);
return model;
}
Aggregations