mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-895 User email should not be necessary for joining a site (#471)
Fixed the first approach. No longer catching the Exception and instead preventing to invoke the email action if the invited user does not have an email address
This commit is contained in:
@@ -2003,23 +2003,15 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
return;
|
||||
}
|
||||
|
||||
// send email to the invitee if possible - but don't fail the invitation if email cannot be sent
|
||||
try
|
||||
{
|
||||
Map<String, String> properties = makePropertiesFromContextVariables(executionVariables, invitePropNames);
|
||||
// send email to the invitee
|
||||
Map<String, String> properties = makePropertiesFromContextVariables(executionVariables, invitePropNames);
|
||||
|
||||
String packageRef = getPackageRef(executionVariables);
|
||||
properties.put(InviteNominatedSender.WF_PACKAGE, packageRef);
|
||||
String packageRef = getPackageRef(executionVariables);
|
||||
properties.put(InviteNominatedSender.WF_PACKAGE, packageRef);
|
||||
|
||||
properties.put(InviteNominatedSender.WF_INSTANCE_ID, inviteId);
|
||||
properties.put(InviteNominatedSender.WF_INSTANCE_ID, inviteId);
|
||||
|
||||
inviteSender.sendMail(emailTemplateXpath, emailSubjectKey, properties);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Swallow exception
|
||||
logger.error("unable to send invite email", e);
|
||||
}
|
||||
inviteSender.sendMail(emailTemplateXpath, emailSubjectKey, properties);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -23,9 +23,9 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.invitation.site;
|
||||
|
||||
|
||||
package org.alfresco.repo.invitation.site;
|
||||
|
||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarAcceptUrl;
|
||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteTicket;
|
||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteeGenPassword;
|
||||
@@ -53,35 +53,39 @@ import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.util.ModelUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.springframework.extensions.surf.util.URLEncoder;
|
||||
|
||||
/**
|
||||
* This class is responsible for sending email invitations, allowing nominated
|
||||
* user's to join a Site.
|
||||
*
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class InviteNominatedSender extends InviteSender
|
||||
{
|
||||
public static final String WF_INSTANCE_ID = "wf_instanceId";
|
||||
public static final String WF_PACKAGE = "wf_package";
|
||||
public static final String SITE_LEAVE_HASH = "#leavesite";
|
||||
private static final String SITE_DASHBOARD_ENDPOINT_PATTERN = "/page/site/{0}/dashboard";
|
||||
|
||||
private static final List<String> INVITE_NOMINATED_EXPECTED_PROPERTIES = Arrays.asList(wfVarInviteeUserName,//
|
||||
wfVarResourceName,//
|
||||
wfVarInviterUserName,//
|
||||
wfVarInviteeUserName,//
|
||||
wfVarRole,//
|
||||
wfVarInviteeGenPassword,//
|
||||
wfVarResourceName,//
|
||||
wfVarInviteTicket,//
|
||||
wfVarServerPath,//
|
||||
wfVarAcceptUrl,//
|
||||
wfVarRejectUrl, WF_INSTANCE_ID,//
|
||||
WF_PACKAGE);
|
||||
|
||||
|
||||
/**
|
||||
* This class is responsible for sending email invitations, allowing nominated
|
||||
* user's to join a Site.
|
||||
*
|
||||
* @author Nick Smith
|
||||
*/
|
||||
public class InviteNominatedSender extends InviteSender
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(InviteNominatedSender.class);
|
||||
public static final String WF_INSTANCE_ID = "wf_instanceId";
|
||||
public static final String WF_PACKAGE = "wf_package";
|
||||
public static final String SITE_LEAVE_HASH = "#leavesite";
|
||||
private static final String SITE_DASHBOARD_ENDPOINT_PATTERN = "/page/site/{0}/dashboard";
|
||||
|
||||
private static final List<String> INVITE_NOMINATED_EXPECTED_PROPERTIES = Arrays.asList(wfVarInviteeUserName,//
|
||||
wfVarResourceName,//
|
||||
wfVarInviterUserName,//
|
||||
wfVarInviteeUserName,//
|
||||
wfVarRole,//
|
||||
wfVarInviteeGenPassword,//
|
||||
wfVarResourceName,//
|
||||
wfVarInviteTicket,//
|
||||
wfVarServerPath,//
|
||||
wfVarAcceptUrl,//
|
||||
wfVarRejectUrl, WF_INSTANCE_ID,//
|
||||
WF_PACKAGE);
|
||||
|
||||
public InviteNominatedSender(ServiceRegistry services, Repository repository, MessageService messageService)
|
||||
{
|
||||
super(services, repository, messageService);
|
||||
@@ -109,7 +113,13 @@ public class InviteNominatedSender extends InviteSender
|
||||
NodeRef invitee = personService.getPerson(inviteeName);
|
||||
Action mail = actionService.createAction(MailActionExecuter.NAME);
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_FROM, getEmail(inviter));
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_TO, getEmail(invitee));
|
||||
String recipient = getEmail(invitee);
|
||||
if(StringUtils.isEmpty(recipient))
|
||||
{
|
||||
logger.warn("Cannot send invitation: Invitee user account does not have email");
|
||||
return;
|
||||
}
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_TO, recipient);
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_SUBJECT, emailSubjectKey);
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_SUBJECT_PARAMS, new Object[] { ModelUtil.getProductName(repoAdminService), getSiteName(properties) });
|
||||
mail.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, getEmailTemplateNodeRef(emailTemplateXpath));
|
||||
@@ -236,5 +246,5 @@ public class InviteNominatedSender extends InviteSender
|
||||
protected String getWorkflowPropForSiteName()
|
||||
{
|
||||
return wfVarResourceName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user