From 82dc2c6ab5251c4c9c455ecd390fedc1ea89a9a1 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 21 Apr 2010 10:21:13 +0000 Subject: [PATCH] Fix for ALF-2510 - filtering out of doclib thumbnails from lists of templates and scripts retrieved from Data Dictionary in Explorer client. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19928 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/bean/TemplateSupportBean.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/source/java/org/alfresco/web/bean/TemplateSupportBean.java b/source/java/org/alfresco/web/bean/TemplateSupportBean.java index 4a87ba218a..048911de36 100644 --- a/source/java/org/alfresco/web/bean/TemplateSupportBean.java +++ b/source/java/org/alfresco/web/bean/TemplateSupportBean.java @@ -26,8 +26,10 @@ import javax.faces.context.FacesContext; import javax.faces.model.SelectItem; import org.alfresco.model.ContentModel; +import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.search.SearchService; @@ -124,7 +126,7 @@ public class TemplateSupportBean implements Serializable Application.getGlossaryFolderName(fc) + "/" + Application.getContentTemplatesFolderName(fc) + "//*"; - templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE); + templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE, MimetypeMap.MIMETYPE_TEXT_PLAIN); contentTemplates.put(templates); } @@ -146,7 +148,7 @@ public class TemplateSupportBean implements Serializable Application.getGlossaryFolderName(fc) + "/" + Application.getEmailTemplatesFolderName(fc) + "//*"; - templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE); + templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE, MimetypeMap.MIMETYPE_TEXT_PLAIN); emailTemplates.put(templates); } @@ -168,7 +170,7 @@ public class TemplateSupportBean implements Serializable Application.getEmailTemplatesFolderName(fc) + "/" + Application.getNotifyEmailTemplatesFolderName(fc) + "//*"; - templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE); + templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE, MimetypeMap.MIMETYPE_TEXT_PLAIN); return templates; } @@ -187,7 +189,7 @@ public class TemplateSupportBean implements Serializable Application.getGlossaryFolderName(fc) + "/" + Application.getRSSTemplatesFolderName(fc) + "//*"; - templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE); + templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE, MimetypeMap.MIMETYPE_TEXT_PLAIN); rssTemplates.put(templates); } @@ -209,7 +211,7 @@ public class TemplateSupportBean implements Serializable Application.getGlossaryFolderName(fc) + "/" + Application.getScriptsFolderName(fc) + "//*"; - scripts = selectDictionaryNodes(fc, xpath, MSG_SELECT_SCRIPT); + scripts = selectDictionaryNodes(fc, xpath, MSG_SELECT_SCRIPT, MimetypeMap.MIMETYPE_JAVASCRIPT); scriptFiles.put(scripts); } @@ -218,12 +220,26 @@ public class TemplateSupportBean implements Serializable } /** - * @param context FacesContext + * @param fc FacesContext * @param xpath XPath to the nodes to select + * @param noSelectionLabel Label to add to the list if no items are found in the search * * @return List of SelectItem wrapper objects for the nodes found at the XPath */ private List selectDictionaryNodes(FacesContext fc, String xpath, String noSelectionLabel) + { + return selectDictionaryNodes(fc, xpath, noSelectionLabel, null); + } + + /** + * @param fc FacesContext + * @param xpath XPath to the nodes to select + * @param noSelectionLabel Label to add to the list if no items are found in the search + * @param mimetype Optional mimetype of items to add, will not add to list if mimetype does not match + * + * @return List of SelectItem wrapper objects for the nodes found at the XPath + */ + private List selectDictionaryNodes(FacesContext fc, String xpath, String noSelectionLabel, String mimetype) { List wrappers = null; @@ -242,7 +258,9 @@ public class TemplateSupportBean implements Serializable if (this.getNodeService().exists(ref) == true) { Node childNode = new Node(ref); - if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) + ContentData content = (ContentData)childNode.getProperties().get(ContentModel.PROP_CONTENT); + if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT) && + (mimetype == null || mimetype.equals(content.getMimetype()))) { wrappers.add(new SelectItem(childNode.getId(), childNode.getName())); }