From 6e197d58267a8dfdb1cc59b5ebc61ba73f1e492c Mon Sep 17 00:00:00 2001 From: Michael Uzqu Date: Mon, 12 May 2008 06:08:59 +0000 Subject: [PATCH] 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 --- .../webframework/metadata.get.desc.xml | 8 +++ .../webframework/metadata.get.html.ftl | 53 +++++++++++++++++++ .../org/alfresco/webframework/metadata.get.js | 33 ++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.desc.xml create mode 100644 config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl create mode 100644 config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js diff --git a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.desc.xml new file mode 100644 index 0000000000..97aada2978 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.desc.xml @@ -0,0 +1,8 @@ + + Content Metadata Retrieval Service + Content Metadata Retrieval Service + /webframework/content/metadata + argument + admin + required + diff --git a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl new file mode 100644 index 0000000000..9677c4e8d5 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl @@ -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> + , + + "${key}" : "${val}" + <#assign first = true> + + + + } + + +} \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js new file mode 100644 index 0000000000..6bc208f4e4 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js @@ -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;