Source Association methods added to jscript/freemarker APIs

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7654 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-12-12 11:53:43 +00:00
parent d36b098c6e
commit 97db217254
17 changed files with 162 additions and 452 deletions

View File

@@ -103,16 +103,6 @@ public class DesktopResponse extends ScriptableObject {
return m_status;
}
/**
* Return the status property
*
* @return int
*/
public int jsGet_status()
{
return m_status;
}
/**
* Determine if there is an optional status message
*
@@ -133,16 +123,6 @@ public class DesktopResponse extends ScriptableObject {
return m_statusMsg;
}
/**
* Return the status message property
*
* @return String
*/
public String jsGet_message()
{
return m_statusMsg != null ? m_statusMsg : "";
}
/**
* Determine if there are optional response values
*

View File

@@ -73,7 +73,7 @@ public final class AVM extends BaseScopableProcessorExtension
/**
* @return a array of all AVM stores in the system
*/
public Object[] getStores()
public Scriptable getStores()
{
List<AVMStoreDescriptor> stores = this.services.getAVMService().getStores();
Object[] results = new Object[stores.size()];
@@ -82,12 +82,7 @@ public final class AVM extends BaseScopableProcessorExtension
{
results[i++] = new AVMScriptStore(this.services, store, getScope());
}
return results;
}
public Scriptable jsGet_stores()
{
return Context.getCurrentContext().newArray(getScope(), getStores());
return Context.getCurrentContext().newArray(getScope(), results);
}
/**
@@ -324,11 +319,6 @@ public final class AVM extends BaseScopableProcessorExtension
'/' + JNDIConstants.DIR_DEFAULT_APPBASE;
}
public static String jsGet_webappsFolderPath()
{
return getWebappsFolderPath();
}
private static String getStoreRootPath(String store)
{
return store + ":" + getWebappsFolderPath();

View File

@@ -113,21 +113,11 @@ public class AVMNode extends ScriptNode
return this.path;
}
public String jsGet_path()
{
return getPath();
}
public int getVersion()
{
return this.version;
}
public int jsGet_version()
{
return getVersion();
}
/**
* @return AVM path to the parent node
*/
@@ -136,15 +126,10 @@ public class AVMNode extends ScriptNode
return AVMNodeConverter.SplitBase(this.path)[0];
}
public String jsGet_parentPath()
{
return getParentPath();
}
/**
* @return QName type of this node
*/
public QName getType()
public String getType()
{
if (this.type == null)
{
@@ -158,34 +143,19 @@ public class AVMNode extends ScriptNode
}
}
return type;
return type.toString();
}
public String jsGet_type()
{
return getType().toString();
}
public boolean isDirectory()
{
return this.avmRef.isDirectory() || this.avmRef.isDeletedDirectory();
}
public boolean jsGet_isDirectory()
{
return isDirectory();
}
public boolean isFile()
{
return this.avmRef.isFile() || this.avmRef.isDeletedFile();
}
public boolean jsGet_isFile()
{
return isFile();
}
/**
* @return Helper to return the 'name' property for the node
*/
@@ -205,11 +175,6 @@ public class AVMNode extends ScriptNode
return (lock != null);
}
public boolean jsGet_isLocked()
{
return isLocked();
}
/**
* @return true if this node is locked and the current user is the lock owner
*/
@@ -228,11 +193,6 @@ public class AVMNode extends ScriptNode
return lockOwner;
}
public boolean jsGet_isLockOwner()
{
return isLockOwner();
}
/**
* @return true if this user can perform operations on the node when locked.
* This is true if the item is either unlocked, or locked and the current user is the lock owner,
@@ -244,11 +204,6 @@ public class AVMNode extends ScriptNode
getWebProject(), path, this.services.getAuthenticationService().getCurrentUserName());
}
public boolean jsGet_hasLockAccess()
{
return hasLockAccess();
}
/**
* Copy this Node into a new parent destination.
*
@@ -361,7 +316,7 @@ public class AVMNode extends ScriptNode
* @return The list of aspects applied to this node
*/
@Override
public Set<QName> getAspects()
public Set<QName> getAspectsSet()
{
if (this.aspects == null)
{
@@ -411,7 +366,7 @@ public class AVMNode extends ScriptNode
return "AVM Path: " + getPath() +
"\nNode Type: " + getType() +
"\nNode Properties: " + this.getProperties().size() +
"\nNode Aspects: " + this.getAspects().toString();
"\nNode Aspects: " + this.getAspectsSet().toString();
}
else
{

View File

@@ -71,11 +71,6 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getName();
}
public String jsGet_name()
{
return getName();
}
/**
* @return Store name
*/
@@ -84,11 +79,6 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getName();
}
public String jsGet_id()
{
return getId();
}
/**
* @return User who created the store
*/
@@ -97,23 +87,13 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getCreator();
}
public String jsGet_creator()
{
return getCreator();
}
/**
* @return Creation date of the store
*/
public Date getCreatedDate()
{
return new Date(this.descriptor.getCreateDate());
}
public Serializable jsGet_createdDate()
public Serializable getCreatedDate()
{
return new ValueConverter().convertValueForScript(
this.services, this.scope, null, getCreatedDate());
this.services, this.scope, null, new Date(this.descriptor.getCreateDate()));
}
/**

View File

@@ -69,11 +69,6 @@ public final class Actions extends BaseScopableProcessorExtension
return registered;
}
public String[] jsGet_registered()
{
return getRegistered();
}
/**
* Create an Action
*
@@ -94,5 +89,4 @@ public final class Actions extends BaseScopableProcessorExtension
}
return scriptAction;
}
}

View File

@@ -85,28 +85,13 @@ public class Association implements Scopeable, Serializable
return assocRef.getTypeQName().toString();
}
public String jsGet_type()
{
return getType();
}
public ScriptNode getSource()
{
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getSourceRef());
}
public ScriptNode jsGet_source()
{
return getSource();
}
public ScriptNode getTarget()
{
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getTargetRef());
}
public ScriptNode jsGet_target()
{
return getTarget();
}
}

View File

@@ -86,16 +86,6 @@ public class Behaviour implements Scopeable, Serializable
return this.name;
}
/**
* JS accessor method
*
* @return the name of the policy
*/
public String jsGet_name()
{
return getName();
}
/**
* The argument values
*
@@ -116,14 +106,4 @@ public class Behaviour implements Scopeable, Serializable
}
return this.jsArgs;
}
/**
* JS accessor method
*
* @return array containing the argument values
*/
public Serializable[] jsGet_args()
{
return getArgs();
}
}

