Updated metadata retrieval webscript for Web Framework

- now writes out child nodes and hasChildren property

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9263 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Michael Uzqu
2008-05-25 16:06:01 +00:00
parent e6797b7cd1
commit 6c5763e8f4
2 changed files with 65 additions and 12 deletions

View File

@@ -1,4 +1,8 @@
{ {
<@serialize object=object includeChildren=includeChildren includeContent=includeContent/>
}
<#macro serialize object includeChildren includeContent>
"isContainer" : ${object.isContainer?string} "isContainer" : ${object.isContainer?string}
, ,
"isDocument" : ${object.isDocument?string} "isDocument" : ${object.isDocument?string}
@@ -21,7 +25,7 @@
, ,
"isLocked" : ${object.isLocked?string} "isLocked" : ${object.isLocked?string}
, ,
"id" : ${object.id} "id" : "${object.id}"
, ,
"nodeRef" : "${object.nodeRef}" "nodeRef" : "${object.nodeRef}"
, ,
@@ -30,24 +34,72 @@
"type" : "${object.type}" "type" : "${object.type}"
, ,
"isCategory" : ${object.isCategory?string} "isCategory" : ${object.isCategory?string}
,
<#if properties?exists> <#if object.children?exists>
<#if object.children?size &gt; 0>
"hasChildren" : true
<#else>
"hasChildren" : false
</#if>
</#if>
<#if object.properties?exists>
, ,
"properties" : "properties" :
{ {
<#assign first = false> <#assign first = true>
<#list properties?keys as key> <#list object.properties?keys as key>
<#assign val = properties[key]> <#assign val = object.properties[key]>
<#if val?exists> <#if val?exists>
<#if first == true> <#assign renderable = false>
<#if val?is_string == true>
<#assign renderable = true>
</#if>
<#if val?is_date == true>
<#assign renderable = true>
</#if>
<#if val?is_boolean == true>
<#assign renderable = true>
</#if>
<#if renderable == true>
<#if first == false>
, ,
</#if> </#if>
<#if val?is_string == true>
"${key}" : "${val}" "${key}" : "${val}"
<#assign first = true>
</#if> </#if>
<#if val?is_date == true>
"${key}" : "${val?datetime}"
</#if>
<#if val?is_boolean == true>
"${key}" : "${val}"
</#if>
<#assign first = false>
</#if>
</#if>
</#list> </#list>
} }
</#if> </#if>
} <#if includeChildren && object.children?exists>
,
"children" :
[
<#assign first = true>
<#list object.children as child>
<#if first == false>
,
</#if>
{
<@serialize object=child includeChildren=false includeContent=includeContent/>
}
<#assign first = false>
</#list>
]
<#else>
,
"children" : [ ]
</#if>
</#macro>

View File

@@ -30,4 +30,5 @@ if(object == null)
// store onto model // store onto model
model.object = object; model.object = object;
model.mimetype = object.mimetype; model.mimetype = object.mimetype;
model.properties = object.properties; model.includeChildren = true;
model.includeContent = false;