As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<webscript> <shortname>Get categories</shortname> <description><![CDATA[Gets all the categories defined (aspect cm:generalclassifiable if aspect not specified) or if the path is specifed only categories under that path.]]></description> <url>/ta/categories?path={path?}&recurse={recurse?}&aspect={aspect?}</url> <arg> <shortname>path</shortname> <description><![CDATA[category path (for example - 'Software Document Classification/Software Descriptions')]]></description> </arg> <arg> <shortname>recurse</shortname> <description><![CDATA[if 0, return only direct subcategories of the category, otherwise return whole tree of subcategories]]></description> <default>0</default> </arg> <arg> <shortname>aspect</shortname> <description><![CDATA[classification aspect]]></description> <default>cm:generalclassifiable</default> </arg> <format default="json">argument</format> <authentication>user</authentication> </webscript>
<#escape x as jsonUtils.encodeJSONString(x)> <#macro dumpCategories categories recurse> <#list categories as c> { "nodeRef": "${c.nodeRef}", "name": "${c.name}", "description": "${(c.properties.description!"")}", <#if c.children?size > 0 && recurse != 0>"children": [<@dumpCategories c.children recurse/>],</#if> "userAccess": { "create": ${c.hasPermission("CreateChildren")?string}, "edit": ${c.hasPermission("Write")?string}, "delete": ${c.hasPermission("Delete")?string} } }<#if c_has_next>,</#if> </#list> </#macro> <#if categories.error?has_content> {"error":"${categories.error.msg}"} <#else> { "results": ${categories.items?size?c}, <#if categories.path?has_content>"path": "${categories.path}",</#if> <#if categories.recurse?has_content>"recurse": ${categories.recurse?c},</#if> "items": [ <@dumpCategories categories.items categories.recurse!0/> ] } </#if> </#escape>
model.categories = getCategories(); function getCategories() { try { var aspect = args["aspect"] == null ? "cm:generalclassifiable" : args["aspect"]; var nodes = roothome.childrenByXPath("/cm:categoryRoot/" + aspect); if(nodes != null && nodes.length == 1) { var path = args["path"]; var recurse = args["recurse"] == null ? 0 : parseInt(args["recurse"]) == 0 ? 0 : 1; if(path == null || path == "") { return({"items" : nodes[0].children, "recurse" : recurse}); } else { nodes = nodes[0].childByNamePath("/" + path); if(nodes != null) { return({"items" : nodes.children, "recurse" : recurse}); } else { return({"error" : {"number" : 200, "msg" : "Subcategory with path " + aspect + "/" + path + " does not exist."}}); } } } else { return({"error": {"number":100, "msg":"Root category with aspect " + aspect + " does not exist."}}); } } catch(e) { status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, e.toString()); return; } }