View File

@@ -74,11 +74,6 @@ public class CategoryNode extends ScriptNode
return buildNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.MEMBERS, CategoryService.Depth.ANY));
}
public ScriptNode[] jsGet_categoryMembers()
{
return getCategoryMembers();
}
/**
* @return all the subcategories of a category
*/
@@ -87,11 +82,6 @@ public class CategoryNode extends ScriptNode
return buildCategoryNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.ANY));
}
public CategoryNode[] jsGet_subCategories()
{
return getSubCategories();
}
/**
* @return members and subcategories of a category
*/
@@ -100,11 +90,6 @@ public class CategoryNode extends ScriptNode
return buildMixedNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.ALL, CategoryService.Depth.ANY));
}
public ScriptNode[] jsGet_membersAndSubCategories()
{
return getMembersAndSubCategories();
}
/**
* @return all the immediate member of a category
*/
@@ -113,11 +98,6 @@ public class CategoryNode extends ScriptNode
return buildNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.MEMBERS, CategoryService.Depth.IMMEDIATE));
}
public ScriptNode[] jsGet_immediateCategoryMembers()
{
return getImmediateCategoryMembers();
}
/**
* @return all the immediate subcategories of a category
*/
@@ -126,11 +106,6 @@ public class CategoryNode extends ScriptNode
return buildCategoryNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE));
}
public CategoryNode[] jsGet_immediateSubCategories()
{
return getImmediateSubCategories();
}
/**
* @return immediate members and subcategories of a category
*/
@@ -139,11 +114,6 @@ public class CategoryNode extends ScriptNode
return buildMixedNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.ALL, CategoryService.Depth.IMMEDIATE));
}
public ScriptNode[] jsGet_immediateMembersAndSubCategories()
{
return getImmediateMembersAndSubCategories();
}
/**
* Create a new subcategory
*

View File

@@ -91,41 +91,21 @@ public class ChildAssociation implements Scopeable, Serializable
return childAssocRef.getTypeQName().toString();
}
public String jsGet_type()
{
return getType();
}
public String getName()
{
return childAssocRef.getQName().toString();
}
public String jsGet_name()
{
return getName();
}
public ScriptNode getParent()
{
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, childAssocRef.getParentRef());
}
public ScriptNode jsGet_parent()
{
return getParent();
}
public ScriptNode getChild()
{
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, childAssocRef.getChildRef());
}
public ScriptNode jsGet_child()
{
return getChild();
}
public boolean isPrimary()
{
return this.childAssocRef.isPrimary();
@@ -135,9 +115,4 @@ public class ChildAssociation implements Scopeable, Serializable
{
return this.childAssocRef.getNthSibling();
}
public int jsGet_nthSibling()
{
return getNthSibling();
}
}

View File

@@ -98,11 +98,6 @@ public final class Classification extends BaseScopableProcessorExtension
return answer;
}
public String[] jsGet_allClassificationAspects()
{
return getAllClassificationAspects();
}
/**
* Create a root category in a classification.
*

View File

@@ -122,7 +122,7 @@ public final class People extends BaseScopableProcessorExtension
public void deleteGroup(ScriptNode group)
{
ParameterCheck.mandatory("Group", group);
if (group.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (group.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
String groupName = (String)group.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
authorityService.deleteAuthority(groupName);
@@ -180,11 +180,11 @@ public final class People extends BaseScopableProcessorExtension
{
ParameterCheck.mandatory("Authority", authority);
ParameterCheck.mandatory("ParentGroup", parentGroup);
if (parentGroup.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (parentGroup.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
String parentGroupName = (String)parentGroup.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
String authorityName;
if (authority.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (authority.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
authorityName = (String)authority.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
}
@@ -206,11 +206,11 @@ public final class People extends BaseScopableProcessorExtension
{
ParameterCheck.mandatory("Authority", authority);
ParameterCheck.mandatory("ParentGroup", parentGroup);
if (parentGroup.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (parentGroup.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
String parentGroupName = (String)parentGroup.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
String authorityName;
if (authority.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (authority.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
authorityName = (String)authority.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
}
@@ -293,7 +293,7 @@ public final class People extends BaseScopableProcessorExtension
{
Object[] members = null;
if (container.getType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
if (container.getQNameType().equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
String groupName = (String)container.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
Set<String> authorities = authorityService.getContainedAuthorities(type, groupName, !recurse);

View File

@@ -93,11 +93,6 @@ public final class ScriptAction implements Serializable, Scopeable
return this.actionDef.getName();
}
public String jsGet_name()
{
return getName();
}
/**
* Return all the properties known about this node. The Map returned implements the Scriptable interface to allow access to the properties via JavaScript associative array
* access. This means properties of a node can be access thus: <code>node.properties["name"]</code>
@@ -122,11 +117,6 @@ public final class ScriptAction implements Serializable, Scopeable
return this.parameters;
}
public Map<String, Serializable> jsGet_parameters()
{
return getParameters();
}
/**
* Execute action
*

View File

@@ -40,11 +40,6 @@ public final class ScriptLogger extends BaseProcessorExtension
return logger.isDebugEnabled();
}
public boolean jsGet_isLoggingEnabled()
{
return isLoggingEnabled();
}
public void log(String str)
{
logger.debug(str);

View File

@@ -122,8 +122,11 @@ public class ScriptNode implements Serializable, Scopeable
/** The aspects applied to this node */
protected Set<QName> aspects = null;
/** The target associations for this node */
private ScriptableQNameMap<String, Object> assocs = null;
/** The target associations from this node */
private ScriptableQNameMap<String, Object> targetAssocs = null;
/** The source assoications to this node */
private ScriptableQNameMap<String, Object> sourceAssocs = null;
/** The child associations for this node */
private ScriptableQNameMap<String, Object> childAssocs = null;
@@ -236,11 +239,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.id;
}
public String jsGet_id()
{
return getId();
}
/**
* @return Returns the NodeRef this Node object represents
*/
@@ -249,15 +247,10 @@ public class ScriptNode implements Serializable, Scopeable
return this.nodeRef;
}
public String jsGet_nodeRef()
{
return getNodeRef().toString();
}
/**
* @return Returns the type.
* @return Returns the QName type.
*/
public QName getType()
public QName getQNameType()
{
if (this.type == null)
{
@@ -267,9 +260,12 @@ public class ScriptNode implements Serializable, Scopeable
return type;
}
public String jsGet_type()
/**
* @return Returns the type.
*/
public String getType()
{
return getType().toString();
return getQNameType().toString();
}
/**
@@ -300,11 +296,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.name;
}
public String jsGet_name()
{
return getName();
}
/**
* Helper to set the 'name' property for the node.
*
@@ -314,7 +305,7 @@ public class ScriptNode implements Serializable, Scopeable
{
if (name != null)
{
QName typeQName = getType();
QName typeQName = getQNameType();
if ((services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER) &&
!services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)) ||
services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT))
@@ -336,11 +327,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public void jsSet_name(String name)
{
setName(name);
}
/**
* @return The children of this Node as JavaScript array of Node object wrappers
*/
@@ -361,11 +347,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.children;
}
public Scriptable jsGet_children()
{
return getChildren();
}
/**
* @return Returns the Node at the specified 'cm:name' based Path walking the children of this Node.
* So a valid call might be:
@@ -403,12 +384,6 @@ public class ScriptNode implements Serializable, Scopeable
return (nodes.length != 0) ? (ScriptNode)nodes[0] : null;
}
// TODO: find out why this doesn't work - the function defs do not seem to get found
// public Node jsFunction_childByNamePath(String path)
// {
// return getChildByNamePath(path);
// }
/**
* @return Returns a JavaScript array of Nodes at the specified XPath starting at this Node.
* So a valid call might be <code>mynode.childrenByXPath("*[@cm:name='Testing']/*");</code>
@@ -429,46 +404,89 @@ public class ScriptNode implements Serializable, Scopeable
@SuppressWarnings("unchecked")
public Map<String, Object> getAssocs()
{
if (this.assocs == null)
if (this.targetAssocs == null)
{
// this Map implements the Scriptable interface for native JS syntax property access
this.assocs = new ScriptableQNameMap<String, Object>(this.services.getNamespaceService());
this.targetAssocs = new ScriptableQNameMap<String, Object>(this.services.getNamespaceService());
// get the list of target nodes for each association type
List<AssociationRef> refs = this.nodeService.getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<ScriptNode> nodes = (List<ScriptNode>)this.assocs.get(qname);
List<ScriptNode> nodes = (List<ScriptNode>)this.targetAssocs.get(qname);
if (nodes == null)
{
// first access of the list for this qname
nodes = new ArrayList<ScriptNode>(4);
this.assocs.put(ref.getTypeQName().toString(), nodes);
this.targetAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add(newInstance(ref.getTargetRef(), this.services, this.scope));
}
// convert each Node list into a JavaScript array object
for (String qname : this.assocs.keySet())
for (String qname : this.targetAssocs.keySet())
{
List<ScriptNode> nodes = (List<ScriptNode>)this.assocs.get(qname);
List<ScriptNode> nodes = (List<ScriptNode>)this.targetAssocs.get(qname);
Object[] objs = nodes.toArray(new Object[nodes.size()]);
this.assocs.put(qname, Context.getCurrentContext().newArray(this.scope, objs));
this.targetAssocs.put(qname, Context.getCurrentContext().newArray(this.scope, objs));
}
}
return this.assocs;
return this.targetAssocs;
}
public Map<String, Object> jsGet_assocs()
public Map<String, Object> getAssociations()
{
return getAssocs();
}
public Map<String, Object> jsGet_associations()
/**
* Return the source associations to this Node. As a Map of assoc name to a JavaScript array of Nodes.
* The Map returned implements the Scriptable interface to allow access to the assoc arrays via JavaScript
* associative array access. This means source associations to this node can be access thus:
* <code>node.sourceAssocs["translations"][0]</code>
*
* @return source associations as a Map of assoc name to a JavaScript array of Nodes.
*/
@SuppressWarnings("unchecked")
public Map<String, Object> getSourceAssocs()
{
return getAssocs();
if (this.sourceAssocs == null)
{
// this Map implements the Scriptable interface for native JS syntax property access
this.sourceAssocs = new ScriptableQNameMap<String, Object>(this.services.getNamespaceService());
// get the list of source nodes for each association type
List<AssociationRef> refs = this.nodeService.getSourceAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<ScriptNode> nodes = (List<ScriptNode>)this.sourceAssocs.get(qname);
if (nodes == null)
{
// first access of the list for this qname
nodes = new ArrayList<ScriptNode>(4);
this.sourceAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add(newInstance(ref.getSourceRef(), this.services, this.scope));
}
// convert each Node list into a JavaScript array object
for (String qname : this.sourceAssocs.keySet())
{
List<ScriptNode> nodes = (List<ScriptNode>)this.sourceAssocs.get(qname);
Object[] objs = nodes.toArray(new Object[nodes.size()]);
this.sourceAssocs.put(qname, Context.getCurrentContext().newArray(this.scope, objs));
}
}
return this.sourceAssocs;
}
public Map<String, Object> getSourceAssociations()
{
return getSourceAssocs();
}
/**
@@ -514,12 +532,7 @@ public class ScriptNode implements Serializable, Scopeable
return this.childAssocs;
}
public Map<String, Object> jsGet_childAssocs()
{
return getChildAssocs();
}
public Map<String, Object> jsGet_childAssociations()
public Map<String, Object> getChildAssociations()
{
return getChildAssocs();
}
@@ -554,11 +567,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.properties;
}
public Map<String, Object> jsGet_properties()
{
return getProperties();
}
/**
* @return true if this Node is a container (i.e. a folder)
*/
@@ -567,18 +575,13 @@ public class ScriptNode implements Serializable, Scopeable
if (isContainer == null)
{
DictionaryService dd = this.services.getDictionaryService();
isContainer = Boolean.valueOf((dd.isSubClass(getType(), ContentModel.TYPE_FOLDER) == true &&
dd.isSubClass(getType(), ContentModel.TYPE_SYSTEM_FOLDER) == false));
isContainer = Boolean.valueOf((dd.isSubClass(getQNameType(), ContentModel.TYPE_FOLDER) == true &&
dd.isSubClass(getQNameType(), ContentModel.TYPE_SYSTEM_FOLDER) == false));
}
return isContainer.booleanValue();
}
public boolean jsGet_isContainer()
{
return getIsContainer();
}
/**
* @return true if this Node is a Document (i.e. with content)
*/
@@ -587,17 +590,12 @@ public class ScriptNode implements Serializable, Scopeable
if (isDocument == null)
{
DictionaryService dd = this.services.getDictionaryService();
isDocument = Boolean.valueOf(dd.isSubClass(getType(), ContentModel.TYPE_CONTENT));
isDocument = Boolean.valueOf(dd.isSubClass(getQNameType(), ContentModel.TYPE_CONTENT));
}
return isDocument.booleanValue();
}
public boolean jsGet_isDocument()
{
return getIsDocument();
}
/**
* @return true if this Node is a Link to a Container (i.e. a folderlink)
*/
@@ -606,17 +604,12 @@ public class ScriptNode implements Serializable, Scopeable
if (isLinkToContainer == null)
{
DictionaryService dd = this.services.getDictionaryService();
isLinkToContainer = Boolean.valueOf(dd.isSubClass(getType(), ApplicationModel.TYPE_FOLDERLINK));
isLinkToContainer = Boolean.valueOf(dd.isSubClass(getQNameType(), ApplicationModel.TYPE_FOLDERLINK));
}
return isLinkToContainer.booleanValue();
}
public boolean jsGet_isLinkToContainer()
{
return getIsLinkToContainer();
}
/**
* @return true if this Node is a Link to a Document (i.e. a filelink)
*/
@@ -625,17 +618,12 @@ public class ScriptNode implements Serializable, Scopeable
if (isLinkToDocument == null)
{
DictionaryService dd = this.services.getDictionaryService();
isLinkToDocument = Boolean.valueOf(dd.isSubClass(getType(), ApplicationModel.TYPE_FILELINK));
isLinkToDocument = Boolean.valueOf(dd.isSubClass(getQNameType(), ApplicationModel.TYPE_FILELINK));
}
return isLinkToDocument.booleanValue();
}
public boolean jsGet_isLinkToDocument()
{
return getIsLinkToDocument();
}
/**
* @return true if the Node is a Category
*/
@@ -645,15 +633,10 @@ public class ScriptNode implements Serializable, Scopeable
return false;
}
public boolean jsGet_isCategory()
{
return getIsCategory();
}
/**
* @return The list of aspects applied to this node
*/
public Set<QName> getAspects()
public Set<QName> getAspectsSet()
{
if (this.aspects == null)
{
@@ -663,16 +646,19 @@ public class ScriptNode implements Serializable, Scopeable
return this.aspects;
}
public String[] jsGet_aspects()
/**
* @return The array of aspects applied to this node
*/
public Scriptable getAspects()
{
Set<QName> aspects = getAspects();
Set<QName> aspects = getAspectsSet();
String[] result = new String[aspects.size()];
int count = 0;
for (QName qname : aspects)
{
result[count++] = qname.toString();
}
return result;
return Context.getCurrentContext().newArray(this.scope, result);
}
/**
@@ -681,7 +667,7 @@ public class ScriptNode implements Serializable, Scopeable
*/
public boolean hasAspect(String aspect)
{
return getAspects().contains(createQName(aspect));
return getAspectsSet().contains(createQName(aspect));
}
/**
@@ -692,11 +678,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.services.getNodeService().getPath(getNodeRef()).toPrefixString(this.services.getNamespaceService());
}
public String jsGet_qnamePath()
{
return getQnamePath();
}
/**
* @return Display path to this node
*/
@@ -711,11 +692,6 @@ public class ScriptNode implements Serializable, Scopeable
return displayPath;
}
public String jsGet_displayPath()
{
return getDisplayPath();
}
/**
* @return the small icon image for this node
*/
@@ -724,11 +700,6 @@ public class ScriptNode implements Serializable, Scopeable
return "/images/filetypes/_default.gif";
}
public String jsGet_icon16()
{
return getIcon16();
}
/**
* @return the large icon image for this node
*/
@@ -737,11 +708,6 @@ public class ScriptNode implements Serializable, Scopeable
return "/images/filetypes32/_default.gif";
}
public String jsGet_icon32()
{
return getIcon32();
}
/**
* @return true if the node is currently locked
*/
@@ -749,7 +715,7 @@ public class ScriptNode implements Serializable, Scopeable
{
boolean locked = false;
if (getAspects().contains(ContentModel.ASPECT_LOCKABLE))
if (getAspectsSet().contains(ContentModel.ASPECT_LOCKABLE))
{
LockStatus lockStatus = this.services.getLockService().getLockStatus(this.nodeRef);
if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER)
@@ -761,11 +727,6 @@ public class ScriptNode implements Serializable, Scopeable
return locked;
}
public boolean jsGet_isLocked()
{
return isLocked();
}
/**
* @return the parent node
*/
@@ -784,11 +745,6 @@ public class ScriptNode implements Serializable, Scopeable
return parent;
}
public ScriptNode jsGet_parent()
{
return getParent();
}
/**
* @return the primary parent association so we can get at the association QName and the association type QName.
*/
@@ -801,11 +757,6 @@ public class ScriptNode implements Serializable, Scopeable
return primaryParentAssoc;
}
public ChildAssociationRef jsGet_primaryParentAssoc()
{
return getPrimaryParentAssoc();
}
// ------------------------------------------------------------------------------
// Content API
@@ -826,11 +777,6 @@ public class ScriptNode implements Serializable, Scopeable
return content;
}
public String jsGet_content()
{
return getContent();
}
/**
* Set the content for this node
*
@@ -845,11 +791,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public void jsSet_content(String content)
{
setContent(content);
}
/**
* @return For a content document, this method returns the URL to the content stream for the default content
* property (@see ContentModel.PROP_CONTENT)
@@ -871,11 +812,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public String jsGet_url()
{
return getUrl();
}
/**
* @return For a content document, this method returns the download URL to the content for
* the default content property (@see ContentModel.PROP_CONTENT)
@@ -898,11 +834,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public String jsGet_downloadUrl()
{
return getDownloadUrl();
}
/**
* @return The mimetype encoding for content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
@@ -919,11 +850,6 @@ public class ScriptNode implements Serializable, Scopeable
return mimetype;
}
public String jsGet_mimetype()
{
return getMimetype();
}
/**
* Set the mimetype encoding for the content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
@@ -939,11 +865,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public void jsSet_mimetype(String mimetype)
{
setMimetype(mimetype);
}
/**
* @return The size in bytes of the content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
@@ -960,11 +881,6 @@ public class ScriptNode implements Serializable, Scopeable
return size;
}
public long jsGet_size()
{
return getSize();
}
// ------------------------------------------------------------------------------
// Security API
@@ -998,7 +914,7 @@ public class ScriptNode implements Serializable, Scopeable
* Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example
* ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character.
*/
public String[] getPermissions()
public Scriptable getPermissions()
{
String userName = this.services.getAuthenticationService().getCurrentUserName();
Set<AccessPermission> acls = this.services.getPermissionService().getAllSetPermissions(getNodeRef());
@@ -1014,7 +930,7 @@ public class ScriptNode implements Serializable, Scopeable
.append(permission.getPermission());
permissions[count++] = buf.toString();
}
return permissions;
return Context.getCurrentContext().newArray(this.scope, permissions);
}
/**
@@ -1044,8 +960,8 @@ public class ScriptNode implements Serializable, Scopeable
public void setPermission(String permission)
{
ParameterCheck.mandatoryString("Permission Name", permission);
this.services.getPermissionService().setPermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission,
true);
this.services.getPermissionService().setPermission(
this.nodeRef, PermissionService.ALL_AUTHORITIES, permission, true);
}
/**
@@ -1058,7 +974,8 @@ public class ScriptNode implements Serializable, Scopeable
{
ParameterCheck.mandatoryString("Permission Name", permission);
ParameterCheck.mandatoryString("Authority", authority);
this.services.getPermissionService().setPermission(this.nodeRef, authority, permission, true);
this.services.getPermissionService().setPermission(
this.nodeRef, authority, permission, true);
}
/**
@@ -1069,8 +986,8 @@ public class ScriptNode implements Serializable, Scopeable
public void removePermission(String permission)
{
ParameterCheck.mandatoryString("Permission Name", permission);
this.services.getPermissionService()
.deletePermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission);
this.services.getPermissionService().deletePermission(
this.nodeRef, PermissionService.ALL_AUTHORITIES, permission);
}
/**
@@ -1083,7 +1000,8 @@ public class ScriptNode implements Serializable, Scopeable
{
ParameterCheck.mandatoryString("Permission Name", permission);
ParameterCheck.mandatoryString("Authority", authority);
this.services.getPermissionService().deletePermission(this.nodeRef, authority, permission);
this.services.getPermissionService().deletePermission(
this.nodeRef, authority, permission);
}
@@ -1116,16 +1034,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.services.getOwnableService().getOwner(this.nodeRef);
}
/**
* Make owner available as a property.
*
* @return
*/
public String jsGet_owner()
{
return getOwner();
}
// ------------------------------------------------------------------------------
// Create and Modify API
@@ -1166,8 +1074,8 @@ public class ScriptNode implements Serializable, Scopeable
QName qnameType = createQName(type);
// Ensure that we are performing a specialise
if (getType().equals(qnameType) == false &&
this.services.getDictionaryService().isSubClass(qnameType, getType()) == true)
if (getQNameType().equals(qnameType) == false &&
this.services.getDictionaryService().isSubClass(qnameType, getQNameType()) == true)
{
// Specialise the type of the node
this.nodeService.setType(this.nodeRef, qnameType);
@@ -1945,7 +1853,7 @@ public class ScriptNode implements Serializable, Scopeable
// TODO: DC: Allow debug output of property values - for now it's disabled as this could potentially
// follow a large network of nodes. Unfortunately, JBPM issues unprotected debug statements
// where node.toString is used - will request this is fixed in next release of JBPM.
return "Node Type: " + getType() + ", Node Aspects: " + this.getAspects().toString();
return "Node Type: " + getType() + ", Node Aspects: " + getAspectsSet().toString();
}
else
{
@@ -1990,7 +1898,8 @@ public class ScriptNode implements Serializable, Scopeable
this.type = null;
this.properties = null;
this.aspects = null;
this.assocs = null;
this.targetAssocs = null;
this.sourceAssocs = null;
this.childAssocs = null;
this.children = null;
this.displayPath = null;
@@ -2214,11 +2123,6 @@ public class ScriptNode implements Serializable, Scopeable
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property);
}
public void jsSet_content(String content)
{
setContent(content);
}
/**
* Set the content stream from another content object
*
@@ -2247,11 +2151,6 @@ public class ScriptNode implements Serializable, Scopeable
URLEncoder.encode(property.toString()) });
}
public String jsGet_url()
{
return getUrl();
}
/**
* @return download URL to the content for a document item only
*/
@@ -2272,11 +2171,6 @@ public class ScriptNode implements Serializable, Scopeable
}
}
public String jsGet_downloadUrl()
{
return getDownloadUrl();
}
public long getSize()
{
return contentData.getSize();
@@ -2310,13 +2204,7 @@ public class ScriptNode implements Serializable, Scopeable
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property);
}
public void jsSet_mimetype(String mimetype)
{
setMimetype(mimetype);
}
private ContentData contentData;
private QName property;
}

