覆盖 Alfresco pickerresults.lib.ftl
Override Alfresco pickerresults.lib.ftl
我在 pickerresults.lib.ftl that i have already reported
中发现了一个错误
简而言之:如果用户没有父文件的权限,行
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",
将失败,使整个脚本失败(并且用户看不到任何文件)
所以,等待错误解决,我需要修补它。我想覆盖文件中定义的宏 "pickerResultsJSON" 删除行或将字符串值替换导致异常的 "${row.item.parent.name!""}"
我不知道如何重新定义宏以及将文件放在放大器中的什么位置。有人可以帮助我吗?
更新
我正在使用 Alfresck SDK 2.0,我的项目结构是:
我已经尝试放置一个包含以下内容的文件 "custom-pickerresults.lib.ftl"(根据 sev 的建议),但它似乎不是正确的位置。或者我应该 "register" 以某种方式吗?
<#macro pickerResultsJSON results>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
由于宏只是变量,您可以这样做:
<#macro pickerResultsJSON>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
至于你要把它放在哪里......你可以把它放在项目中全局包含的任何文件中。由于我不确定您的项目结构是什么,因此可能需要反复试验。
非常感谢 sev,他为我指明了正确的道路。
我意识到 pickerresults.lib.ftl
被 Web 服务 pickerchildren.get.desc.xml
和 pickerchildren.post.desc.xml
使用,所以解决方案是将 Web 服务定义和文件连同库一起复制到 [=18] =]
/alfresco-myamp-repo/src/main/amp/config/alfresco/extension/templates/webscripts/com/my/repository/forms/
(repository/forms/
只是因为原始文件在 config/alfresco/templates/webscripts/org/alfresco/repository/forms/
中,但 /alfresco-myamp-repo/src/main/amp/config/alfresco/extension
下的任何其他文件夹都应该这样做)
并像这样更改库:
...
"type": "${row.item.typeShort}",
"parentType": "${row.item.parentTypeShort!""}",
<#-- from here -->
<#attempt>
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",</#if>
<#recover>
"parentName": "<unknown>",
</#attempt>
<#-- to here -->
"isContainer": ${row.item.isContainer?string},
<#if row.container??>"container": "${row.container!""}",</#if>
...
这样即使用户没有权限读取 parent 的名称,模板也可以无误地完成(我不知道值 "unknown" 是否代替了parent 名称可能会引起任何麻烦,但我现在什么都没注意到)
我在 pickerresults.lib.ftl that i have already reported
中发现了一个错误简而言之:如果用户没有父文件的权限,行
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",
将失败,使整个脚本失败(并且用户看不到任何文件)
所以,等待错误解决,我需要修补它。我想覆盖文件中定义的宏 "pickerResultsJSON" 删除行或将字符串值替换导致异常的 "${row.item.parent.name!""}"
我不知道如何重新定义宏以及将文件放在放大器中的什么位置。有人可以帮助我吗?
更新
我正在使用 Alfresck SDK 2.0,我的项目结构是:
我已经尝试放置一个包含以下内容的文件 "custom-pickerresults.lib.ftl"(根据 sev 的建议),但它似乎不是正确的位置。或者我应该 "register" 以某种方式吗?
<#macro pickerResultsJSON results>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
由于宏只是变量,您可以这样做:
<#macro pickerResultsJSON>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
至于你要把它放在哪里......你可以把它放在项目中全局包含的任何文件中。由于我不确定您的项目结构是什么,因此可能需要反复试验。
非常感谢 sev,他为我指明了正确的道路。
我意识到 pickerresults.lib.ftl
被 Web 服务 pickerchildren.get.desc.xml
和 pickerchildren.post.desc.xml
使用,所以解决方案是将 Web 服务定义和文件连同库一起复制到 [=18] =]
/alfresco-myamp-repo/src/main/amp/config/alfresco/extension/templates/webscripts/com/my/repository/forms/
(repository/forms/
只是因为原始文件在 config/alfresco/templates/webscripts/org/alfresco/repository/forms/
中,但 /alfresco-myamp-repo/src/main/amp/config/alfresco/extension
下的任何其他文件夹都应该这样做)
并像这样更改库:
...
"type": "${row.item.typeShort}",
"parentType": "${row.item.parentTypeShort!""}",
<#-- from here -->
<#attempt>
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",</#if>
<#recover>
"parentName": "<unknown>",
</#attempt>
<#-- to here -->
"isContainer": ${row.item.isContainer?string},
<#if row.container??>"container": "${row.container!""}",</#if>
...
这样即使用户没有权限读取 parent 的名称,模板也可以无误地完成(我不知道值 "unknown" 是否代替了parent 名称可能会引起任何麻烦,但我现在什么都没注意到)