diff --git a/config/alfresco/templates/email/invite_user_email.ftl b/config/alfresco/templates/email/invite_user_email.ftl new file mode 100644 index 0000000000..4686476111 --- /dev/null +++ b/config/alfresco/templates/email/invite_user_email.ftl @@ -0,0 +1,13 @@ +You have been invited to '${space.name}' by ${person.properties.firstName}<#if person.properties.lastName?exists> ${person.properties.lastName}. + +You will have the role of: ${role} + +You can view the space through the Alfresco client: +<#assign ref=space.nodeRef> +<#assign workspace=ref[0..ref?index_of("://")-1]> +<#assign storenode=ref[ref?index_of("://")+3..]> +http://yourserver:8080/alfresco/navigate/browse/${workspace}/${storenode} + +Regards + +Alfresco diff --git a/config/alfresco/templates/email/simple_email_template.ftl b/config/alfresco/templates/email/notify_user_email.ftl similarity index 74% rename from config/alfresco/templates/email/simple_email_template.ftl rename to config/alfresco/templates/email/notify_user_email.ftl index 64d8c54c68..8a4d5e8473 100644 --- a/config/alfresco/templates/email/simple_email_template.ftl +++ b/config/alfresco/templates/email/notify_user_email.ftl @@ -1,4 +1,4 @@ -A new document '${document.name}', is available in the '${space.name}' space, it was added by '${person.properties.firstName}<#if person.properties.lastName?exists> ${person.properties.lastName}'. +A new document '${document.name}', is available in the '${space.name}' space, it was added by ${person.properties.firstName}<#if person.properties.lastName?exists> ${person.properties.lastName}. You can view it through this link: http://yourserver:8080/alfresco${document.url} diff --git a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java index d0ae8cd24d..7199749564 100644 --- a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java +++ b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java @@ -17,7 +17,6 @@ package org.alfresco.web.bean; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,24 +24,19 @@ import java.util.Map; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; -import javax.faces.model.SelectItem; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.TemplateImageResolver; import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.data.IDataContainer; -import org.alfresco.web.data.QuickSort; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils.URLMode; import org.alfresco.web.ui.common.component.UIActionLink; @@ -254,42 +248,6 @@ public class SpaceDetailsBean return model; } - /** - * @return the list of available Content Templates that can be applied to the current document. - */ - public SelectItem[] getTemplates() - { - // get the template from the special Content Templates folder - FacesContext context = FacesContext.getCurrentInstance(); - String xpath = Application.getRootPath(context) + "/" + - Application.getGlossaryFolderName(context) + "/" + - Application.getContentTemplatesFolderName(context) + "//*"; - NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef()); - NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService(); - List results = Repository.getServiceRegistry(context).getSearchService().selectNodes( - rootNodeRef, xpath, null, resolver, false); - - List templates = new ArrayList(results.size()); - if (results.size() != 0) - { - DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService(); - for (NodeRef ref : results) - { - 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(); - } - - return templates.toArray(new SelectItem[templates.size()]); - } - // ------------------------------------------------------------------------------ // Action event handlers @@ -299,27 +257,30 @@ public class SpaceDetailsBean */ public String applyTemplate() { - try + if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false) { - // apply the templatable aspect if required - if (getSpace().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false) + try { - this.nodeService.addAspect(getSpace().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null); + // apply the templatable aspect if required + if (getSpace().hasAspect(ContentModel.ASPECT_TEMPLATABLE) == false) + { + this.nodeService.addAspect(getSpace().getNodeRef(), ContentModel.ASPECT_TEMPLATABLE, null); + } + + // get the selected template from the Template Picker + NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template); + + // set the template NodeRef into the templatable aspect property + this.nodeService.setProperty(getSpace().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef); + + // reset space details for next refresh of details page + getSpace().reset(); + } + catch (Exception e) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e); } - - // get the selected template from the Template Picker - NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template); - - // set the template NodeRef into the templatable aspect property - this.nodeService.setProperty(getSpace().getNodeRef(), ContentModel.PROP_TEMPLATE, templateRef); - - // reset space details for next refresh of details page - getSpace().reset(); - } - catch (Exception e) - { - Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e); } return OUTCOME_RETURN; } diff --git a/source/java/org/alfresco/web/bean/TemplateSupportBean.java b/source/java/org/alfresco/web/bean/TemplateSupportBean.java new file mode 100644 index 0000000000..24a14ad454 --- /dev/null +++ b/source/java/org/alfresco/web/bean/TemplateSupportBean.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.web.bean; + +import java.util.ArrayList; +import java.util.List; + +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.cache.ExpiringValueCache; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.data.IDataContainer; +import org.alfresco.web.data.QuickSort; + +/** + * Provide access to commonly used lists of templates. + *