View File

@@ -58,14 +58,4 @@ public class Session extends BaseProcessorExtension
{
return services.getAuthenticationService().getCurrentTicket();
}
/**
* Expose the user's authentication ticket as JavaScipt property.
*
* @return
*/
public String jsGet_ticket()
{
return getTicket();
}
}

View File

@@ -78,7 +78,10 @@ public class TemplateNode extends BasePermissionsNode
private static Log logger = LogFactory.getLog(TemplateNode.class);
/** Target associations from this node */
private Map<String, List<TemplateNode>> assocs = null;
private Map<String, List<TemplateNode>> targetAssocs = null;
/** Source associations to this node */
private Map<String, List<TemplateNode>> sourceAssocs = null;
/** The child associations from this node */
private Map<String, List<TemplateNode>> childAssocs = null;
@@ -224,25 +227,61 @@ public class TemplateNode extends BasePermissionsNode
*/
public Map<String, List<TemplateNode>> getAssocs()
{
if (this.assocs == null)
if (this.targetAssocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.assocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
this.targetAssocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.assocs.get(qname);
List<TemplateNode> nodes = this.targetAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.assocs.put(ref.getTypeQName().toString(), nodes);
this.targetAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getTargetRef(), this.services, this.imageResolver) );
}
}
return this.assocs;
return this.targetAssocs;
}
public Map<String, List<TemplateNode>> getAssociations()
{
return getAssocs();
}
/**
* @return Source associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getSourceAssocs()
{
if (this.sourceAssocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getSourceAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.sourceAssocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.sourceAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.sourceAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getSourceRef(), this.services, this.imageResolver) );
}
}
return this.sourceAssocs;
}
public Map<String, List<TemplateNode>> getSourceAssociations()
{
return getSourceAssocs();
}
/**
@@ -271,6 +310,11 @@ public class TemplateNode extends BasePermissionsNode
return this.childAssocs;
}
public Map<String, List<TemplateNode>> getChildAssociations()
{
return getChildAssocs();
}
/**
* @return true if the node is currently locked
*/

View File

@@ -217,7 +217,7 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
private String mapAuthorityToName(ScriptNode authority, boolean allowGroup)
{
String name = null;
QName type = authority.getType();
QName type = authority.getQNameType();
if (type.equals(ContentModel.TYPE_PERSON))
{
name = (String)authority.getProperties().get(ContentModel.PROP_USERNAME);
@@ -232,5 +232,4 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
}
return name;
}
}