mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
. Email template support added to Run Action, Create New Rule email action pages
. MailActionExecuter now uses the TemplateService to process the template selected in the UI git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2522 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -674,6 +674,9 @@ action_copy=Copy to
|
||||
action_extract_metadata=Extract metadata from content
|
||||
action_move=Move to
|
||||
action_mail=Send email to
|
||||
action_mail_message_text=Enter message text
|
||||
action_mail_template_text=Or select an email template for the message body
|
||||
action_mail_template=Template
|
||||
action_check_in=Check in content as ''{0}'' with comment ''{1}''
|
||||
action_check_out=Check out content to
|
||||
action_set_property_value=Sets property
|
||||
|
@@ -66,6 +66,7 @@ public class Application
|
||||
private static String glossaryFolderName;
|
||||
private static String spaceTemplatesFolderName;
|
||||
private static String contentTemplatesFolderName;
|
||||
private static String emailTemplatesFolderName;
|
||||
private static String savedSearchesFolderName;
|
||||
|
||||
/**
|
||||
@@ -323,6 +324,22 @@ public class Application
|
||||
return getContentTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Email templates folder name
|
||||
*/
|
||||
public static String getEmailTemplatesFolderName(ServletContext context)
|
||||
{
|
||||
return getEmailTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Email templates folder name
|
||||
*/
|
||||
public static String getEmailTemplatesFolderName(FacesContext context)
|
||||
{
|
||||
return getEmailTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the Saved Searches folder name
|
||||
*/
|
||||
@@ -634,6 +651,24 @@ public class Application
|
||||
return contentTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Email Templates folder name
|
||||
*
|
||||
* @param context The spring context
|
||||
* @return The email folder name
|
||||
*/
|
||||
private static String getEmailTemplatesFolderName(WebApplicationContext context)
|
||||
{
|
||||
if (emailTemplatesFolderName == null)
|
||||
{
|
||||
ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP);
|
||||
Properties configuration = bootstrap.getConfiguration();
|
||||
emailTemplatesFolderName = configuration.getProperty("spaces.templates.email.childname");
|
||||
}
|
||||
|
||||
return emailTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Saved Searches folder name
|
||||
*
|
||||
|
@@ -41,6 +41,8 @@ import org.alfresco.repo.action.executer.MoveActionExecuter;
|
||||
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
|
||||
import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
|
||||
import org.alfresco.repo.action.executer.TransformActionExecuter;
|
||||
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
@@ -85,11 +87,16 @@ public abstract class BaseActionWizard extends AbstractWizardBean
|
||||
public static final String PROP_MESSAGE = "message";
|
||||
public static final String PROP_SUBJECT = "subject";
|
||||
public static final String PROP_TO = "to";
|
||||
public static final String PROP_FROM = "from";
|
||||
public static final String PROP_TEMPLATE = "template";
|
||||
public static final String PROP_OBJECT_TYPE = "objecttype";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(BaseActionWizard.class);
|
||||
private static final String IMPORT_ENCODING = "UTF-8";
|
||||
|
||||
/** no selection marker for SelectItem lists */
|
||||
private static final String NO_SELECTION = "none";
|
||||
|
||||
// new rule/action wizard specific properties
|
||||
protected boolean multiActionMode = false;
|
||||
protected String action;
|
||||
@@ -105,6 +112,8 @@ public abstract class BaseActionWizard extends AbstractWizardBean
|
||||
protected Map<String, String> actionDescriptions;
|
||||
protected Map<String, Serializable> currentActionProperties;
|
||||
protected List<SelectItem> objectTypes;
|
||||
/** cache of email templates that last 10 seconds - enough for a couple of page refreshes */
|
||||
protected ExpiringValueCache<List<SelectItem>> cachedTemplates = new ExpiringValueCache<List<SelectItem>>(1000*10);
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
@@ -323,6 +332,17 @@ public abstract class BaseActionWizard extends AbstractWizardBean
|
||||
// add the subject for the email
|
||||
actionParams.put(MailActionExecuter.PARAM_SUBJECT,
|
||||
this.currentActionProperties.get(PROP_SUBJECT));
|
||||
|
||||
// add the from address
|
||||
String from = Application.getClientConfig(FacesContext.getCurrentInstance()).getFromEmailAddress();
|
||||
actionParams.put(MailActionExecuter.PARAM_FROM, from);
|
||||
|
||||
// add the template if one was selected by the user
|
||||
String template = (String)this.currentActionProperties.get(PROP_TEMPLATE);
|
||||
if (template != null && template.equals(NO_SELECTION) == false)
|
||||
{
|
||||
actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), template));
|
||||
}
|
||||
}
|
||||
else if (this.action.equals(ImporterActionExecuter.NAME))
|
||||
{
|
||||
@@ -911,4 +931,62 @@ public abstract class BaseActionWizard extends AbstractWizardBean
|
||||
|
||||
return this.users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of available Content Templates that can be applied to the current document.
|
||||
*/
|
||||
public List<SelectItem> getTemplates()
|
||||
{
|
||||
List<SelectItem> templates = cachedTemplates.get();
|
||||
if (templates == null)
|
||||
{
|
||||
// get the template from the special Content Templates folder
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(context) + "/" +
|
||||
Application.getGlossaryFolderName(context) + "/" +
|
||||
Application.getEmailTemplatesFolderName(context) + "//*";
|
||||
try
|
||||
{
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService();
|
||||
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
|
||||
|
||||
templates = new ArrayList<SelectItem>(results.size() + 1);
|
||||
if (results.size() != 0)
|
||||
{
|
||||
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
|
||||
for (NodeRef ref : results)
|
||||
{
|
||||
if (nodeService.exists(ref) == true)
|
||||
{
|
||||
Node childNode = new Node(ref);
|
||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
templates.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
}
|
||||
catch (AccessDeniedException accessErr)
|
||||
{
|
||||
// ignore the result if we cannot access the root
|
||||
}
|
||||
|
||||
// add an entry (at the start) to instruct the user to select a template
|
||||
if (templates == null)
|
||||
{
|
||||
templates = new ArrayList<SelectItem>(1);
|
||||
}
|
||||
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
||||
|
||||
cachedTemplates.put(templates);
|
||||
}
|
||||
|
||||
return templates;
|
||||
}
|
||||
}
|
||||
|
@@ -146,9 +146,12 @@
|
||||
<td width="90%">
|
||||
<h:inputText id="subject" value="#{NewActionWizard.actionProperties.subject}"
|
||||
size="75" maxlength="1024"
|
||||
onkeyup="javascript:checkButtonState();"/>
|
||||
onkeyup="javascript:checkButtonState();"/> *
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr><td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.action_mail_message_text}"/></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.message}"/>:</td>
|
||||
<td>
|
||||
@@ -156,6 +159,19 @@
|
||||
rows="5" cols="75" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr><td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.action_mail_template_text}"/></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.action_mail_template}"/>:</td>
|
||||
<td>
|
||||
<%-- Templates drop-down selector --%>
|
||||
<h:selectOneMenu value="#{NewActionWizard.actionProperties.template}">
|
||||
<f:selectItems value="#{NewActionWizard.templates}" />
|
||||
</h:selectOneMenu>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.to}"/>:</td>
|
||||
<td>
|
||||
|
@@ -126,15 +126,19 @@
|
||||
<tr>
|
||||
<td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.set_action_values}" /></td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr>
|
||||
<td><h:outputText value="#{msg.subject}"/>:</td>
|
||||
<td width="90%">
|
||||
<h:inputText id="subject" value="#{NewRuleWizard.actionProperties.subject}"
|
||||
size="75" maxlength="1024"
|
||||
onkeyup="javascript:checkButtonState();"/>
|
||||
onkeyup="javascript:checkButtonState();"/> *
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr><td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.action_mail_message_text}"/></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.message}"/>:</td>
|
||||
<td>
|
||||
@@ -142,6 +146,19 @@
|
||||
rows="5" cols="75" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr><td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.action_mail_template_text}"/></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.action_mail_template}"/>:</td>
|
||||
<td>
|
||||
<%-- Templates drop-down selector --%>
|
||||
<h:selectOneMenu value="#{NewRuleWizard.actionProperties.template}">
|
||||
<f:selectItems value="#{NewRuleWizard.templates}" />
|
||||
</h:selectOneMenu>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr>
|
||||
<td valign="top"><h:outputText value="#{msg.to}"/>:</td>
|
||||
<td>
|
||||
@@ -151,6 +168,7 @@
|
||||
</h:selectOneMenu>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td class="paddingRow"></td></tr>
|
||||
</table>
|
||||
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>
|
||||
|
Reference in New Issue
Block a user