Merge pull request #120 from Alfresco/dev-dhrn-ACS-777

[ACS-777] Email notification for digital workspace
This commit is contained in:
Eugenio Romano
2020-11-16 09:24:26 +00:00
committed by GitHub
24 changed files with 959 additions and 426 deletions

View File

@@ -45,15 +45,24 @@ public interface SiteMembershipRequests
/**
* Create a site membership request for the user 'inviteeId'
* @param inviteeId the site inviteee id
* @param inviteeId the site invite id
* @param siteInvite the site invite
* @return SiteMembershipRequest
*/
SiteMembershipRequest createSiteMembershipRequest(String inviteeId, final SiteMembershipRequest siteInvite);
/**
* Create a site membership request for the user 'inviteeId'
* @param inviteeId the site invitee id
* @param siteInvite the site invite
* @param client the client name which is registered to send emails
* @return SiteMembershipRequest
*/
SiteMembershipRequest createSiteMembershipRequest(String inviteeId, final SiteMembershipRequest siteInvite, final String client);
/**
* Update the site membership request for inviteeId and site
* @param inviteeId the site inviteee id
* @param inviteeId the site invite id
* @param siteInvite the site invite
* @return the updated siteMembershipRequest
*/
@@ -62,7 +71,7 @@ public interface SiteMembershipRequests
/**
* Cancel site membership request for invitee and site.
*
* @param inviteeId the site inviteee id
* @param inviteeId the site invite id
* @param siteId the site id
*/
void cancelSiteMembershipRequest(String inviteeId, String siteId);
@@ -70,7 +79,7 @@ public interface SiteMembershipRequests
/**
* Get the site membership request for inviteeId and siteId, if it exists.
*
* @param inviteeId the site inviteee id
* @param inviteeId the site invite id
* @param siteId the site id
* @return the site membership request
*/
@@ -79,7 +88,7 @@ public interface SiteMembershipRequests
/**
* Get a paged list of site membership requests for inviteeId.
*
* @param inviteeId the site inviteee id
* @param inviteeId the site invite id
* @param paging paging information
* @return a paged list of site membership requests
*/

View File

@@ -158,9 +158,9 @@ public class SiteMembershipRequestsImpl implements SiteMembershipRequests
}
private SiteMembershipRequest inviteToModeratedSite(final String message, final String inviteeId, final String siteId,
final String inviteeRole)
final String inviteeRole, final String clientName)
{
ModeratedInvitation invitation = invitationService.inviteModerated(message, inviteeId, ResourceType.WEB_SITE, siteId, inviteeRole);
ModeratedInvitation invitation = invitationService.inviteModerated(message, inviteeId, ResourceType.WEB_SITE, siteId, inviteeRole, clientName);
SiteMembershipRequest ret = new SiteMembershipRequest();
ret.setId(siteId);
@@ -270,7 +270,76 @@ public class SiteMembershipRequestsImpl implements SiteMembershipRequests
if(siteVisibility.equals(SiteVisibility.MODERATED))
{
request = inviteToModeratedSite(message, inviteeId, siteId, inviteeRole);
request = inviteToModeratedSite(message, inviteeId, siteId, inviteeRole, null);
}
else if(siteVisibility.equals(SiteVisibility.PUBLIC))
{
request = inviteToPublicSite(siteInfo, message, inviteeId, inviteeRole);
}
else
{
// note: security, no indication that this is a private site
throw new RelationshipResourceNotFoundException(inviteeId, siteId);
}
return request;
}
@Override
public SiteMembershipRequest createSiteMembershipRequest(String inviteeId, SiteMembershipRequest siteInvite, String client)
{
SiteMembershipRequest request = null;
inviteeId = people.validatePerson(inviteeId, true);
// Note that the order of error checking is important. The server first needs to check for the status 404
// conditions before checking for status 400 conditions. Otherwise the server is open to a probing attack.
String siteId = siteInvite.getId();
final 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();
final SiteVisibility siteVisibility = siteInfo.getVisibility();
if(siteVisibility.equals(SiteVisibility.PRIVATE))
{
// note: security, no indication that this is a private site
throw new RelationshipResourceNotFoundException(inviteeId, siteId);
}
// Is the invitee already a member of the site?
boolean isMember = siteService.isMember(siteId, inviteeId);
if(isMember)
{
// yes
throw new InvalidArgumentException(inviteeId + " is already a member of site " + siteId);
}
// Is there an outstanding site invite request for the (invitee, site)?
Invitation invitation = getSiteInvitation(inviteeId, siteId);
if(invitation != null)
{
// yes
throw new InvalidArgumentException(inviteeId + " is already invited to site " + siteId);
}
final String inviteeRole = DEFAULT_ROLE;
String message = siteInvite.getMessage();
if(message == null)
{
// the invitation service ignores null messages so convert to an empty message.
message = "";
}
if(siteVisibility.equals(SiteVisibility.MODERATED))
{
request = inviteToModeratedSite(message, inviteeId, siteId, inviteeRole, client);
}
else if(siteVisibility.equals(SiteVisibility.PUBLIC))
{

View File

@@ -53,6 +53,7 @@ public class SiteMembershipRequest implements Comparable<SiteMembershipRequest>
private Date modifiedAt;
private String title; // for sorting only
private Person person;
private String client;
public static Pair<String, String> splitId(String id)
{
@@ -137,11 +138,21 @@ public class SiteMembershipRequest implements Comparable<SiteMembershipRequest>
this.person = person;
}
public String getClient()
{
return client;
}
public void setClient(String client)
{
this.client = client;
}
@Override
public String toString()
{
return "SiteMembershipRequest [id=" + id + ", message=" + message + ", createdAt=" + createdAt
+ ", modifiedAt=" + modifiedAt + "]";
+ ", modifiedAt=" + modifiedAt + ", client=" + client + "]";
}
@Override

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.people;
import java.util.ArrayList;
@@ -73,7 +73,14 @@ RelationshipResourceAction.Create<SiteMembershipRequest>, RelationshipResourceAc
List<SiteMembershipRequest> result = new ArrayList<SiteMembershipRequest>(invites.size());
for(SiteMembershipRequest invite : invites)
{
SiteMembershipRequest siteInvite = siteMembershipRequests.createSiteMembershipRequest(personId, invite);
SiteMembershipRequest siteInvite = null;
if(invite.getClient() != null)
{
siteInvite = siteMembershipRequests.createSiteMembershipRequest(personId, invite, invite.getClient());
} else
{
siteInvite = siteMembershipRequests.createSiteMembershipRequest(personId, invite);
}
result.add(siteInvite);
}
return result;