mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Implimenting moderated reject email. And adding @Auditable to invitation service.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13692 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
Your request to join site '${resourceName}' has not been approved.
|
||||||
|
|
||||||
|
'${reviewComments}'
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
Alfresco Share Team
|
39
config/alfresco/bootstrap/invite/moderated-reject-email.xml
Normal file
39
config/alfresco/bootstrap/invite/moderated-reject-email.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
|
||||||
|
xmlns:app="http://www.alfresco.org/model/application/1.0"
|
||||||
|
xmlns:cm="http://www.alfresco.org/model/content/1.0">
|
||||||
|
<cm:folder view:childName="cm:invite">
|
||||||
|
<view:aspects>
|
||||||
|
<app:uifacets></app:uifacets>
|
||||||
|
</view:aspects>
|
||||||
|
<view:properties>
|
||||||
|
<cm:description>Invitation Moderated reject email template</cm:description>
|
||||||
|
<app:icon>space-icon-default</app:icon>
|
||||||
|
<cm:title>Invitation Moderated reject email</cm:title>
|
||||||
|
<cm:name>invite</cm:name>
|
||||||
|
</view:properties>
|
||||||
|
<view:associations>
|
||||||
|
<cm:contains>
|
||||||
|
<cm:content
|
||||||
|
view:childName="cm:moderated-reject-email.ftl">
|
||||||
|
<view:aspects>
|
||||||
|
<cm:titled></cm:titled>
|
||||||
|
<cm:author></cm:author>
|
||||||
|
<app:inlineeditable></app:inlineeditable>
|
||||||
|
</view:aspects>
|
||||||
|
<view:properties>
|
||||||
|
<app:editInline>
|
||||||
|
true
|
||||||
|
</app:editInline>
|
||||||
|
<cm:description>Email template used to generate the reject email for Alfresco Share, Moderated Invitation</cm:description>
|
||||||
|
<cm:content>contentUrl=classpath:alfresco\bootstrap\invite\moderated-reject-email.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_</cm:content>
|
||||||
|
<cm:title>moderated-reject-email.ftl</cm:title>
|
||||||
|
<cm:author></cm:author>
|
||||||
|
<cm:name>moderated-reject-email.ftl</cm:name>
|
||||||
|
</view:properties>
|
||||||
|
<view:associations></view:associations>
|
||||||
|
</cm:content>
|
||||||
|
</cm:contains>
|
||||||
|
</view:associations>
|
||||||
|
</cm:folder>
|
||||||
|
</view:view>
|
@@ -1,24 +1,39 @@
|
|||||||
package org.alfresco.repo.invitation;
|
package org.alfresco.repo.invitation;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.action.executer.MailActionExecuter;
|
||||||
|
import org.alfresco.repo.invitation.site.RejectInviteAction;
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
|
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
|
import org.alfresco.service.cmr.repository.TemplateService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.jbpm.graph.exe.ExecutionContext;
|
import org.jbpm.graph.exe.ExecutionContext;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* JBPM Action fired when a moderated invitation is rejected.
|
||||||
*/
|
*/
|
||||||
public class ModeratedActionReject extends JBPMSpringActionHandler
|
public class ModeratedActionReject extends JBPMSpringActionHandler
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 4377660284993206875L;
|
private static final long serialVersionUID = 4377660284993206875L;
|
||||||
|
private static final Log logger = LogFactory.getLog(ModeratedActionReject.class);
|
||||||
|
|
||||||
private MutableAuthenticationDao mutableAuthenticationDao;
|
private MutableAuthenticationDao mutableAuthenticationDao;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private WorkflowService workflowService;
|
private WorkflowService workflowService;
|
||||||
|
private ActionService actionService;
|
||||||
|
private TemplateService templateService;
|
||||||
|
//private String rejectTemplate = " PATH:\"app:company_home/app:dictionary/app:email_templates/cm:invite/cm:moderated-reject-email.ftl\"";
|
||||||
|
private String rejectTemplate = "/alfresco/bootstrap/invite/moderated-reject-email.ftl";
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler#initialiseHandler(org.springframework.beans.factory.BeanFactory)
|
* @see org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler#initialiseHandler(org.springframework.beans.factory.BeanFactory)
|
||||||
@@ -30,6 +45,8 @@ public class ModeratedActionReject extends JBPMSpringActionHandler
|
|||||||
mutableAuthenticationDao = (MutableAuthenticationDao) factory.getBean("authenticationDao");
|
mutableAuthenticationDao = (MutableAuthenticationDao) factory.getBean("authenticationDao");
|
||||||
personService = (PersonService) services.getPersonService();
|
personService = (PersonService) services.getPersonService();
|
||||||
workflowService = (WorkflowService) services.getWorkflowService();
|
workflowService = (WorkflowService) services.getWorkflowService();
|
||||||
|
templateService = (TemplateService) services.getTemplateService();
|
||||||
|
actionService = (ActionService) services.getActionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -46,6 +63,31 @@ public class ModeratedActionReject extends JBPMSpringActionHandler
|
|||||||
final String reviewer = (String)executionContext.getVariable(WorkflowModelModeratedInvitation.wfVarReviewer);
|
final String reviewer = (String)executionContext.getVariable(WorkflowModelModeratedInvitation.wfVarReviewer);
|
||||||
final String reviewComments = (String)executionContext.getVariable(WorkflowModelModeratedInvitation.wfVarReviewComments);
|
final String reviewComments = (String)executionContext.getVariable(WorkflowModelModeratedInvitation.wfVarReviewComments);
|
||||||
|
|
||||||
|
// send email to the invitee if possible - but don't fail the rejection if email cannot be sent
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
|
||||||
|
model.put("resourceName", resourceName);
|
||||||
|
model.put("resourceType", resourceType);
|
||||||
|
model.put("inviteeRole", inviteeRole);
|
||||||
|
model.put("reviewComments", reviewComments);
|
||||||
|
model.put("reviewer", reviewer);
|
||||||
|
model.put("inviteeUserName", inviteeUserName);
|
||||||
|
|
||||||
|
String emailMsg = templateService.processTemplate("freemarker", rejectTemplate, model);
|
||||||
|
|
||||||
|
Action emailAction = actionService.createAction("mail");
|
||||||
|
emailAction.setParameterValue(MailActionExecuter.PARAM_TO, inviteeUserName);
|
||||||
|
emailAction.setParameterValue(MailActionExecuter.PARAM_FROM, reviewer);
|
||||||
|
emailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Rejected invitation to web site:" + resourceName);
|
||||||
|
emailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, emailMsg);
|
||||||
|
emailAction.setExecuteAsynchronously(true);
|
||||||
|
actionService.executeAction(emailAction, null);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
// Swallow exception
|
||||||
|
logger.error("unable to send reject email", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -26,6 +26,8 @@ package org.alfresco.service.cmr.invitation;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.service.Auditable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The invitation service provides the ability to invite
|
* The invitation service provides the ability to invite
|
||||||
* people to resources. For example adding a user to a shared web site.
|
* people to resources. For example adding a user to a shared web site.
|
||||||
@@ -64,6 +66,14 @@ public interface InvitationService
|
|||||||
* @throws InvitationExceptionUserError
|
* @throws InvitationExceptionUserError
|
||||||
* @throws InvitationExceptionForbidden
|
* @throws InvitationExceptionForbidden
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"inviteeUserName",
|
||||||
|
"resourceType",
|
||||||
|
"resourceName",
|
||||||
|
"inviteeRole",
|
||||||
|
"serverPath",
|
||||||
|
"acceptUrl",
|
||||||
|
"rejectUrl"})
|
||||||
|
|
||||||
public NominatedInvitation inviteNominated(
|
public NominatedInvitation inviteNominated(
|
||||||
String inviteeUserName,
|
String inviteeUserName,
|
||||||
Invitation.ResourceType resourceType,
|
Invitation.ResourceType resourceType,
|
||||||
@@ -94,6 +104,16 @@ public interface InvitationService
|
|||||||
* @throws InvitationExceptionUserError
|
* @throws InvitationExceptionUserError
|
||||||
* @throws InvitationExceptionForbidden
|
* @throws InvitationExceptionForbidden
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {
|
||||||
|
"inviteeFirstName",
|
||||||
|
"inviteeLastName",
|
||||||
|
"inviteeEmail",
|
||||||
|
"resourceType",
|
||||||
|
"resourceName",
|
||||||
|
"inviteeRole",
|
||||||
|
"serverPath",
|
||||||
|
"acceptUrl",
|
||||||
|
"rejectUrl"})
|
||||||
public NominatedInvitation inviteNominated(
|
public NominatedInvitation inviteNominated(
|
||||||
String inviteeFirstName,
|
String inviteeFirstName,
|
||||||
String inviteeLastName,
|
String inviteeLastName,
|
||||||
@@ -112,6 +132,12 @@ public interface InvitationService
|
|||||||
* @param resourceName which resource
|
* @param resourceName which resource
|
||||||
* @param inviteeRole which role ?
|
* @param inviteeRole which role ?
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {
|
||||||
|
"inviteeComments",
|
||||||
|
"inviteeUserName",
|
||||||
|
"resourceType",
|
||||||
|
"resourceName",
|
||||||
|
"inviteeRole"})
|
||||||
public ModeratedInvitation inviteModerated(
|
public ModeratedInvitation inviteModerated(
|
||||||
String inviteeComments,
|
String inviteeComments,
|
||||||
String inviteeUserName,
|
String inviteeUserName,
|
||||||
@@ -126,6 +152,7 @@ public interface InvitationService
|
|||||||
* @param ticket
|
* @param ticket
|
||||||
* @return the invitation
|
* @return the invitation
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"invitationId", "reason"})
|
||||||
public Invitation accept(String invitationId, String ticket);
|
public Invitation accept(String invitationId, String ticket);
|
||||||
|
|
||||||
|
|
||||||
@@ -135,22 +162,22 @@ public interface InvitationService
|
|||||||
* @param invitationId the request to approve
|
* @param invitationId the request to approve
|
||||||
* @param reason - comments about the acceptance
|
* @param reason - comments about the acceptance
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"invitationId", "reason"})
|
||||||
public Invitation approve(String invitationId, String reason);
|
public Invitation approve(String invitationId, String reason);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User or moderator rejects this request
|
* User or moderator rejects this request
|
||||||
* @param invitationId
|
* @param invitationId
|
||||||
* @param reason
|
* @param reason
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"invitationId", "reason"})
|
||||||
public Invitation reject(String invitationId, String reason);
|
public Invitation reject(String invitationId, String reason);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cancel this request
|
* cancel this request
|
||||||
*/
|
*/
|
||||||
|
@Auditable(parameters = {"invitationId"})
|
||||||
public Invitation cancel (String invitationId);
|
public Invitation cancel (String invitationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user