Search in sources :

Example 1 with InvitationExceptionUserError

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;
}
Also used : WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) Invitation(org.alfresco.service.cmr.invitation.Invitation) InvitationExceptionForbidden(org.alfresco.service.cmr.invitation.InvitationExceptionForbidden) InvitationExceptionUserError(org.alfresco.service.cmr.invitation.InvitationExceptionUserError)

Aggregations

HashMap (java.util.HashMap)1 Invitation (org.alfresco.service.cmr.invitation.Invitation)1 InvitationExceptionForbidden (org.alfresco.service.cmr.invitation.InvitationExceptionForbidden)1 InvitationExceptionUserError (org.alfresco.service.cmr.invitation.InvitationExceptionUserError)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1