mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Cleanup of ACL reading/writing for PermissionsDaoComponent. All access is
through the AccessControlListDAO interface. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3700 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -206,17 +206,31 @@
|
|||||||
<property name="sessionFactory">
|
<property name="sessionFactory">
|
||||||
<ref bean="sessionFactory" />
|
<ref bean="sessionFactory" />
|
||||||
</property>
|
</property>
|
||||||
<property name="protocolToNodeService">
|
<property name="protocolToACLDAO">
|
||||||
<map>
|
<map>
|
||||||
<entry key="workspace"><ref bean="dbNodeService"></ref></entry>
|
<entry key="workspace"><ref bean="nodeACLDAO"></ref></entry>
|
||||||
<entry key="versionStore"><ref bean="versionNodeService"></ref></entry>
|
<entry key="avm"><ref bean="avmACLDAO"/></entry>
|
||||||
<entry key="avm"><ref bean="avmNodeService"/></entry>
|
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
<property name="defaultNodeService">
|
<property name="defaultACLDAO">
|
||||||
<ref bean="dbNodeService"/>
|
<ref bean="nodeACLDAO"/>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="nodeACLDAO" class="org.alfresco.repo.domain.hibernate.NodeAccessControlListDAO">
|
||||||
|
<property name="nodeDaoService">
|
||||||
|
<ref bean="nodeDaoService"/>
|
||||||
|
</property>
|
||||||
|
<property name="sessionFactory">
|
||||||
|
<ref bean="sessionFactory"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="avmACLDAO" class="org.alfresco.repo.domain.hibernate.AVMAccessControlListDAO">
|
||||||
|
<property name="avmRepository">
|
||||||
|
<ref bean="avmRepository"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="nodeDaoServiceImpl" class="org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl">
|
<bean id="nodeDaoServiceImpl" class="org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl">
|
||||||
<property name="sessionFactory">
|
<property name="sessionFactory">
|
||||||
|
@@ -36,8 +36,8 @@ public class AVMCrawlTest extends AVMServiceTestBase
|
|||||||
public void testCrawl()
|
public void testCrawl()
|
||||||
{
|
{
|
||||||
int n = 2; // Number of Threads.
|
int n = 2; // Number of Threads.
|
||||||
int m = 4; // How many multiples of content to start with.
|
int m = 2; // How many multiples of content to start with.
|
||||||
long runTime = 1200000; // Ten minutes
|
long runTime = 600000; // Ten minutes
|
||||||
fService.purgeAVMStore("main");
|
fService.purgeAVMStore("main");
|
||||||
BulkLoader loader = new BulkLoader();
|
BulkLoader loader = new BulkLoader();
|
||||||
loader.setAvmService(fService);
|
loader.setAvmService(fService);
|
||||||
|
@@ -29,7 +29,6 @@ import java.util.Set;
|
|||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.DbAccessControlList;
|
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.node.AbstractNodeServiceImpl;
|
import org.alfresco.repo.node.AbstractNodeServiceImpl;
|
||||||
import org.alfresco.service.cmr.avm.AVMException;
|
import org.alfresco.service.cmr.avm.AVMException;
|
||||||
@@ -1428,46 +1427,4 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("AVM does not support this operation.");
|
throw new UnsupportedOperationException("AVM does not support this operation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the ACL on a node.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @param acl The list to set.
|
|
||||||
*/
|
|
||||||
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
|
|
||||||
{
|
|
||||||
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
|
||||||
int version = (Integer)avmVersionPath[0];
|
|
||||||
if (version >= 0)
|
|
||||||
{
|
|
||||||
throw new InvalidNodeRefException("Read Only Node.", nodeRef);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fAVMService.setACL((String)avmVersionPath[1], acl);
|
|
||||||
}
|
|
||||||
catch (AVMNotFoundException e)
|
|
||||||
{
|
|
||||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ACL on a node.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @return The ACL.
|
|
||||||
*/
|
|
||||||
public DbAccessControlList getAccessControlList(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return fAVMService.getACL((Integer)avmVersionPath[0],
|
|
||||||
(String)avmVersionPath[1]);
|
|
||||||
}
|
|
||||||
catch (AVMNotFoundException e)
|
|
||||||
{
|
|
||||||
throw new InvalidNodeRefException("Not Found.", nodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -891,33 +891,4 @@ public class AVMServiceImpl implements AVMService
|
|||||||
}
|
}
|
||||||
return fAVMRepository.hasAspect(version, path, aspectName);
|
return fAVMRepository.hasAspect(version, path, aspectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set ACL on a node.
|
|
||||||
* @param path The path to the node.
|
|
||||||
* @param acl The ACL to set.
|
|
||||||
*/
|
|
||||||
public void setACL(String path, DbAccessControlList acl)
|
|
||||||
{
|
|
||||||
if (path == null)
|
|
||||||
{
|
|
||||||
throw new AVMBadArgumentException("Null path.");
|
|
||||||
}
|
|
||||||
fAVMRepository.setACL(path, acl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ACL on a node.
|
|
||||||
* @param version The version to look under.
|
|
||||||
* @param path The path to the node.
|
|
||||||
* @return The ACL.
|
|
||||||
*/
|
|
||||||
public DbAccessControlList getACL(int version, String path)
|
|
||||||
{
|
|
||||||
if (path == null)
|
|
||||||
{
|
|
||||||
throw new AVMBadArgumentException("Null path.");
|
|
||||||
}
|
|
||||||
return fAVMRepository.getACL(version, path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,8 @@ public class AVMStressTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int nCopies = 4;
|
int nCopies = 2;
|
||||||
int nThreads = 8;
|
int nThreads = 2;
|
||||||
BulkLoader loader = new BulkLoader();
|
BulkLoader loader = new BulkLoader();
|
||||||
loader.setAvmService(fService);
|
loader.setAvmService(fService);
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
@@ -32,7 +32,7 @@ public class SimultaneousLoadTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int n = 8;
|
int n = 4;
|
||||||
int m = 1;
|
int m = 1;
|
||||||
fReaper.setInactiveBaseSleep(60000);
|
fReaper.setInactiveBaseSleep(60000);
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.domain;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This abstracts the reading and writing of ACLs on nodes
|
||||||
|
* from particular node implementations.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public interface AccessControlListDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the ACL from a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @return The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public DbAccessControlList getAccessControlList(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ACL on a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @param acl The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl);
|
||||||
|
}
|
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.domain.hibernate;
|
||||||
|
|
||||||
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.repo.avm.AVMRepository;
|
||||||
|
import org.alfresco.repo.domain.AccessControlListDAO;
|
||||||
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMException;
|
||||||
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AVM implementation for getting and setting ACLs.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class AVMAccessControlListDAO implements AccessControlListDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Reference to the AVM Repository instance.
|
||||||
|
*/
|
||||||
|
private AVMRepository fAVMRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructory.
|
||||||
|
*/
|
||||||
|
public AVMAccessControlListDAO()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvmRepository(AVMRepository repository)
|
||||||
|
{
|
||||||
|
fAVMRepository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ACL from a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @return The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public DbAccessControlList getAccessControlList(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
|
int version = (Integer)avmVersionPath[0];
|
||||||
|
String path = (String)avmVersionPath[1];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return fAVMRepository.getACL(version, path);
|
||||||
|
}
|
||||||
|
catch (AVMException e)
|
||||||
|
{
|
||||||
|
throw new InvalidNodeRefException(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ACL on a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @param acl The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
|
||||||
|
{
|
||||||
|
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
|
||||||
|
int version = (Integer)avmVersionPath[1];
|
||||||
|
if (version >= 0)
|
||||||
|
{
|
||||||
|
throw new InvalidNodeRefException("Read Only Node.", nodeRef);
|
||||||
|
}
|
||||||
|
String path = (String)avmVersionPath[1];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fAVMRepository.setACL(path, acl);
|
||||||
|
}
|
||||||
|
catch (AVMException e)
|
||||||
|
{
|
||||||
|
throw new InvalidNodeRefException(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.domain.hibernate;
|
||||||
|
|
||||||
|
import org.alfresco.repo.domain.AccessControlListDAO;
|
||||||
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
|
import org.alfresco.repo.domain.Node;
|
||||||
|
import org.alfresco.repo.node.db.NodeDaoService;
|
||||||
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Node implementation for getting and setting ACLs.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class NodeAccessControlListDAO extends HibernateDaoSupport implements AccessControlListDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The DAO for Nodes.
|
||||||
|
*/
|
||||||
|
private NodeDaoService fNodeDAOService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
public NodeAccessControlListDAO()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeDaoService(NodeDaoService nodeDAOService)
|
||||||
|
{
|
||||||
|
fNodeDAOService = nodeDAOService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ACL from a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @return The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public DbAccessControlList getAccessControlList(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
Node node = fNodeDAOService.getNode(nodeRef);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new InvalidNodeRefException(nodeRef);
|
||||||
|
}
|
||||||
|
return node.getAccessControlList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ACL on a node.
|
||||||
|
* @param nodeRef The reference to the node.
|
||||||
|
* @param acl The ACL.
|
||||||
|
* @throws InvalidNodeRefException
|
||||||
|
*/
|
||||||
|
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
|
||||||
|
{
|
||||||
|
Node node = fNodeDAOService.getNode(nodeRef);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new InvalidNodeRefException(nodeRef);
|
||||||
|
}
|
||||||
|
DbAccessControlList oldAcl = node.getAccessControlList();
|
||||||
|
if (oldAcl != null)
|
||||||
|
{
|
||||||
|
node.setAccessControlList(null);
|
||||||
|
this.getHibernateTemplate().delete(oldAcl);
|
||||||
|
}
|
||||||
|
node.setAccessControlList(acl);
|
||||||
|
}
|
||||||
|
}
|
@@ -22,6 +22,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.repo.domain.AccessControlListDAO;
|
||||||
import org.alfresco.repo.domain.DbAccessControlEntry;
|
import org.alfresco.repo.domain.DbAccessControlEntry;
|
||||||
import org.alfresco.repo.domain.DbAccessControlList;
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
import org.alfresco.repo.domain.DbAuthority;
|
import org.alfresco.repo.domain.DbAuthority;
|
||||||
@@ -35,6 +36,7 @@ import org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry;
|
|||||||
import org.alfresco.repo.security.permissions.impl.SimplePermissionEntry;
|
import org.alfresco.repo.security.permissions.impl.SimplePermissionEntry;
|
||||||
import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
|
import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
|
||||||
import org.alfresco.repo.transaction.TransactionalDao;
|
import org.alfresco.repo.transaction.TransactionalDao;
|
||||||
|
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.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
@@ -60,9 +62,9 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
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";
|
||||||
|
|
||||||
private Map<String, NodeService> protocolToNodeService;
|
private Map<String, AccessControlListDAO> fProtocolToACLDAO;
|
||||||
|
|
||||||
private NodeService defaultNodeService;
|
private AccessControlListDAO fDefaultACLDAO;
|
||||||
|
|
||||||
/** a uuid identifying this unique instance */
|
/** a uuid identifying this unique instance */
|
||||||
private String uuid;
|
private String uuid;
|
||||||
@@ -128,14 +130,14 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
getSession().flush();
|
getSession().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProtocolToNodeService(Map<String, NodeService> map)
|
public void setProtocolToACLDAO(Map<String, AccessControlListDAO> map)
|
||||||
{
|
{
|
||||||
protocolToNodeService = map;
|
fProtocolToACLDAO = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultNodeService(NodeService defaultNodeService)
|
public void setDefaultACLDAO(AccessControlListDAO defaultACLDAO)
|
||||||
{
|
{
|
||||||
this.defaultNodeService = defaultNodeService;
|
fDefaultACLDAO = defaultACLDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodePermissionEntry getPermissions(NodeRef nodeRef)
|
public NodePermissionEntry getPermissions(NodeRef nodeRef)
|
||||||
@@ -144,14 +146,16 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
// Null objects are not cached in hibernate
|
// Null objects are not cached in hibernate
|
||||||
// If the object does not exist it will repeatedly query to check its
|
// If the object does not exist it will repeatedly query to check its
|
||||||
// non existence.
|
// non existence.
|
||||||
|
|
||||||
NodePermissionEntry npe = null;
|
NodePermissionEntry npe = null;
|
||||||
DbAccessControlList acl = null;
|
DbAccessControlList acl = null;
|
||||||
if (nodeExists(nodeRef))
|
try
|
||||||
{
|
{
|
||||||
// get the persisted version
|
|
||||||
acl = getAccessControlList(nodeRef, false);
|
acl = getAccessControlList(nodeRef, false);
|
||||||
}
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
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
|
||||||
@@ -186,7 +190,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
private DbAccessControlList getAccessControlList(NodeRef nodeRef, boolean create)
|
private DbAccessControlList getAccessControlList(NodeRef nodeRef, boolean create)
|
||||||
{
|
{
|
||||||
DbAccessControlList acl =
|
DbAccessControlList acl =
|
||||||
getNodeService(nodeRef).getAccessControlList(nodeRef);
|
getACLDAO(nodeRef).getAccessControlList(nodeRef);
|
||||||
if (acl == null && create)
|
if (acl == null && create)
|
||||||
{
|
{
|
||||||
acl = createAccessControlList(nodeRef);
|
acl = createAccessControlList(nodeRef);
|
||||||
@@ -212,7 +216,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
getHibernateTemplate().save(acl);
|
getHibernateTemplate().save(acl);
|
||||||
|
|
||||||
// maintain inverse
|
// maintain inverse
|
||||||
getNodeService(nodeRef).setAccessControlList(nodeRef, acl);
|
getACLDAO(nodeRef).setAccessControlList(nodeRef, acl);
|
||||||
|
|
||||||
// done
|
// done
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -226,15 +230,19 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void deletePermissions(NodeRef nodeRef)
|
public void deletePermissions(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
if (!nodeExists(nodeRef))
|
DbAccessControlList acl = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
acl = getAccessControlList(nodeRef, false);
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DbAccessControlList acl = getAccessControlList(nodeRef, false);
|
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
{
|
{
|
||||||
// maintain referencial integrity
|
// maintain referencial integrity
|
||||||
getNodeService(nodeRef).setAccessControlList(nodeRef, null);
|
getACLDAO(nodeRef).setAccessControlList(nodeRef, null);
|
||||||
// delete the access control list - it will cascade to the entries
|
// delete the access control list - it will cascade to the entries
|
||||||
getHibernateTemplate().delete(acl);
|
getHibernateTemplate().delete(acl);
|
||||||
}
|
}
|
||||||
@@ -264,12 +272,15 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public void deletePermissions(final NodeRef nodeRef, final String authority)
|
public void deletePermissions(final NodeRef nodeRef, final String authority)
|
||||||
{
|
{
|
||||||
if (!nodeExists(nodeRef))
|
DbAccessControlList acl = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
acl = getACLDAO(nodeRef).getAccessControlList(nodeRef);
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DbAccessControlList acl =
|
|
||||||
getNodeService(nodeRef).getAccessControlList(nodeRef);
|
|
||||||
int deletedCount = 0;
|
int deletedCount = 0;
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
{
|
{
|
||||||
@@ -291,12 +302,15 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
*/
|
*/
|
||||||
public void deletePermission(NodeRef nodeRef, String authority, PermissionReference permission)
|
public void deletePermission(NodeRef nodeRef, String authority, PermissionReference permission)
|
||||||
{
|
{
|
||||||
if (!nodeExists(nodeRef))
|
DbAccessControlList acl = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
acl = getACLDAO(nodeRef).getAccessControlList(nodeRef);
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DbAccessControlList acl =
|
|
||||||
getNodeService(nodeRef).getAccessControlList(nodeRef);
|
|
||||||
int deletedCount = 0;
|
int deletedCount = 0;
|
||||||
if (acl != null)
|
if (acl != null)
|
||||||
{
|
{
|
||||||
@@ -431,7 +445,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
if (acl != null)
|
if (acl != null)
|
||||||
{
|
{
|
||||||
// maintain referencial integrity
|
// maintain referencial integrity
|
||||||
getNodeService(nodeRef).setAccessControlList(nodeRef, null);
|
getACLDAO(nodeRef).setAccessControlList(nodeRef, null);
|
||||||
// drop the list
|
// drop the list
|
||||||
getHibernateTemplate().delete(acl);
|
getHibernateTemplate().delete(acl);
|
||||||
}
|
}
|
||||||
@@ -477,12 +491,15 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
public boolean getInheritParentPermissions(NodeRef nodeRef)
|
public boolean getInheritParentPermissions(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
if (!nodeExists(nodeRef))
|
DbAccessControlList acl = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
acl = getAccessControlList(nodeRef, false);
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
{
|
{
|
||||||
return INHERIT_PERMISSIONS_DEFAULT;
|
return INHERIT_PERMISSIONS_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
DbAccessControlList acl = getAccessControlList(nodeRef, false);
|
|
||||||
if (acl == null)
|
if (acl == null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -499,7 +516,7 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
private SimpleNodePermissionEntry createSimpleNodePermissionEntry(NodeRef nodeRef)
|
private SimpleNodePermissionEntry createSimpleNodePermissionEntry(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
DbAccessControlList acl =
|
DbAccessControlList acl =
|
||||||
getNodeService(nodeRef).getAccessControlList(nodeRef);
|
getACLDAO(nodeRef).getAccessControlList(nodeRef);
|
||||||
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
|
||||||
@@ -567,27 +584,17 @@ public class PermissionsDaoComponentImpl extends HibernateDaoSupport implements
|
|||||||
perm.getName());
|
perm.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to check node existence.
|
|
||||||
* @param nodeRef The node ref to check.
|
|
||||||
* @return Whether the node exists.
|
|
||||||
*/
|
|
||||||
private boolean nodeExists(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
return getNodeService(nodeRef).exists(nodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to choose appropriate NodeService for the given NodeRef
|
* Helper to choose appropriate NodeService for the given NodeRef
|
||||||
* @param nodeRef The NodeRef to dispatch from.
|
* @param nodeRef The NodeRef to dispatch from.
|
||||||
* @return The appropriate NodeService.
|
* @return The appropriate NodeService.
|
||||||
*/
|
*/
|
||||||
private NodeService getNodeService(NodeRef nodeRef)
|
private AccessControlListDAO getACLDAO(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
NodeService ret = protocolToNodeService.get(nodeRef.getStoreRef().getProtocol());
|
AccessControlListDAO ret = fProtocolToACLDAO.get(nodeRef.getStoreRef().getProtocol());
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
{
|
{
|
||||||
return defaultNodeService;
|
return fDefaultACLDAO;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.avm.AVMContext;
|
import org.alfresco.repo.avm.AVMContext;
|
||||||
import org.alfresco.repo.domain.ChildAssoc;
|
import org.alfresco.repo.domain.ChildAssoc;
|
||||||
import org.alfresco.repo.domain.DbAccessControlList;
|
|
||||||
import org.alfresco.repo.domain.Node;
|
import org.alfresco.repo.domain.Node;
|
||||||
import org.alfresco.repo.domain.NodeAssoc;
|
import org.alfresco.repo.domain.NodeAssoc;
|
||||||
import org.alfresco.repo.domain.NodeStatus;
|
import org.alfresco.repo.domain.NodeStatus;
|
||||||
@@ -1840,26 +1839,4 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
" name: " + useName);
|
" name: " + useName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the ACL on a node.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @param acl The ACL to set.
|
|
||||||
*/
|
|
||||||
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
|
|
||||||
{
|
|
||||||
Node node = getNodeNotNull(nodeRef);
|
|
||||||
node.setAccessControlList(acl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ACL on a node.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @return The ACL.
|
|
||||||
*/
|
|
||||||
public DbAccessControlList getAccessControlList(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
Node node = getNodeNotNull(nodeRef);
|
|
||||||
return node.getAccessControlList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.DbAccessControlList;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
||||||
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
||||||
@@ -557,24 +556,4 @@ public class NodeServiceImpl implements NodeService, VersionModel
|
|||||||
{
|
{
|
||||||
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
|
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the access control list on a node. Defer to DbNodeService.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @param acl The list to set.
|
|
||||||
*/
|
|
||||||
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
|
|
||||||
{
|
|
||||||
dbNodeService.setAccessControlList(nodeRef, acl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the access control list on a node. Defer to DbNodeService.
|
|
||||||
* @param nodeRef The reference to the node.
|
|
||||||
* @return The list.
|
|
||||||
*/
|
|
||||||
public DbAccessControlList getAccessControlList(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
return dbNodeService.getAccessControlList(nodeRef);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -588,19 +588,4 @@ public interface AVMService
|
|||||||
* @return Whether the given node has the given aspect.
|
* @return Whether the given node has the given aspect.
|
||||||
*/
|
*/
|
||||||
public boolean hasAspect(int version, String path, QName aspectName);
|
public boolean hasAspect(int version, String path, QName aspectName);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ACL on a given node.
|
|
||||||
* @param version The version to look under.
|
|
||||||
* @param path The path to the node.
|
|
||||||
* @return The ACL.
|
|
||||||
*/
|
|
||||||
public DbAccessControlList getACL(int version, String path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the ACL on a given node.
|
|
||||||
* @param path The path to the node.
|
|
||||||
* @param acl The ACL to set.
|
|
||||||
*/
|
|
||||||
public void setACL(String path, DbAccessControlList acl);
|
|
||||||
}
|
}
|
||||||
|
@@ -561,20 +561,4 @@ public interface NodeService
|
|||||||
NodeRef destinationParentNodeRef,
|
NodeRef destinationParentNodeRef,
|
||||||
QName assocTypeQName,
|
QName assocTypeQName,
|
||||||
QName assocQName);
|
QName assocQName);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the access control list associated with a Node.
|
|
||||||
* @param nodeRef The reference to the Node.
|
|
||||||
* @return The access control list.
|
|
||||||
*/
|
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
|
||||||
public DbAccessControlList getAccessControlList(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the access control list on a node.
|
|
||||||
* @param nodeRef The node reference.
|
|
||||||
* @param acl The list to set.
|
|
||||||
*/
|
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "acl"})
|
|
||||||
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user