This changes PermissionsDaoComponentImpl to work with NodeRefs instead

of Nodes so that Permissions can be used with AVM nodes.  It needs
to be factored a little bit differently, so consider this a WIP.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3698 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-05 14:17:34 +00:00
parent 8c2ad19b2f
commit 1fd96d13d5
12 changed files with 308 additions and 77 deletions

View File

@@ -29,6 +29,7 @@ import java.util.Set;
import java.util.SortedMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.node.AbstractNodeServiceImpl;
import org.alfresco.service.cmr.avm.AVMException;
@@ -1427,4 +1428,46 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{
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);
}
}
}

View File

@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMCycleException;
import org.alfresco.service.cmr.avm.AVMException;
@@ -1139,4 +1140,31 @@ public class AVMRepository
AVMStore store = getAVMStoreByName(pathParts[0]);
return store.hasAspect(version, pathParts[1], aspectName);
}
/**
* Set the ACL on a node.
* @param path The path to the node.
* @param acl The ACL to set.
*/
public void setACL(String path, DbAccessControlList acl)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]);
store.setACL(pathParts[1], 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)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getACL(version, pathParts[1]);
}
}

View File

@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.avm.AVMRepository;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMException;
@@ -890,4 +891,33 @@ public class AVMServiceImpl implements AVMService
}
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);
}
}

View File

@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
@@ -383,4 +384,19 @@ public interface AVMStore
* @return Whether the node has the aspect.
*/
public boolean hasAspect(int version, String path, QName aspectName);
/**
* Set the ACL on a node.
* @param path The path to the node.
* @param acl The ACL to set.
*/
public void setACL(String path, DbAccessControlList 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);
}

View File

@@ -30,6 +30,7 @@ import java.util.SortedMap;
import java.util.TreeMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMException;
@@ -1106,4 +1107,28 @@ public class AVMStoreImpl implements AVMStore, Serializable
AVMNode node = lPath.getCurrentNode();
return AVMContext.fgInstance.fAVMAspectNameDAO.exists(node, aspectName);
}
/**
* Set the ACL on a node.
* @param path The path to the node.
* @param acl The ACL to set.
*/
public void setACL(String path, DbAccessControlList acl)
{
Lookup lPath = lookup(-1, path, true);
AVMNode node = lPath.getCurrentNode();
node.setAcl(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)
{
Lookup lPath = lookup(version, path, false);
return lPath.getCurrentNode().getAcl();
}
}