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 m_status;
} }
/**
* Return the status property
*
* @return int
*/
public int jsGet_status()
{
return m_status;
}
/** /**
* Determine if there is an optional status message * Determine if there is an optional status message
* *
@@ -133,16 +123,6 @@ public class DesktopResponse extends ScriptableObject {
return m_statusMsg; 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 * 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 * @return a array of all AVM stores in the system
*/ */
public Object[] getStores() public Scriptable getStores()
{ {
List<AVMStoreDescriptor> stores = this.services.getAVMService().getStores(); List<AVMStoreDescriptor> stores = this.services.getAVMService().getStores();
Object[] results = new Object[stores.size()]; Object[] results = new Object[stores.size()];
@@ -82,12 +82,7 @@ public final class AVM extends BaseScopableProcessorExtension
{ {
results[i++] = new AVMScriptStore(this.services, store, getScope()); results[i++] = new AVMScriptStore(this.services, store, getScope());
} }
return results; return Context.getCurrentContext().newArray(getScope(), results);
}
public Scriptable jsGet_stores()
{
return Context.getCurrentContext().newArray(getScope(), getStores());
} }
/** /**
@@ -324,11 +319,6 @@ public final class AVM extends BaseScopableProcessorExtension
'/' + JNDIConstants.DIR_DEFAULT_APPBASE; '/' + JNDIConstants.DIR_DEFAULT_APPBASE;
} }
public static String jsGet_webappsFolderPath()
{
return getWebappsFolderPath();
}
private static String getStoreRootPath(String store) private static String getStoreRootPath(String store)
{ {
return store + ":" + getWebappsFolderPath(); return store + ":" + getWebappsFolderPath();

View File

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

View File

@@ -71,11 +71,6 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getName(); return this.descriptor.getName();
} }
public String jsGet_name()
{
return getName();
}
/** /**
* @return Store name * @return Store name
*/ */
@@ -84,11 +79,6 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getName(); return this.descriptor.getName();
} }
public String jsGet_id()
{
return getId();
}
/** /**
* @return User who created the store * @return User who created the store
*/ */
@@ -97,23 +87,13 @@ public class AVMScriptStore implements Serializable
return this.descriptor.getCreator(); return this.descriptor.getCreator();
} }
public String jsGet_creator()
{
return getCreator();
}
/** /**
* @return Creation date of the store * @return Creation date of the store
*/ */
public Date getCreatedDate() public Serializable getCreatedDate()
{
return new Date(this.descriptor.getCreateDate());
}
public Serializable jsGet_createdDate()
{ {
return new ValueConverter().convertValueForScript( 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; return registered;
} }
public String[] jsGet_registered()
{
return getRegistered();
}
/** /**
* Create an Action * Create an Action
* *
@@ -94,5 +89,4 @@ public final class Actions extends BaseScopableProcessorExtension
} }
return scriptAction; return scriptAction;
} }
} }

View File

@@ -85,28 +85,13 @@ public class Association implements Scopeable, Serializable
return assocRef.getTypeQName().toString(); return assocRef.getTypeQName().toString();
} }
public String jsGet_type()
{
return getType();
}
public ScriptNode getSource() public ScriptNode getSource()
{ {
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getSourceRef()); return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getSourceRef());
} }
public ScriptNode jsGet_source()
{
return getSource();
}
public ScriptNode getTarget() public ScriptNode getTarget()
{ {
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getTargetRef()); 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; return this.name;
} }
/**
* JS accessor method
*
* @return the name of the policy
*/
public String jsGet_name()
{
return getName();
}
/** /**
* The argument values * The argument values
* *
@@ -116,14 +106,4 @@ public class Behaviour implements Scopeable, Serializable
} }
return this.jsArgs; 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)); 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 * @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)); 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 * @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)); 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 * @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)); 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 * @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)); 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 * @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)); return buildMixedNodes(services.getCategoryService().getChildren(getNodeRef(), CategoryService.Mode.ALL, CategoryService.Depth.IMMEDIATE));
} }
public ScriptNode[] jsGet_immediateMembersAndSubCategories()
{
return getImmediateMembersAndSubCategories();
}
/** /**
* Create a new subcategory * Create a new subcategory
* *

View File

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

View File

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

View File

@@ -122,7 +122,7 @@ public final class People extends BaseScopableProcessorExtension
public void deleteGroup(ScriptNode group) public void deleteGroup(ScriptNode group)
{ {
ParameterCheck.mandatory("Group", 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); String groupName = (String)group.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
authorityService.deleteAuthority(groupName); authorityService.deleteAuthority(groupName);
@@ -180,11 +180,11 @@ public final class People extends BaseScopableProcessorExtension
{ {
ParameterCheck.mandatory("Authority", authority); ParameterCheck.mandatory("Authority", authority);
ParameterCheck.mandatory("ParentGroup", parentGroup); 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 parentGroupName = (String)parentGroup.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
String authorityName; 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); 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("Authority", authority);
ParameterCheck.mandatory("ParentGroup", parentGroup); 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 parentGroupName = (String)parentGroup.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
String authorityName; 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); authorityName = (String)authority.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
} }
@@ -293,7 +293,7 @@ public final class People extends BaseScopableProcessorExtension
{ {
Object[] members = null; 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); String groupName = (String)container.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
Set<String> authorities = authorityService.getContainedAuthorities(type, groupName, !recurse); 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(); 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 * 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> * 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; return this.parameters;
} }
public Map<String, Serializable> jsGet_parameters()
{
return getParameters();
}
/** /**
* Execute action * Execute action
* *

View File

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

View File

@@ -122,8 +122,11 @@ public class ScriptNode implements Serializable, Scopeable
/** The aspects applied to this node */ /** The aspects applied to this node */
protected Set<QName> aspects = null; protected Set<QName> aspects = null;
/** The target associations for this node */ /** The target associations from this node */
private ScriptableQNameMap<String, Object> assocs = null; private ScriptableQNameMap<String, Object> targetAssocs = null;
/** The source assoications to this node */
private ScriptableQNameMap<String, Object> sourceAssocs = null;
/** The child associations for this node */ /** The child associations for this node */
private ScriptableQNameMap<String, Object> childAssocs = null; private ScriptableQNameMap<String, Object> childAssocs = null;
@@ -236,11 +239,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.id; return this.id;
} }
public String jsGet_id()
{
return getId();
}
/** /**
* @return Returns the NodeRef this Node object represents * @return Returns the NodeRef this Node object represents
*/ */
@@ -249,15 +247,10 @@ public class ScriptNode implements Serializable, Scopeable
return this.nodeRef; 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) if (this.type == null)
{ {
@@ -267,9 +260,12 @@ public class ScriptNode implements Serializable, Scopeable
return type; 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; return this.name;
} }
public String jsGet_name()
{
return getName();
}
/** /**
* Helper to set the 'name' property for the node. * Helper to set the 'name' property for the node.
* *
@@ -314,7 +305,7 @@ public class ScriptNode implements Serializable, Scopeable
{ {
if (name != null) if (name != null)
{ {
QName typeQName = getType(); QName typeQName = getQNameType();
if ((services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER) && if ((services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER) &&
!services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)) || !services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)) ||
services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT)) 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 * @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; 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. * @return Returns the Node at the specified 'cm:name' based Path walking the children of this Node.
* So a valid call might be: * So a valid call might be:
@@ -403,12 +384,6 @@ public class ScriptNode implements Serializable, Scopeable
return (nodes.length != 0) ? (ScriptNode)nodes[0] : null; 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. * @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> * 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") @SuppressWarnings("unchecked")
public Map<String, Object> getAssocs() 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 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 // get the list of target nodes for each association type
List<AssociationRef> refs = this.nodeService.getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL); List<AssociationRef> refs = this.nodeService.getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
for (AssociationRef ref : refs) for (AssociationRef ref : refs)
{ {
String qname = ref.getTypeQName().toString(); 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) if (nodes == null)
{ {
// first access of the list for this qname // first access of the list for this qname
nodes = new ArrayList<ScriptNode>(4); 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)); nodes.add(newInstance(ref.getTargetRef(), this.services, this.scope));
} }
// convert each Node list into a JavaScript array object // 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()]); 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(); 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; return this.childAssocs;
} }
public Map<String, Object> jsGet_childAssocs() public Map<String, Object> getChildAssociations()
{
return getChildAssocs();
}
public Map<String, Object> jsGet_childAssociations()
{ {
return getChildAssocs(); return getChildAssocs();
} }
@@ -554,11 +567,6 @@ public class ScriptNode implements Serializable, Scopeable
return this.properties; return this.properties;
} }
public Map<String, Object> jsGet_properties()
{
return getProperties();
}
/** /**
* @return true if this Node is a container (i.e. a folder) * @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) if (isContainer == null)
{ {
DictionaryService dd = this.services.getDictionaryService(); DictionaryService dd = this.services.getDictionaryService();
isContainer = Boolean.valueOf((dd.isSubClass(getType(), ContentModel.TYPE_FOLDER) == true && isContainer = Boolean.valueOf((dd.isSubClass(getQNameType(), ContentModel.TYPE_FOLDER) == true &&
dd.isSubClass(getType(), ContentModel.TYPE_SYSTEM_FOLDER) == false)); dd.isSubClass(getQNameType(), ContentModel.TYPE_SYSTEM_FOLDER) == false));
} }
return isContainer.booleanValue(); return isContainer.booleanValue();
} }
public boolean jsGet_isContainer()
{
return getIsContainer();
}
/** /**
* @return true if this Node is a Document (i.e. with content) * @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) if (isDocument == null)
{ {
DictionaryService dd = this.services.getDictionaryService(); 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(); return isDocument.booleanValue();
} }
public boolean jsGet_isDocument()
{
return getIsDocument();
}
/** /**
* @return true if this Node is a Link to a Container (i.e. a folderlink) * @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) if (isLinkToContainer == null)
{ {
DictionaryService dd = this.services.getDictionaryService(); 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(); return isLinkToContainer.booleanValue();
} }
public boolean jsGet_isLinkToContainer()
{
return getIsLinkToContainer();
}
/** /**
* @return true if this Node is a Link to a Document (i.e. a filelink) * @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) if (isLinkToDocument == null)
{ {
DictionaryService dd = this.services.getDictionaryService(); 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(); return isLinkToDocument.booleanValue();
} }
public boolean jsGet_isLinkToDocument()
{
return getIsLinkToDocument();
}
/** /**
* @return true if the Node is a Category * @return true if the Node is a Category
*/ */
@@ -645,15 +633,10 @@ public class ScriptNode implements Serializable, Scopeable
return false; return false;
} }
public boolean jsGet_isCategory()
{
return getIsCategory();
}
/** /**
* @return The list of aspects applied to this node * @return The list of aspects applied to this node
*/ */
public Set<QName> getAspects() public Set<QName> getAspectsSet()
{ {
if (this.aspects == null) if (this.aspects == null)
{ {
@@ -663,16 +646,19 @@ public class ScriptNode implements Serializable, Scopeable
return this.aspects; 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()]; String[] result = new String[aspects.size()];
int count = 0; int count = 0;
for (QName qname : aspects) for (QName qname : aspects)
{ {
result[count++] = qname.toString(); 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) 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()); return this.services.getNodeService().getPath(getNodeRef()).toPrefixString(this.services.getNamespaceService());
} }
public String jsGet_qnamePath()
{
return getQnamePath();
}
/** /**
* @return Display path to this node * @return Display path to this node
*/ */
@@ -711,11 +692,6 @@ public class ScriptNode implements Serializable, Scopeable
return displayPath; return displayPath;
} }
public String jsGet_displayPath()
{
return getDisplayPath();
}
/** /**
* @return the small icon image for this node * @return the small icon image for this node
*/ */
@@ -724,11 +700,6 @@ public class ScriptNode implements Serializable, Scopeable
return "/images/filetypes/_default.gif"; return "/images/filetypes/_default.gif";
} }
public String jsGet_icon16()
{
return getIcon16();
}
/** /**
* @return the large icon image for this node * @return the large icon image for this node
*/ */
@@ -737,11 +708,6 @@ public class ScriptNode implements Serializable, Scopeable
return "/images/filetypes32/_default.gif"; return "/images/filetypes32/_default.gif";
} }
public String jsGet_icon32()
{
return getIcon32();
}
/** /**
* @return true if the node is currently locked * @return true if the node is currently locked
*/ */
@@ -749,7 +715,7 @@ public class ScriptNode implements Serializable, Scopeable
{ {
boolean locked = false; boolean locked = false;
if (getAspects().contains(ContentModel.ASPECT_LOCKABLE)) if (getAspectsSet().contains(ContentModel.ASPECT_LOCKABLE))
{ {
LockStatus lockStatus = this.services.getLockService().getLockStatus(this.nodeRef); LockStatus lockStatus = this.services.getLockService().getLockStatus(this.nodeRef);
if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER) if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER)
@@ -761,11 +727,6 @@ public class ScriptNode implements Serializable, Scopeable
return locked; return locked;
} }
public boolean jsGet_isLocked()
{
return isLocked();
}
/** /**
* @return the parent node * @return the parent node
*/ */
@@ -784,11 +745,6 @@ public class ScriptNode implements Serializable, Scopeable
return parent; 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. * @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; return primaryParentAssoc;
} }
public ChildAssociationRef jsGet_primaryParentAssoc()
{
return getPrimaryParentAssoc();
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Content API // Content API
@@ -826,11 +777,6 @@ public class ScriptNode implements Serializable, Scopeable
return content; return content;
} }
public String jsGet_content()
{
return getContent();
}
/** /**
* Set the content for this node * 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 * @return For a content document, this method returns the URL to the content stream for the default content
* property (@see ContentModel.PROP_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 * @return For a content document, this method returns the download URL to the content for
* the default content property (@see ContentModel.PROP_CONTENT) * 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 * @return The mimetype encoding for content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT) * (@see ContentModel.PROP_CONTENT)
@@ -919,11 +850,6 @@ public class ScriptNode implements Serializable, Scopeable
return mimetype; return mimetype;
} }
public String jsGet_mimetype()
{
return getMimetype();
}
/** /**
* Set the mimetype encoding for the content attached to the node from the default content property * Set the mimetype encoding for the content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT) * (@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 * @return The size in bytes of the content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT) * (@see ContentModel.PROP_CONTENT)
@@ -960,11 +881,6 @@ public class ScriptNode implements Serializable, Scopeable
return size; return size;
} }
public long jsGet_size()
{
return getSize();
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Security API // 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 * Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example
* ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character. * ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character.
*/ */
public String[] getPermissions() public Scriptable getPermissions()
{ {
String userName = this.services.getAuthenticationService().getCurrentUserName(); String userName = this.services.getAuthenticationService().getCurrentUserName();
Set<AccessPermission> acls = this.services.getPermissionService().getAllSetPermissions(getNodeRef()); Set<AccessPermission> acls = this.services.getPermissionService().getAllSetPermissions(getNodeRef());
@@ -1014,7 +930,7 @@ public class ScriptNode implements Serializable, Scopeable
.append(permission.getPermission()); .append(permission.getPermission());
permissions[count++] = buf.toString(); 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) public void setPermission(String permission)
{ {
ParameterCheck.mandatoryString("Permission Name", permission); ParameterCheck.mandatoryString("Permission Name", permission);
this.services.getPermissionService().setPermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission, this.services.getPermissionService().setPermission(
true); this.nodeRef, PermissionService.ALL_AUTHORITIES, permission, true);
} }
/** /**
@@ -1058,7 +974,8 @@ public class ScriptNode implements Serializable, Scopeable
{ {
ParameterCheck.mandatoryString("Permission Name", permission); ParameterCheck.mandatoryString("Permission Name", permission);
ParameterCheck.mandatoryString("Authority", authority); 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) public void removePermission(String permission)
{ {
ParameterCheck.mandatoryString("Permission Name", permission); ParameterCheck.mandatoryString("Permission Name", permission);
this.services.getPermissionService() this.services.getPermissionService().deletePermission(
.deletePermission(this.nodeRef, PermissionService.ALL_AUTHORITIES, permission); this.nodeRef, PermissionService.ALL_AUTHORITIES, permission);
} }
/** /**
@@ -1083,7 +1000,8 @@ public class ScriptNode implements Serializable, Scopeable
{ {
ParameterCheck.mandatoryString("Permission Name", permission); ParameterCheck.mandatoryString("Permission Name", permission);
ParameterCheck.mandatoryString("Authority", authority); 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); return this.services.getOwnableService().getOwner(this.nodeRef);
} }
/**
* Make owner available as a property.
*
* @return
*/
public String jsGet_owner()
{
return getOwner();
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Create and Modify API // Create and Modify API
@@ -1166,8 +1074,8 @@ public class ScriptNode implements Serializable, Scopeable
QName qnameType = createQName(type); QName qnameType = createQName(type);
// Ensure that we are performing a specialise // Ensure that we are performing a specialise
if (getType().equals(qnameType) == false && if (getQNameType().equals(qnameType) == false &&
this.services.getDictionaryService().isSubClass(qnameType, getType()) == true) this.services.getDictionaryService().isSubClass(qnameType, getQNameType()) == true)
{ {
// Specialise the type of the node // Specialise the type of the node
this.nodeService.setType(this.nodeRef, qnameType); 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 // 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 // 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. // 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 else
{ {
@@ -1990,7 +1898,8 @@ public class ScriptNode implements Serializable, Scopeable
this.type = null; this.type = null;
this.properties = null; this.properties = null;
this.aspects = null; this.aspects = null;
this.assocs = null; this.targetAssocs = null;
this.sourceAssocs = null;
this.childAssocs = null; this.childAssocs = null;
this.children = null; this.children = null;
this.displayPath = null; this.displayPath = null;
@@ -2214,11 +2123,6 @@ public class ScriptNode implements Serializable, Scopeable
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property); 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 * Set the content stream from another content object
* *
@@ -2247,11 +2151,6 @@ public class ScriptNode implements Serializable, Scopeable
URLEncoder.encode(property.toString()) }); URLEncoder.encode(property.toString()) });
} }
public String jsGet_url()
{
return getUrl();
}
/** /**
* @return download URL to the content for a document item only * @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() public long getSize()
{ {
return contentData.getSize(); return contentData.getSize();
@@ -2310,13 +2204,7 @@ public class ScriptNode implements Serializable, Scopeable
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property); this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property);
} }
public void jsSet_mimetype(String mimetype)
{
setMimetype(mimetype);
}
private ContentData contentData; private ContentData contentData;
private QName property; private QName property;
} }

View File

@@ -58,14 +58,4 @@ public class Session extends BaseProcessorExtension
{ {
return services.getAuthenticationService().getCurrentTicket(); 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); private static Log logger = LogFactory.getLog(TemplateNode.class);
/** Target associations from this node */ /** 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 */ /** The child associations from this node */
private Map<String, List<TemplateNode>> childAssocs = null; private Map<String, List<TemplateNode>> childAssocs = null;
@@ -224,25 +227,61 @@ public class TemplateNode extends BasePermissionsNode
*/ */
public Map<String, List<TemplateNode>> getAssocs() 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); 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) for (AssociationRef ref : refs)
{ {
String qname = ref.getTypeQName().toString(); String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.assocs.get(qname); List<TemplateNode> nodes = this.targetAssocs.get(qname);
if (nodes == null) if (nodes == null)
{ {
// first access for the list for this qname // first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4); 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) ); 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; return this.childAssocs;
} }
public Map<String, List<TemplateNode>> getChildAssociations()
{
return getChildAssocs();
}
/** /**
* @return true if the node is currently locked * @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) private String mapAuthorityToName(ScriptNode authority, boolean allowGroup)
{ {
String name = null; String name = null;
QName type = authority.getType(); QName type = authority.getQNameType();
if (type.equals(ContentModel.TYPE_PERSON)) if (type.equals(ContentModel.TYPE_PERSON))
{ {
name = (String)authority.getProperties().get(ContentModel.PROP_USERNAME); name = (String)authority.getProperties().get(ContentModel.PROP_USERNAME);
@@ -232,5 +232,4 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
} }
return name; return name;
} }
} }