From 11b84ca0cbb870c7b5cb3ad97ff61170aab6becb Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Fri, 10 Feb 2006 14:43:19 +0000 Subject: [PATCH] . Update of all example template files - for bootstrap and source distribution. . Fixed templates list in Preview screen to catch AccessDeniedException for Guest user access to templates folder git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2339 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../templates/RSS_2.0_recent_docs.ftl | 2 +- config/alfresco/templates/doc_info.ftl | 33 +++++------ config/alfresco/templates/general_example.ftl | 49 ++++++++++++++++ config/alfresco/templates/localizable.ftl | 14 +++-- config/alfresco/templates/my_docs_inline.ftl | 15 +++++ config/alfresco/templates/translatable.ftl | 20 ++++--- config/alfresco/templates/xpath_search.ftl | 26 +++++++++ .../web/bean/preview/BasePreviewBean.java | 56 +++++++++++-------- 8 files changed, 162 insertions(+), 53 deletions(-) create mode 100644 config/alfresco/templates/general_example.ftl create mode 100644 config/alfresco/templates/my_docs_inline.ftl create mode 100644 config/alfresco/templates/xpath_search.ftl diff --git a/config/alfresco/templates/RSS_2.0_recent_docs.ftl b/config/alfresco/templates/RSS_2.0_recent_docs.ftl index 25e1d9e516..4e4e68a4e8 100644 --- a/config/alfresco/templates/RSS_2.0_recent_docs.ftl +++ b/config/alfresco/templates/RSS_2.0_recent_docs.ftl @@ -12,7 +12,7 @@ ${date?string(datetimeformat)} ${date?string(datetimeformat)} 120 - Alfresco 1.1 + Alfresco 1.2 ${space.name} 32 diff --git a/config/alfresco/templates/doc_info.ftl b/config/alfresco/templates/doc_info.ftl index 859ba73dd7..00af7cc5b0 100644 --- a/config/alfresco/templates/doc_info.ftl +++ b/config/alfresco/templates/doc_info.ftl @@ -1,17 +1,18 @@ <#-- Shows some general info about the current document, including NodeRef and aspects applied --> -

=====Template Start=====

- -

Current Document Info:

-Name: ${document.name}
-Ref: ${document.nodeRef}
-Type: ${document.type}
-Content URL: /alfresco${document.url}
-Locked: <#if document.isLocked>Yes<#else>No
-Aspects: - -<#list document.aspects as aspect> - - -
${aspect}
- -

=====Template End=====

+

General document info

+<#if document?exists> +

Current Document Info:

+ Name: ${document.name}
+ Ref: ${document.nodeRef}
+ Type: ${document.type}
+ Content URL: /alfresco${document.url}
+ Locked: <#if document.isLocked>Yes<#else>No
+ Aspects: + + <#list document.aspects as aspect> + + +
${aspect}
+<#else> + No document found! + diff --git a/config/alfresco/templates/general_example.ftl b/config/alfresco/templates/general_example.ftl new file mode 100644 index 0000000000..c39d9b855f --- /dev/null +++ b/config/alfresco/templates/general_example.ftl @@ -0,0 +1,49 @@ +

=====Example Template Start=====

+ +Company Home Space: ${companyhome.properties.name} +
+My Home Space: ${userhome.properties.name} +
+Company Home children count: ${companyhome.children?size} +
+Company Home first child node name: ${companyhome.children[0].properties.name} +
+<#if document?exists> +Current Document Name: ${document.name} +
+ +Current Space Name: ${space.name} + +

List of child spaces in my Home Space:

+ +<#list userhome.children as child> + <#if child.isContainer> + + + + + + + +
${child.properties.name} (${child.children?size})Path: ${child.displayPath}
+ +

List of docs in my Home Space (text only content shown inline, JPG images shown as thumbnails):

+ +<#list userhome.children as child> + <#if child.isDocument> + + <#if child.mimetype = "text/plain"> + + <#elseif child.mimetype = "image/jpeg"> + + + + +
${child.properties.name}
${child.content}
+ +

Assoc example:

+<#if userhome.children[0].assocs["cm:contains"]?exists> + ${userhome.children[0].assocs["cm:contains"][0].name} + + +

=====Example Template End=====

