use of org.alfresco.rest.api.model.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getSiteMembershipRequest.
private SiteMembershipRequest getSiteMembershipRequest(ModeratedInvitation moderatedInvitation, boolean includePersonDetails) {
SiteMembershipRequest siteMembershipRequest = null;
ResourceType resourceType = moderatedInvitation.getResourceType();
if (resourceType.equals(ResourceType.WEB_SITE)) {
final String siteId = moderatedInvitation.getResourceName();
SiteInfo siteInfo = AuthenticationUtil.runAsSystem(new RunAsWork<SiteInfo>() {
@Override
public SiteInfo doWork() throws Exception {
SiteInfo siteInfo = sites.validateSite(siteId);
return siteInfo;
}
});
if (siteInfo == null) {
// site does not exist
throw new EntityNotFoundException(siteId);
}
if (siteInfo.getVisibility().equals(SiteVisibility.MODERATED)) {
// return a site membership request only if this is a moderated site
siteMembershipRequest = new SiteMembershipRequest();
String title = siteInfo.getTitle();
siteMembershipRequest.setTitle(title);
siteMembershipRequest.setId(siteId);
siteMembershipRequest.setMessage(moderatedInvitation.getInviteeComments());
siteMembershipRequest.setCreatedAt(moderatedInvitation.getCreatedAt());
siteMembershipRequest.setModifiedAt(moderatedInvitation.getModifiedAt());
if (includePersonDetails) {
Person person = people.getPerson(moderatedInvitation.getInviteeUserName());
siteMembershipRequest.setPerson(person);
}
}
} else {
logger.warn("Unexpected resource type " + resourceType + " for site membership request");
}
return siteMembershipRequest;
}
use of org.alfresco.rest.api.model.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class PersonSiteMembershipRequestsRelation method create.
@Override
@WebApiDescription(title = "Create a site membership request for personId and siteIds. The personId will be invited to the site as a SiteConsumer.")
public List<SiteMembershipRequest> create(String personId, List<SiteMembershipRequest> invites, Parameters parameters) {
List<SiteMembershipRequest> result = new ArrayList<SiteMembershipRequest>(invites.size());
for (SiteMembershipRequest invite : invites) {
SiteMembershipRequest siteInvite = siteMembershipRequests.createSiteMembershipRequest(personId, invite);
result.add(siteInvite);
}
return result;
}
use of org.alfresco.rest.api.model.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method inviteToModeratedSite.
private SiteMembershipRequest inviteToModeratedSite(final String message, final String inviteeId, final String siteId, final String inviteeRole) {
ModeratedInvitation invitation = invitationService.inviteModerated(message, inviteeId, ResourceType.WEB_SITE, siteId, inviteeRole);
SiteMembershipRequest ret = new SiteMembershipRequest();
ret.setId(siteId);
ret.setMessage(message);
ret.setCreatedAt(invitation.getCreatedAt());
return ret;
}
use of org.alfresco.rest.api.model.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method inviteToSite.
private SiteMembershipRequest inviteToSite(String siteId, String inviteeId, String inviteeRole, String message) {
siteService.setMembership(siteId, inviteeId, inviteeRole);
SiteMembershipRequest ret = new SiteMembershipRequest();
ret.setId(siteId);
ret.setMessage(message);
Date createdAt = new Date();
ret.setCreatedAt(createdAt);
return ret;
}
Aggregations