mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Export permissions and permission inheritance.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2106 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -156,6 +157,39 @@ import org.alfresco.service.namespace.QName;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void startACL(NodeRef nodeRef)
|
||||
{
|
||||
for (Exporter exporter : exporters)
|
||||
{
|
||||
exporter.startACL(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
|
||||
*/
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
for (Exporter exporter : exporters)
|
||||
{
|
||||
exporter.permission(nodeRef, permission);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void endACL(NodeRef nodeRef)
|
||||
{
|
||||
for (Exporter exporter : exporters)
|
||||
{
|
||||
exporter.endACL(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
@@ -38,7 +38,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
@@ -72,6 +74,8 @@ public class ExporterComponent
|
||||
private ContentService contentService;
|
||||
private DescriptorService descriptorService;
|
||||
private AuthenticationService authenticationService;
|
||||
private PermissionService permissionService;
|
||||
|
||||
|
||||
/** Indent Size */
|
||||
private int indentSize = 2;
|
||||
@@ -133,6 +137,15 @@ public class ExporterComponent
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService the permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterService#exportView(java.io.OutputStream, org.alfresco.service.cmr.view.ExporterCrawlerParameters, org.alfresco.service.cmr.view.Exporter)
|
||||
*/
|
||||
@@ -198,7 +211,7 @@ public class ExporterComponent
|
||||
try
|
||||
{
|
||||
XMLWriter writer = new XMLWriter(viewWriter, format);
|
||||
return new ViewXMLExporter(namespaceService, nodeService, dictionaryService, writer);
|
||||
return new ViewXMLExporter(namespaceService, nodeService, dictionaryService, permissionService, writer);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
@@ -319,6 +332,18 @@ public class ExporterComponent
|
||||
}
|
||||
exporter.endAspects(nodeRef);
|
||||
|
||||
// Export node permissions
|
||||
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
|
||||
if (permissions.size() > 0)
|
||||
{
|
||||
exporter.startACL(nodeRef);
|
||||
for (AccessPermission permission : permissions)
|
||||
{
|
||||
exporter.permission(nodeRef, permission);
|
||||
}
|
||||
exporter.endACL(nodeRef);
|
||||
}
|
||||
|
||||
// Export node properties
|
||||
exporter.startProperties(nodeRef);
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
|
||||
@@ -215,6 +216,21 @@ public class ExporterComponentTest extends BaseSpringTest
|
||||
// System.out.println("TestProgress: endAssocs: " + nodeRef);
|
||||
}
|
||||
|
||||
public void startACL(NodeRef nodeRef)
|
||||
{
|
||||
// System.out.println("TestProgress: startACL: " + nodeRef);
|
||||
}
|
||||
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
// System.out.println("TestProgress: permission: " + permission);
|
||||
}
|
||||
|
||||
public void endACL(NodeRef nodeRef)
|
||||
{
|
||||
// System.out.println("TestProgress: endACL: " + nodeRef);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
@@ -129,6 +130,30 @@ import org.alfresco.util.ParameterCheck;
|
||||
exporter.endAspect(nodeRef, aspect);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void startACL(NodeRef nodeRef)
|
||||
{
|
||||
exporter.startACL(nodeRef);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
|
||||
*/
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
exporter.permission(nodeRef, permission);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void endACL(NodeRef nodeRef)
|
||||
{
|
||||
exporter.endACL(nodeRef);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
@@ -28,6 +28,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
import org.alfresco.service.cmr.view.ExporterException;
|
||||
@@ -61,6 +63,12 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
private static final String EXPORTEDDATE_LOCALNAME = "exportDate";
|
||||
private static final String EXPORTERVERSION_LOCALNAME = "exporterVersion";
|
||||
private static final String EXPORTOF_LOCALNAME = "exportOf";
|
||||
private static final String ACL_LOCALNAME = "acl";
|
||||
private static final String ACE_LOCALNAME = "ace";
|
||||
private static final String ACCESS_LOCALNAME = "access";
|
||||
private static final String AUTHORITY_LOCALNAME = "authority";
|
||||
private static final String PERMISSION_LOCALNAME = "permission";
|
||||
private static final String INHERITPERMISSIONS_LOCALNAME = "inherit";
|
||||
private static QName VIEW_QNAME;
|
||||
private static QName VALUES_QNAME;
|
||||
private static QName VALUE_QNAME;
|
||||
@@ -75,12 +83,19 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
private static QName EXPORTEDDATE_QNAME;
|
||||
private static QName EXPORTERVERSION_QNAME;
|
||||
private static QName EXPORTOF_QNAME;
|
||||
private static QName ACL_QNAME;
|
||||
private static QName ACE_QNAME;
|
||||
private static QName ACCESS_QNAME;
|
||||
private static QName AUTHORITY_QNAME;
|
||||
private static QName PERMISSION_QNAME;
|
||||
private static QName INHERITPERMISSIONS_QNAME;
|
||||
private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||
|
||||
// Service dependencies
|
||||
private NamespaceService namespaceService;
|
||||
private NodeService nodeService;
|
||||
private DictionaryService dictionaryService;
|
||||
private PermissionService permissionService;
|
||||
|
||||
// View context
|
||||
private ContentHandler contentHandler;
|
||||
@@ -94,11 +109,13 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
* @param nodeService node service
|
||||
* @param contentHandler content handler
|
||||
*/
|
||||
ViewXMLExporter(NamespaceService namespaceService, NodeService nodeService, DictionaryService dictionaryService, ContentHandler contentHandler)
|
||||
ViewXMLExporter(NamespaceService namespaceService, NodeService nodeService,
|
||||
DictionaryService dictionaryService, PermissionService permissionService, ContentHandler contentHandler)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
this.nodeService = nodeService;
|
||||
this.dictionaryService = dictionaryService;
|
||||
this.permissionService = permissionService;
|
||||
this.contentHandler = contentHandler;
|
||||
|
||||
VIEW_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, namespaceService);
|
||||
@@ -115,6 +132,12 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
EXPORTEDDATE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTEDDATE_LOCALNAME, namespaceService);
|
||||
EXPORTERVERSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTERVERSION_LOCALNAME, namespaceService);
|
||||
EXPORTOF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, namespaceService);
|
||||
ACL_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACL_LOCALNAME, namespaceService);
|
||||
ACE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACE_LOCALNAME, namespaceService);
|
||||
ACCESS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACCESS_LOCALNAME, namespaceService);
|
||||
AUTHORITY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, AUTHORITY_LOCALNAME, namespaceService);
|
||||
PERMISSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PERMISSION_LOCALNAME, namespaceService);
|
||||
INHERITPERMISSIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, INHERITPERMISSIONS_LOCALNAME, namespaceService);
|
||||
}
|
||||
|
||||
|
||||
@@ -299,6 +322,75 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void startACL(NodeRef nodeRef)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attrs = new AttributesImpl();
|
||||
boolean inherit = permissionService.getInheritParentPermissions(nodeRef);
|
||||
if (!inherit)
|
||||
{
|
||||
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_1_0_URI, INHERITPERMISSIONS_LOCALNAME, INHERITPERMISSIONS_QNAME.toPrefixString(), null, "false");
|
||||
}
|
||||
contentHandler.startElement(ACL_QNAME.getNamespaceURI(), ACL_QNAME.getLocalName(), toPrefixString(ACL_QNAME), attrs);
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ExporterException("Failed to process start ACL event - node ref " + nodeRef.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
|
||||
*/
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
try
|
||||
{
|
||||
// output access control entry
|
||||
AttributesImpl attrs = new AttributesImpl();
|
||||
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_1_0_URI, ACCESS_LOCALNAME, ACCESS_QNAME.toPrefixString(), null, permission.getAccessStatus().toString());
|
||||
contentHandler.startElement(ACE_QNAME.getNamespaceURI(), ACE_QNAME.getLocalName(), toPrefixString(ACE_QNAME), attrs);
|
||||
|
||||
// output authority
|
||||
contentHandler.startElement(AUTHORITY_QNAME.getNamespaceURI(), AUTHORITY_QNAME.getLocalName(), toPrefixString(AUTHORITY_QNAME), EMPTY_ATTRIBUTES);
|
||||
String authority = permission.getAuthority();
|
||||
contentHandler.characters(authority.toCharArray(), 0, authority.length());
|
||||
contentHandler.endElement(AUTHORITY_QNAME.getNamespaceURI(), AUTHORITY_QNAME.getLocalName(), toPrefixString(AUTHORITY_QNAME));
|
||||
|
||||
// output permission
|
||||
contentHandler.startElement(PERMISSION_QNAME.getNamespaceURI(), PERMISSION_QNAME.getLocalName(), toPrefixString(PERMISSION_QNAME), EMPTY_ATTRIBUTES);
|
||||
String strPermission = permission.getPermission();
|
||||
contentHandler.characters(strPermission.toCharArray(), 0, strPermission.length());
|
||||
contentHandler.endElement(PERMISSION_QNAME.getNamespaceURI(), PERMISSION_QNAME.getLocalName(), toPrefixString(PERMISSION_QNAME));
|
||||
|
||||
// end access control entry
|
||||
contentHandler.endElement(ACE_QNAME.getNamespaceURI(), ACE_QNAME.getLocalName(), toPrefixString(ACE_QNAME));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ExporterException("Failed to process permission event - node ref " + nodeRef.toString() + "; permission " + permission);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void endACL(NodeRef nodeRef)
|
||||
{
|
||||
try
|
||||
{
|
||||
contentHandler.endElement(ACL_QNAME.getNamespaceURI(), ACL_QNAME.getLocalName(), toPrefixString(ACL_QNAME));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ExporterException("Failed to process end ACL event - node ref " + nodeRef.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
@@ -21,6 +21,7 @@ import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
@@ -95,6 +96,15 @@ public interface Exporter
|
||||
* @param nodeRef
|
||||
*/
|
||||
public void endAspects(NodeRef nodeRef);
|
||||
|
||||
|
||||
public void startACL(NodeRef nodeRef);
|
||||
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission);
|
||||
|
||||
public void endACL(NodeRef nodeRef);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Start export of properties
|
||||
|
@@ -26,6 +26,7 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.Exporter;
|
||||
import org.alfresco.service.cmr.view.ExporterContext;
|
||||
@@ -501,6 +502,27 @@ public final class Export extends Tool
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void startACL(NodeRef nodeRef)
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
|
||||
*/
|
||||
public void permission(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void endACL(NodeRef nodeRef)
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -592,6 +614,7 @@ public final class Export extends Tool
|
||||
public void end()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user