org.alfresco.repo.jscript
Class ApplicationScriptUtils

java.lang.Object
  extended by org.alfresco.repo.processor.BaseProcessorExtension
      extended by org.alfresco.repo.jscript.BaseScopableProcessorExtension
          extended by org.alfresco.repo.jscript.ApplicationScriptUtils
All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension, Scopeable

public final class ApplicationScriptUtils
extends BaseScopableProcessorExtension

Utility functions specifically for external application use.


Constructor Summary
ApplicationScriptUtils()
           
 
Method Summary
 java.lang.String getDownloadAPIUrl(ScriptNode node)
           
protected  java.lang.String getShortQName(org.alfresco.service.namespace.QName longQName)
          Given a long-form QName, this method uses the namespace service to create a short-form QName string.
protected  java.util.Map parseToJSON(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map properties, boolean useShortQNames)
          Converts a map of node properties to a format suitable for JSON output
 void setDecoratedProperties(java.util.Map decoratedProperties)
          Set the properties that require decorator beans
 void setServiceRegistry(ServiceRegistry serviceRegistry)
          Set the service registry
 void setUserPermissions(java.lang.String[] userPermissions)
          Define the list of user permissions to return in the JSON body
 java.lang.String toJSON(ScriptNode node)
          Returns the JSON representation of a node.
 java.lang.String toJSON(ScriptNode node, boolean useShortQNames)
          Returns the JSON representation of this node.
protected  java.lang.Object toJSONObj(ScriptNode node, boolean useShortQNames)
          Returns a JSON object representing the node.
 
Methods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScope
 
Methods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationScriptUtils

public ApplicationScriptUtils()
Method Detail

setServiceRegistry

public void setServiceRegistry(ServiceRegistry serviceRegistry)
Set the service registry

Parameters:
serviceRegistry - the service registry

setDecoratedProperties

public void setDecoratedProperties(java.util.Map decoratedProperties)
Set the properties that require decorator beans

Parameters:
decoratedProperties -

setUserPermissions

public void setUserPermissions(java.lang.String[] userPermissions)
Define the list of user permissions to return in the JSON body

Parameters:
userPermissions -

toJSON

public java.lang.String toJSON(ScriptNode node)
Returns the JSON representation of a node. Long-form QNames are used in the result.

Parameters:
node - the node to convert to JSON representation.
Returns:
The JSON representation of this node

toJSON

public java.lang.String toJSON(ScriptNode node,
                               boolean useShortQNames)
Returns the JSON representation of this node.

Parameters:
node - the node to convert to JSON representation.
useShortQNames - if true short-form qnames will be returned, else long-form.
Returns:
The JSON representation of this node

toJSONObj

protected java.lang.Object toJSONObj(ScriptNode node,
                                     boolean useShortQNames)
Returns a JSON object representing the node.

Parameters:
node - the node to convert to JSON representation.
useShortQNames - if true short-form qnames will be returned, else long-form.
Returns:
The JSON representation of this node

getShortQName

protected java.lang.String getShortQName(org.alfresco.service.namespace.QName longQName)
Given a long-form QName, this method uses the namespace service to create a short-form QName string.

Parameters:
longQName -
Returns:
the short form of the QName string, e.g. "cm:content"

parseToJSON

protected java.util.Map parseToJSON(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                    java.util.Map properties,
                                    boolean useShortQNames)
Converts a map of node properties to a format suitable for JSON output

Parameters:
nodeRef -
properties -
useShortQNames -
Returns:
a decorated map of properties suitable for JSON output

getDownloadAPIUrl

public java.lang.String getDownloadAPIUrl(ScriptNode node)
Parameters:
node - the node to construct the download URL for
Returns:
For a content document, this method returns the URL to the /api/node/content API for the default content property

For a container node, this method returns an empty string



Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.