Added Web Script to support object/user loading from Web Framework

A single web script that grabs a content object and hands back the metadata as JSON.  This is for a single object and is used in various places.  One such place is during the Login Process.  The AlfrescoUserFactory calls over to retrieve the user's properties, which it can then make available to web scripts running within the Web Tier.

The author was very careful not to rely upon json.js or to generate JSON via Javascript.  The much-esteemed and greatly praised doclib example was closely followed and the results work quite well.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9070 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Michael Uzqu
2008-05-12 06:08:59 +00:00
parent 63e68d53ef
commit 6e197d5826
3 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Content Metadata Retrieval Service</shortname>
<description>Content Metadata Retrieval Service</description>
<url>/webframework/content/metadata</url>
<format default="html">argument</format>
<authentication>admin</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,53 @@
{
"isContainer" : ${object.isContainer?string}
,
"isDocument" : ${object.isDocument?string}
,
"url" : "${object.url}"
,
"downloadUrl" : "${object.downloadUrl}"
,
"mimetype" : "${mimetype}"
,
"size" : "${object.size}"
,
"displayPath" : "${object.displayPath}"
,
"qnamePath" : "${object.qnamePath}"
,
"icon16" : "${object.icon16}"
,
"icon32" : "${object.icon32}"
,
"isLocked" : ${object.isLocked?string}
,
"id" : ${object.id}
,
"nodeRef" : "${object.nodeRef}"
,
"name" : "${object.name}"
,
"type" : "${object.type}"
,
"isCategory" : ${object.isCategory?string}
<#if properties?exists>
,
"properties" :
{
<#assign first = false>
<#list properties?keys as key>
<#assign val = properties[key]>
<#if val?exists>
<#if first == true>
,
</#if>
"${key}" : "${val}"
<#assign first = true>
</#if>
</#list>
}
</#if>
}

View File

@@ -0,0 +1,33 @@
var object = null;
// allow for content to be loaded from id
if(args["id"] != null)
{
var id = args["id"];
object = search.findNode(id);
}
// if not by id, then allow for user id
if(object == null && args["user"] != null)
{
var userId = args["user"];
object = people.getPerson(userId);
}
// load content by relative path
if(object == null)
{
var path = args["path"];
if(path == null || path == "" || path == "/")
path = "/Company Home";
else
path = "/Company Home" + path;
// look up the content by path
object = roothome.childByNamePath(path);
}
// store onto model
model.object = object;
model.mimetype = object.mimetype;
model.properties = object.properties;