mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
. Rhino JavaScript integration:
- APIs for testing of Permissions and checking that an Aspect exists on a node . Added new command processor to config for Command Servlet - new command processor to allow execution of Alfresco JavaScript files via URLs - Wiki docs: http://wiki.alfresco.com/wiki/URL_Addressability#Script_Command_Processor . Fixed issue where a deleted/missing NodeRef on the end of a Link object would cause errors in the web-client - Still needs cleanup/change to assoc mechanism as per AWC-647 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2774 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -45,6 +45,7 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
@@ -305,7 +306,7 @@ public final class Node implements Serializable
|
|||||||
*
|
*
|
||||||
* The Map returned implements the Scriptable interface to allow access to the assoc arrays via
|
* The Map returned implements the Scriptable interface to allow access to the assoc arrays via
|
||||||
* JavaScript associative array access. This means associations of this node can be access thus:
|
* JavaScript associative array access. This means associations of this node can be access thus:
|
||||||
* <code>node.getAssocs()["translations"][0]</code>
|
* <code>node.assocs["translations"][0]</code>
|
||||||
*
|
*
|
||||||
* @return associations as a Map of assoc name to an Array of Nodes.
|
* @return associations as a Map of assoc name to an Array of Nodes.
|
||||||
*/
|
*/
|
||||||
@@ -351,7 +352,7 @@ public final class Node implements Serializable
|
|||||||
*
|
*
|
||||||
* The Map returned implements the Scriptable interface to allow access to the properties via
|
* 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:
|
* JavaScript associative array access. This means properties of a node can be access thus:
|
||||||
* <code>node.getProperties()["name"]</code>
|
* <code>node.properties["name"]</code>
|
||||||
*
|
*
|
||||||
* @return Map of properties for this Node.
|
* @return Map of properties for this Node.
|
||||||
*/
|
*/
|
||||||
@@ -454,28 +455,30 @@ public final class Node implements Serializable
|
|||||||
*/
|
*/
|
||||||
public boolean hasAspect(String aspect)
|
public boolean hasAspect(String aspect)
|
||||||
{
|
{
|
||||||
if (this.aspects == null)
|
return getAspects().contains(createQName(aspect));
|
||||||
{
|
|
||||||
this.aspects = this.nodeService.getAspects(this.nodeRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aspect.startsWith(NAMESPACE_BEGIN))
|
/**
|
||||||
|
* Return true if the user has the specified permission on the node.
|
||||||
|
* <p>
|
||||||
|
* The default permissions are found in <code>org.alfresco.service.cmr.security.PermissionService</code>.
|
||||||
|
* Most commonly used are "Write", "Delete" and "AddChildren".
|
||||||
|
*
|
||||||
|
* @param permission as found in <code>org.alfresco.service.cmr.security.PermissionService</code>
|
||||||
|
*
|
||||||
|
* @return true if the user has the specified permission on the node.
|
||||||
|
*/
|
||||||
|
public boolean hasPermission(String permission)
|
||||||
{
|
{
|
||||||
return aspects.contains((createQName(aspect)));
|
boolean allowed = false;
|
||||||
}
|
|
||||||
else
|
if (permission != null && permission.length() != 0)
|
||||||
{
|
{
|
||||||
boolean found = false;
|
AccessStatus status = this.services.getPermissionService().hasPermission(this.nodeRef, permission);
|
||||||
for (QName qname : this.aspects)
|
allowed = (AccessStatus.ALLOWED == status);
|
||||||
{
|
|
||||||
if (qname.toPrefixString(this.services.getNamespaceService()).equals(aspect))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -996,6 +999,19 @@ public final class Node implements Serializable
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an aspect to the Node. As no properties are provided in this call, it can only be
|
||||||
|
* used to add aspects that do not require any mandatory properties.
|
||||||
|
*
|
||||||
|
* @param type Type name of the aspect to add
|
||||||
|
*
|
||||||
|
* @return true if the aspect was added successfully, false if an error occured.
|
||||||
|
*/
|
||||||
|
public boolean addAspect(String type)
|
||||||
|
{
|
||||||
|
return addAspect(type, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an aspect to the Node.
|
* Add an aspect to the Node.
|
||||||
*
|
*
|
||||||
@@ -1059,6 +1075,13 @@ public final class Node implements Serializable
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to create a QName from either a fully qualified or short-name QName string
|
||||||
|
*
|
||||||
|
* @param s Fully qualified or short-name QName string
|
||||||
|
*
|
||||||
|
* @return QName
|
||||||
|
*/
|
||||||
private QName createQName(String s)
|
private QName createQName(String s)
|
||||||
{
|
{
|
||||||
QName qname;
|
QName qname;
|
||||||
|
Reference in New Issue
Block a user