. 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
This commit is contained in:
Kevin Roast
2006-02-10 14:43:19 +00:00
parent 4192db5f76
commit 11b84ca0cb
8 changed files with 162 additions and 53 deletions

View File

@@ -12,7 +12,7 @@
<lastBuildDate>${date?string(datetimeformat)}</lastBuildDate>
<pubDate>${date?string(datetimeformat)}</pubDate>
<ttl>120</ttl>
<generator>Alfresco 1.1</generator>
<generator>Alfresco 1.2</generator>
<image>
<title>${space.name}</title>
<width>32</width>

View File

@@ -1,17 +1,18 @@
<#-- Shows some general info about the current document, including NodeRef and aspects applied -->
<h3>=====Template Start=====</h3>
<h4>Current Document Info:</h4>
<b>Name:</b> ${document.name}<br>
<b>Ref:</b> ${document.nodeRef}<br>
<b>Type:</b> ${document.type}<br>
<b>Content URL:</b> <a href="/alfresco${document.url}">/alfresco${document.url}</a><br>
<b>Locked:</b> <#if document.isLocked>Yes<#else>No</#if><br>
<b>Aspects:</b>
<table>
<#list document.aspects as aspect>
<tr><td>${aspect}</td></tr>
</#list>
</table>
<h3>=====Template End=====</h3>
<h3>General document info</h3>
<#if document?exists>
<h4>Current Document Info:</h4>
<b>Name:</b> ${document.name}<br>
<b>Ref:</b> ${document.nodeRef}<br>
<b>Type:</b> ${document.type}<br>
<b>Content URL:</b> <a href="/alfresco${document.url}">/alfresco${document.url}</a><br>
<b>Locked:</b> <#if document.isLocked>Yes<#else>No</#if><br>
<b>Aspects:</b>
<table>
<#list document.aspects as aspect>
<tr><td>${aspect}</td></tr>
</#list>
</table>
<#else>
No document found!
</#if>

View File

@@ -0,0 +1,49 @@
<h3>=====Example Template Start=====</h3>
<b>Company Home Space:</b> ${companyhome.properties.name}
<br>
<b>My Home Space:</b> ${userhome.properties.name}
<br>
<b>Company Home children count:</b> ${companyhome.children?size}
<br>
<b>Company Home first child node name:</b> ${companyhome.children[0].properties.name}
<br>
<#if document?exists>
<b>Current Document Name:</b> ${document.name}
<br>
</#if>
<b>Current Space Name:</b> ${space.name}
<h4>List of child spaces in my Home Space:</h4>
<table>
<#list userhome.children as child>
<#if child.isContainer>
<tr>
<td><img src="/alfresco${child.icon32}"></td>
<td><b>${child.properties.name}</b> (${child.children?size})</td>
<td><b>Path:</b> ${child.displayPath}</td>
</tr>
</#if>
</#list>
</table>
<h4>List of docs in my Home Space (text only content shown inline, JPG images shown as thumbnails):</h4>
<table>
<#list userhome.children as child>
<#if child.isDocument>
<tr><td><img src="/alfresco${child.icon16}"></td><td><a href="/alfresco${child.url}">${child.properties.name}</a></td></tr>
<#if child.mimetype = "text/plain">
<tr><td></td><td>${child.content}</td></tr>
<#elseif child.mimetype = "image/jpeg">
<tr><td></td><td><img width=100 height=65 src="/alfresco${child.url}"></td></tr>
</#if>
</#if>
</#list>
</table>
<h4>Assoc example:</h4>
<#if userhome.children[0].assocs["cm:contains"]?exists>
${userhome.children[0].assocs["cm:contains"][0].name}
</#if>
<h3>=====Example Template End=====</h3>

View File

@@ -1,10 +1,14 @@
<#-- Shows if a document is localizable and the locale if set -->
<b>Localisable:</b>
<#if hasAspect(document, "cm:localizable") = 1>
Yes<br>
<#if document.properties.locale?exists>
Locale: ${document.properties.locale.properties.name}
<#if document?exists>
<#if hasAspect(document, "cm:localizable") = 1>
Yes<br>
<#if document.properties.locale?exists>
Locale: ${document.properties.locale.properties.name}
</#if>
<#else>
No<br>
</#if>
<#else>
No<br>
No document found!
</#if>

View File

@@ -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 -->
<table>
<#list userhome.children as child>
<#if child.isDocument>
<tr><td>${child.properties.name}</td></tr>
<#if child.mimetype = "text/plain">
<tr><td style='padding-left:16px'>${child.content}</td></tr>
<#elseif child.mimetype = "image/jpeg">
<tr><td style='padding-left:16px'><img width=100 height=65 src="/alfresco${child.url}"><td></tr>
</#if>
</#if>
</#list>
</table>

View File

@@ -1,12 +1,16 @@
<#-- Shows the translations applied to a doc through the translatable aspect -->
<b>Translatable:</b>
<#if hasAspect(document, "cm:translatable") = 1>
Yes<br>
<table>
<#list document.assocs["cm:translations"] as t>
<tr><td>${t.content}</td></tr>
</#list>
</table>
<#if document?exists>
<#if hasAspect(document, "cm:translatable") = 1>
Yes<br>
<table>
<#list document.assocs["cm:translations"] as t>
<tr><td>${t.content}</td></tr>
</#list>
</table>
<#else>
No<br>
</#if>
<#else>
No<br>
No document found!
</#if>

View File

@@ -0,0 +1,26 @@
<#-- Shows use of the childByNamePath, childrenByXPath and childrenByLuceneSearch API -->
<h3>Template Documents in 'Company Home/Data Dictionary/Content Templates':</h3>
<table>
<#list companyhome.childByNamePath["Data Dictionary/Content Templates"].children as child>
<#if child.isDocument>
<tr><td><a href="/alfresco${child.url}" target="new">${child.properties.name}</a></td></tr>
</#if>
</#list>
</table>
<h3>Folders in 'Company Home/Data Dictionary/Space Templates/Software Engineering Project':</h3>
<table>
<#list companyhome.childrenByXPath["*[@cm:name='Data Dictionary']/*[@cm:name='Space Templates']/*[@cm:name='Software Engineering Project']/*"] as child>
<#if child.isContainer>
<tr><td><img src="/alfresco${child.icon32}"> ${child.properties.name}</td></tr>
</#if>
</#list>
</table>
<h3>Lucene Search - documents containing the text 'Alfresco'</h3>
<table>
<#list companyhome.childrenByLuceneSearch["TEXT:alfresco"] as child>
<tr><td><a href="/alfresco${child.url}" target="new">${child.properties.name}</a></td></tr>
</#list>
</table>

View File

@@ -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<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
templates = new ArrayList<SelectItem>(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<NodeRef> 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<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);