. Invite Users screens for Manage Content Users and Manage Space Users now support email templates

. Added additional template model objects to the model supported by the MailActionExecutor
. Refactored various beans in the web-client that build lists of templates, to use a new Template support bean
. Added new email template files (one for Invite Users, the other for Email Actions)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2537 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-09 17:14:21 +00:00
parent c46e4f9449
commit 827c3b97b4
16 changed files with 320 additions and 254 deletions

View File

@@ -0,0 +1,13 @@
You have been invited to '${space.name}' by ${person.properties.firstName}<#if person.properties.lastName?exists> ${person.properties.lastName}</#if>.
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

View File

@@ -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}</#if>'. 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}</#if>.
You can view it through this link: You can view it through this link:
http://yourserver:8080/alfresco${document.url} http://yourserver:8080/alfresco${document.url}

View File

@@ -17,7 +17,6 @@
package org.alfresco.web.bean; package org.alfresco.web.bean;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -25,24 +24,19 @@ import java.util.Map;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel; 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.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateImageResolver; import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; 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;
import org.alfresco.web.ui.common.Utils.URLMode; import org.alfresco.web.ui.common.Utils.URLMode;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
@@ -254,42 +248,6 @@ public class SpaceDetailsBean
return model; 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<NodeRef> results = Repository.getServiceRegistry(context).getSearchService().selectNodes(
rootNodeRef, xpath, null, resolver, false);
List<SelectItem> templates = new ArrayList<SelectItem>(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 // Action event handlers
@@ -298,6 +256,8 @@ public class SpaceDetailsBean
* Action handler to apply the selected Template and Templatable aspect to the current Space * Action handler to apply the selected Template and Templatable aspect to the current Space
*/ */
public String applyTemplate() public String applyTemplate()
{
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
{ {
try try
{ {
@@ -321,6 +281,7 @@ public class SpaceDetailsBean
Utils.addErrorMessage(MessageFormat.format(Application.getMessage( Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e); FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
} }
}
return OUTCOME_RETURN; return OUTCOME_RETURN;
} }

View File

@@ -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.
* <p>
* 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<List<SelectItem>> contentTemplates = new ExpiringValueCache<List<SelectItem>>(1000*10);
/** cache of email templates that last 30 seconds - enough for a few page refreshes */
private ExpiringValueCache<List<SelectItem>> emailTemplates = new ExpiringValueCache<List<SelectItem>>(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<SelectItem> getContentTemplates()
{
List<SelectItem> 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<SelectItem> getEmailTemplates()
{
List<SelectItem> 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<SelectItem> selectTemplateNodes(FacesContext fc, String xpath)
{
List<SelectItem> templates = null;
try
{
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).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(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<SelectItem>(1);
}
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
return templates;
}
}

View File

@@ -35,6 +35,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NavigationBean; 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.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.IDataContainer;
@@ -48,33 +49,15 @@ import org.alfresco.web.ui.common.Utils;
*/ */
public abstract class BasePreviewBean public abstract class BasePreviewBean
{ {
private static final String NO_SELECTION = "none";
/** BrowseBean instance */ /** BrowseBean instance */
protected BrowseBean browseBean; protected BrowseBean browseBean;
/** NodeService instance */
protected NodeService nodeService;
/** The SearchService instance */
protected SearchService searchService;
/** The NavigationBean bean reference */ /** The NavigationBean bean reference */
protected NavigationBean navigator; protected NavigationBean navigator;
/** The selected Template Id */
protected NodeRef template; protected NodeRef template;
/** cache of templates that last 10 seconds - enough for a couple of page refreshes */
private ExpiringValueCache<List<SelectItem>> cachedTemplates = new ExpiringValueCache<List<SelectItem>>(1000*10);
/**
* @param nodeService The nodeService to set.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/** /**
* @param browseBean The BrowseBean to set. * @param browseBean The BrowseBean to set.
@@ -84,14 +67,6 @@ public abstract class BasePreviewBean
this.browseBean = browseBean; this.browseBean = browseBean;
} }
/**
* @param searchService The searchService to set.
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/** /**
* @param navigator The NavigationBean to set. * @param navigator The NavigationBean to set.
*/ */
@@ -127,64 +102,6 @@ public abstract class BasePreviewBean
return getNode().getName(); return getNode().getName();
} }
/**
* @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.getContentTemplatesFolderName(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;
}
/** /**
* Returns a model for use by the template on the Preview page. * 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) 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); this.template = new NodeRef(Repository.getStoreRef(), template);
} }

View File

@@ -44,8 +44,6 @@ import org.alfresco.repo.action.executer.MoveActionExecuter;
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter; import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter; import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
import org.alfresco.repo.action.executer.TransformActionExecuter; 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.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.dictionary.AspectDefinition; 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.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application; 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.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.IDataContainer;
@@ -73,6 +72,8 @@ import org.apache.commons.logging.LogFactory;
*/ */
public abstract class BaseActionWizard extends AbstractWizardBean public abstract class BaseActionWizard extends AbstractWizardBean
{ {
private static final Log logger = LogFactory.getLog(BaseActionWizard.class);
// parameter names for actions // parameter names for actions
public static final String PROP_CATEGORY = "category"; public static final String PROP_CATEGORY = "category";
public static final String PROP_ASPECT = "aspect"; 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_TEMPLATE = "template";
public static final String PROP_OBJECT_TYPE = "objecttype"; 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"; 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 // new rule/action wizard specific properties
protected boolean multiActionMode = false; protected boolean multiActionMode = false;
protected String action; protected String action;
@@ -122,8 +119,6 @@ public abstract class BaseActionWizard extends AbstractWizardBean
protected Map<String, String> actionDescriptions; protected Map<String, String> actionDescriptions;
protected Map<String, Serializable> currentActionProperties; protected Map<String, Serializable> currentActionProperties;
protected List<SelectItem> objectTypes; protected List<SelectItem> objectTypes;
/** cache of email templates that last 30 seconds - enough for a few page refreshes */
protected ExpiringValueCache<List<SelectItem>> cachedTemplates = new ExpiringValueCache<List<SelectItem>>(1000*30);
/** datamodel for table of selected email recipients */ /** datamodel for table of selected email recipients */
protected DataModel emailRecipientsDataModel; protected DataModel emailRecipientsDataModel;
@@ -367,7 +362,7 @@ public abstract class BaseActionWizard extends AbstractWizardBean
// add the template if one was selected by the user // add the template if one was selected by the user
String template = (String)this.currentActionProperties.get(PROP_TEMPLATE); 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)); actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), template));
} }
@@ -1020,64 +1015,6 @@ public abstract class BaseActionWizard extends AbstractWizardBean
return this.users; 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;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Action event handlers // Action event handlers

