RM-692 (The RM groups are no longer 'public')

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@50465 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-05-29 16:32:06 +00:00
parent 2f8192d5f7
commit af124de682
8 changed files with 1653 additions and 58 deletions

View File

@@ -108,4 +108,17 @@
<property name="filePlanPermissionServiceImpl" ref="filePlanPermissionService"/>
</bean>
<bean id="org_alfresco_module_rm_RMv21RolesPatch"
parent="module.baseComponent"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv21RolesPatch">
<property name="moduleId" value="org_alfresco_module_rm"/>
<property name="name" value="org_alfresco_module_rm_RMv21RolesPatch"/>
<property name="description" value="Add existing roles to the rm zone."/>
<property name="sinceVersion" value="2.1"/>
<property name="appliesFromVersion" value="2.1"/>
<property name="filePlanService" ref="FilePlanService"/>
<property name="filePlanRoleService" ref="FilePlanRoleService"/>
<property name="authorityService" ref="AuthorityService"></property>
</bean>
</beans>

View File

@@ -1479,4 +1479,49 @@
<property name="path" value="alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml" />
</bean>
<bean id="authorityDAO" class="org.alfresco.repo.security.authority.RMAuthorityDAOImpl" init-method="init">
<property name="storeUrl">
<value>${spaces.store}</value>
</property>
<property name="nodeService">
<ref bean="mlAwareNodeService" />
</property>
<property name="searchService">
<ref bean="admSearchService" />
</property>
<property name="namespacePrefixResolver">
<ref bean="namespaceService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="personService">
<ref bean="personService" />
</property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="authorityLookupCache">
<ref bean="authorityLookupCache" />
</property>
<property name="userAuthorityCache">
<ref bean="userToAuthorityCache" />
</property>
<property name="childAuthorityCache">
<ref bean="authorityToChildAuthorityCache" />
</property>
<property name="zoneAuthorityCache">
<ref bean="zoneToAuthorityCache" />
</property>
<property name="policyComponent">
<ref bean="policyComponent"/>
</property>
<property name="cannedQueryRegistry">
<ref bean="cannedQueryRegistry" />
</property>
<property name="aclDAO">
<ref bean="aclDAO" />
</property>
</bean>
</beans>

View File

@@ -6,7 +6,9 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -24,6 +26,7 @@ import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServi
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authority.RMAuthority;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -374,7 +377,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
// Create "all" role group for root node
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName,
"All Roles", null);
"All Roles", new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Put all the role groups in it
Set<Role> roles = filePlanRoleService.getRoles(rmRoot);

View File

@@ -0,0 +1,88 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.repo.module.AbstractModuleComponent;
import org.alfresco.repo.security.authority.RMAuthority;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.springframework.beans.factory.BeanNameAware;
/**
* Adds the existing rm roles to a new zone "APP.RM"
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RMv21RolesPatch extends AbstractModuleComponent implements BeanNameAware
{
private FilePlanService filePlanService;
private FilePlanRoleService filePlanRoleService;
private AuthorityService authorityService;
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
{
this.filePlanRoleService = filePlanRoleService;
}
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
@Override
protected void executeInternal() throws Throwable
{
Set<NodeRef> filePlans = filePlanService.getFilePlans();
for (NodeRef filePlan : filePlans)
{
boolean parentAddedToZone = false;
Set<Role> roles = filePlanRoleService.getRoles(filePlan);
for (Role role : roles)
{
String roleGroupName = role.getRoleGroupName();
addAuthorityToZone(roleGroupName);
if (parentAddedToZone == false)
{
String allRolesGroup = authorityService.getName(AuthorityType.GROUP, "AllRoles" + filePlan.getId());
addAuthorityToZone(allRolesGroup);
parentAddedToZone = true;
}
}
}
}
private void addAuthorityToZone(String roleGroupName)
{
authorityService.addAuthorityToZones(roleGroupName, new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
}
}

View File

@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -39,6 +40,7 @@ import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authority.RMAuthority;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -184,7 +186,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
public NodeRef doWork()
{
// Create "all" role group for root node
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, getAllRolesGroupShortName(rmRootNode), "All Roles", null);
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, getAllRolesGroupShortName(rmRootNode), "All Roles", new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Set the permissions
permissionService.setInheritParentPermissions(rmRootNode, false);
@@ -607,7 +609,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
// Create a group that relates to the records management role
Set<String> zones = new HashSet<String>(2);
zones.add(getZoneName(rmRootNode));
zones.add(AuthorityService.ZONE_APP_DEFAULT);
zones.add(RMAuthority.ZONE_APP_RM);
String roleGroup = authorityService.createAuthority(AuthorityType.GROUP, fullRoleName, roleDisplayLabel, zones);
// Add the roleGroup to the "all" role group

View File

@@ -22,7 +22,9 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -40,6 +42,7 @@ import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServi
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.Role;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authority.RMAuthority;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -261,7 +264,7 @@ public class BootstrapTestDataGet extends DeclarativeWebScript
String allRoles = authorityService.createAuthority(AuthorityType.GROUP,
allRoleShortName,
"All Roles",
null);
new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Put all the role groups in it
Set<Role> roles = recordsManagementSecurityService.getRoles(rmRoot);

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.security.authority;
/**
* Interface for defining constants
*
* @author Tuna Aksoy
* @since 2.1
*/
public interface RMAuthority
{
/**
* The default rm zone.
*/
public static String ZONE_APP_RM = "APP.RM";
}