mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126547 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124158 jkaabimofrad: SFS-405, RA-778: (WIP) - Added quick-share client registry config. - Modified the send shared-link email API, based on the revised acceptance criteria. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126893 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -83,11 +83,11 @@ public interface QuickShareLinks
|
||||
/**
|
||||
* Notifies users by email that a content has been shared with them.
|
||||
*
|
||||
* @param nodeId The content id
|
||||
* @param sharedId The string id of the quick share
|
||||
* @param emailRequest The email details including its template details
|
||||
* @param parameters The {@link Parameters} object to get the parameters passed into the request
|
||||
*/
|
||||
void emailSharedLink(String nodeId, QuickShareLinkEmailRequest emailRequest, Parameters parameters);
|
||||
void emailSharedLink(String sharedId, QuickShareLinkEmailRequest emailRequest, Parameters parameters);
|
||||
|
||||
/**
|
||||
* Find (search) for shared links visible to current user.
|
||||
|
@@ -21,6 +21,7 @@ package org.alfresco.rest.api.impl;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.repo.quickshare.QuickShareClientNotFoundException;
|
||||
import org.alfresco.repo.quickshare.QuickShareServiceImpl.QuickShareEmailRequest;
|
||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
@@ -74,6 +75,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.SearchLanguageConversion;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -353,33 +355,37 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emailSharedLink(String nodeId, QuickShareLinkEmailRequest emailRequest, Parameters parameters)
|
||||
public void emailSharedLink(String sharedId, QuickShareLinkEmailRequest emailRequest, Parameters parameters)
|
||||
{
|
||||
checkEnabled();
|
||||
checkValidShareId(sharedId);
|
||||
validateEmailRequest(emailRequest);
|
||||
|
||||
try
|
||||
{ NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
final String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
{
|
||||
NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();
|
||||
String sharedNodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
QuickShareEmailRequest request = new QuickShareEmailRequest();
|
||||
request.setSharedNodeName(nodeName);
|
||||
request.setSharedNodeURL(emailRequest.getSharedNodeUrl());
|
||||
request.setSharedNodeName(sharedNodeName);
|
||||
request.setClient(emailRequest.getClient());
|
||||
request.setSharedId(sharedId);
|
||||
request.setSenderMessage(emailRequest.getMessage());
|
||||
request.setLocale(I18NUtil.parseLocale(emailRequest.getLocale()));
|
||||
request.setTemplateId(emailRequest.getTemplateId());
|
||||
request.setToEmails(emailRequest.getRecipientEmails());
|
||||
request.setSendFromDefaultEmail(emailRequest.getIsSendFromDefaultEmail());
|
||||
request.setIgnoreSendFailure(emailRequest.getIsIgnoreSendFailure());
|
||||
quickShareService.sendEmailNotification(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (InvalidSharedIdException ex)
|
||||
{
|
||||
String errorMsg = ex.getMessage();
|
||||
if (errorMsg == null)
|
||||
{
|
||||
errorMsg = "";
|
||||
throw new EntityNotFoundException(sharedId);
|
||||
}
|
||||
throw new InvalidArgumentException("Couldn't send an email. " + errorMsg);
|
||||
catch (InvalidNodeRefException inre)
|
||||
{
|
||||
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
|
||||
throw new EntityNotFoundException(sharedId);
|
||||
}
|
||||
catch (QuickShareClientNotFoundException ex)
|
||||
{
|
||||
throw new InvalidArgumentException("Client is not registered [" + emailRequest.getClient() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,4 +591,16 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
||||
throw new InvalidArgumentException("A valid sharedId must be specified !");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateEmailRequest(QuickShareLinkEmailRequest emailRequest)
|
||||
{
|
||||
if (StringUtils.isEmpty(emailRequest.getClient()))
|
||||
{
|
||||
throw new InvalidArgumentException("A valid client must be specified.");
|
||||
}
|
||||
if (emailRequest.getRecipientEmails() == null || emailRequest.getRecipientEmails().isEmpty())
|
||||
{
|
||||
throw new InvalidArgumentException("A valid recipientEmail must be specified.");
|
||||
}
|
||||
}
|
||||
}
|
@@ -28,32 +28,20 @@ import java.util.List;
|
||||
*/
|
||||
public class QuickShareLinkEmailRequest extends Target
|
||||
{
|
||||
private String templateId;
|
||||
private String sharedNodeUrl;
|
||||
private String client;
|
||||
private String message;
|
||||
private String locale;
|
||||
private List<String> recipientEmails;
|
||||
private Boolean isSendFromDefaultEmail;
|
||||
private Boolean isIgnoreSendFailure;
|
||||
|
||||
public String getTemplateId()
|
||||
public String getClient()
|
||||
{
|
||||
return templateId;
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId)
|
||||
public QuickShareLinkEmailRequest setClient(String client)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getSharedNodeUrl()
|
||||
{
|
||||
return sharedNodeUrl;
|
||||
}
|
||||
|
||||
public void setSharedNodeUrl(String sharedNodeUrl)
|
||||
{
|
||||
this.sharedNodeUrl = sharedNodeUrl;
|
||||
this.client = client;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
@@ -86,37 +74,14 @@ public class QuickShareLinkEmailRequest extends Target
|
||||
this.recipientEmails = recipientEmails;
|
||||
}
|
||||
|
||||
public Boolean getIsSendFromDefaultEmail()
|
||||
{
|
||||
return isSendFromDefaultEmail;
|
||||
}
|
||||
|
||||
public void setIsSendFromDefaultEmail(Boolean isSendFromDefaultEmail)
|
||||
{
|
||||
this.isSendFromDefaultEmail = isSendFromDefaultEmail;
|
||||
}
|
||||
|
||||
public Boolean getIsIgnoreSendFailure()
|
||||
{
|
||||
return isIgnoreSendFailure;
|
||||
}
|
||||
|
||||
public void setIsIgnoreSendFailure(Boolean isIgnoreSendFailure)
|
||||
{
|
||||
this.isIgnoreSendFailure = isIgnoreSendFailure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(250);
|
||||
sb.append("QuickShareLinkEmailRequest [templateId='").append(templateId)
|
||||
.append(", sharedNodeUrl='").append(sharedNodeUrl)
|
||||
.append(", message='").append(message)
|
||||
.append(", locale='").append(locale)
|
||||
sb.append("QuickShareLinkEmailRequest [client=").append(client)
|
||||
.append(", message=").append(message)
|
||||
.append(", locale=").append(locale)
|
||||
.append(", recipientEmails=").append(recipientEmails)
|
||||
.append(", isSendFromDefaultEmail").append(isSendFromDefaultEmail)
|
||||
.append(", isIgnoreSendFailure=").append(isIgnoreSendFailure)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@@ -32,9 +32,9 @@ import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAct
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -131,10 +131,10 @@ public class QuickShareLinkEntityResource implements EntityResourceAction.ReadBy
|
||||
}
|
||||
|
||||
@Operation("email")
|
||||
@WebApiDescription(title = "Email shared link", description = "Email the shared link")
|
||||
public void email(String nodeId, QuickShareLinkEmailRequest emailRequest, Parameters parameters, WithResponse withResponse)
|
||||
@WebApiDescription(title = "Email shared link", successStatus = Status.STATUS_ACCEPTED)
|
||||
public void email(String sharedId, QuickShareLinkEmailRequest emailRequest, Parameters parameters)
|
||||
{
|
||||
quickShareLinks.emailSharedLink(nodeId, emailRequest, parameters);
|
||||
quickShareLinks.emailSharedLink(sharedId, emailRequest, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user