View File

@@ -20,6 +20,7 @@ import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
@@ -32,7 +33,9 @@ import javax.faces.model.SelectItem;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef; 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.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PermissionService; 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.service.namespace.NamespaceService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService; 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.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User; import org.alfresco.web.bean.repository.User;
import org.alfresco.web.ui.common.SortableSelectItem; import org.alfresco.web.ui.common.SortableSelectItem;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIGenericPicker; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
@@ -97,6 +102,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
private String body = null; private String body = null;
private String internalSubject = null; private String internalSubject = null;
private String automaticText = null; private String automaticText = null;
private String template = null;
/** /**
* @return a cached list of available permissions for the type being dealt with * @return a cached list of available permissions for the type being dealt with
@@ -166,6 +172,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
body = ""; body = "";
automaticText = ""; automaticText = "";
internalSubject = null; internalSubject = null;
template = null;
} }
/** /**
@@ -280,20 +287,32 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
if (to != null && to.length() != 0) if (to != null && to.length() != 0)
{ {
String msgRole = Application.getMessage(FacesContext.getCurrentInstance(), MSG_INVITED_ROLE); FacesContext fc = FacesContext.getCurrentInstance();
String body;
if (this.template == null || this.template.equals(TemplateSupportBean.NO_SELECTION) == true)
{
String msgRole = Application.getMessage(fc, MSG_INVITED_ROLE);
String roleMessage = MessageFormat.format(msgRole, new Object[] {roleText}); String roleMessage = MessageFormat.format(msgRole, new Object[] {roleText});
// TODO: include External Authentication link to the invited node body = this.internalSubject + "\r\n\r\n" + roleMessage + "\r\n\r\n";// + url + "\r\n\r\n";
//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) if (this.body != null && this.body.length() != 0)
{ {
body += this.body; body += this.body;
} }
}
else
{
// use template service to format the email
ServiceRegistry services = Repository.getServiceRegistry(fc);
Map<String, Object> 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(); SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
simpleMailMessage.setTo(to); simpleMailMessage.setTo(to);
@@ -600,6 +619,22 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
this.subject = subject; 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() * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
*/ */

