mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
121917 jkaabimofrad: RA-778: Added support for QuickShare service to email users notifying them that a content has been shared with them. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126436 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,15 +19,18 @@
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.model.QuickShareLink;
|
||||
import org.alfresco.rest.api.model.QuickShareLinkEmailRequest;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Centralises access to quick share services and maps between representations.
|
||||
*
|
||||
* @author janv
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*
|
||||
* @since publicapi1.0
|
||||
*/
|
||||
@@ -74,4 +77,13 @@ public interface QuickShareLinks
|
||||
* @return
|
||||
*/
|
||||
List<QuickShareLink> create(List<QuickShareLink> nodeIds, Parameters parameters);
|
||||
|
||||
/**
|
||||
* Notifies users by email that a content has been shared with them.
|
||||
*
|
||||
* @param nodeId The content id
|
||||
* @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);
|
||||
}
|
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.repo.quickshare.QuickShareServiceImpl.QuickShareEmailRequest;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
@@ -26,6 +28,7 @@ import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.QuickShareLinks;
|
||||
import org.alfresco.rest.api.model.ContentInfo;
|
||||
import org.alfresco.rest.api.model.QuickShareLink;
|
||||
import org.alfresco.rest.api.model.QuickShareLinkEmailRequest;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
@@ -47,6 +50,7 @@ import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -59,6 +63,7 @@ import java.util.Map;
|
||||
* TODO - if QuickShare is disabled should we return 403 (as below) or 404 (eg. when accessing a link) ?
|
||||
*
|
||||
* @author janv
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*
|
||||
* @since publicapi1.0
|
||||
*/
|
||||
@@ -266,6 +271,35 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emailSharedLink(String nodeId, QuickShareLinkEmailRequest emailRequest, Parameters parameters)
|
||||
{
|
||||
try
|
||||
{ NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
final String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
QuickShareEmailRequest request = new QuickShareEmailRequest();
|
||||
request.setSharedNodeName(nodeName);
|
||||
request.setSharedNodeURL(emailRequest.getSharedNodeUrl());
|
||||
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)
|
||||
{
|
||||
String errorMsg = ex.getMessage();
|
||||
if (errorMsg == null)
|
||||
{
|
||||
errorMsg = "";
|
||||
}
|
||||
throw new InvalidArgumentException("Couldn't send an email. " + errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private QuickShareLink getQuickShareInfo(String sharedId)
|
||||
{
|
||||
checkValidShareId(sharedId);
|
||||
|
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Representation of an email request for the quick share link
|
||||
*
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public class QuickShareLinkEmailRequest extends Target
|
||||
{
|
||||
private String templateId;
|
||||
private String sharedNodeUrl;
|
||||
private String message;
|
||||
private String locale;
|
||||
private List<String> recipientEmails;
|
||||
private Boolean isSendFromDefaultEmail;
|
||||
private Boolean isIgnoreSendFailure;
|
||||
|
||||
public String getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getSharedNodeUrl()
|
||||
{
|
||||
return sharedNodeUrl;
|
||||
}
|
||||
|
||||
public void setSharedNodeUrl(String sharedNodeUrl)
|
||||
{
|
||||
this.sharedNodeUrl = sharedNodeUrl;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getLocale()
|
||||
{
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale)
|
||||
{
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public List<String> getRecipientEmails()
|
||||
{
|
||||
return recipientEmails;
|
||||
}
|
||||
|
||||
public void setRecipientEmails(List<String> recipientEmails)
|
||||
{
|
||||
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)
|
||||
.append(", recipientEmails=").append(recipientEmails)
|
||||
.append(", isSendFromDefaultEmail").append(isSendFromDefaultEmail)
|
||||
.append(", isIgnoreSendFailure=").append(isIgnoreSendFailure)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -20,7 +20,9 @@ package org.alfresco.rest.api.quicksharelinks;
|
||||
|
||||
import org.alfresco.rest.api.QuickShareLinks;
|
||||
import org.alfresco.rest.api.model.QuickShareLink;
|
||||
import org.alfresco.rest.api.model.QuickShareLinkEmailRequest;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiNoAuth;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
@@ -38,6 +40,7 @@ import java.util.List;
|
||||
* An implementation of an Entity Resource for Shared Links.
|
||||
*
|
||||
* @author janv
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
@EntityResource(name="shared-links", title = "Shared Links")
|
||||
public class QuickShareLinkEntityResource implements EntityResourceAction.ReadById<QuickShareLink>,
|
||||
@@ -121,4 +124,11 @@ public class QuickShareLinkEntityResource implements EntityResourceAction.ReadBy
|
||||
{
|
||||
return quickShareLinks.create(nodeIds, parameters);
|
||||
}
|
||||
|
||||
@Operation("email")
|
||||
@WebApiDescription(title = "Email shared link", description = "Email the shared link")
|
||||
public void email(String nodeId, QuickShareLinkEmailRequest emailRequest, Parameters parameters)
|
||||
{
|
||||
quickShareLinks.emailSharedLink(nodeId, emailRequest, parameters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user