> recordMetaDataAspects;
@@ -398,7 +400,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
this.recordableVersionService = recordableVersionService;
}
-
+
/**
* Init method
*/
@@ -1753,7 +1755,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
private void validateLinkConditions(NodeRef record, NodeRef recordFolder)
{
// ensure that the linking record folders have compatible disposition schedules
- DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record);
+
+ // get the origin disposition schedule for the record, not the calculated one
+ DispositionSchedule recordDispositionSchedule = dispositionService.getOriginDispositionSchedule(record);
+
if (recordDispositionSchedule != null)
{
DispositionSchedule recordFolderDispositionSchedule = dispositionService.getDispositionSchedule(recordFolder);
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java
index 8309c84f44..d45d9745c2 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java
@@ -30,6 +30,7 @@ package org.alfresco.repo.security.permissions.impl;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -40,6 +41,7 @@ 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.role.FilePlanRoleService;
import org.alfresco.repo.cache.SimpleCache;
+
import org.alfresco.repo.security.permissions.AccessControlEntry;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.security.permissions.processor.PermissionPostProcessor;
@@ -55,6 +57,7 @@ import org.alfresco.util.PropertyCheck;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationEvent;
+
/**
* Extends the core permission service implementation allowing the consideration of the read records permission.
*
@@ -67,6 +70,20 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
/** Writers simple cache */
protected SimpleCache> writersCache;
+ /**
+ * Configured Permission mapping.
+ *
+ * This string comes from alfresco-global.properties and allows fine tuning of the how permissions are mapped.
+ * This was added as a fix for MNT-16852 to enhance compatibility with our Outlook Integration.
+ */
+ protected List configuredReadPermissions;
+ /**
+ * Configured Permission mapping.
+ *
+ * This string also comes from alfresco-global.properties.
+ */
+ protected List configuredFilePermissions;
+
/** File plan service */
private FilePlanService filePlanService;
@@ -124,6 +141,28 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
this.writersCache = writersCache;
}
+ /**
+ * Maps the string from the properties file (rm.haspermissionmap.read)
+ * to the list used in the hasPermission method
+ *
+ * @param readMapping the mapping of permissions to ReadRecord
+ */
+ public void setConfiguredReadPermissions(String readMapping)
+ {
+ this.configuredReadPermissions = Arrays.asList(readMapping.split(","));
+ }
+
+ /**
+ * Maps the string set in the properties file (rm.haspermissionmap.write)
+ * to the list used in the hasPermission method
+ *
+ * @param fileMapping the mapping of permissions to FileRecord
+ */
+ public void setConfiguredFilePermissions(String fileMapping)
+ {
+ this.configuredFilePermissions = Arrays.asList(fileMapping.split(","));
+ }
+
/**
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent)
*/
@@ -166,7 +205,7 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
for (PermissionPostProcessor postProcessor : postProcessors)
{
// post process permission
- result = postProcessor.process(result, nodeRef, perm);
+ result = postProcessor.process(result, nodeRef, perm, this.configuredReadPermissions, this.configuredFilePermissions);
}
}
return result;
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPostProcessor.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPostProcessor.java
index 5740594975..175c5f1392 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPostProcessor.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/processor/PermissionPostProcessor.java
@@ -27,6 +27,8 @@
package org.alfresco.repo.security.permissions.processor;
+import java.util.List;
+
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -46,7 +48,9 @@ public interface PermissionPostProcessor
* @param accessStatus current access status
* @param nodeRef node reference
* @param perm permission
+ *
* @return {@link AccessStatus}
*/
- AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm);
+ AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm,
+ List configuredReadPermissions, List configuredFilePermissions);
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
index 50cdfc2553..bbbaf76323 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMNodes.java
@@ -37,9 +37,14 @@ import org.alfresco.rest.api.Nodes;
*/
public interface RMNodes extends Nodes
{
- String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
- String PARAM_INCLUDE_IS_CLOSED = "isClosed";
- String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
+ public static String PATH_FILE_PLAN = "-filePlan-";
+ public static String PATH_TRANSFERS = "-transfers-";
+ public static String PATH_UNFILED = "-unfiled-";
+ public static String PATH_HOLDS = "-holds-";
+
+ public static String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
+ public static String PARAM_INCLUDE_IS_CLOSED = "isClosed";
+ public static String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
/**
* Identifies if one node is RM site node.
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
index b7dfa839fb..eaadab28ef 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java
@@ -74,11 +74,6 @@ import org.alfresco.util.Pair;
*/
public class RMNodesImpl extends NodesImpl implements RMNodes
{
- String FILE_PLAN = "-filePlan-";
- String TRANSFERS = "-transfers-";
- String UNFILED = "-unfiled-";
- String HOLDS = "-holds-";
-
private enum RMNodeType
{
// Note: ordered
@@ -213,7 +208,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
throw new InvalidArgumentException("Missing nodeId");
}
- if (nodeId.equals(FILE_PLAN))
+ if (nodeId.equals(PATH_FILE_PLAN))
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
@@ -225,7 +220,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
throw new EntityNotFoundException(nodeId);
}
}
- else if (nodeId.equals(TRANSFERS))
+ else if (nodeId.equals(PATH_TRANSFERS))
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
@@ -237,7 +232,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
throw new EntityNotFoundException(nodeId);
}
}
- else if (nodeId.equals(UNFILED))
+ else if (nodeId.equals(PATH_UNFILED))
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
@@ -249,7 +244,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
throw new EntityNotFoundException(nodeId);
}
}
- else if (nodeId.equals(HOLDS))
+ else if (nodeId.equals(PATH_HOLDS))
{
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/package-info.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/package-info.java
index 3c21339b64..e8f77618fc 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/package-info.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/nodes/package-info.java
@@ -26,7 +26,7 @@
*/
/**
- * Package info that defines the Information Governance REST API
+ * Package info that defines the Information Governance Nodes REST API
*
* @author Ana Bozianu
* @since 2.6
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java
new file mode 100644
index 0000000000..daa9ab1818
--- /dev/null
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java
@@ -0,0 +1,208 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * 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 .
+ * #L%
+ */
+package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition;
+
+import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Map;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
+import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
+import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
+import org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ApplicationContextHelper;
+import org.springframework.extensions.webscripts.GUID;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Integration tests for records linked to multiple disposition schedules.
+ *
+ * @author Tom Page
+ * @since 2.3.1
+ */
+public class MultipleSchedulesTest extends BaseRMTestCase
+{
+ /** A unique prefix for the constants in this test. */
+ protected static final String TEST_PREFIX = MultipleSchedulesTest.class.getName() + GUID.generate() + "_";
+ /** The name to use for the first category. */
+ protected static final String CATEGORY_A_NAME = TEST_PREFIX + "CategoryA";
+ /** The name to use for the folder within the first category. */
+ protected static final String FOLDER_A_NAME = TEST_PREFIX + "FolderA";
+ /** The name to use for the second category. */
+ protected static final String CATEGORY_B_NAME = TEST_PREFIX + "CategoryB";
+ /** The name to use for the folder within the second category. */
+ protected static final String FOLDER_B_NAME = TEST_PREFIX + "FolderB";
+ /** The name to use for the record. */
+ protected static final String RECORD_NAME = TEST_PREFIX + "Record";
+
+ /** The internal disposition service is used to avoid permissions issues when updating the record. */
+ private DispositionService internalDispositionService;
+
+ /** The first category node. */
+ private NodeRef categoryA;
+ /** The folder node within the first category. */
+ private NodeRef folderA;
+ /** The second category node. */
+ private NodeRef categoryB;
+ /** The folder node within the second category. */
+ private NodeRef folderB;
+ /** The record node. */
+ private NodeRef record;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ BehaviourTest.initBehaviourTests(retryingTransactionHelper);
+
+ // Get the application context
+ applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
+ internalDispositionService = (DispositionService) applicationContext.getBean("dispositionService");
+
+ // Ensure different records are used for each test.
+ record = null;
+ }
+
+ /**
+ * Create two categories each containing a folder. Set up a schedule on category A that applies to records (cutoff
+ * immediately, destroy immediately). Set up a schedule on category B that is the same, but with a week delay before
+ * destroy becomes eligible.
+ */
+ private void setUpFilePlan()
+ {
+ // Only set up the file plan if it hasn't already been done.
+ if (categoryA != null)
+ {
+ return;
+ }
+
+ // Create two categories.
+ categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
+ categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
+ // Create a disposition schedule for category A (Cut off immediately, then Destroy immediately).
+ DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false);
+ Map cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
+ PROP_DISPOSITION_DESCRIPTION, "description",
+ PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
+ dispositionService.addDispositionActionDefinition(dispSchedA, cutOffParamsA);
+ Map destroyParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
+ PROP_DISPOSITION_DESCRIPTION, "description",
+ PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
+ dispositionService.addDispositionActionDefinition(dispSchedA, destroyParamsA);
+ // Create a disposition schedule for category B (Cut off immediately, then Destroy one week after cutoff).
+ DispositionSchedule dispSchedB = utils.createBasicDispositionSchedule(categoryB, "instructions", "authority", true, false);
+ Map cutOffParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
+ PROP_DISPOSITION_DESCRIPTION, "description",
+ PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
+ dispositionService.addDispositionActionDefinition(dispSchedB, cutOffParamsB);
+ Map destroyParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
+ PROP_DISPOSITION_DESCRIPTION, "description",
+ PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK,
+ PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE);
+ dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB);
+ // Create a folder within each category.
+ folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME);
+ folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME);
+ }
+
+ /**
+ * RM-2526
+ *
+ * Given a record subject to a disposition schedule
+ * And it is linked to a disposition schedule with the same step order, but a longer destroy step
+ * When the record is moved onto the destroy step
+ * Then the "as of" date is calculated using the longer period.
+ *
+ */
+ public void testLinkedToLongerSchedule()
+ {
+ Calendar calendar = Calendar.getInstance();
+ test()
+ .given(() -> {
+ setUpFilePlan();
+ // Create a record filed under category A and linked to category B.
+ record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
+ recordService.link(record, folderB);
+ })
+ .when(() -> {
+ // Cut off the record.
+ dispositionService.cutoffDisposableItem(record);
+ // Ensure the update has been applied to the record.
+ internalDispositionService.updateNextDispositionAction(record);
+ calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
+ calendar.add(Calendar.WEEK_OF_YEAR, 1);
+ })
+ .then()
+ .expect(calendar.getTime())
+ .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
+ .because("Record should follow largest rentention schedule period, which is one week.");
+ }
+
+ /**
+ * RM-2526
+ *
+ * Given a record subject to a disposition schedule
+ * And it is linked to a disposition schedule with the same step order, but a shorter destroy step
+ * When the record is moved onto the destroy step
+ * Then the "as of" date is calculated using the longer period.
+ *
+ */
+ public void testLinkedToShorterSchedule()
+ {
+ Calendar calendar = Calendar.getInstance();
+ test()
+ .given(() -> {
+ setUpFilePlan();
+ // Create a record filed under category B and linked to category A.
+ record = fileFolderService.create(folderB, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
+ recordService.link(record, folderA);
+ })
+ .when(() -> {
+ // Cut off the record.
+ dispositionService.cutoffDisposableItem(record);
+ // Ensure the update has been applied to the record.
+ internalDispositionService.updateNextDispositionAction(record);
+ calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
+ calendar.add(Calendar.WEEK_OF_YEAR, 1);
+ })
+ .then()
+ .expect(calendar.getTime())
+ .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
+ .because("Record should follow largest rentention schedule period, which is one week.");
+ }
+}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
index 462198f5a7..355d9c7eef 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
@@ -44,6 +44,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.impl.EditDispositionAct
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -51,7 +52,7 @@ import org.alfresco.service.namespace.QName;
* Update next disposition step integration tests.
*
* @author Roxana Lucanu
-* @since 2.4.1
+* @since 2.3.1
*/
public class UpdateNextDispositionActionTest extends BaseRMTestCase
{
@@ -103,11 +104,6 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
// complete record
utils.completeRecord(record);
- // set the disposition as of date to now on the record
- rmActionService.executeRecordsManagementAction(record,
- EditDispositionActionAsOfDateAction.NAME,
- Collections.singletonMap(EditDispositionActionAsOfDateAction.PARAM_AS_OF_DATE, new Date()));
-
// cut off
rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null);
}
@@ -115,7 +111,7 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
@Override
public void then() throws Exception
{
- assertTrue(nodeService.hasAspect(record, ASPECT_CUT_OFF));
+ assertTrue("Record " + record + " doesn't have the cutOff aspect.", nodeService.hasAspect(record, ASPECT_CUT_OFF));
}
});
}
@@ -128,7 +124,7 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
Map cutOff = new HashMap(3);
cutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
cutOff.put(PROP_DISPOSITION_DESCRIPTION, generate());
- cutOff.put(PROP_DISPOSITION_PERIOD, PERIOD_ONE_WEEK);
+ cutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(ds, cutOff);
// create the properties for TRANSFER action and add it to the disposition action definition
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
index 65721473d3..5973378a60 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/DispositionServiceImplTest.java
@@ -666,7 +666,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
checkDisposableItemChanged(mhRecordFolder42);
checkDisposableItemChanged(record43);
checkDisposableItemUnchanged(mhRecordFolder44);
- checkDisposableItemUnchanged(record45);;
+ checkDisposableItemUnchanged(record45);
}
});
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/permission/RecordsManagementPermissionPostProcessorUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/permission/RecordsManagementPermissionPostProcessorUnitTest.java
new file mode 100644
index 0000000000..e578c587e2
--- /dev/null
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/permission/RecordsManagementPermissionPostProcessorUnitTest.java
@@ -0,0 +1,120 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * 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 .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.permission;
+
+import static java.util.Arrays.asList;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+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.test.util.AlfMock;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.security.AccessStatus;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Unit tests for {@link RecordsManagementPermissionPostProcessor}.
+ *
+ * @author David Webster
+ * @since 2.4.1
+ */
+public class RecordsManagementPermissionPostProcessorUnitTest
+{
+
+ private @InjectMocks
+ RecordsManagementPermissionPostProcessor recordsManagementPermissionPostProcessor = new RecordsManagementPermissionPostProcessor();
+
+ private @Mock NodeService nodeService;
+ private @Mock PermissionService permissionService;
+
+ @Before
+ public void setup()
+ {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ /**
+ * Given the configured permissions are set
+ * When process is called
+ * Then access is allowed
+ */
+ @Test
+ public void configurePermissionsAllowed()
+ {
+ AccessStatus accessStatus = AccessStatus.DENIED;
+ NodeRef nodeRef = new NodeRef("node://ref/");
+ String perm = AlfMock.generateText();
+ // permissions includes the perm created above
+ List configuredReadPermissions = asList("ReadProperties", "ReadChildren", perm);
+ List configuredFilePermissions = asList("WriteProperties", "AddChildren");
+
+ when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
+ .thenReturn(true);
+ when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
+ .thenReturn(AccessStatus.ALLOWED);
+
+ AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
+
+ assertEquals(AccessStatus.ALLOWED, result);
+ }
+
+ /**
+ * Given the configured permissions are not set
+ * When process is called
+ * Then access is denied
+ */
+ @Test
+ public void configurePermissionsDenied()
+ {
+ AccessStatus accessStatus = AccessStatus.DENIED;
+ NodeRef nodeRef = new NodeRef("node://ref/");
+ String perm = AlfMock.generateText();
+ // permissions do not include perm created above
+ List configuredReadPermissions = asList("ReadProperties", "ReadChildren");
+ List configuredFilePermissions = asList("WriteProperties", "AddChildren");
+
+ when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
+ .thenReturn(true);
+ when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
+ .thenReturn(AccessStatus.ALLOWED);
+
+ AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
+
+ assertEquals(AccessStatus.DENIED, result);
+ }
+}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
index 506b8c03da..1bc023392e 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImplUnitTest.java
@@ -274,7 +274,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
when(recordDispositionSchedule.isRecordLevelDisposition())
.thenReturn(true);
- when(mockedDispositionService.getDispositionSchedule(record))
+ when(mockedDispositionService.getOriginDispositionSchedule(record))
.thenReturn(recordDispositionSchedule);
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java
index 48686b492f..06ca96df8a 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -146,15 +147,21 @@ public class ExtendedPermissionServiceImplUnitTest extends BaseUnitTest
{
NodeRef nodeRef = generateCmContent("anyname");
String perm = AlfMock.generateText();
+ List configuredReadPermissions = asList("ReadProperties", "ReadChildren");
+ List configuredFilePermissions = asList("WriteProperties", "AddChildren");
+
+ extendedPermissionServiceImpl.setConfiguredReadPermissions("ReadProperties,ReadChildren");
+ extendedPermissionServiceImpl.setConfiguredFilePermissions("WriteProperties,AddChildren");
+
when(mockedPermissionProcessorRegistry.getPermissionPostProcessors())
.thenReturn(asList(mockedPermissionPostProcessor));
- when(mockedPermissionPostProcessor.process(AccessStatus.UNDETERMINED, nodeRef, perm))
+ when(mockedPermissionPostProcessor.process(AccessStatus.UNDETERMINED, nodeRef, perm, configuredReadPermissions, configuredFilePermissions))
.thenReturn(AccessStatus.ALLOWED);
AccessStatus result = extendedPermissionServiceImpl.hasPermission(nodeRef, perm);
assertEquals(AccessStatus.ALLOWED, result);
- verify(mockedPermissionPostProcessor).process(AccessStatus.UNDETERMINED, nodeRef, perm);
+ verify(mockedPermissionPostProcessor).process(AccessStatus.UNDETERMINED, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
verify(extendedPermissionServiceImpl).hasPermissionImpl(nodeRef, perm);
}