View File

@@ -58,7 +58,7 @@ public class DefaultModelHelper
* *
* @return Map containing the default model. * @return Map containing the default model.
*/ */
public static Map buildDefaultModel(ServiceRegistry services, User user) public static Map<String, Object> buildDefaultModel(ServiceRegistry services, User user)
{ {
if (services == null) if (services == null)
{ {
@@ -70,7 +70,7 @@ public class DefaultModelHelper
} }
// create FreeMarker default model and merge // create FreeMarker default model and merge
Map root = new HashMap(16, 1.0f); Map<String, Object> root = new HashMap<String, Object>(16, 1.0f);
// supply the CompanyHome space as "companyhome" // supply the CompanyHome space as "companyhome"
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()); NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId());

View File

@@ -838,6 +838,23 @@
</managed-property> </managed-property>
</managed-bean> </managed-bean>
<managed-bean>
<description>
Backing bean used by screens requiring access to lists of Templates
</description>
<managed-bean-name>TemplateSupportBean</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.TemplateSupportBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>searchService</property-name>
<value>#{SearchService}</value>
</managed-property>
</managed-bean>
<managed-bean> <managed-bean>
<description> <description>
Backing bean used by the document preview dialog Backing bean used by the document preview dialog
@@ -849,14 +866,6 @@
<property-name>browseBean</property-name> <property-name>browseBean</property-name>
<value>#{BrowseBean}</value> <value>#{BrowseBean}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>searchService</property-name>
<value>#{SearchService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>navigator</property-name> <property-name>navigator</property-name>
<value>#{NavigationBean}</value> <value>#{NavigationBean}</value>
@@ -874,14 +883,6 @@
<property-name>browseBean</property-name> <property-name>browseBean</property-name>
<value>#{BrowseBean}</value> <value>#{BrowseBean}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>searchService</property-name>
<value>#{SearchService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>navigator</property-name> <property-name>navigator</property-name>
<value>#{NavigationBean}</value> <value>#{NavigationBean}</value>

View File

@@ -100,7 +100,7 @@
<td width=100%> <td width=100%>
<%-- Templates drop-down selector --%> <%-- Templates drop-down selector --%>
<h:selectOneMenu value="#{SpaceDetailsBean.template}"> <h:selectOneMenu value="#{SpaceDetailsBean.template}">
<f:selectItems value="#{SpaceDetailsBean.templates}" /> <f:selectItems value="#{TemplateSupportBean.contentTemplates}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>

View File

@@ -80,7 +80,7 @@
<div style="padding-top:4px"> <div style="padding-top:4px">
<%-- Templates drop-down selector --%> <%-- Templates drop-down selector --%>
<h:selectOneMenu id="template" value="#{DocumentPreviewBean.template}" onchange="document.forms['preview-file'].submit(); return true;"> <h:selectOneMenu id="template" value="#{DocumentPreviewBean.template}" onchange="document.forms['preview-file'].submit(); return true;">
<f:selectItems value="#{DocumentPreviewBean.templates}" /> <f:selectItems value="#{TemplateSupportBean.contentTemplates}" />
</h:selectOneMenu> </h:selectOneMenu>
</div> </div>
</td> </td>

View File

