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
This commit is contained in:
Kevin Roast
2010-04-21 10:21:13 +00:00
parent 9d9cf7d7cd
commit 82dc2c6ab5

View File

@@ -26,8 +26,10 @@ import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem; import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.dictionary.DictionaryService; 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.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
@@ -124,7 +126,7 @@ public class TemplateSupportBean implements Serializable
Application.getGlossaryFolderName(fc) + "/" + Application.getGlossaryFolderName(fc) + "/" +
Application.getContentTemplatesFolderName(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); contentTemplates.put(templates);
} }
@@ -146,7 +148,7 @@ public class TemplateSupportBean implements Serializable
Application.getGlossaryFolderName(fc) + "/" + Application.getGlossaryFolderName(fc) + "/" +
Application.getEmailTemplatesFolderName(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); emailTemplates.put(templates);
} }
@@ -168,7 +170,7 @@ public class TemplateSupportBean implements Serializable
Application.getEmailTemplatesFolderName(fc) + "/" + Application.getEmailTemplatesFolderName(fc) + "/" +
Application.getNotifyEmailTemplatesFolderName(fc) + "//*"; Application.getNotifyEmailTemplatesFolderName(fc) + "//*";
templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE); templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE, MimetypeMap.MIMETYPE_TEXT_PLAIN);
return templates; return templates;
} }
@@ -187,7 +189,7 @@ public class TemplateSupportBean implements Serializable
Application.getGlossaryFolderName(fc) + "/" + Application.getGlossaryFolderName(fc) + "/" +
Application.getRSSTemplatesFolderName(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); rssTemplates.put(templates);
} }
@@ -209,7 +211,7 @@ public class TemplateSupportBean implements Serializable
Application.getGlossaryFolderName(fc) + "/" + Application.getGlossaryFolderName(fc) + "/" +
Application.getScriptsFolderName(fc) + "//*"; Application.getScriptsFolderName(fc) + "//*";
scripts = selectDictionaryNodes(fc, xpath, MSG_SELECT_SCRIPT); scripts = selectDictionaryNodes(fc, xpath, MSG_SELECT_SCRIPT, MimetypeMap.MIMETYPE_JAVASCRIPT);
scriptFiles.put(scripts); 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 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 * @return List of SelectItem wrapper objects for the nodes found at the XPath
*/ */
private List<SelectItem> selectDictionaryNodes(FacesContext fc, String xpath, String noSelectionLabel) private List<SelectItem> 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<SelectItem> selectDictionaryNodes(FacesContext fc, String xpath, String noSelectionLabel, String mimetype)
{ {
List<SelectItem> wrappers = null; List<SelectItem> wrappers = null;
@@ -242,7 +258,9 @@ public class TemplateSupportBean implements Serializable
if (this.getNodeService().exists(ref) == true) if (this.getNodeService().exists(ref) == true)
{ {
Node childNode = new Node(ref); 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())); wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
} }