Fix AR-377 - able to export everything regardless of permissions (run in background = false).

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2260 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-01-31 13:06:04 +00:00
parent 43833a3d46
commit 89abae6099
3 changed files with 89 additions and 41 deletions

View File

@@ -631,17 +631,11 @@
<bean id="importerComponent" class="org.alfresco.repo.importer.ImporterComponent">
<!-- For now, hard-wire the view parser -->
<property name="viewParser">
<ref bean="viewParser" />
</property>
<property name="namespaceService">
<ref bean="namespaceService" />
<ref bean="NamespaceService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="behaviourFilter">
<ref bean="policyBehaviourFilter" />
<ref bean="DictionaryService" />
</property>
<property name="nodeService">
<ref bean="NodeService" />
@@ -653,10 +647,22 @@
<ref bean="ContentService" />
</property>
<property name="ruleService">
<ref bean="ruleService" />
<ref bean="RuleService" />
</property>
<property name="permissionService">
<ref bean="permissionService" />
<ref bean="PermissionService" />
</property>
<property name="authorityService">
<ref bean="AuthorityService" />
</property>
<property name="viewParser">
<ref bean="viewParser" />
</property>
<property name="behaviourFilter">
<ref bean="policyBehaviourFilter" />
</property>
<property name="ownableService">
<ref bean="ownableService" />
</property>
</bean>
@@ -828,28 +834,28 @@
<!-- Exporter -->
<bean id="exporterComponent" class="org.alfresco.repo.exporter.ExporterComponent">
<property name="namespaceService">
<ref bean="namespaceService" />
<ref bean="NamespaceService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
<ref bean="DictionaryService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
<ref bean="NodeService" />
</property>
<property name="searchService">
<ref bean="searchService" />
<ref bean="SearchService" />
</property>
<property name="contentService">
<ref bean="contentService" />
<ref bean="ContentService" />
</property>
<property name="descriptorService">
<ref bean="DescriptorService" />
</property>
<property name="authenticationService">
<ref bean="authenticationService" />
<ref bean="AuthenticationService" />
</property>
<property name="permissionService">
<ref bean="permissionService" />
<ref bean="PermissionService" />
</property>
</bean>

View File

@@ -41,6 +41,7 @@ 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.security.AccessStatus;
import org.alfresco.service.cmr.view.ExportPackageHandler;
import org.alfresco.service.cmr.view.Exporter;
import org.alfresco.service.cmr.view.ExporterContext;
@@ -333,16 +334,20 @@ public class ExporterComponent
exporter.endAspects(nodeRef);
// Export node permissions
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
boolean inheritPermissions = permissionService.getInheritParentPermissions(nodeRef);
if (permissions.size() > 0 || !inheritPermissions)
AccessStatus readPermission = permissionService.hasPermission(nodeRef, PermissionService.READ_PERMISSIONS);
if (readPermission.equals(AccessStatus.ALLOWED))
{
exporter.startACL(nodeRef);
for (AccessPermission permission : permissions)
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
boolean inheritPermissions = permissionService.getInheritParentPermissions(nodeRef);
if (permissions.size() > 0 || !inheritPermissions)
{
exporter.permission(nodeRef, permission);
exporter.startACL(nodeRef);
for (AccessPermission permission : permissions)
{
exporter.permission(nodeRef, permission);
}
exporter.endACL(nodeRef);
}
exporter.endACL(nodeRef);
}
// Export node properties

View File

