From af45c9f93e23a582ef6a7c131cfae087b2a736d1 Mon Sep 17 00:00:00 2001 From: Alexandru Balan Date: Thu, 19 Feb 2015 07:58:30 +0000 Subject: [PATCH 01/15] RM-1932 Changed the notification frequency based on 2.3 code changes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@97445 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../model/rma/aspect/DispositionLifecycleAspect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java index b3e923051f..fce16e9a4b 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/DispositionLifecycleAspect.java @@ -77,7 +77,7 @@ public class DispositionLifecycleAspect extends BaseBehaviourBean @Behaviour ( kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.FIRST_EVENT + notificationFrequency = NotificationFrequency.EVERY_EVENT ) public void onAddAspect(final NodeRef nodeRef, final QName aspect) { From 16d55f9ee7f949d704989055efc329746533ecd6 Mon Sep 17 00:00:00 2001 From: Alexandru Balan Date: Fri, 20 Feb 2015 08:08:42 +0000 Subject: [PATCH 02/15] RM-1586 - server-side fix for legacy custom property names that might contain spaces git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@97533 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../script/CustomPropertyDefinitionPut.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java index 5e38684cd4..25722e80a8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java @@ -34,6 +34,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; import org.springframework.extensions.surf.util.ParameterCheck; +import org.springframework.extensions.surf.util.URLEncoder; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; @@ -133,7 +134,7 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript String propId = (String)params.get(PROP_ID); ParameterCheck.mandatoryString("propId", propId); - QName propQName = rmAdminService.getQNameForClientId(propId); + QName propQName = rmAdminService.getQNameForClientId(URLEncoder.encode(propId)); if (propQName == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, From db6cfb18daacfdacac6608c15263e4f1dd03ac4a Mon Sep 17 00:00:00 2001 From: Gloria Broadbent Date: Fri, 6 Mar 2015 10:49:48 +0000 Subject: [PATCH 03/15] SPANISH: Updated bundle for RM 2.2.1 based on EN-rev98763 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@98840 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../messages/admin-service_es.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties index 030b067435..7f63a1946a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/admin-service_es.properties @@ -13,9 +13,9 @@ rm.admin.child-assoc-exists=La asociaci\u00f3n secundaria ''{0}'' ya existe. rm.admin.cannot-find-assoc-def=No se puede encontrar la definici\u00f3n de asociaci\u00f3n ''{0}''. rm.admin.constraint-exists=La restricci\u00f3n ''{0}'' ya existe. rm.admin.contraint-cannot-find=No se puede encontrar la definici\u00f3n para la restricci\u00f3n ''{0}''. -rm.admin.unexpected_type_constraint=Tipo ineseperado ''{0}'' para la restricci\u00f3n ''{1}''. The expected is ''{2}''. +rm.admin.unexpected_type_constraint=Tipo inesperado ''{0}'' para la restricci\u00f3n ''{1}''. Lo esperado es ''{2}''. rm.admin.custom-model-not-found=No se puede encontrar el modelo personalizado ''{0}''. -rm.admin.custom-model-no-content=El modelo personalizado no t (nodeRef={0}) +rm.admin.custom-model-no-content=El modelo personalizado no tiene contenido (nodeRef={0}) rm.admin.error-write-custom-model=Error al escribir contenido de modelo personalizado. (nodeRef={0}) rm.admin.error-client-id=Error al generar el identificador del cliente porque ya est\u00e1 en uso. (clientid={0}) rm.admin.error-split-id=No se puede separar el identificador ''{0}'', porque el separador ''{1}'' no est\u00e1 presente. \ No newline at end of file From 541880b226aa9abebed85c818d9f4efec88c01c2 Mon Sep 17 00:00:00 2001 From: Gloria Broadbent Date: Fri, 6 Mar 2015 10:53:09 +0000 Subject: [PATCH 04/15] RUSSIAN: Updated bundle for RM 2.2.1 based on EN-rev98763 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@98845 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org_alfresco_module_rm/messages/records-model_ru.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties index 02bf8b0709..9a323e705d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties @@ -106,6 +106,7 @@ rma_recordsmanagement.property.rma_eventExecutionCompletedAt.decription=\u0414\u rma_recordsmanagement.type.rma_hold.title=\u0411\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0430 rma_recordsmanagement.type.rma_hold.decription=\u0411\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0430 +rma_recordsmanagement.property.rma_holdReason.title=\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 rma_recordsmanagement.property.rma_holdReason.decription=\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 rma_recordsmanagement.association.rma_frozenRecords.title=\u0417\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 rma_recordsmanagement.association.rma_frozenRecords.decription=\u0417\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 From 769ad9ad765cdaa205edb92a43311a0b26132cbf Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Mon, 9 Mar 2015 21:50:25 +0000 Subject: [PATCH 05/15] Merged V2.3 to V2.2 : 93334: RM-1822 (Non-system-admin user not allowed to read inheritable permissions) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99084 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-permissions.get.desc.xml | 9 ++++ .../documentlibrary/rm-permissions.get.js | 42 +++++++++++++++++++ .../rm-permissions.get.json.ftl | 1 + 3 files changed, 52 insertions(+) create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.desc.xml create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.js create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.json.ftl diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.desc.xml new file mode 100644 index 0000000000..c7d8a558de --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.desc.xml @@ -0,0 +1,9 @@ + + permissions + Document List Component - permissions data webscript + /slingshot/doclib/rm/permissions/{store_type}/{store_id}/{id} + argument + user + required + internal + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.js new file mode 100644 index 0000000000..815c3c7282 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.js @@ -0,0 +1,42 @@ + + +function getRmPermissions() +{ + /** + * nodeRef input: store_type, store_id and id + */ + var storeType = url.templateArgs.store_type, + storeId = url.templateArgs.store_id, + id = url.templateArgs.id, + nodeRef = storeType + "://" + storeId + "/" + id, + node = ParseArgs.resolveNode(nodeRef); + + if (node == null) + { + node = search.findNode(nodeRef); + if (node === null) + { + status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); + return null; + } + } + + var permissionData = model.data, + settable = node.getSettablePermissions(), + canReadInherited = true; + + if (node.parent.hasPermission("ReadRecords")) + { + permissionData["inherited"] = parsePermissions(node.parent.getPermissions(), settable); + } + else + { + canReadInherited = false; + } + + permissionData["canReadInherited"] = canReadInherited; + + model.data = permissionData; +} + +getRmPermissions(); \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.json.ftl new file mode 100644 index 0000000000..ba9755faf0 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/rm-permissions.get.json.ftl @@ -0,0 +1 @@ +<#include "permissions.get.json.ftl"> \ No newline at end of file From 1931466253e48103c987b0b07c1b3676bdd4331b Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Mon, 9 Mar 2015 21:53:53 +0000 Subject: [PATCH 06/15] Merged V2.3 to V2.2: 92881: RM-1799 (Root category is not displayed for the non-rm-admin user who created it) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99085 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../FilePlanPermissionServiceImpl.java | 23 +++++ .../integration/issue/IssueTestSuite.java | 3 +- .../test/integration/issue/RM1799Test.java | 93 +++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java index 82e9388d28..93310d7c41 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java @@ -43,6 +43,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; 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.AuthorityType; import org.alfresco.service.cmr.security.OwnableService; @@ -294,6 +295,28 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl // remove owner getOwnableService().setOwner(nodeRef, NO_OWNER); + if (isParentNodeFilePlan) + { + Set perms = permissionService.getAllSetPermissions(parent); + for (AccessPermission perm : perms) + { + if (RMPermissionModel.FILING.equals(perm.getPermission())) + { + AccessStatus accessStatus = perm.getAccessStatus(); + boolean allow = false; + if (AccessStatus.ALLOWED.equals(accessStatus)) + { + allow = true; + } + permissionService.setPermission( + nodeRef, + perm.getAuthority(), + perm.getPermission(), + allow); + } + } + } + return null; } }); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java index ba0d7003ee..2c11e9689e 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java @@ -41,7 +41,8 @@ import org.junit.runners.Suite.SuiteClasses; RM452Test.class, RM804Test.class, RM994Test.class, - RM1039Test.class + RM1039Test.class, + RM1799Test.class }) public class IssueTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java new file mode 100644 index 0000000000..5a1253ade4 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1799Test.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2005-2015 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.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AccessStatus; +import org.alfresco.util.GUID; + +/** + * Test for RM-1799 + * + * @author Tuna Aksoy + * @since 2.3 + */ +public class RM1799Test extends BaseRMTestCase +{ + private String myUser; + private NodeRef category; + + @Override + protected boolean isRecordTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupTestUsersImpl(NodeRef filePlan) + { + super.setupTestUsersImpl(filePlan); + + myUser = GUID.generate(); + createPerson(myUser); + filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser); + } + + public void testRM1799() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + filePlanPermissionService.setPermission(filePlan, myUser, RMPermissionModel.FILING); + return null; + } + }, ADMIN_USER); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + category = filePlanService.createRecordCategory(filePlan, GUID.generate()); + return null; + } + }, myUser); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(category, RMPermissionModel.FILING)); + return null; + } + }, myUser); + } +} From 62d442060d2872fce818bc2a988acb7f02683b33 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Mon, 9 Mar 2015 21:57:32 +0000 Subject: [PATCH 07/15] Merged V2.3 to V2.2: 96580: RM-1904 (SubCategory moved to root have inheritance on) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99086 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../FilePlanPermissionServiceImpl.java | 19 ++++++++++++++++- .../FilePlanPermissionServiceImplTest.java | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java index 93310d7c41..3832853292 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java @@ -62,7 +62,8 @@ import org.apache.commons.logging.LogFactory; @BehaviourBean public class FilePlanPermissionServiceImpl extends ServiceBaseImpl implements FilePlanPermissionService, - RMPermissionModel + RMPermissionModel, + NodeServicePolicies.OnMoveNodePolicy { /** Permission service */ private PermissionService permissionService; @@ -92,6 +93,10 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl NodeServicePolicies.OnMoveNodePolicy.QNAME, ASPECT_RECORD, new JavaBehaviour(this, "onMoveRecord", TRANSACTION_COMMIT)); + getPolicyComponent().bindClassBehaviour( + NodeServicePolicies.OnMoveNodePolicy.QNAME, + TYPE_RECORD_CATEGORY, + new JavaBehaviour(this, "onMoveNode", TRANSACTION_COMMIT)); } /** @@ -489,4 +494,16 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { return isFilePlanContainer(nodeRef) || isRecordFolder(nodeRef) || isRecord(nodeRef); } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + if (isFilePlan(newChildAssocRef.getParentRef())) + { + permissionService.setInheritParentPermissions(oldChildAssocRef.getChildRef(), false); + } + } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java index 7929c67cca..eea15bc001 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/FilePlanPermissionServiceImplTest.java @@ -1240,4 +1240,25 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase assertTrue(accessPermissions.containsKey(adminRole)); assertEquals(RMPermissionModel.FILING, accessPermissions.get(adminRole)); } + + public void testMoveSubCategoryIntoFilePlan() + { + final NodeRef rootCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); + final NodeRef subCategory = filePlanService.createRecordCategory(rootCategory, GUID.generate()); + + assertFalse(permissionService.getInheritParentPermissions(rootCategory)); + assertTrue(permissionService.getInheritParentPermissions(subCategory)); + + final NodeRef movedSubCategory = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + return fileFolderService.move(subCategory, filePlan, null).getNodeRef(); + } + }); + + assertFalse(permissionService.getInheritParentPermissions(rootCategory)); + assertFalse(permissionService.getInheritParentPermissions(movedSubCategory)); + } } From e5a8426a0f4501fbf920660986ee0754a7133cdf Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 10 Mar 2015 03:09:44 +0000 Subject: [PATCH 08/15] Upgrade Alfresco version to 4.2.4.6 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99087 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b6465d826..76f272a5d0 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ - 4.2.3.1 + 4.2.4.6 org.postgresql.Driver From 79e31a391ac627deb145328d8dcd460e5fd8b247 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 10 Mar 2015 03:10:49 +0000 Subject: [PATCH 09/15] RM-2026: Unable to complete historical records when mandatory meta-data missing git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99088 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco-global.properties | 5 + .../rm-action-context.xml | 3 +- .../action/impl/DeclareRecordAction.java | 14 +- .../dod/RM1194ExcludeDoDRecordTypesTest.java | 2 +- .../record/CompleteRecordTest.java | 233 ++++++++++++++++++ .../integration/record/RecordTestSuite.java | 3 +- .../legacy/service/RecordServiceImplTest.java | 2 +- rm-server/test/resources/test-context.xml | 9 +- rm-server/test/resources/test-model.xml | 9 + 9 files changed, 274 insertions(+), 6 deletions(-) create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java 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 60f0b0e0d6..1270de1af6 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 @@ -47,3 +47,8 @@ rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes=rma:record,cm:c # Global RM disposition lifecycle trigger cron job expression # rm.dispositionlifecycletrigger.cronexpression=0 0/5 * * * ? + +# +# Indicates whether mandatory properties are checked before completing a record +# +rm.completerecord.mandatorypropertiescheck.enabled=true diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index f8db542201..0c2cddd8ee 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -265,7 +265,7 @@ - + @@ -384,6 +384,7 @@ + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java index fc7eb74eb3..82369c4613 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java @@ -54,6 +54,17 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase /** Logger */ private static Log logger = LogFactory.getLog(DeclareRecordAction.class); + + /** check mandatory properties */ + private boolean checkMandatoryPropertiesEnabled = true; + + /** + * @param checkMandatoryPropertiesEnabled true if check mandatory properties is enabled, false otherwise + */ + public void setCheckMandatoryPropertiesEnabled(boolean checkMandatoryPropertiesEnabled) + { + this.checkMandatoryPropertiesEnabled = checkMandatoryPropertiesEnabled; + } /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) @@ -69,7 +80,8 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase { List missingProperties = new ArrayList(5); // Aspect not already defined - check mandatory properties then add - if (mandatoryPropertiesSet(actionedUponNodeRef, missingProperties)) + if (!checkMandatoryPropertiesEnabled || + mandatoryPropertiesSet(actionedUponNodeRef, missingProperties)) { recordService.disablePropertyEditableCheck(); try diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java index 5019fc9114..f44d4bb753 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java @@ -108,7 +108,7 @@ public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements D assertNotNull(record); Set aspects = recordService.getRecordMetadataAspects(record); assertNotNull(aspects); - assertEquals(1, aspects.size()); + assertEquals(2, aspects.size()); } }); } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java new file mode 100644 index 0000000000..c86a12e277 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2005-2014 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.test.integration.record; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult; +import org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * Complete record tests. + * + * @author Roy Wetherall + * @since 2.2.1 + */ +public class CompleteRecordTest extends BaseRMTestCase +{ + private static final QName ASPECT_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "recordMetaDataWithProperty"); + private static final QName PROP_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customMandatoryProperty"); + + /** complete record action */ + private DeclareRecordAction action; + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() + */ + @Override + protected void initServices() + { + super.initServices(); + + // get the action + action = (DeclareRecordAction)applicationContext.getBean("declareRecord"); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl() + */ + @Override + protected void tearDownImpl() + { + super.tearDownImpl(); + + // ensure action is returned to original state + action.setCheckMandatoryPropertiesEnabled(true); + } + + /** + * Given the the application is configured to check for mandatory values before complete + * And a filed record is missing mandatory values + * When I try to complete the record + * Then the missing properties parameter of the action will be populated + * And the record will not be complete + */ + public void testCheckForMandatoryValuesMissing() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(true); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + nodeService.addAspect(record, ASPECT_TEST, null); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNotNull(result.getValue()); + assertFalse(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured to check for mandatory values before complete + * And a filed record has all mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testCheckForMandatoryValuePresent() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(true); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + Map properties = new HashMap(1); + properties.put(PROP_TEST, "something"); + nodeService.addAspect(record, ASPECT_TEST, properties); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured not to check for mandatory values before complete + * And a filed record is missing mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testDontCheckForMandatoryValuesMissing() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // disable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(false); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + nodeService.addAspect(record, ASPECT_TEST, null); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } + + /** + * Given the the application is configured to not to check for mandatory values before complete + * And a filed record has all mandatory values + * When I try to complete the record + * Then the record is completed + */ + public void testDontCheckForMandatoryValuePresent() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + private NodeRef record; + private RecordsManagementActionResult result; + + public void given() + { + // enable mandatory parameter check + action.setCheckMandatoryPropertiesEnabled(false); + + // create a record + record = utils.createRecord(rmFolder, "record.txt", "title"); + + // add the record aspect (that has a mandatory property) + Map properties = new HashMap(1); + properties.put(PROP_TEST, "something"); + nodeService.addAspect(record, ASPECT_TEST, properties); + } + + public void when() + { + // complete record + result = rmActionService.executeRecordsManagementAction(record, "declareRecord"); + } + + public void then() + { + assertNotNull(result); + assertNull(result.getValue()); + assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + }); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java index 6e7e7d97c8..241cdc7bd6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java @@ -33,7 +33,8 @@ import org.junit.runners.Suite.SuiteClasses; { RejectRecordTest.class, CreateRecordTest.class, - MoveRecordTest.class + MoveRecordTest.class, + CompleteRecordTest.class }) public class RecordTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java index 14f5ffa379..aac8a820f7 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java @@ -95,7 +95,7 @@ public class RecordServiceImplTest extends BaseRMTestCase { Set aspects = recordService.getRecordMetadataAspects(filePlan); assertNotNull(aspects); - assertEquals(1, aspects.size()); + assertEquals(2, aspects.size()); assertTrue(aspects.containsAll(getAspectList())); return null; diff --git a/rm-server/test/resources/test-context.xml b/rm-server/test/resources/test-context.xml index 525e861629..a5396c0b50 100644 --- a/rm-server/test/resources/test-context.xml +++ b/rm-server/test/resources/test-context.xml @@ -232,5 +232,12 @@ - + + + + + + + + \ No newline at end of file diff --git a/rm-server/test/resources/test-model.xml b/rm-server/test/resources/test-model.xml index 6007fd32ae..c35643dd3b 100644 --- a/rm-server/test/resources/test-model.xml +++ b/rm-server/test/resources/test-model.xml @@ -49,6 +49,15 @@ + + + + + d:text + true + + + From 4978949842605abf33f3ff3559aeb037aa9b2067 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 10 Mar 2015 04:32:04 +0000 Subject: [PATCH 10/15] Merged HEAD to V2.2: 89735: RM-1677- No items error for RM Admin if record was declared from moderated/private site * fixes RM-2018 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99089 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../jscript/app/JSONConversionComponent.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 186409450f..82b94f8fd0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -294,7 +294,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC if (originatingLocation != null) { String pathSeparator = "/"; - String displayPath = PathUtil.getDisplayPath(nodeService.getPath(originatingLocation), true); + String displayPath = getDisplayPath(originatingLocation); String[] displayPathElements = displayPath.split(pathSeparator); Object[] subPath = ArrayUtils.subarray(displayPathElements, 5, displayPathElements.length); StringBuffer originatingLocationPath = new StringBuffer(); @@ -305,6 +305,23 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC rootJSONObject.put("originatingLocationPath", originatingLocationPath.toString()); } } + + /** + * Helper method to get the display path. + * + * @param nodeRef node reference + * @return String display path + */ + private String getDisplayPath(final NodeRef nodeRef) + { + return AuthenticationUtil.runAs(new RunAsWork() + { + public String doWork() throws Exception + { + return PathUtil.getDisplayPath(nodeService.getPath(nodeRef), true); + } + }, AuthenticationUtil.getAdminUserName()); + } /** * @param nodeRef From 40eb6387110842f0db78b2b76dd5634c979bbd26 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 12 Mar 2015 23:14:33 +0000 Subject: [PATCH 11/15] Merged V2.3 to V2.1.1: 96823: RM-1903 (Can't manage permissions without "Manage Access Controls" capability) 97435: RM-1903: Can't manage permissions without "Manage Access Controls" capability 97436: RM-1903 - updates to unit tests 97595: RM-1903 (Can't manage permissions without "Manage Access Controls" capability) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99374 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-capabilities-security-context.xml | 2 + .../messages/capability-service.properties | 4 +- .../rm-service-context.xml | 4 +- .../security/rm-method-security.properties | 10 ++-- .../capability/policy/CapabilityPolicy.java | 46 ------------------- .../webscript/RmAuthoritiesRestApiTest.java | 2 +- 6 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CapabilityPolicy.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml index 2e21669949..60ca183ea8 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-security-context.xml @@ -5,6 +5,7 @@ + @@ -21,6 +22,7 @@ + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties index 39dba8ecf9..a68671673c 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/capability-service.properties @@ -84,8 +84,8 @@ capability.CreateModifyDestroyRoles.title=Create Modify Destroy Roles capability.CreateModifyDestroyUsersAndGroups.title=Create Modify Destroy Users and Groups capability.PasswordControl.title=Password Control capability.DisplayRightsReport.title=Display Rights Report -capability.ManageAccessControls.title=Manage Access Controls -capability.ManageAccessRights.title=Manage Access Rights +capability.ManageAccessControls.title=Group and User Role Assignment +capability.ManageAccessRights.title=Manage Permissions # Configuration capability.group.config.title=Configuration diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml index 4e1382c967..6de002f343 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml @@ -551,8 +551,8 @@ org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getUsersAssignedToRole=RM.Read.0 org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getGroupsAssignedToRole=RM.Read.0 org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getAllAssignedToRole=RM.Read.0 - org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.assignRoleToAuthority=RM_CAP.0.rma:filePlanComponent.CreateModifyDestroyUsersAndGroups - org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.unassignRoleFromAuthority=RM_CAP.0.rma:filePlanComponent.CreateModifyDestroyUsersAndGroups + org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.assignRoleToAuthority=RM_CAP.0.rma:filePlanComponent.ManageAccessControls + org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.unassignRoleFromAuthority=RM_CAP.0.rma:filePlanComponent.ManageAccessControls org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getAllRolesContainerGroup=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.*=RM_DENY ]]> diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties index d282d207e2..928fb0ae67 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties @@ -173,12 +173,12 @@ rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getPermiss rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.hasPermission=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermission=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=RM.Capability.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=RM_CAP.0.rma:filePlanComponent.ManageAccessRights rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM.Capability.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM_CAP.0.rma:filePlanComponent.ManageAccessRights rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.*=RM_DENY ## Site service diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CapabilityPolicy.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CapabilityPolicy.java deleted file mode 100644 index 6f60fd7f67..0000000000 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/policy/CapabilityPolicy.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005-2014 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.capability.policy; - -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.aopalliance.intercept.MethodInvocation; - -/** - * - * @author Roy Wetherall - * @since 2.1 - */ -public class CapabilityPolicy extends AbstractBasePolicy -{ - /** - * @see org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy#evaluate(org.aopalliance.intercept.MethodInvocation, java.lang.Class[], org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition) - */ - @Override - @SuppressWarnings("rawtypes") - public int evaluate( - MethodInvocation invocation, - Class[] params, - ConfigAttributeDefinition cad) - { - NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent()); - return getCapabilityService().getCapability(RMPermissionModel.MANAGE_ACCESS_CONTROLS).evaluate(testNodeRef); - } - -} \ No newline at end of file diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java index cbfeb3ae1e..64c4b968f5 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/webscript/RmAuthoritiesRestApiTest.java @@ -81,7 +81,7 @@ public class RmAuthoritiesRestApiTest extends BaseRMWebScriptTestCase // Create test role Set capabilities = new HashSet(2); capabilities.add(capabilityService.getCapability(RMPermissionModel.VIEW_RECORDS)); - capabilities.add(capabilityService.getCapability(RMPermissionModel.CREATE_MODIFY_DESTROY_USERS_AND_GROUPS)); + capabilities.add(capabilityService.getCapability(RMPermissionModel.MANAGE_ACCESS_CONTROLS)); filePlanRoleService.createRole(filePlan, ROLE_INCLUDING_CAPABILITY, ROLE_INCLUDING_CAPABILITY, capabilities); // Add user to the role filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_INCLUDING_CAPABILITY, USER_WITH_CAPABILITY); From 0161f18ec603c9812d2a78e1289025e72b181fa8 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Sun, 15 Mar 2015 23:48:58 +0000 Subject: [PATCH 12/15] RM-2058: RM Manager can't access Users and Groups (after upgarde) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@99471 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/rm-default-roles-bootstrap.json | 7 +- .../patch/v22/RMv22CapabilityPatch.java | 8 +- .../patch/v22/RMv22HoldCapabilityPatch.java | 2 +- .../v22/RMv22CapabilityPatchUnitTest.java | 124 ++++++++++++++++++ .../test/AllUnitTestSuite.java | 4 +- 5 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json index 486c1fd0ba..faaeb7c1a2 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json @@ -73,7 +73,8 @@ "RequestRecordInformation", "FileUnfiledRecords", "RejectRecords", - "LinkToRecords" + "LinkToRecords", + "ManageAccessControls" ] }, { @@ -124,7 +125,6 @@ "DeleteRecords", "TriggerAnEvent", "CreateModifyDestroyRoles", - "CreateModifyDestroyUsersAndGroups", "PasswordControl", "EnableDisableAuditByTypes", "SelectAuditMetadata", @@ -143,7 +143,8 @@ "RemoveFromHold", "FileHoldReport", "DeleteHold", - "EditHold" + "EditHold", + "ManageAccessControls" ] }, { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java index 824a06098e..1226edf1ee 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatch.java @@ -35,7 +35,7 @@ public class RMv22CapabilityPatch extends CapabilityPatch */ protected void applyCapabilityPatch(NodeRef filePlan) { - // add new capability + // add new capbilities addCapability(filePlan, "FileDestructionReport", FilePlanRoleService.ROLE_ADMIN, @@ -52,5 +52,11 @@ public class RMv22CapabilityPatch extends CapabilityPatch "RemoveFromHold", FilePlanRoleService.ROLE_ADMIN, FilePlanRoleService.ROLE_RECORDS_MANAGER); + + // @see https://issues.alfresco.com/jira/browse/RM-2058 + addCapability(filePlan, + "ManageAccessControls", + FilePlanRoleService.ROLE_SECURITY_OFFICER, + FilePlanRoleService.ROLE_RECORDS_MANAGER); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java index c0582e0f26..a3967cc1c5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22HoldCapabilityPatch.java @@ -23,7 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.service.cmr.repository.NodeRef; /** - * RM v2.2 patch to add new hold releated capabilities. + * RM v2.2 patch to update capabilities. * * @author Roy Wetherall * @since 2.2 diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java new file mode 100644 index 0000000000..aa080f0977 --- /dev/null +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/patch/v22/RMv22CapabilityPatchUnitTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2005-2014 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.v22; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Collections; + +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; +import org.alfresco.service.cmr.security.AuthorityType; +import org.junit.Test; +import org.mockito.InjectMocks; + +/** + * Unit test for RMv22CapabilityPatch + * + * @author Roy Wetherall + */ +public class RMv22CapabilityPatchUnitTest extends BaseUnitTest +{ + /** patch */ + private @InjectMocks RMv22CapabilityPatch patch; + + /** + * Given that I am upgrading an existing repository to v2.2 + * When I execute the patch + * Then the capabilities are updated + */ + @Test + public void executePatch() + { + when(mockedFilePlanService.getFilePlans()) + .thenReturn(Collections.singleton(filePlan)); + when(mockedAuthorityService.getName(eq(AuthorityType.GROUP), anyString())) + .thenReturn( + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_ADMIN, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + FilePlanRoleService.ROLE_SECURITY_OFFICER, + FilePlanRoleService.ROLE_RECORDS_MANAGER); + + // execute patch + patch.applyInternal(); + + // verify that the correct capabilities have been added + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "FileDestructionReport", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "FileDestructionReport", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "CreateHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "CreateHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "AddToHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "AddToHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_ADMIN, + "RemoveFromHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "RemoveFromHold", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_RECORDS_MANAGER, + "ManageAccessControls", + true); + verify(mockedPermissionService, times(1)).setPermission( + filePlan, + FilePlanRoleService.ROLE_SECURITY_OFFICER, + "ManageAccessControls", + true); + } + +} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java index c034f95cdb..de7b7120b9 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/AllUnitTestSuite.java @@ -26,6 +26,7 @@ import org.alfresco.module.org_alfresco_module_rm.job.DispositionLifecycleJobExe import org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator.FrozenEvaluatorUnitTest; import org.alfresco.module.org_alfresco_module_rm.jscript.app.evaluator.TransferEvaluatorUnitTest; import org.alfresco.module.org_alfresco_module_rm.model.compatibility.DictionaryBootstrapPostProcessorUnitTest; +import org.alfresco.module.org_alfresco_module_rm.patch.v22.RMv22CapabilityPatchUnitTest; import org.alfresco.module.org_alfresco_module_rm.patch.v22.RMv22RemoveInPlaceRolesFromAllPatchUnitTest; import org.alfresco.module.org_alfresco_module_rm.record.RecordMetadataBootstrapUnitTest; import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImplUnitTest; @@ -75,7 +76,8 @@ import org.junit.runners.Suite.SuiteClasses; FileReportActionUnitTest.class, // patches - RMv22RemoveInPlaceRolesFromAllPatchUnitTest.class + RMv22RemoveInPlaceRolesFromAllPatchUnitTest.class, + RMv22CapabilityPatchUnitTest.class }) public class AllUnitTestSuite { From 7bb27bbf7a6fa3f4ca260f3f3dc4a8a278024a34 Mon Sep 17 00:00:00 2001 From: Alexandru Balan Date: Mon, 30 Mar 2015 15:14:49 +0000 Subject: [PATCH 13/15] RM-1586 : Add another search for the property in the case of legacy html encoded properties git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@100725 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../script/CustomPropertyDefinitionPut.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java index 25722e80a8..1199ab8575 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java @@ -134,7 +134,11 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript String propId = (String)params.get(PROP_ID); ParameterCheck.mandatoryString("propId", propId); - QName propQName = rmAdminService.getQNameForClientId(URLEncoder.encode(propId)); + QName propQName = rmAdminService.getQNameForClientId(propId); + if (propQName == null) + { + propQName = rmAdminService.getQNameForClientId(URLEncoder.encode(propId)); + } if (propQName == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, From 4f4bd07440416f8daffcf1dc4ae659d9718a83df Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 7 Apr 2015 10:16:15 +0000 Subject: [PATCH 14/15] RM-193 (Roles are displayed incorrectly in User Rights Report) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@101230 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org_alfresco_module_rm/script/UserRightsReportGet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java index 694bd4448e..88ca563b53 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java @@ -133,7 +133,7 @@ public class UserRightsReportGet extends DeclarativeWebScript // get the users for the current RM role String group = role.getRoleGroupName(); - Set users = filePlanRoleService.getUsersAssignedToRole(filePlanNode, roleName); + Set users = authorityService.getContainedAuthorities(AuthorityType.USER, group, false); roleModel.setUsers(users); // setup a user model object for each user From 227ef9357393b5a849afe8712b055387a0a42e97 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 29 Apr 2015 08:35:10 +0000 Subject: [PATCH 15/15] Merged BRANCHES/V2.2.1.x to BRANCHES/V2.2: 102241: RM-2072 (Concurrency exceptions and deadlocks on Records Management "File to" rule) 102242: RM-1100 (Uncaught LockAcquisitionException in RM 2.0.4) 102267: RM-2072 (Concurrency exceptions and deadlocks on Records Management "File to" rule) 102269: RM-2072 (Concurrency exceptions and deadlocks on Records Management "File to" rule) 102279: RM-2072 (Concurrency exceptions and deadlocks on Records Management "File to" rule) 102486: RM-2072: Concurrency exceptions and deadlocks on Records Management "File to" rule 102636: RM-2191 ("Create Category" and "Manage Permissions" buttons are enabled for user with read-only permissions) 102675: RM-2190 (Concurrency exception when upload document to several folders with rules configured to file records) 102687: RM-2192 (User has no access to the recorded document after it was filed) 102698: Removed warnings 102699: .ant-targets-build.xml files added to svn:ignore 102700: .ant-targets-build.xml files added to svn:ignore 102701: RM-2190 (Concurrency exception when upload document to several folders with rules configured to file records) 102756: RM-2192 (User has no access to the recorded document after it was filed) 102762: Commented out intermittently failing test 102795: (RECORD ONLY) Deploy RM 2.2.1.1 on Maven Repository 102807: (RECORD ONLY) Changed the artifact version to 2.2.1.2-SNAPSHOT git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2@103037 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-action-context.xml | 1 + .../action/dm/CreateRecordAction.java | 7 +- .../impl/CopyMoveLinkFileToBaseAction.java | 118 ++++++---- .../job/RecordsManagementJob.java | 17 +- .../jscript/app/JSONConversionComponent.java | 52 +++-- .../rma/aspect/ExtendedSecurityAspect.java | 47 +--- .../record/RecordServiceImpl.java | 29 ++- .../recordfolder/RecordFolderServiceImpl.java | 12 +- .../role/FilePlanRoleServiceImpl.java | 10 +- .../security/ExtendedSecurityServiceImpl.java | 86 +++----- .../integration/issue/IssueTestSuite.java | 4 +- .../test/integration/issue/RM2072Test.java | 182 ++++++++++++++++ .../test/integration/issue/RM2190Test.java | 201 ++++++++++++++++++ .../test/integration/issue/RM2192Test.java | 156 ++++++++++++++ .../test/legacy/action/FileToActionTest.java | 38 +++- .../ExtendedSecurityServiceImplTest.java | 20 -- .../legacy/service/RecordServiceImplTest.java | 46 +--- 17 files changed, 781 insertions(+), 245 deletions(-) create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2190Test.java create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2192Test.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index 0c2cddd8ee..e70406b839 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -759,6 +759,7 @@ + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java index f8174a1059..e7d091eea5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java @@ -211,8 +211,11 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase hideRecord = hideRecordValue.booleanValue(); } - // create record from existing document - recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord); + synchronized (this) + { + // create record from existing document + recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord); + } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java index 55fb6adf81..1c1325b416 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java @@ -11,16 +11,18 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.action.ParameterDefinitionImpl; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.dao.ConcurrencyFailureException; import org.springframework.util.StringUtils; /** @@ -33,6 +35,9 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr { private static Log logger = LogFactory.getLog(CopyMoveLinkFileToBaseAction.class); + /** Retrying transaction helper */ + private RetryingTransactionHelper retryingTransactionHelper; + /** action parameters */ public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder"; public static final String PARAM_PATH = "path"; @@ -89,6 +94,14 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr this.filePlanService = filePlanService; } + /** + * @param retryingTransactionHelper retrying transaction helper + */ + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) + { + this.retryingTransactionHelper = retryingTransactionHelper; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) */ @@ -103,7 +116,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @Override - protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) { String actionName = action.getActionDefinitionName(); if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) @@ -125,8 +138,25 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER); if (recordFolder == null) { - // get the reference to the record folder based on the relative path - recordFolder = createOrResolvePath(action, actionedUponNodeRef, targetIsUnfiledRecords); + final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords; + recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef result = null; + try + { + // get the reference to the record folder based on the relative path + result = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); + } + catch (DuplicateChildNodeNameException ex) + { + throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); + } + + return result; + } + }, false, true); } // now we have the reference to the target folder we can do some final checks to see if the action is valid @@ -140,18 +170,22 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr { try { - if(getMode() == CopyMoveLinkFileToActionMode.MOVE) - { - fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null); - } - else if(getMode() == CopyMoveLinkFileToActionMode.COPY) - { - fileFolderService.copy(actionedUponNodeRef, finalRecordFolder, null); - } - else if(getMode() == CopyMoveLinkFileToActionMode.LINK) - { - recordService.link(actionedUponNodeRef, finalRecordFolder); - } + synchronized (this) + { + if(getMode() == CopyMoveLinkFileToActionMode.MOVE) + { + fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null); + } + else if(getMode() == CopyMoveLinkFileToActionMode.COPY) + { + fileFolderService.copy(actionedUponNodeRef, finalRecordFolder, null); + } + else if(getMode() == CopyMoveLinkFileToActionMode.LINK) + { + recordService.link(actionedUponNodeRef, finalRecordFolder); + } + } + } catch (FileNotFoundException fileNotFound) { @@ -333,18 +367,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr */ private NodeRef getChild(NodeRef parent, String childName) { - NodeRef child = null; - List children = nodeService.getChildAssocs(parent); - for (ChildAssociationRef childAssoc : children) { - NodeRef childNodeRef = childAssoc.getChildRef(); - String existingChildName = (String)nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME); - if(existingChildName.equals(childName)) - { - child = childNodeRef; - break; - } - } - return child; + return nodeService.getChildByName(parent, ContentModel.ASSOC_CONTAINS, childName); } /** @@ -364,22 +387,31 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr @Override public NodeRef doWork() { - NodeRef child = null; - if(targetisUnfiledRecords) + // double check that the child hasn't been created by another thread + NodeRef child = getChild(parent, childName); + if (child == null) { - child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); - } - else if(lastAsFolder) - { - child = recordFolderService.createRecordFolder(parent, childName); - } - else - { - if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(parent))) - { - throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path could not be created."); - } - child = filePlanService.createRecordCategory(parent, childName); + if(targetisUnfiledRecords) + { + // create unfiled folder + child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); + } + else if(lastAsFolder) + { + // create record folder + child = recordFolderService.createRecordFolder(parent, childName); + } + else + { + // ensure we are not trying to create a record categtory in a record folder + if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(parent))) + { + throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path has a record category within a record folder."); + } + + // create record category + child = filePlanService.createRecordCategory(parent, childName); + } } return child; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java index 4f20ee4986..77bfa96e95 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java @@ -25,6 +25,8 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -39,6 +41,8 @@ import org.quartz.JobExecutionException; */ public class RecordsManagementJob implements Job { + private static Log logger = LogFactory.getLog(RecordsManagementJob.class); + private static final long DEFAULT_TIME = 30000L; private JobLockService jobLockService; @@ -108,7 +112,18 @@ public class RecordsManagementJob implements Job } finally { - jobLockService.releaseLock(lockToken, getLockQName()); + try + { + jobLockService.releaseLock(lockToken, getLockQName()); + } + catch (LockAcquisitionException e) + { + // Ignore + if (logger.isDebugEnabled()) + { + logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "(" + e.getMessage() + ")"); + } + } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 82b94f8fd0..d75a5969d8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -18,6 +18,10 @@ */ package org.alfresco.module.org_alfresco_module_rm.jscript.app; +import static org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel.READ_RECORDS; +import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; + import java.util.ArrayList; import java.util.List; @@ -305,10 +309,10 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC rootJSONObject.put("originatingLocationPath", originatingLocationPath.toString()); } } - + /** * Helper method to get the display path. - * + * * @param nodeRef node reference * @return String display path */ @@ -329,9 +333,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC * @return */ @SuppressWarnings("unchecked") - private JSONObject setRmNodeValues(NodeRef nodeRef, boolean useShortQName) + private JSONObject setRmNodeValues(final NodeRef nodeRef, final boolean useShortQName) { - JSONObject rmNodeValues = new JSONObject(); + JSONObject rmNodeValues = new JSONObject(); // UI convenience type rmNodeValues.put("uiType", getUIType(nodeRef)); @@ -341,17 +345,20 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC rmNodeValues.put("kind", kind.toString()); // File plan node reference - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - rmNodeValues.put("filePlan", filePlan.toString()); - - // Unfiled container node reference - NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); - if (unfiledRecordContainer != null) + NodeRef filePlan = getFilePlan(nodeRef); + if (permissionService.hasPermission(filePlan, READ_RECORDS).equals(ALLOWED)) { - rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString()); - rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName)); - QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); - rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); + rmNodeValues.put("filePlan", filePlan.toString()); + + // Unfiled container node reference + NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); + if (unfiledRecordContainer != null) + { + rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString()); + rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName)); + QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); + rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); + } } // Set the indicators array @@ -363,6 +370,23 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC return rmNodeValues; } + /** + * Helper method to get the file plan as a system user for the given node + * + * @param nodeRef The node reference + * @return The file plan where the node is in + */ + private NodeRef getFilePlan(final NodeRef nodeRef) + { + return runAsSystem(new RunAsWork() + { + public NodeRef doWork() + { + return filePlanService.getFilePlan(nodeRef); + } + }); + } + @SuppressWarnings("unchecked") private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef) { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java index 3ed8750cd2..a35d5cdd82 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/ExtendedSecurityAspect.java @@ -18,22 +18,14 @@ */ package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; -import java.util.Set; - import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.repo.copy.CopyBehaviourCallback; import org.alfresco.repo.copy.CopyDetails; import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** @@ -46,8 +38,7 @@ import org.alfresco.service.namespace.QName; ( defaultType = "rma:extendedSecurity" ) -public class ExtendedSecurityAspect extends BaseBehaviourBean - implements NodeServicePolicies.OnMoveNodePolicy +public class ExtendedSecurityAspect extends BaseBehaviourBean { /** extended security service */ protected ExtendedSecurityService extendedSecurityService; @@ -74,40 +65,4 @@ public class ExtendedSecurityAspect extends BaseBehaviourBean { return new DoNothingCopyBehaviourCallback(); } - - /** - * Update extended security when moving a node. - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) - */ - @Override - @Behaviour - ( - kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onMoveNode(final ChildAssociationRef origAssoc, final ChildAssociationRef newAssoc) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - NodeRef record = newAssoc.getChildRef(); - NodeRef newParent = newAssoc.getParentRef(); - NodeRef oldParent = origAssoc.getParentRef(); - - Set readers = extendedSecurityService.getExtendedReaders(record); - Set writers = extendedSecurityService.getExtendedWriters(record); - - extendedSecurityService.addExtendedSecurity(newParent, readers, writers); - extendedSecurityService.removeExtendedSecurity(oldParent, readers, writers); - - return null; - } - }); - } - - - } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index 0cc4cd45f2..724158dde3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -973,7 +973,7 @@ public class RecordServiceImpl extends BaseBehaviourBean * @see org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService#isFiled(org.alfresco.service.cmr.repository.NodeRef) */ @Override - public boolean isFiled(NodeRef nodeRef) + public boolean isFiled(final NodeRef nodeRef) { ParameterCheck.mandatory("nodeRef", nodeRef); @@ -981,15 +981,24 @@ public class RecordServiceImpl extends BaseBehaviourBean if (isRecord(nodeRef)) { - ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(nodeRef); - if (childAssocRef != null) - { - NodeRef parent = childAssocRef.getParentRef(); - if (parent != null && recordFolderService.isRecordFolder(parent)) - { - result = true; - } - } + result = AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Boolean doWork() throws Exception + { + boolean result = false; + ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(nodeRef); + if (childAssocRef != null) + { + NodeRef parent = childAssocRef.getParentRef(); + if (parent != null && recordFolderService.isRecordFolder(parent)) + { + result = true; + } + } + return result; + } + }); + } return result; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java index eb59072ab3..e432769e1b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java @@ -32,6 +32,8 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; @@ -146,7 +148,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderClosed(NodeRef) */ @Override - public boolean isRecordFolderClosed(NodeRef nodeRef) + public boolean isRecordFolderClosed(final NodeRef nodeRef) { ParameterCheck.mandatory("nodeRef", nodeRef); @@ -156,7 +158,13 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); } - return ((Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED)).booleanValue(); + return AuthenticationUtil.runAsSystem(new RunAsWork() + { + public Boolean doWork() throws Exception + { + return ((Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED)); + } + }); } @Override 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 89193d0def..2ef8b753d8 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 @@ -40,6 +40,7 @@ import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamic import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authority.RMAuthority; +import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; @@ -835,7 +836,14 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService, if (!getAllAssignedToRole(filePlan, role).contains(authorityName)) { String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan)); - authorityService.addAuthority(roleAuthority, authorityName); + try + { + authorityService.addAuthority(roleAuthority, authorityName); + } + catch (DuplicateChildNodeNameException exception) + { + // ignore, because the work has already been performed + } } return null; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java index 61268ae7cb..a4fd365b8c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java @@ -46,10 +46,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl implements ExtendedSecurityService, RecordsManagementModel { - /** Ad hoc properties used for reference counting */ - private static final QName PROP_EXTENDED_READER_ROLE = QName.createQName(RM_URI, "extendedReaderRole"); - private static final QName PROP_EXTENDED_WRITER_ROLE = QName.createQName(RM_URI, "extendedWriterRole"); - /** File plan service */ private FilePlanService filePlanService; @@ -72,7 +68,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl this.filePlanRoleService = filePlanRoleService; } - /** + /** * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#hasExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) */ public boolean hasExtendedSecurity(NodeRef nodeRef) @@ -137,6 +133,9 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl if (nodeRef != null) { addExtendedSecurityImpl(nodeRef, readers, writers, applyToParents); + + // add to the extended security roles + addExtendedSecurityRoles(nodeRef, readers, writers); } } @@ -149,37 +148,37 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl * @param applyToParents */ @SuppressWarnings("unchecked") - private void addExtendedSecurityImpl(NodeRef nodeRef, Set readers, Set writers, boolean applyToParents) + private void addExtendedSecurityImpl(final NodeRef nodeRef, Set readers, Set writers, boolean applyToParents) { ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("applyToParents", applyToParents); - // add the aspect if missing - if (!nodeService.hasAspect(nodeRef, ASPECT_EXTENDED_SECURITY)) - { - nodeService.addAspect(nodeRef, ASPECT_EXTENDED_SECURITY, null); - } - + // get the properties + final Map properties = nodeService.getProperties(nodeRef); + // update the readers map if (readers != null && readers.size() != 0) { // get reader map - Map readersMap = (Map)nodeService.getProperty(nodeRef, PROP_READERS); + Map readersMap = (Map)properties.get(PROP_READERS); // set the readers property (this will in turn apply the aspect if required) - nodeService.setProperty(nodeRef, PROP_READERS, (Serializable)addToMap(readersMap, readers)); + properties.put(PROP_READERS, (Serializable)addToMap(readersMap, readers)); } - + // update the writers map - if (writers != null && writers.size() != 0) - { - // get writer map - Map writersMap = (Map)nodeService.getProperty(nodeRef, PROP_WRITERS); - - // set the writers property (this will in turn apply the aspect if required) - nodeService.setProperty(nodeRef, PROP_WRITERS, (Serializable)addToMap(writersMap, writers)); - } + if (writers != null && writers.size() != 0) + { + // get writer map + Map writersMap = (Map)properties.get(PROP_WRITERS); + + // set the writers property (this will in turn apply the aspect if required) + properties.put(PROP_WRITERS, (Serializable)addToMap(writersMap, writers)); + } + // set properties + nodeService.setProperties(nodeRef, properties); + // apply the readers to any renditions of the content if (isRecord(nodeRef)) { @@ -189,22 +188,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl NodeRef child = assoc.getChildRef(); addExtendedSecurityImpl(child, readers, writers, false); } - } - - // add to the extended security roles - addExtendedSecurityRoles(nodeRef, readers, writers); - - if (applyToParents) - { - // apply the extended readers up the file plan primary hierarchy - NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef(); - if (parent != null && - filePlanService.isFilePlanComponent(parent)) - { - addExtendedSecurityImpl(parent, readers, null, applyToParents); - addExtendedSecurityImpl(parent, writers, null, applyToParents); - } - } + } } /** @@ -217,37 +201,29 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - addExtendedSecurityRolesImpl(filePlan, readers, PROP_EXTENDED_READER_ROLE, FilePlanRoleService.ROLE_EXTENDED_READERS); - addExtendedSecurityRolesImpl(filePlan, writers, PROP_EXTENDED_WRITER_ROLE, FilePlanRoleService.ROLE_EXTENDED_WRITERS); + addExtendedSecurityRolesImpl(filePlan, readers, FilePlanRoleService.ROLE_EXTENDED_READERS); + addExtendedSecurityRolesImpl(filePlan, writers, FilePlanRoleService.ROLE_EXTENDED_WRITERS); } /** + * Add extended security roles implementation * - * @param filePlan - * @param authorities - * @param propertyName - * @param roleName + * @param filePlan file plan + * @param authorities authorities + * @param roleName role name */ - @SuppressWarnings("unchecked") - private void addExtendedSecurityRolesImpl(NodeRef filePlan, Set authorities, QName propertyName, String roleName) + private void addExtendedSecurityRolesImpl(NodeRef filePlan, Set authorities, String roleName) { if (authorities != null) { - // get the reference count - Map referenceCountMap = (Map)nodeService.getProperty(filePlan, propertyName); - for (String authority : authorities) { - if ((!authority.equals(PermissionService.ALL_AUTHORITIES) && !authority.equals(PermissionService.OWNER_AUTHORITY)) && - (referenceCountMap == null || !referenceCountMap.containsKey(authority))) + if ((!authority.equals(PermissionService.ALL_AUTHORITIES) && !authority.equals(PermissionService.OWNER_AUTHORITY))) { // add the authority to the role filePlanRoleService.assignRoleToAuthority(filePlan, roleName, authority); } } - - // update the reference count - nodeService.setProperty(filePlan, propertyName, (Serializable)addToMap(referenceCountMap, authorities)); } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java index 2c11e9689e..8c52e12ea1 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java @@ -42,7 +42,9 @@ import org.junit.runners.Suite.SuiteClasses; RM804Test.class, RM994Test.class, RM1039Test.class, - RM1799Test.class + RM1799Test.class, + //RM2190Test.class, + RM2192Test.class }) public class IssueTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java new file mode 100644 index 0000000000..37cf0048aa --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2072Test.java @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2005-2014 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.test.integration.issue; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.rule.Rule; +import org.alfresco.service.cmr.rule.RuleService; +import org.alfresco.service.cmr.rule.RuleType; + + +/** + * System test for RM-2072: Concurrency exceptions and deadlocks on Records Management "File to" rule + * + * @author Roy Wetherall + * @since 2.2.1.1 + */ +public class RM2072Test extends BaseRMTestCase +{ + private static final int NUMBER_OF_BATCHES = 1; + private static final int NUMBER_IN_BATCH = 500; + + private RuleService ruleService; + private NodeRef ruleFolder; + + @Override + protected void initServices() + { + super.initServices(); + + ruleService = (RuleService)applicationContext.getBean("RuleService"); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + /** + * Given that I have auto declare configured + * And that I have auto file configured to a path where only the record folder needs to be created + * When I add lots of documents in the same transaction + * Then the rules should fire + * And the documents should be filed in the new record folder + */ + public void testAutoDeclareAutoFileCreateRecordFolderOnly() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // create the folder + ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER).getNodeRef(); + + // create record category + NodeRef nodeRefA = filePlanService.createRecordCategory(filePlan, "A"); + NodeRef nodeRefB = filePlanService.createRecordCategory(nodeRefA, "B"); + filePlanService.createRecordCategory(nodeRefB, "C"); + + Action action = actionService.createAction(CreateRecordAction.NAME); + action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + + Rule rule = new Rule(); + rule.setRuleType(RuleType.INBOUND); + rule.setTitle("my rule"); + rule.setAction(action); + rule.setExecuteAsynchronously(true); + ruleService.saveRule(ruleFolder, rule); + + Action fileAction = actionService.createAction(FileToAction.NAME); + fileAction.setParameterValue(FileToAction.PARAM_PATH, "/A/B/C/{date.year.long}/{date.month.long}/{date.day.month}"); + fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + Rule fileRule = new Rule(); + fileRule.setRuleType(RuleType.INBOUND); + fileRule.setTitle("my rule"); + fileRule.setAction(fileAction); + fileRule.setExecuteAsynchronously(true); + ruleService.saveRule(filePlanService.getUnfiledContainer(filePlan), fileRule); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(ruleService.getRules(ruleFolder).isEmpty()); + } + }); + + List records = new ArrayList(NUMBER_OF_BATCHES*NUMBER_IN_BATCH); + + for (int i = 0; i < NUMBER_OF_BATCHES; i++) + { + final int finali = i; + records.addAll(doTestInTransaction(new Test>() + { + @Override + public List run() throws Exception + { + List records = new ArrayList(NUMBER_IN_BATCH); + for (int j = 0; j < NUMBER_IN_BATCH; j++) + { + int count = (finali+1)*(j+1); + String name = "content" + count + ".txt"; + System.out.println(name + " - creating"); + + NodeRef record = fileFolderService.create(ruleFolder, name, ContentModel.TYPE_CONTENT).getNodeRef(); + records.add(record); + } + return records; + } + })); + } + + try + { + while(!records.isEmpty()) + { + Thread.sleep(1000); + + final Iterator temp = records.iterator(); + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + while (temp.hasNext()) + { + NodeRef record = temp.next(); + if (nodeService.hasAspect(record, ASPECT_RECORD) && recordService.isFiled(record)) + { + String name = (String) nodeService.getProperty(record, ContentModel.PROP_NAME); + System.out.println(name + " - complete"); + temp.remove(); + } + } + + return null; + } + }); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + throw exception; + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2190Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2190Test.java new file mode 100644 index 0000000000..3a298c7bd3 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2190Test.java @@ -0,0 +1,201 @@ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import static java.util.Arrays.asList; +import static org.alfresco.service.cmr.rule.RuleType.INBOUND; +import static org.alfresco.util.GUID.generate; +import static org.springframework.util.StringUtils.tokenizeToStringArray; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.model.FileNotFoundException; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.rule.Rule; +import org.alfresco.service.cmr.rule.RuleService; + +/** + * System test for RM-2190: Concurrency exception when upload document to several folders with rules configured to file records + * + * @author Tuna Aksoy + * @since 2.2.1.1 + */ +public class RM2190Test extends BaseRMTestCase +{ + private static final int NUMBER_OF_BATCHES = 1; + private static final int NUMBER_IN_BATCH = 10; + + private static final String PATH = "/111/222/333"; + + private RuleService ruleService; + + private NodeRef rootFolder; + private NodeRef folder1; + private NodeRef folder2; + + @Override + protected void initServices() + { + super.initServices(); + + ruleService = (RuleService) applicationContext.getBean("RuleService"); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testUploadDocumentsSimultaneouslyWithRules() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + rootFolder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef(); + + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + + Rule declareRule = new Rule(); + declareRule.setRuleType(INBOUND); + declareRule.setTitle(generate()); + declareRule.setAction(createAction); + declareRule.setExecuteAsynchronously(true); + declareRule.applyToChildren(true); + ruleService.saveRule(rootFolder, declareRule); + + folder1 = fileFolderService.create(rootFolder, generate(), TYPE_FOLDER).getNodeRef(); + folder2 = fileFolderService.create(rootFolder, generate(), TYPE_FOLDER).getNodeRef(); + + Action fileAction = actionService.createAction(FileToAction.NAME); + fileAction.setParameterValue(FileToAction.PARAM_PATH, PATH); + fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + Rule fileRule = new Rule(); + fileRule.setRuleType(INBOUND); + fileRule.setTitle(generate()); + fileRule.setAction(fileAction); + fileRule.setExecuteAsynchronously(true); + ruleService.saveRule(unfiledContainer, fileRule); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(ruleService.getRules(rootFolder).isEmpty()); + assertFalse(ruleService.getRules(unfiledContainer).isEmpty()); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() throws FileNotFoundException, InterruptedException + { + Thread thread1 = new Thread() + { + public void run() { + List files = addFilesToFolder(folder1); + waitForFilesToBeDeclared(files); + } + }; + + Thread thread2 = new Thread() + { + public void run() { + List files = addFilesToFolder(folder2); + waitForFilesToBeDeclared(files); + } + }; + + thread1.start(); + thread2.start(); + + thread1.join(300000); + thread2.join(300000); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + FileInfo category = fileFolderService.resolveNamePath(filePlan, asList(tokenizeToStringArray(PATH, "/", false, true))); + assertEquals(NUMBER_IN_BATCH * 2, nodeService.getChildAssocs(category.getNodeRef()).size()); + } + }); + } + + private List addFilesToFolder(final NodeRef folder) + { + List records = new ArrayList(NUMBER_OF_BATCHES * NUMBER_IN_BATCH); + + for (int i = 0; i < NUMBER_OF_BATCHES; i++) + { + final int finali = i; + records.addAll(doTestInTransaction(new Test>() + { + @Override + public List run() throws Exception + { + List files = new ArrayList(NUMBER_IN_BATCH); + for (int j = 0; j < NUMBER_IN_BATCH; j++) + { + int count = (finali+1)*(j+1); + String name = folder.getId() + " - content" + count + ".txt"; + System.out.println(name + " - creating"); + + NodeRef file = fileFolderService.create(folder, name, TYPE_CONTENT).getNodeRef(); + files.add(file); + } + return files; + } + })); + } + + return records; + } + + private void waitForFilesToBeDeclared(List files) + { + while (!files.isEmpty()) + { + final Iterator temp = files.iterator(); + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + while (temp.hasNext()) + { + NodeRef record = temp.next(); + if (nodeService.hasAspect(record, ASPECT_RECORD) && recordService.isFiled(record)) + { + String name = (String) nodeService.getProperty(record, PROP_NAME); + System.out.println(name + " - complete"); + temp.remove(); + } + } + + return null; + } + }); + } + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2192Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2192Test.java new file mode 100644 index 0000000000..bf9759c9a0 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2192Test.java @@ -0,0 +1,156 @@ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_RECORDS_MANAGER; +import static org.alfresco.repo.site.SiteModel.SITE_MANAGER; +import static org.alfresco.repo.site.SiteServiceImpl.getSiteContainer; +import static org.alfresco.service.cmr.rule.RuleType.INBOUND; +import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; +import static org.alfresco.service.cmr.site.SiteService.DOCUMENT_LIBRARY; +import static org.alfresco.service.cmr.site.SiteVisibility.PUBLIC; +import static org.alfresco.util.GUID.generate; + +import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.jscript.app.JSONConversionComponent; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.rule.Rule; +import org.alfresco.service.cmr.rule.RuleService; + +/** + * Integration test for RM-2192 + * + * @author Tuna Aksoy + * @since 2.2.1.1 + */ +public class RM2192Test extends BaseRMTestCase +{ + private static final String PATH = "/111/222/333"; + + private RuleService ruleService; + private JSONConversionComponent converter; + + private NodeRef folder; + private String user; + private NodeRef documentLibrary2; + + @Override + protected void initServices() + { + super.initServices(); + + ruleService = (RuleService) applicationContext.getBean("RuleService"); + converter = (JSONConversionComponent) applicationContext.getBean("jsonConversionComponent"); + } + + @Override + protected boolean isCollaborationSiteTest() + { + return true; + } + + @Override + protected boolean isRecordTest() + { + return true; + } + + @Override + protected boolean isUserTest() + { + return true; + } + + @Override + protected void setupCollaborationSiteTestDataImpl() + { + super.setupCollaborationSiteTestDataImpl(); + + String collabSiteId2 = generate(); + siteService.createSite("site-dashboard", collabSiteId2, generate(), generate(), PUBLIC); + documentLibrary2 = getSiteContainer( + collabSiteId2, + DOCUMENT_LIBRARY, + true, + siteService, + transactionService, + taggingService); + + assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary2); + + user = generate(); + createPerson(user); + + siteService.setMembership(collabSiteId2, user, SITE_MANAGER); + + filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_RECORDS_MANAGER, user); + } + + public void testAccessToRecordAfterDeclaring() + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + folder = fileFolderService.create(documentLibrary2, generate(), TYPE_FOLDER).getNodeRef(); + + Action createAction = actionService.createAction(CreateRecordAction.NAME); + createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan); + + Rule declareRule = new Rule(); + declareRule.setRuleType(INBOUND); + declareRule.setTitle(generate()); + declareRule.setAction(createAction); + declareRule.setExecuteAsynchronously(true); + declareRule.applyToChildren(true); + ruleService.saveRule(folder, declareRule); + + Action fileAction = actionService.createAction(FileToAction.NAME); + fileAction.setParameterValue(FileToAction.PARAM_PATH, PATH); + fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true); + + Rule fileRule = new Rule(); + fileRule.setRuleType(INBOUND); + fileRule.setTitle(generate()); + fileRule.setAction(fileAction); + fileRule.setExecuteAsynchronously(true); + ruleService.saveRule(unfiledContainer, fileRule); + + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(ruleService.getRules(folder).isEmpty()); + assertFalse(ruleService.getRules(unfiledContainer).isEmpty()); + } + }); + + doTestInTransaction(new Test() + { + NodeRef document; + + @Override + public Void run() + { + document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); + + return null; + } + + @Override + public void test(Void result) throws InterruptedException + { + Thread.sleep(10000); + + assertEquals(permissionService.hasPermission(document, READ_RECORDS), ALLOWED); + assertTrue(recordService.isFiled(document)); + assertNotNull(converter.toJSON(document, true)); + } + }, user); + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java index f1d3c9d8a9..a00ef18e61 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileToActionTest.java @@ -29,6 +29,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; import org.alfresco.module.org_alfresco_module_rm.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; @@ -113,9 +114,17 @@ public class FileToActionTest extends BaseRMTestCase assertTrue(recordService.isRecord(dmDocument)); assertFalse(recordService.isFiled(dmDocument)); - // is the unfiled container the primary parent of the filed record - NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); - assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + // is the unfiled container the primary parent of the filed record + NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertEquals(filePlanService.getUnfiledContainer(filePlan), parent); + + // TODO Auto-generated method stub + return null; + }}); return null; } @@ -203,12 +212,17 @@ public class FileToActionTest extends BaseRMTestCase private void createRecord(final String path, final String name, final String resolvedPath) { + final String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/"); + + // set parameters + Map params = new HashMap(1); + params.put(FileToAction.PARAM_PATH, path); + params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); + doTestInTransaction(new Test() { public Void run() throws Exception { - String[] pathValues = StringUtils.tokenizeToStringArray(resolvedPath, "/"); - // show the folder doesn't exist to begin with FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); assertNull(createdRecordFolder); @@ -218,11 +232,19 @@ public class FileToActionTest extends BaseRMTestCase params.put(FileToAction.PARAM_PATH, path); params.put(FileToAction.PARAM_CREATE_RECORD_PATH, true); - // execute file-to action - rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + return null; + } + }, ADMIN_USER); + // execute file-to action + rmActionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params); + + doTestInTransaction(new Test() + { + public Void run() throws Exception + { // show the folder has now been created - createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); + FileInfo createdRecordFolder = fileFolderService.resolveNamePath(filePlan, new ArrayList(Arrays.asList(pathValues)), false); assertNotNull(createdRecordFolder); assertEquals(name, createdRecordFolder.getName()); NodeRef createdRecordFolderNodeRef = createdRecordFolder.getNodeRef(); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java index 324b0ce759..faeadd3554 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ExtendedSecurityServiceImplTest.java @@ -105,9 +105,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase testMap.put(monkey, Integer.valueOf(1)); testMap.put(elephant, Integer.valueOf(1)); - checkExtendedReaders(filePlan, testMap); - checkExtendedReaders(rmContainer, testMap); - checkExtendedReaders(rmFolder, testMap); checkExtendedReaders(record, testMap); Set extendedReadersToo = new HashSet(2); @@ -125,9 +122,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase testMapThree.put(elephant, Integer.valueOf(1)); testMapThree.put(snake, Integer.valueOf(1)); - checkExtendedReaders(filePlan, testMapThree); - checkExtendedReaders(rmContainer, testMapThree); - checkExtendedReaders(rmFolder, testMapThree); checkExtendedReaders(recordToo, testMapToo); // test remove (with no parent inheritance) @@ -142,9 +136,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase testMapFour.put(monkey, Integer.valueOf(1)); testMapFour.put(snake, Integer.valueOf(1)); - checkExtendedReaders(filePlan, testMapThree); - checkExtendedReaders(rmContainer, testMapThree); - checkExtendedReaders(rmFolder, testMapFour); checkExtendedReaders(recordToo, testMapToo); // test remove (apply to parents) @@ -158,9 +149,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase testMapFour.remove(snake); testMapToo.remove(snake); - checkExtendedReaders(filePlan, testMapThree); - checkExtendedReaders(rmContainer, testMapThree); - checkExtendedReaders(rmFolder, testMapFour); checkExtendedReaders(recordToo, testMapToo); return null; @@ -197,9 +185,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase extendedSecurityService.addExtendedSecurity(record, extendedReaders, null); - checkExtendedReaders(filePlan, testMap); - checkExtendedReaders(rmContainer, testMap); - checkExtendedReaders(rmFolder, testMap); checkExtendedReaders(record, testMap); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); @@ -212,11 +197,6 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase @Override public void test(Void result) throws Exception { - checkExtendedReaders(filePlan, testMap); - assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); - // assertEquals(0, extendedSecurityService.getExtendedReaders(rmFolder).size()); - checkExtendedReaders(moveRecordCategory, testMap); - checkExtendedReaders(moveRecordFolder, testMap); checkExtendedReaders(record, testMap); } }); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java index aac8a820f7..1cf86bb235 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java @@ -28,7 +28,6 @@ import org.alfresco.module.org_alfresco_module_rm.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority; @@ -38,7 +37,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.AccessPermission; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; @@ -304,15 +302,12 @@ public class RecordServiceImplTest extends BaseRMTestCase public void test(Void result) { - checkPermissions(READ_RECORDS, AccessStatus.ALLOWED, // file - // plan - AccessStatus.ALLOWED, // unfiled container + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // record category AccessStatus.DENIED, // record folder AccessStatus.ALLOWED); // doc/record - permissionReport(); - assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); @@ -362,9 +357,8 @@ public class RecordServiceImplTest extends BaseRMTestCase @Override public Void run() { - checkPermissions(READ_RECORDS, AccessStatus.ALLOWED, // file - // plan - AccessStatus.ALLOWED, // unfiled container + checkPermissions(READ_RECORDS, AccessStatus.DENIED, // file plan + AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // record category AccessStatus.DENIED, // record folder AccessStatus.ALLOWED); // doc/record @@ -394,38 +388,6 @@ public class RecordServiceImplTest extends BaseRMTestCase }, dmConsumer); } - private void permissionReport() - { - Set writers = extendedSecurityService.getExtendedWriters(dmDocument); - for (String writer : writers) - { - System.out.println("writer: " + writer); - } - - System.out.println("Users assigned to extended writers role:"); - Set assignedUsers = filePlanRoleService.getUsersAssignedToRole(filePlan, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - for (String assignedUser : assignedUsers) - { - System.out.println(" ... " + assignedUser); - } - - Set perms = permissionService.getAllSetPermissions(filePlan); - for (AccessPermission perm : perms) - { - if (perm.getPermission().contains(RMPermissionModel.EDIT_NON_RECORD_METADATA)) - { - System.out.println(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString()); - } - } - for (AccessPermission perm : perms) - { - if (perm.getPermission().contains(RMPermissionModel.VIEW_RECORDS)) - { - System.out.println(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString()); - } - } - } - public void testCreateRecordNoLink() throws Exception { // show that users without WRITE can not create a record from a document