use of org.alfresco.service.cmr.invitation.Invitation in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method rejectSiteMembershipRequest.
@Override
public void rejectSiteMembershipRequest(String siteId, String inviteeId, SiteMembershipRejection siteMembershipRejection) {
SiteInfo siteInfo = sites.validateSite(siteId);
if (siteInfo == null) {
throw new EntityNotFoundException(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();
// Validate invitation.
Invitation invitation = getSiteInvitation(inviteeId, siteId);
if (invitation == null || !(invitation instanceof ModeratedInvitation)) {
throw new RelationshipResourceNotFoundException(siteId, inviteeId);
}
ModeratedInvitation moderatedInvitation = (ModeratedInvitation) invitation;
ResourceType resourceType = moderatedInvitation.getResourceType();
if (!resourceType.equals(ResourceType.WEB_SITE) || !SiteVisibility.MODERATED.equals(siteInfo.getVisibility())) {
// note: security, no indication that this has a different visibility
throw new RelationshipResourceNotFoundException(siteId, inviteeId);
}
String reason = null;
if (siteMembershipRejection != null && !(siteMembershipRejection.getComment() == null || siteMembershipRejection.getComment().isEmpty())) {
reason = siteMembershipRejection.getComment();
}
try {
invitationService.reject(invitation.getInviteId(), reason);
} catch (InvitationExceptionForbidden ex) {
throw new PermissionDeniedException();
}
}
use of org.alfresco.service.cmr.invitation.Invitation in project alfresco-remote-api by Alfresco.
the class InvitationDelete method checkAndCancelTheInvitation.
protected void checkAndCancelTheInvitation(final String invId, String siteShortName) {
Invitation invitation = null;
try {
invitation = invitationService.getInvitation(invId);
} catch (org.alfresco.service.cmr.invitation.InvitationExceptionNotFound ienf) {
throwInvitationNotFoundException(invId, siteShortName);
}
if (invitation == null) {
throwInvitationNotFoundException(invId, siteShortName);
}
// check that this invitation really belongs to the specified siteShortName
if (invitation != null && invitation.getResourceName() != null && !siteShortName.equals(invitation.getResourceName())) {
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow");
}
invitationService.cancel(invId);
}
use of org.alfresco.service.cmr.invitation.Invitation 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;
}
use of org.alfresco.service.cmr.invitation.Invitation in project alfresco-remote-api by Alfresco.
the class RepoService method rejectSiteInvitation.
public Invitation rejectSiteInvitation(String personId, String siteId) {
Invitation ret = null;
List<Invitation> invitations = invitationService.listPendingInvitationsForInvitee(personId);
for (Invitation invitation : invitations) {
if (invitation.getResourceName().equals(siteId)) {
ret = invitationService.reject(invitation.getInviteId(), "I reject you");
}
}
return ret;
}
use of org.alfresco.service.cmr.invitation.Invitation in project alfresco-remote-api by Alfresco.
the class RepoService method approveSiteInvitation.
public Invitation approveSiteInvitation(String personId, String siteId) {
Invitation ret = null;
List<Invitation> invitations = invitationService.listPendingInvitationsForInvitee(personId);
for (Invitation invitation : invitations) {
if (invitation.getResourceName().equals(siteId)) {
ret = invitationService.approve(invitation.getInviteId(), "I accept you");
}
}
return ret;
}
Aggregations