mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Relaxed requirement that nodes must exist when permissions are retrieved
- A non-existent node reference gets permission checked on its way to the version NodeService git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2832 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -56,6 +56,7 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|||||||
*/
|
*/
|
||||||
public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements PermissionsDaoComponent
|
public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements PermissionsDaoComponent
|
||||||
{
|
{
|
||||||
|
private static final boolean INHERIT_PERMISSIONS_DEFAULT = true;
|
||||||
public static final String QUERY_GET_PERMISSION = "permission.GetPermission";
|
public static final String QUERY_GET_PERMISSION = "permission.GetPermission";
|
||||||
public static final String QUERY_GET_AC_ENTRIES_FOR_AUTHORITY = "permission.GetAccessControlEntriesForAuthority";
|
public static final String QUERY_GET_AC_ENTRIES_FOR_AUTHORITY = "permission.GetAccessControlEntriesForAuthority";
|
||||||
public static final String QUERY_GET_AC_ENTRIES_FOR_PERMISSION = "permission.GetAccessControlEntriesForPermission";
|
public static final String QUERY_GET_AC_ENTRIES_FOR_PERMISSION = "permission.GetAccessControlEntriesForPermission";
|
||||||
@@ -90,9 +91,13 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
return npe;
|
return npe;
|
||||||
}
|
}
|
||||||
Node node = getNode(nodeRef);
|
DbAccessControlList acl = null;
|
||||||
// get the persisted version
|
Node node = getNode(nodeRef, false);
|
||||||
DbAccessControlList acl = getAccessControlList(node, false);
|
if (node != null)
|
||||||
|
{
|
||||||
|
// get the persisted version
|
||||||
|
acl = getAccessControlList(node, false);
|
||||||
|
}
|
||||||
if (acl == null)
|
if (acl == null)
|
||||||
{
|
{
|
||||||
// there isn't an access control list for the node - spoof a null one
|
// there isn't an access control list for the node - spoof a null one
|
||||||
@@ -147,7 +152,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
DbAccessControlList acl = new DbAccessControlListImpl();
|
DbAccessControlList acl = new DbAccessControlListImpl();
|
||||||
acl.setNode(node);
|
acl.setNode(node);
|
||||||
acl.setInherits(true);
|
acl.setInherits(INHERIT_PERMISSIONS_DEFAULT);
|
||||||
getHibernateTemplate().save(acl);
|
getHibernateTemplate().save(acl);
|
||||||
|
|
||||||
// maintain inverse
|
// maintain inverse
|
||||||
@@ -168,12 +173,14 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @return Returns the node for the given reference, or null
|
* @param mustExist true if an exception must be thrown if the node does not exist
|
||||||
|
* @return Returns the node for the given reference, or null if <code>mustExist == false</code>
|
||||||
|
* @throws InvalidNodeRefException if the node must exist but doesn't
|
||||||
*/
|
*/
|
||||||
private Node getNode(NodeRef nodeRef)
|
private Node getNode(NodeRef nodeRef, boolean mustExist)
|
||||||
{
|
{
|
||||||
Node node = nodeDaoService.getNode(nodeRef);
|
Node node = nodeDaoService.getNode(nodeRef);
|
||||||
if (node == null)
|
if (node == null && mustExist)
|
||||||
{
|
{
|
||||||
throw new InvalidNodeRefException(nodeRef);
|
throw new InvalidNodeRefException(nodeRef);
|
||||||
}
|
}
|
||||||
@@ -182,7 +189,11 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void deletePermissions(NodeRef nodeRef)
|
public void deletePermissions(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, false);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
DbAccessControlList acl = getAccessControlList(node, false);
|
DbAccessControlList acl = getAccessControlList(node, false);
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
{
|
{
|
||||||
@@ -217,7 +228,11 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void deletePermissions(final NodeRef nodeRef, final String authority)
|
public void deletePermissions(final NodeRef nodeRef, final String authority)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, false);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
DbAccessControlList acl = node.getAccessControlList();
|
DbAccessControlList acl = node.getAccessControlList();
|
||||||
int deletedCount = 0;
|
int deletedCount = 0;
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
@@ -240,7 +255,11 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
*/
|
*/
|
||||||
public void deletePermission(NodeRef nodeRef, String authority, PermissionReference permission)
|
public void deletePermission(NodeRef nodeRef, String authority, PermissionReference permission)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, false);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
DbAccessControlList acl = node.getAccessControlList();
|
DbAccessControlList acl = node.getAccessControlList();
|
||||||
int deletedCount = 0;
|
int deletedCount = 0;
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
@@ -260,7 +279,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void setPermission(NodeRef nodeRef, String authority, PermissionReference permission, boolean allow)
|
public void setPermission(NodeRef nodeRef, String authority, PermissionReference permission, boolean allow)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, true);
|
||||||
// get the entry
|
// get the entry
|
||||||
DbAccessControlEntry entry = getAccessControlEntry(node, authority, permission);
|
DbAccessControlEntry entry = getAccessControlEntry(node, authority, permission);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
@@ -372,7 +391,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
public void setPermission(NodePermissionEntry nodePermissionEntry)
|
public void setPermission(NodePermissionEntry nodePermissionEntry)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodePermissionEntry.getNodeRef();
|
NodeRef nodeRef = nodePermissionEntry.getNodeRef();
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, true);
|
||||||
|
|
||||||
// Get the access control list
|
// Get the access control list
|
||||||
// Note the logic here requires to know whether it was created or not
|
// Note the logic here requires to know whether it was created or not
|
||||||
@@ -407,7 +426,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void setInheritParentPermissions(NodeRef nodeRef, boolean inheritParentPermissions)
|
public void setInheritParentPermissions(NodeRef nodeRef, boolean inheritParentPermissions)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, true);
|
||||||
|
|
||||||
DbAccessControlList acl = null;
|
DbAccessControlList acl = null;
|
||||||
if (!inheritParentPermissions)
|
if (!inheritParentPermissions)
|
||||||
@@ -428,7 +447,11 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public boolean getInheritParentPermissions(NodeRef nodeRef)
|
public boolean getInheritParentPermissions(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Node node = getNode(nodeRef);
|
Node node = getNode(nodeRef, false);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return INHERIT_PERMISSIONS_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
DbAccessControlList acl = getAccessControlList(node, false);
|
DbAccessControlList acl = getAccessControlList(node, false);
|
||||||
if (acl == null)
|
if (acl == null)
|
||||||
|
Reference in New Issue
Block a user