Package org.alfresco.repo.jscript
Class ScriptUtils
java.lang.Object
org.alfresco.repo.processor.BaseProcessorExtension
org.alfresco.repo.jscript.BaseScopableProcessorExtension
org.alfresco.repo.jscript.ScriptUtils
- All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension,Scopeable
Place for general and miscellaneous utility functions not already found in generic JavaScript.
- Author:
- Kevin Roast
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreatePaging(int maxItems, int skipCount) Builds a paging object, from the supplied Max Items and Skip CountcreatePaging(int maxItems, int skipCount, String queryExecutionId) Builds a paging object, from the supplied Max Items, Skip Count and Query Execution IDcreatePaging(Map<String, String> args) Builds a paging object, from the supplied Args object.voidDisable rule execution for this threaddisplayPath(ScriptNode node) Function to return the cm:name display path for a node with minimum performance overhead.voidEnable rule execution for this threadfromISO8601(String isoDateString) Parse date from ISO formatted stringReturns current thread's localegetNodeFromString(String nodeRefString) Gets a JS node object from a string noderefGiven a short-form QName string, this method returns the fully qualified QName string.booleanmoduleInstalled(String moduleName) Function to check if a module is installedFunction to pad a string with zero '0' characters to the required lengthresolveNodeReference(String reference) Use the Node Locator Service to find the a node reference from a number of possible locator types.voidSets current Locale from stringvoidsetNodeService(NodeService nodeService) voidsetServiceRegistry(ServiceRegistry services) Sets the service registryshortQName(String s) Given a long-form QName string, this method uses the namespace service to create a short-form QName string.booleanGets a boolean value from a stringtoISO8601(long timeInMillis) Format timeInMillis to ISO 8601 formatted stringFormat date to ISO 8601 formatted stringMethods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScopeMethods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
-
Field Details
-
services
Services
-
-
Constructor Details
-
ScriptUtils
public ScriptUtils()
-
-
Method Details
-
setServiceRegistry
Sets the service registry- Parameters:
services- the service registry
-
setNodeService
- Parameters:
nodeService- the NodeService to set
-
displayPath
Function to return the cm:name display path for a node with minimum performance overhead.- Parameters:
node- ScriptNode- Returns:
- cm:name based human readable display path for the give node.
-
pad
Function to pad a string with zero '0' characters to the required length- Parameters:
s- String to pad with leading zero '0' characterslen- Length to pad to- Returns:
- padded string or the original if already at >=len characters
-
getNodeFromString
Gets a JS node object from a string noderef- Parameters:
nodeRefString- string reference to a node- Returns:
- a JS node object
-
resolveNodeReference
Use the Node Locator Service to find the a node reference from a number of possible locator types. This method is responsible for determining the locator type and then calling the Service as the Service does not know how to guess which locator to use.This service supports 'virtual' nodes including the following:
alfresco://company/home The Company Home root node
alfresco://user/home The User Home node under Company Home
alfresco://company/shared The Shared node under Company Home
alfresco://sites/home The Sites home node under Company Home
workspace://.../... Any standard NodeRef
/app:company_home/cm:... XPath QName style node reference- Parameters:
reference- The node reference - See above for list of possible node references supported.- Returns:
- ScriptNode representing the node or null if not found
-
toBoolean
Gets a boolean value from a string- Parameters:
booleanString- boolean string- Returns:
- boolean the boolean value
- See Also:
-
moduleInstalled
Function to check if a module is installed- Parameters:
moduleName- module name (e.g. "org.alfresco.module.foo")- Returns:
- boolean true if the module is currently installed
-
toISO8601
Format timeInMillis to ISO 8601 formatted string- Parameters:
timeInMillis- long- Returns:
- String
-
toISO8601
Format date to ISO 8601 formatted string- Parameters:
date- Date- Returns:
- String
-
fromISO8601
Parse date from ISO formatted string- Parameters:
isoDateString- String- Returns:
- Date
-
shortQName
Given a long-form QName string, this method uses the namespace service to create a short-form QName string.- Parameters:
s- Fully qualified QName string- Returns:
- the short form of the QName string, e.g. "cm:content"
-
longQName
Given a short-form QName string, this method returns the fully qualified QName string.- Parameters:
s- Short form QName string, e.g. "cm:content"- Returns:
- Fully qualified QName string
-
createPaging
Builds a paging object, from the supplied Max Items and Skip Count -
createPaging
Builds a paging object, from the supplied Max Items, Skip Count and Query Execution ID -
createPaging
Builds a paging object, from the supplied Args object. Requires that the parameters have their standard names, i.e. "maxItems" and "skipCount"- Parameters:
args- Mandatory hash of paging argumentsPossible arguments include:
maxItems - max count of items to return, default -1 (all)
skipCount - number of items to skip, default -1 (none)
queryId
queryExecutionId
-
disableRules
public void disableRules()Disable rule execution for this thread -
enableRules
public void enableRules()Enable rule execution for this thread -
setLocale
Sets current Locale from string -
getLocale
Returns current thread's locale
-