1
votes

I'm using Alfresco Share 4.2c and association.ftl to display associations and to allow objects in the repository to be picked. I run into problem to display metadata for user who doesn't have permission to see associated object. I got an error:

Template processing error: "get(properties) failed on instance of org.alfresco.repo.template.TemplateNode" get(properties) failed on instance of org.alfresco.repo.template.TemplateNode. The problematic instruction:---------- ==> ${row.item.properties.name!""} escaped ${jsonUtils.encodeJSONString(row.item.properties.name!"")} [on line 36, column 42 in org/alfresco/repository/forms/pickerresults.lib.ftl] in user-directive pickerResultsLib.pickerResultsJSON [on line 2, column 1 in org/alfresco/repository/forms/pickeritems.post.json.ftl]

and AccessDeniedException.

Any help or advice for this problem is appreciated. I would also like to have a label on the document details page with text "Access denied". Maybe I have to create my custom association.ftl? Thanks in advance!

1
For association related control you could configure it in share-config-custom.xml. what are the steps you have followed for this? - mitpatoliya
In share-config-custom.xml I have <control template="/org/alfresco/components/form/controls/association.ftl" > <control-param name="displayMode">items</control-param> <control-param name="showTargetLink">true</control-param> </control> and it works fine for users who have permissions to access related document, on document details page there is a link to that document. In case that user doesn't have that permission I get the error and on the document details page there is no item. - Jovana

1 Answers

2
votes

copy /alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl to the extension folder and change the following loop

<#list results as row>
            {
                "type": "${row.item.typeShort}",
                "parentType": "${row.item.parentTypeShort!""}",
                "isContainer": ${row.item.isContainer?string},
                "name": "${row.item.properties.name!""}",
                "title": "${row.item.properties.title!""}",
                "description": "${row.item.properties.description!""}",
                <#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
                <#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
                <#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
                "displayPath": "${row.item.displayPath!""}",
                "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
                "selectable" : ${row.selectable?string}</#if>
            }<#if row_has_next>,</#if>
        </#list>

Encapsulate the inside with an extra if row.item.hasPermission("Read") Something like this:

    <#list results as row>
        <#if row.item.hasPermission("Read")>
                {
                    "type": "${row.item.typeShort}",
                    "parentType": "${row.item.parentTypeShort!""}",
                    "isContainer": ${row.item.isContainer?string},
                    "name": "${row.item.properties.name!""}",
                    "title": "${row.item.properties.title!""}",
                    "description": "${row.item.properties.description!""}",
                    <#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
                    <#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
                    <#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
                    "displayPath": "${row.item.displayPath!""}",
                    "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
                    "selectable" : ${row.selectable?string}</#if>
                }<#if row_has_next>,</#if>
            </#if>
</#list>