@@ -53,6 +53,8 @@ import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.view.ImportPackageHandler;
import org.alfresco.service.cmr.view.ImporterBinding;
@@ -92,6 +94,8 @@ public class ImporterComponent
private ContentService contentService;
private RuleService ruleService;
private PermissionService permissionService;
private AuthorityService authorityService;
private OwnableService ownableService;
// binding markers
private static final String START_BINDING_MARKER = "${";
@@ -172,7 +176,23 @@ public class ImporterComponent
this.permissionService = permissionService;
}
/**
* @param authorityService authorityService
*/
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
/**
* @param ownableService ownableService
*/
public void setOwnableService(OwnableService ownableService)
{
this.ownableService = ownableService;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.view.ImporterService#importView(java.io.InputStreamReader, org.alfresco.service.cmr.view.Location, java.util.Properties, org.alfresco.service.cmr.view.ImporterProgress)
*/
@@ -1031,7 +1051,7 @@ public class ImporterComponent
*/
private void reportPropertySet(NodeRef nodeRef, Map<QName, Serializable> properties)
{
if (progress != null)
if (progress != null && properties != null)
{
for (QName property : properties.keySet())
{
@@ -1048,7 +1068,7 @@ public class ImporterComponent
*/
private void reportPermissionSet(NodeRef nodeRef, List<AccessPermission> permissions)
{
if (progress != null)
if (progress != null && permissions != null)
{
for (AccessPermission permission : permissions)
{
@@ -1115,16 +1135,28 @@ public class ImporterComponent
ChildAssociationRef assocRef = nodeService.createNode(parentRef, assocType, childQName, nodeType.getName(), initialProperties);
NodeRef nodeRef = assocRef.getChildRef();
// Apply permissions
boolean inheritPermissions = node.getInheritPermissions();
if (!inheritPermissions)
// Note: non-admin authorities take ownership of new nodes
if (!authorityService.hasAdminAuthority())
{
permissionService.setInheritParentPermissions(nodeRef, false);
ownableService.takeOwnership(nodeRef);
}
List<AccessPermission> permissions = node.getAccessControlEntries();
for (AccessPermission permission : permissions)
// apply permissions
List<AccessPermission> permissions = null;
AccessStatus writePermission = permissionService.hasPermission(nodeRef, PermissionService.CHANGE_PERMISSIONS);
if (writePermission.equals(AccessStatus.ALLOWED))
{
permissionService.setPermission(nodeRef, permission.getAuthority(), permission.getPermission(), permission.getAccessStatus().equals(AccessStatus.ALLOWED));
permissions = node.getAccessControlEntries();
for (AccessPermission permission : permissions)
{
permissionService.setPermission(nodeRef, permission.getAuthority(), permission.getPermission(), permission.getAccessStatus().equals(AccessStatus.ALLOWED));
}
// note: apply inheritance after setting permissions as this may affect whether you can apply permissions
boolean inheritPermissions = node.getInheritPermissions();
if (!inheritPermissions)
{
permissionService.setInheritParentPermissions(nodeRef, false);
}
}
// Disable behaviour for the node until the complete node (and its children have been imported)
@@ -1290,15 +1322,20 @@ public class ImporterComponent
}
// Apply permissions
boolean inheritPermissions = node.getInheritPermissions();
if (!inheritPermissions)
List<AccessPermission> permissions = null;
AccessStatus writePermission = permissionService.hasPermission(existingNodeRef, PermissionService.CHANGE_PERMISSIONS);
if (writePermission.equals(AccessStatus.ALLOWED))
{
permissionService.setInheritParentPermissions(existingNodeRef, false);
}
List<AccessPermission> permissions = node.getAccessControlEntries();
for (AccessPermission permission : permissions)
{
permissionService.setPermission(existingNodeRef, permission.getAuthority(), permission.getPermission(), permission.getAccessStatus().equals(AccessStatus.ALLOWED));
boolean inheritPermissions = node.getInheritPermissions();
if (!inheritPermissions)
{
permissionService.setInheritParentPermissions(existingNodeRef, false);
}
permissions = node.getAccessControlEntries();
for (AccessPermission permission : permissions)
{
permissionService.setPermission(existingNodeRef, permission.getAuthority(), permission.getPermission(), permission.getAccessStatus().equals(AccessStatus.ALLOWED));
}
}
// report update