Jovana
Jovana

Reputation: 108

Association control - access denied

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!

Upvotes: 1

Views: 396

Answers (1)

Tahir Malik
Tahir Malik

Reputation: 6643

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>

Upvotes: 2

Related Questions