Search in sources :

Example 6 with SiteMembershipRequest

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;
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ResourceType(org.alfresco.service.cmr.invitation.Invitation.ResourceType) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) SiteMembershipRequest(org.alfresco.rest.api.model.SiteMembershipRequest) Person(org.alfresco.rest.api.model.Person) PermissionDeniedException(org.alfresco.rest.framework.core.exceptions.PermissionDeniedException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) UnknownAuthorityException(org.alfresco.repo.security.authority.UnknownAuthorityException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) RelationshipResourceNotFoundException(org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)

Example 7 with 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;
}
Also used : ArrayList(java.util.ArrayList) SiteMembershipRequest(org.alfresco.rest.api.model.SiteMembershipRequest) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 8 with SiteMembershipRequest

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;
}
Also used : ModeratedInvitation(org.alfresco.service.cmr.invitation.ModeratedInvitation) SiteMembershipRequest(org.alfresco.rest.api.model.SiteMembershipRequest)

Example 9 with SiteMembershipRequest

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;
}
Also used : SiteMembershipRequest(org.alfresco.rest.api.model.SiteMembershipRequest) Date(java.util.Date)

Aggregations

SiteMembershipRequest (org.alfresco.rest.api.model.SiteMembershipRequest)9 ModeratedInvitation (org.alfresco.service.cmr.invitation.ModeratedInvitation)5 RelationshipResourceNotFoundException (org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException)4 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)4 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)3 Invitation (org.alfresco.service.cmr.invitation.Invitation)3 ArrayList (java.util.ArrayList)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 UnknownAuthorityException (org.alfresco.repo.security.authority.UnknownAuthorityException)2 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)2 PermissionDeniedException (org.alfresco.rest.framework.core.exceptions.PermissionDeniedException)2 Date (java.util.Date)1 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)1 TenantRunAsWork (org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork)1 Person (org.alfresco.rest.api.model.Person)1 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)1 ResourceType (org.alfresco.service.cmr.invitation.Invitation.ResourceType)1 InvitationExceptionNotFound (org.alfresco.service.cmr.invitation.InvitationExceptionNotFound)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)1