diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
index d1f174fa68..1c7d41af91 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
@@ -21,4 +21,7 @@ audit.rm.enabled=true
#
# Extended permission service cache sizing
#
-cache.writersSharedCache.maxItems=10000
\ No newline at end of file
+cache.writersSharedCache.maxItems=10000
+
+# Global RM admin default pwd
+rm.rmadmin.pwd=rmadmin
\ No newline at end of file
diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml
index 10212b6e9d..e76c17d6c4 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml
@@ -76,5 +76,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java
index 545d846d92..1db2d4fd45 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java
@@ -43,7 +43,7 @@ public class RMv2ModelPatch extends AbstractModuleComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{
/** Logger */
- private static Log logger = LogFactory.getLog(NotificationTemplatePatch.class);
+ private static Log logger = LogFactory.getLog(RMv2ModelPatch.class);
private static long BATCH_SIZE = 100000L;
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2RMAdminUserPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2RMAdminUserPatch.java
new file mode 100644
index 0000000000..30fb517c94
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2RMAdminUserPatch.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.module.org_alfresco_module_rm.patch;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
+import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
+import org.alfresco.repo.module.AbstractModuleComponent;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.security.MutableAuthenticationService;
+import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * RM v2.1: RM admin user patch
+ *
+ * @author Roy Wetherall
+ */
+public class RMv2RMAdminUserPatch extends AbstractModuleComponent implements BeanNameAware
+{
+ /** Logger */
+ private static Log logger = LogFactory.getLog(RMv2RMAdminUserPatch.class);
+
+ private String password = "rmadmin";
+
+ private MutableAuthenticationService authenticationService;
+
+ private PersonService personService;
+
+ private RecordsManagementService recordsManagementService;
+
+ private FilePlanRoleService filePlanRoleService;
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public void setPersonService(PersonService personService)
+ {
+ this.personService = personService;
+ }
+
+ public void setAuthenticationService(MutableAuthenticationService authenticationService)
+ {
+ this.authenticationService = authenticationService;
+ }
+
+ public void setRecordsManagementService(RecordsManagementService recordsManagementService)
+ {
+ this.recordsManagementService = recordsManagementService;
+ }
+
+ public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
+ {
+ this.filePlanRoleService = filePlanRoleService;
+ }
+
+ /**
+ * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
+ */
+ @Override
+ protected void executeInternal() throws Throwable
+ {
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("RM Module RMv2RMAdminUserPatch ...");
+ }
+
+ if (authenticationService.authenticationExists(FilePlanRoleService.RM_ADMIN_USER) == false)
+ {
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug(" ... creating RM Admin user");
+ }
+
+ authenticationService.createAuthentication(FilePlanRoleService.RM_ADMIN_USER, password.toCharArray());
+ Map properties = new HashMap();
+ properties.put(ContentModel.PROP_USERNAME, FilePlanRoleService.RM_ADMIN_USER);
+ personService.createPerson(properties);
+
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug(" ... assigning RM Admin user to file plans");
+ }
+
+ List filePlans = recordsManagementService.getFilePlans();
+ for (NodeRef filePlan : filePlans)
+ {
+ filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, FilePlanRoleService.RM_ADMIN_USER);
+ }
+
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug(" ... RMv2RMAdminUserPatch complete");
+ }
+ }
+
+ }
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java
index afb260d62a..5649abc597 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java
@@ -31,6 +31,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public interface FilePlanRoleService
{
+ /** Default rm admin user */
+ public static final String RM_ADMIN_USER = "rmadmin";
+
/** Default role names */
public static final String ROLE_USER = "User";
public static final String ROLE_POWER_USER = "PowerUser";
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java
index 0336be3606..ad07d9a4af 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java
@@ -332,6 +332,9 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
// Add the creating user to the administration group
String user = AuthenticationUtil.getFullyAuthenticatedUser();
authorityService.addAuthority(role.getRoleGroupName(), user);
+
+ // add the dynamic admin authority
+ authorityService.addAuthority(role.getRoleGroupName(), FilePlanRoleService.RM_ADMIN_USER);
}
}
}
@@ -619,6 +622,11 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
public Role doWork() throws Exception
{
+ if (existsRole(rmRootNode, role) == false)
+ {
+ throw new AlfrescoRuntimeException("Unable to update role " + role + ", because it does not exist.");
+ }
+
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode));
// Reset the role display name
@@ -646,6 +654,12 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
*/
public void deleteRole(final NodeRef rmRootNode, final String role)
{
+ // ensure that we are not trying to delete the admin role
+ if (ROLE_ADMIN.equals(role) == true)
+ {
+ throw new AlfrescoRuntimeException("Can not delete the records management administration role.");
+ }
+
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork