use of org.alfresco.service.cmr.invitation.InvitationExceptionUserError in project alfresco-remote-api by Alfresco.
the class InviteResponse method execute.
private Map<String, Object> execute(WebScriptRequest req, Status status) {
// initialise model to pass on for template to render
Map<String, Object> model = new HashMap<String, Object>();
String inviteId = req.getServiceMatch().getTemplateVars().get("inviteId");
String inviteTicket = req.getServiceMatch().getTemplateVars().get("inviteTicket");
// Check that the task is still open.
// if(inviteStart)
// process response
String action = req.getServiceMatch().getTemplateVars().get("action");
if (action.equals("accept")) {
try {
Invitation invitation = invitationService.accept(inviteId, inviteTicket);
// add model properties for template to render
model.put(MODEL_PROP_KEY_RESPONSE, RESPONSE_ACCEPT);
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, invitation.getResourceName());
} catch (InvitationExceptionForbidden fe) {
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
} catch (InvitationExceptionUserError fe) {
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
}
} else if (action.equals("reject")) {
try {
Invitation invitation = invitationService.reject(inviteId, "Rejected");
// add model properties for template to render
model.put(MODEL_PROP_KEY_RESPONSE, RESPONSE_REJECT);
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, invitation.getResourceName());
} catch (InvitationExceptionForbidden fe) {
throw new WebScriptException(Status.STATUS_FORBIDDEN, fe.toString());
} catch (InvitationExceptionUserError fe) {
throw new WebScriptException(Status.STATUS_CONFLICT, fe.toString());
}
} else {
/* handle unrecognised method */
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "action " + action + " is not supported by this webscript.");
}
return model;
}
Aggregations