diff --git a/config/alfresco/templates/localizable.ftl b/config/alfresco/templates/localizable.ftl index 12cf233a83..2b800f9ec0 100644 --- a/config/alfresco/templates/localizable.ftl +++ b/config/alfresco/templates/localizable.ftl @@ -1,10 +1,14 @@ <#-- Shows if a document is localizable and the locale if set --> Localisable: -<#if hasAspect(document, "cm:localizable") = 1> - Yes
- <#if document.properties.locale?exists> - Locale: ${document.properties.locale.properties.name} +<#if document?exists> + <#if hasAspect(document, "cm:localizable") = 1> + Yes
+ <#if document.properties.locale?exists> + Locale: ${document.properties.locale.properties.name} + + <#else> + No
<#else> - No
+ No document found! diff --git a/config/alfresco/templates/my_docs_inline.ftl b/config/alfresco/templates/my_docs_inline.ftl new file mode 100644 index 0000000000..20e56a336c --- /dev/null +++ b/config/alfresco/templates/my_docs_inline.ftl @@ -0,0 +1,15 @@ +<#-- List of docs in the Home Space for current user --> +<#-- If the doc mimetype is plain/text then the content is shown inline --> +<#-- If the doc mimetype is JPEG then the image is shown inline as a small thumbnail image --> + +<#list userhome.children as child> + <#if child.isDocument> + + <#if child.mimetype = "text/plain"> + + <#elseif child.mimetype = "image/jpeg"> + + + + +
${child.properties.name}
${child.content}
diff --git a/config/alfresco/templates/translatable.ftl b/config/alfresco/templates/translatable.ftl index f47dc69d98..664f6e78e2 100644 --- a/config/alfresco/templates/translatable.ftl +++ b/config/alfresco/templates/translatable.ftl @@ -1,12 +1,16 @@ <#-- Shows the translations applied to a doc through the translatable aspect --> Translatable: -<#if hasAspect(document, "cm:translatable") = 1> - Yes
- - <#list document.assocs["cm:translations"] as t> - - -
${t.content}
+<#if document?exists> + <#if hasAspect(document, "cm:translatable") = 1> + Yes
+ + <#list document.assocs["cm:translations"] as t> + + +
${t.content}
+ <#else> + No
+ <#else> - No
+ No document found! diff --git a/config/alfresco/templates/xpath_search.ftl b/config/alfresco/templates/xpath_search.ftl new file mode 100644 index 0000000000..9d9a34c150 --- /dev/null +++ b/config/alfresco/templates/xpath_search.ftl @@ -0,0 +1,26 @@ +<#-- Shows use of the childByNamePath, childrenByXPath and childrenByLuceneSearch API --> + +

Template Documents in 'Company Home/Data Dictionary/Content Templates':

+ +<#list companyhome.childByNamePath["Data Dictionary/Content Templates"].children as child> + <#if child.isDocument> + + + +
${child.properties.name}
+ +

Folders in 'Company Home/Data Dictionary/Space Templates/Software Engineering Project':

+ +<#list companyhome.childrenByXPath["*[@cm:name='Data Dictionary']/*[@cm:name='Space Templates']/*[@cm:name='Software Engineering Project']/*"] as child> + <#if child.isContainer> + + + +
${child.properties.name}
+ +

Lucene Search - documents containing the text 'Alfresco'

+ +<#list companyhome.childrenByLuceneSearch["TEXT:alfresco"] as child> + + +
${child.properties.name}
diff --git a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java index 1472bf6bcb..4a1b92451f 100644 --- a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java +++ b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java @@ -17,24 +17,21 @@ package org.alfresco.web.bean.preview; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import javax.faces.context.FacesContext; -import javax.faces.event.ActionEvent; 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.repository.TemplateImageResolver; -import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.NavigationBean; @@ -43,7 +40,6 @@ 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.component.UIActionLink; /** * Backing bean for the Preview Document in Template action page @@ -144,29 +140,43 @@ public abstract class BasePreviewBean 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 = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false); - - templates = new ArrayList(results.size() + 1); - if (results.size() != 0) + try { - 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())); - } - } + NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef()); + NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService(); + List results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false); - // make sure the list is sorted by the label - QuickSort sorter = new QuickSort(templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE); - sorter.sort(); + 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);