@@ -80,7 +80,7 @@
<div style="padding-top:4px"> <div style="padding-top:4px">
<%-- Templates drop-down selector --%> <%-- Templates drop-down selector --%>
<h:selectOneMenu id="template" value="#{SpacePreviewBean.template}" onchange="document.forms['preview-space'].submit(); return true;"> <h:selectOneMenu id="template" value="#{SpacePreviewBean.template}" onchange="document.forms['preview-space'].submit(); return true;">
<f:selectItems value="#{SpacePreviewBean.templates}" /> <f:selectItems value="#{TemplateSupportBean.contentTemplates}" />
</h:selectOneMenu> </h:selectOneMenu>
</div> </div>
</td> </td>

View File

@@ -165,7 +165,7 @@
<td> <td>
<%-- Templates drop-down selector --%> <%-- Templates drop-down selector --%>
<h:selectOneMenu value="#{NewActionWizard.actionProperties.template}"> <h:selectOneMenu value="#{NewActionWizard.actionProperties.template}">
<f:selectItems value="#{NewActionWizard.templates}" /> <f:selectItems value="#{TemplateSupportBean.emailTemplates}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>

View File

@@ -136,14 +136,14 @@
</td> </td>
</tr> </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> <tr>
<td><h:outputText value="#{msg.body}" />:</td> <td valign="top"><h:outputText value="#{msg.body}" />:</td>
<td> <td>
<h:inputTextarea value="#{InviteContentUsersWizard.body}" rows="2" cols="48" /> <h:inputTextarea value="#{InviteContentUsersWizard.body}" rows="2" cols="48" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr>
<tr> <tr>
<td colspan=2> <td colspan=2>
<table border=0 cellspacing=2 cellpadding=0> <table border=0 cellspacing=2 cellpadding=0>
@@ -159,6 +159,19 @@
</td> </td>
</tr> </tr>
<%-- template selector --%>
<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>
<%-- Email templates drop-down selector --%>
<h:selectOneMenu value="#{InviteContentUsersWizard.template}">
<f:selectItems value="#{TemplateSupportBean.emailTemplates}" />
</h:selectOneMenu>
</td>
</tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>
<tr> <tr>
<td colspan=2><h:outputText value="#{InviteContentUsersWizard.stepInstructions}" /></td> <td colspan=2><h:outputText value="#{InviteContentUsersWizard.stepInstructions}" /></td>

View File

@@ -136,14 +136,14 @@
</td> </td>
</tr> </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> <tr>
<td><h:outputText value="#{msg.body}" />:</td> <td valign="top"><h:outputText value="#{msg.body}" />:</td>
<td> <td>
<h:inputTextarea value="#{InviteSpaceUsersWizard.body}" rows="2" cols="48" /> <h:inputTextarea value="#{InviteSpaceUsersWizard.body}" rows="2" cols="48" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr>
<tr> <tr>
<td colspan=2> <td colspan=2>
<table border=0 cellspacing=2 cellpadding=0> <table border=0 cellspacing=2 cellpadding=0>
@@ -159,6 +159,19 @@
</td> </td>
</tr> </tr>
<%-- template selector --%>
<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>
<%-- Email templates drop-down selector --%>
<h:selectOneMenu value="#{InviteSpaceUsersWizard.template}">
<f:selectItems value="#{TemplateSupportBean.emailTemplates}" />
</h:selectOneMenu>
</td>
</tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>
<tr> <tr>
<td colspan=2><h:outputText value="#{InviteSpaceUsersWizard.stepInstructions}" /></td> <td colspan=2><h:outputText value="#{InviteSpaceUsersWizard.stepInstructions}" /></td>

View File

@@ -151,7 +151,7 @@
<td> <td>
<%-- Templates drop-down selector --%> <%-- Templates drop-down selector --%>
<h:selectOneMenu value="#{NewRuleWizard.actionProperties.template}"> <h:selectOneMenu value="#{NewRuleWizard.actionProperties.template}">
<f:selectItems value="#{NewRuleWizard.templates}" /> <f:selectItems value="#{TemplateSupportBean.emailTemplates}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>