+ * The lists are cached for a small period of time to help performance in the client, + * as generally the contents of the template folders are not changed frequently. + * + * @author Kevin Roast + */ +public class TemplateSupportBean +{ + /** "no selection" marker for SelectItem lists */ + public static final String NO_SELECTION = "none"; + + /** NodeService instance */ + private NodeService nodeService; + + /** The SearchService instance */ + private SearchService searchService; + + /** cache of content templates that last 10 seconds - enough for a couple of page refreshes */ + private ExpiringValueCache> contentTemplates = new ExpiringValueCache>(1000*10); + + /** cache of email templates that last 30 seconds - enough for a few page refreshes */ + private ExpiringValueCache> emailTemplates = new ExpiringValueCache>(1000*30); + + + /** + * @param nodeService The NodeService to set. + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param searchService The SearchService to set. + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + /** + * @return the list of available Content Templates that can be applied to the current document. + */ + public List getContentTemplates() + { + List templates = contentTemplates.get(); + if (templates == null) + { + // get the template from the special Content Templates folder + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + + Application.getGlossaryFolderName(fc) + "/" + + Application.getContentTemplatesFolderName(fc) + "//*"; + + templates = selectTemplateNodes(fc, xpath); + + contentTemplates.put(templates); + } + + return templates; + } + + /** + * @return the list of available Email Templates. + */ + public List getEmailTemplates() + { + List templates = emailTemplates.get(); + if (templates == null) + { + // get the template from the special Email Templates folder + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + + Application.getGlossaryFolderName(fc) + "/" + + Application.getEmailTemplatesFolderName(fc) + "//*"; + + templates = selectTemplateNodes(fc, xpath); + + emailTemplates.put(templates); + } + + return templates; + } + + /** + * @param context FacesContext + * @param xpath XPath to the template nodes to select + * + * @return List of SelectItem object from the template nodes found at the XPath + */ + private List selectTemplateNodes(FacesContext fc, String xpath) + { + List templates = null; + + try + { + NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef()); + NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService(); + List results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false); + + templates = new ArrayList(results.size() + 1); + if (results.size() != 0) + { + DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService(); + for (NodeRef ref : results) + { + if (this.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(1); + } + templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template"))); + + return templates; + } +} diff --git a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java index 4a1b92451f..49d8869516 100644 --- a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java +++ b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java @@ -35,6 +35,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.app.Application; import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.NavigationBean; +import org.alfresco.web.bean.TemplateSupportBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; @@ -48,33 +49,15 @@ import org.alfresco.web.ui.common.Utils; */ public abstract class BasePreviewBean { - private static final String NO_SELECTION = "none"; - /** BrowseBean instance */ protected BrowseBean browseBean; - /** NodeService instance */ - protected NodeService nodeService; - - /** The SearchService instance */ - protected SearchService searchService; - /** The NavigationBean bean reference */ protected NavigationBean navigator; + /** The selected Template Id */ protected NodeRef template; - /** cache of templates that last 10 seconds - enough for a couple of page refreshes */ - private ExpiringValueCache> cachedTemplates = new ExpiringValueCache>(1000*10); - - - /** - * @param nodeService The nodeService to set. - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } /** * @param browseBean The BrowseBean to set. @@ -84,14 +67,6 @@ public abstract class BasePreviewBean this.browseBean = browseBean; } - /** - * @param searchService The searchService to set. - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - /** * @param navigator The NavigationBean to set. */ @@ -127,64 +102,6 @@ public abstract class BasePreviewBean return getNode().getName(); } - /** - * @return the list of available Content Templates that can be applied to the current document. - */ - public List getTemplates() - { - List 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.getContentTemplatesFolderName(context) + "//*"; - try - { - NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef()); - NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService(); - List results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false); - - templates = new ArrayList(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(1); - } - templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template"))); - - cachedTemplates.put(templates); - } - - return templates; - } - /** * Returns a model for use by the template on the Preview page. * @@ -222,7 +139,7 @@ public abstract class BasePreviewBean */ public void setTemplate(String template) { - if (template != null && template.equals(NO_SELECTION) == false) + if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false) { this.template = new NodeRef(Repository.getStoreRef(), template); } diff --git a/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java b/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java index b5b5e42c38..5e9827eae8 100644 --- a/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/BaseActionWizard.java @@ -44,8 +44,6 @@ 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; @@ -58,6 +56,7 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; +import org.alfresco.web.bean.TemplateSupportBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; @@ -73,6 +72,8 @@ import org.apache.commons.logging.LogFactory; */ public abstract class BaseActionWizard extends AbstractWizardBean { + private static final Log logger = LogFactory.getLog(BaseActionWizard.class); + // parameter names for actions public static final String PROP_CATEGORY = "category"; public static final String PROP_ASPECT = "aspect"; @@ -97,12 +98,8 @@ public abstract class BaseActionWizard extends AbstractWizardBean 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; @@ -122,8 +119,6 @@ public abstract class BaseActionWizard extends AbstractWizardBean protected Map actionDescriptions; protected Map currentActionProperties; protected List objectTypes; - /** cache of email templates that last 30 seconds - enough for a few page refreshes */ - protected ExpiringValueCache> cachedTemplates = new ExpiringValueCache>(1000*30); /** datamodel for table of selected email recipients */ protected DataModel emailRecipientsDataModel; @@ -367,7 +362,7 @@ public abstract class BaseActionWizard extends AbstractWizardBean // 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) + if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false) { actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), template)); } @@ -1020,64 +1015,6 @@ 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 getTemplates() - { - List 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 results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false); - - templates = new ArrayList(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(1); - } - templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template"))); - - cachedTemplates.put(templates); - } - - return templates; - } - // ------------------------------------------------------------------------------ // Action event handlers diff --git a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java index b85a176e07..80fd96f85e 100644 --- a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.ResourceBundle; import java.util.Set; @@ -32,7 +33,9 @@ import javax.faces.model.SelectItem; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.PermissionService; @@ -40,12 +43,14 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.UIContextService; +import org.alfresco.web.bean.TemplateSupportBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; import org.alfresco.web.ui.common.SortableSelectItem; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIGenericPicker; +import org.alfresco.web.ui.repo.component.template.DefaultModelHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.mail.SimpleMailMessage; @@ -97,6 +102,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean private String body = null; private String internalSubject = null; private String automaticText = null; + private String template = null; /** * @return a cached list of available permissions for the type being dealt with @@ -166,6 +172,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean body = ""; automaticText = ""; internalSubject = null; + template = null; } /** @@ -280,19 +287,31 @@ public abstract class InviteUsersWizard extends AbstractWizardBean if (to != null && to.length() != 0) { - String msgRole = Application.getMessage(FacesContext.getCurrentInstance(), MSG_INVITED_ROLE); - String roleMessage = MessageFormat.format(msgRole, new Object[] {roleText}); + FacesContext fc = FacesContext.getCurrentInstance(); - // TODO: include External Authentication link to the invited node - //String args = node.getStoreRef().getProtocol() + '/' + - // node.getStoreRef().getIdentifier() + '/' + - // node.getId(); - //String url = ExternalAccessServlet.generateExternalURL(LoginBean.OUTCOME_SPACEDETAILS, args); - - String body = this.internalSubject + "\r\n\r\n" + roleMessage + "\r\n\r\n";// + url + "\r\n\r\n"; - if (this.body != null && this.body.length() != 0) + String body; + if (this.template == null || this.template.equals(TemplateSupportBean.NO_SELECTION) == true) { - body += this.body; + String msgRole = Application.getMessage(fc, MSG_INVITED_ROLE); + String roleMessage = MessageFormat.format(msgRole, new Object[] {roleText}); + + body = this.internalSubject + "\r\n\r\n" + roleMessage + "\r\n\r\n";// + url + "\r\n\r\n"; + if (this.body != null && this.body.length() != 0) + { + body += this.body; + } + } + else + { + // use template service to format the email + ServiceRegistry services = Repository.getServiceRegistry(fc); + Map model = DefaultModelHelper.buildDefaultModel( + services, Application.getCurrentUser(fc)); + model.put("role", roleText); + model.put("space", new TemplateNode(node, Repository.getServiceRegistry(fc), null)); + + NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.template); + body = services.getTemplateService().processTemplate("freemarker", templateRef.toString(), model); } SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); @@ -599,6 +618,22 @@ public abstract class InviteUsersWizard extends AbstractWizardBean { this.subject = subject; } + + /** + * @return Returns the email template Id + */ + public String getTemplate() + { + return this.template; + } + + /** + * @param template The email template to set. + */ + public void setTemplate(String template) + { + this.template = template; + } /** * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription() diff --git a/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java b/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java index 3c9a7c40da..22721ceb8b 100644 --- a/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java +++ b/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java @@ -58,7 +58,7 @@ public class DefaultModelHelper * * @return Map containing the default model. */ - public static Map buildDefaultModel(ServiceRegistry services, User user) + public static Map buildDefaultModel(ServiceRegistry services, User user) { if (services == null) { @@ -70,7 +70,7 @@ public class DefaultModelHelper } // create FreeMarker default model and merge - Map root = new HashMap(16, 1.0f); + Map root = new HashMap(16, 1.0f); // supply the CompanyHome space as "companyhome" NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()); diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index df2ee6e1d2..cb9fe84049 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -838,6 +838,23 @@ + + + Backing bean used by screens requiring access to lists of Templates + + TemplateSupportBean + org.alfresco.web.bean.TemplateSupportBean + session + + nodeService + #{NodeService} + + + searchService + #{SearchService} + + + Backing bean used by the document preview dialog @@ -849,14 +866,6 @@ browseBean #{BrowseBean} - - nodeService - #{NodeService} - - - searchService - #{SearchService} - navigator #{NavigationBean} @@ -874,14 +883,6 @@ browseBean #{BrowseBean} - - nodeService - #{NodeService} - - - searchService - #{SearchService} - navigator #{NavigationBean} diff --git a/source/web/jsp/dialog/apply-template.jsp b/source/web/jsp/dialog/apply-template.jsp index 4e11c06c52..62332cce64 100644 --- a/source/web/jsp/dialog/apply-template.jsp +++ b/source/web/jsp/dialog/apply-template.jsp @@ -100,7 +100,7 @@ <%-- Templates drop-down selector --%> - + diff --git a/source/web/jsp/dialog/preview-file.jsp b/source/web/jsp/dialog/preview-file.jsp index 2c468c209a..4fb60d7e98 100644 --- a/source/web/jsp/dialog/preview-file.jsp +++ b/source/web/jsp/dialog/preview-file.jsp @@ -80,7 +80,7 @@

<%-- Templates drop-down selector --%> - +
diff --git a/source/web/jsp/dialog/preview-space.jsp b/source/web/jsp/dialog/preview-space.jsp index b733b41a98..4a1c0c30d6 100644 --- a/source/web/jsp/dialog/preview-space.jsp +++ b/source/web/jsp/dialog/preview-space.jsp @@ -80,7 +80,7 @@
<%-- Templates drop-down selector --%> - +
diff --git a/source/web/jsp/wizard/create-action/action-email.jsp b/source/web/jsp/wizard/create-action/action-email.jsp index c71076599f..4fc2a9523f 100644 --- a/source/web/jsp/wizard/create-action/action-email.jsp +++ b/source/web/jsp/wizard/create-action/action-email.jsp @@ -165,7 +165,7 @@ <%-- Templates drop-down selector --%> - + diff --git a/source/web/jsp/wizard/invite-content-users/notify.jsp b/source/web/jsp/wizard/invite-content-users/notify.jsp index 290880b643..9d51686c15 100644 --- a/source/web/jsp/wizard/invite-content-users/notify.jsp +++ b/source/web/jsp/wizard/invite-content-users/notify.jsp @@ -136,14 +136,14 @@ + + - : + : - - @@ -159,6 +159,19 @@ + <%-- template selector --%> + + + + + + + diff --git a/source/web/jsp/wizard/invite-users/notify.jsp b/source/web/jsp/wizard/invite-users/notify.jsp index 59f8b2b797..6d2305c325 100644 --- a/source/web/jsp/wizard/invite-users/notify.jsp +++ b/source/web/jsp/wizard/invite-users/notify.jsp @@ -136,14 +136,14 @@ + + - + - -
: + <%-- Email templates drop-down selector --%> + + + +
::
@@ -159,6 +159,19 @@ + <%-- template selector --%> + + + + + + + diff --git a/source/web/jsp/wizard/new-rule/action-email.jsp b/source/web/jsp/wizard/new-rule/action-email.jsp index 9cd1570165..15a01c4856 100644 --- a/source/web/jsp/wizard/new-rule/action-email.jsp +++ b/source/web/jsp/wizard/new-rule/action-email.jsp @@ -151,7 +151,7 @@
: + <%-- Email templates drop-down selector --%> + + + +
<%-- Templates drop-down selector --%> - +