diff --git a/source/java/org/alfresco/filesys/alfresco/DesktopResponse.java b/source/java/org/alfresco/filesys/alfresco/DesktopResponse.java index 1745ea143c..90a30d9ed9 100644 --- a/source/java/org/alfresco/filesys/alfresco/DesktopResponse.java +++ b/source/java/org/alfresco/filesys/alfresco/DesktopResponse.java @@ -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 * diff --git a/source/java/org/alfresco/repo/jscript/AVM.java b/source/java/org/alfresco/repo/jscript/AVM.java index 66b3d3e989..f084d40317 100644 --- a/source/java/org/alfresco/repo/jscript/AVM.java +++ b/source/java/org/alfresco/repo/jscript/AVM.java @@ -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 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(); diff --git a/source/java/org/alfresco/repo/jscript/AVMNode.java b/source/java/org/alfresco/repo/jscript/AVMNode.java index d91761da92..ae2ba1f706 100644 --- a/source/java/org/alfresco/repo/jscript/AVMNode.java +++ b/source/java/org/alfresco/repo/jscript/AVMNode.java @@ -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 getAspects() + public Set 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 { diff --git a/source/java/org/alfresco/repo/jscript/AVMScriptStore.java b/source/java/org/alfresco/repo/jscript/AVMScriptStore.java index 1b81b327d8..61518d8916 100644 --- a/source/java/org/alfresco/repo/jscript/AVMScriptStore.java +++ b/source/java/org/alfresco/repo/jscript/AVMScriptStore.java @@ -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())); } /** diff --git a/source/java/org/alfresco/repo/jscript/Actions.java b/source/java/org/alfresco/repo/jscript/Actions.java index e5574472b0..341d0c2d01 100644 --- a/source/java/org/alfresco/repo/jscript/Actions.java +++ b/source/java/org/alfresco/repo/jscript/Actions.java @@ -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; } - } diff --git a/source/java/org/alfresco/repo/jscript/Association.java b/source/java/org/alfresco/repo/jscript/Association.java index 25b783bb3b..b66a643140 100644 --- a/source/java/org/alfresco/repo/jscript/Association.java +++ b/source/java/org/alfresco/repo/jscript/Association.java @@ -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(); - } } diff --git a/source/java/org/alfresco/repo/jscript/Behaviour.java b/source/java/org/alfresco/repo/jscript/Behaviour.java index 52307cdb5c..c0cb4796e1 100644 --- a/source/java/org/alfresco/repo/jscript/Behaviour.java +++ b/source/java/org/alfresco/repo/jscript/Behaviour.java @@ -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(); - } } diff --git a/source/java/org/alfresco/repo/jscript/CategoryNode.java b/source/java/org/alfresco/repo/jscript/CategoryNode.java index a31296c65f..d9307aeaf2 100644 --- a/source/java/org/alfresco/repo/jscript/CategoryNode.java +++ b/source/java/org/alfresco/repo/jscript/CategoryNode.java @@ -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 * diff --git a/source/java/org/alfresco/repo/jscript/ChildAssociation.java b/source/java/org/alfresco/repo/jscript/ChildAssociation.java index cfde83e24a..f72f147df5 100644 --- a/source/java/org/alfresco/repo/jscript/ChildAssociation.java +++ b/source/java/org/alfresco/repo/jscript/ChildAssociation.java @@ -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(); - } } diff --git a/source/java/org/alfresco/repo/jscript/Classification.java b/source/java/org/alfresco/repo/jscript/Classification.java index 3004304885..2690e209bc 100644 --- a/source/java/org/alfresco/repo/jscript/Classification.java +++ b/source/java/org/alfresco/repo/jscript/Classification.java @@ -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. * diff --git a/source/java/org/alfresco/repo/jscript/People.java b/source/java/org/alfresco/repo/jscript/People.java index 761be5dc29..5617c5b907 100644 --- a/source/java/org/alfresco/repo/jscript/People.java +++ b/source/java/org/alfresco/repo/jscript/People.java @@ -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 authorities = authorityService.getContainedAuthorities(type, groupName, !recurse); diff --git a/source/java/org/alfresco/repo/jscript/ScriptAction.java b/source/java/org/alfresco/repo/jscript/ScriptAction.java index be8de7d219..1df302e55b 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptAction.java +++ b/source/java/org/alfresco/repo/jscript/ScriptAction.java @@ -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: node.properties["name"] @@ -122,11 +117,6 @@ public final class ScriptAction implements Serializable, Scopeable return this.parameters; } - public Map jsGet_parameters() - { - return getParameters(); - } - /** * Execute action * diff --git a/source/java/org/alfresco/repo/jscript/ScriptLogger.java b/source/java/org/alfresco/repo/jscript/ScriptLogger.java index 3131377570..8e9cb59781 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptLogger.java +++ b/source/java/org/alfresco/repo/jscript/ScriptLogger.java @@ -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); diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 9f29f65134..1bad6c1c98 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -122,8 +122,11 @@ public class ScriptNode implements Serializable, Scopeable /** The aspects applied to this node */ protected Set aspects = null; - /** The target associations for this node */ - private ScriptableQNameMap assocs = null; + /** The target associations from this node */ + private ScriptableQNameMap targetAssocs = null; + + /** The source assoications to this node */ + private ScriptableQNameMap sourceAssocs = null; /** The child associations for this node */ private ScriptableQNameMap 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 mynode.childrenByXPath("*[@cm:name='Testing']/*"); @@ -429,46 +404,89 @@ public class ScriptNode implements Serializable, Scopeable @SuppressWarnings("unchecked") public Map 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(this.services.getNamespaceService()); + this.targetAssocs = new ScriptableQNameMap(this.services.getNamespaceService()); // get the list of target nodes for each association type List refs = this.nodeService.getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL); for (AssociationRef ref : refs) { String qname = ref.getTypeQName().toString(); - List nodes = (List)this.assocs.get(qname); + List nodes = (List)this.targetAssocs.get(qname); if (nodes == null) { // first access of the list for this qname nodes = new ArrayList(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 nodes = (List)this.assocs.get(qname); + List nodes = (List)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 jsGet_assocs() + public Map getAssociations() { return getAssocs(); } - public Map 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: + * node.sourceAssocs["translations"][0] + * + * @return source associations as a Map of assoc name to a JavaScript array of Nodes. + */ + @SuppressWarnings("unchecked") + public Map getSourceAssocs() { - return getAssocs(); + if (this.sourceAssocs == null) + { + // this Map implements the Scriptable interface for native JS syntax property access + this.sourceAssocs = new ScriptableQNameMap(this.services.getNamespaceService()); + + // get the list of source nodes for each association type + List refs = this.nodeService.getSourceAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL); + for (AssociationRef ref : refs) + { + String qname = ref.getTypeQName().toString(); + List nodes = (List)this.sourceAssocs.get(qname); + if (nodes == null) + { + // first access of the list for this qname + nodes = new ArrayList(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 nodes = (List)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 getSourceAssociations() + { + return getSourceAssocs(); } /** @@ -514,12 +532,7 @@ public class ScriptNode implements Serializable, Scopeable return this.childAssocs; } - public Map jsGet_childAssocs() - { - return getChildAssocs(); - } - - public Map jsGet_childAssociations() + public Map getChildAssociations() { return getChildAssocs(); } @@ -554,11 +567,6 @@ public class ScriptNode implements Serializable, Scopeable return this.properties; } - public Map 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 getAspects() + public Set 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 aspects = getAspects(); + Set 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 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; } diff --git a/source/java/org/alfresco/repo/jscript/Session.java b/source/java/org/alfresco/repo/jscript/Session.java index aa3cf0b09e..936f82d099 100644 --- a/source/java/org/alfresco/repo/jscript/Session.java +++ b/source/java/org/alfresco/repo/jscript/Session.java @@ -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(); - } } diff --git a/source/java/org/alfresco/repo/template/TemplateNode.java b/source/java/org/alfresco/repo/template/TemplateNode.java index 70641bdc88..2ab825d6f8 100644 --- a/source/java/org/alfresco/repo/template/TemplateNode.java +++ b/source/java/org/alfresco/repo/template/TemplateNode.java @@ -78,7 +78,10 @@ public class TemplateNode extends BasePermissionsNode private static Log logger = LogFactory.getLog(TemplateNode.class); /** Target associations from this node */ - private Map> assocs = null; + private Map> targetAssocs = null; + + /** Source associations to this node */ + private Map> sourceAssocs = null; /** The child associations from this node */ private Map> childAssocs = null; @@ -224,25 +227,61 @@ public class TemplateNode extends BasePermissionsNode */ public Map> getAssocs() { - if (this.assocs == null) + if (this.targetAssocs == null) { List refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL); - this.assocs = new QNameMap>(this.services.getNamespaceService()); + this.targetAssocs = new QNameMap>(this.services.getNamespaceService()); for (AssociationRef ref : refs) { String qname = ref.getTypeQName().toString(); - List nodes = this.assocs.get(qname); + List nodes = this.targetAssocs.get(qname); if (nodes == null) { // first access for the list for this qname nodes = new ArrayList(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> getAssociations() + { + return getAssocs(); + } + + /** + * @return Source associations for this Node. As a Map of assoc name to a List of TemplateNodes. + */ + public Map> getSourceAssocs() + { + if (this.sourceAssocs == null) + { + List refs = this.services.getNodeService().getSourceAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL); + this.sourceAssocs = new QNameMap>(this.services.getNamespaceService()); + for (AssociationRef ref : refs) + { + String qname = ref.getTypeQName().toString(); + List nodes = this.sourceAssocs.get(qname); + if (nodes == null) + { + // first access for the list for this qname + nodes = new ArrayList(4); + this.sourceAssocs.put(ref.getTypeQName().toString(), nodes); + } + nodes.add( new TemplateNode(ref.getSourceRef(), this.services, this.imageResolver) ); + } + } + + return this.sourceAssocs; + } + + public Map> getSourceAssociations() + { + return getSourceAssocs(); } /** @@ -271,6 +310,11 @@ public class TemplateNode extends BasePermissionsNode return this.childAssocs; } + public Map> getChildAssociations() + { + return getChildAssocs(); + } + /** * @return true if the node is currently locked */ diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoAssignment.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoAssignment.java index 9891c2ab91..fc8ec7ca35 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoAssignment.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoAssignment.java @@ -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; } - }