Search in sources :

Example 1 with InvitationExceptionNotFound

use of org.alfresco.service.cmr.invitation.InvitationExceptionNotFound in project alfresco-remote-api by Alfresco.

the class SiteMembershipRequestsImpl method updateSiteMembershipRequest.

@Override
public SiteMembershipRequest updateSiteMembershipRequest(String inviteeId, final SiteMembershipRequest siteInvite) {
    SiteMembershipRequest updatedSiteInvite = null;
    inviteeId = people.validatePerson(inviteeId, true);
    String siteId = siteInvite.getId();
    SiteInfo siteInfo = sites.validateSite(siteId);
    if (siteInfo == null) {
        // site does not exist
        throw new RelationshipResourceNotFoundException(inviteeId, siteId);
    }
    // set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
    siteId = siteInfo.getShortName();
    String message = siteInvite.getMessage();
    if (message == null) {
        // the invitation service ignores null messages so convert to an empty message.
        message = "";
    }
    try {
        ModeratedInvitation updatedInvitation = invitationService.updateModeratedInvitation(inviteeId, siteId, message);
        if (updatedInvitation == null) {
            throw new RelationshipResourceNotFoundException(inviteeId, siteId);
        }
        updatedSiteInvite = getSiteMembershipRequest(updatedInvitation);
    } catch (InvitationExceptionNotFound e) {
        throw new RelationshipResourceNotFoundException(inviteeId, siteId);
    }
    if (updatedSiteInvite == null) {
        throw new RelationshipResourceNotFoundException(inviteeId, siteId);
    }
    return updatedSiteInvite;
}
Also used : RelationshipResourceNotFoundException(org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ModeratedInvitation(org.alfresco.service.cmr.invitation.ModeratedInvitation) InvitationExceptionNotFound(org.alfresco.service.cmr.invitation.InvitationExceptionNotFound) SiteMembershipRequest(org.alfresco.rest.api.model.SiteMembershipRequest)

Example 2 with InvitationExceptionNotFound

use of org.alfresco.service.cmr.invitation.InvitationExceptionNotFound in project alfresco-remote-api by Alfresco.

the class InviteByTicket 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>();
    // get inviteId and inviteTicket
    String inviteId = req.getServiceMatch().getTemplateVars().get("inviteId");
    String inviteTicket = req.getServiceMatch().getTemplateVars().get("inviteTicket");
    try {
        Invitation invitation = invitationService.getInvitation(inviteId);
        if (invitation instanceof NominatedInvitation) {
            NominatedInvitation theInvitation = (NominatedInvitation) invitation;
            String ticket = theInvitation.getTicket();
            if (ticket == null || (!ticket.equals(inviteTicket))) {
                throw new WebScriptException(Status.STATUS_NOT_FOUND, "Ticket mismatch");
            }
            // return the invite info
            model.put("invite", toInviteInfo(theInvitation));
            return model;
        } else {
            // Not a nominated invitation
            throw new WebScriptException(Status.STATUS_FORBIDDEN, "Not a nominated invitation");
        }
    } catch (InvitationExceptionNotFound nfe) {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "No invite found for given id");
    }
}
Also used : NominatedInvitation(org.alfresco.service.cmr.invitation.NominatedInvitation) WorkflowModelNominatedInvitation(org.alfresco.repo.invitation.WorkflowModelNominatedInvitation) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) NominatedInvitation(org.alfresco.service.cmr.invitation.NominatedInvitation) WorkflowModelNominatedInvitation(org.alfresco.repo.invitation.WorkflowModelNominatedInvitation) Invitation(org.alfresco.service.cmr.invitation.Invitation) InvitationExceptionNotFound(org.alfresco.service.cmr.invitation.InvitationExceptionNotFound)

Aggregations

InvitationExceptionNotFound (org.alfresco.service.cmr.invitation.InvitationExceptionNotFound)2 HashMap (java.util.HashMap)1 WorkflowModelNominatedInvitation (org.alfresco.repo.invitation.WorkflowModelNominatedInvitation)1 SiteMembershipRequest (org.alfresco.rest.api.model.SiteMembershipRequest)1 RelationshipResourceNotFoundException (org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException)1 Invitation (org.alfresco.service.cmr.invitation.Invitation)1 ModeratedInvitation (org.alfresco.service.cmr.invitation.ModeratedInvitation)1 NominatedInvitation (org.alfresco.service.cmr.invitation.NominatedInvitation)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1