From 76cd3109ea27d157e80f3bdeeef065a3b8a905a8 Mon Sep 17 00:00:00 2001 From: roxana Date: Tue, 1 Nov 2016 15:25:04 +0200 Subject: [PATCH 01/23] Changed the test a bit to check a more complex case. --- .../disposition/MultipleSchedulesTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java index 26d119210d..fc23b3390a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java @@ -34,6 +34,10 @@ public class MultipleSchedulesTest extends BaseRMTestCase 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 third category. */ + protected static final String CATEGORY_C_NAME = TEST_PREFIX + "CategoryC"; + /** The name to use for the folder within the third category. */ + protected static final String FOLDER_C_NAME = TEST_PREFIX + "FolderC"; /** The name to use for the record. */ protected static final String RECORD_NAME = TEST_PREFIX + "Record"; @@ -48,6 +52,10 @@ public class MultipleSchedulesTest extends BaseRMTestCase private NodeRef categoryB; /** The folder node within the second category. */ private NodeRef folderB; + /** The third category node. */ + private NodeRef categoryC; + /** The folder node within the third category. */ + private NodeRef folderC; /** The record node. */ private NodeRef record; @@ -82,6 +90,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase // Create two categories. categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME); categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME); + categoryC = filePlanService.createRecordCategory(filePlan, CATEGORY_C_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, @@ -103,9 +112,21 @@ public class MultipleSchedulesTest extends BaseRMTestCase PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK, PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE); dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB); + // Create a disposition schedule for category C (Cut off immediately, then Destroy one year after cutoff). + DispositionSchedule dispSchedC = utils.createBasicDispositionSchedule(categoryC, "instructions", "authority", true, false); + Map cutOffParamsC = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME, + PROP_DISPOSITION_DESCRIPTION, "description", + PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dispSchedC, cutOffParamsC); + Map destroyParamsC = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, + PROP_DISPOSITION_DESCRIPTION, "description", + PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_YEAR, + PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE); + dispositionService.addDispositionActionDefinition(dispSchedC, destroyParamsC); // Create a folder within each category. folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME); folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME); + folderC = recordFolderService.createRecordFolder(categoryC, FOLDER_C_NAME); } /** @@ -123,6 +144,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase 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); @@ -187,19 +209,22 @@ public class MultipleSchedulesTest extends BaseRMTestCase test() .given(() -> { setUpFilePlan(); - // Create a record filed under category A and linked to category B. + // Create a record filed under category A and linked to category B and C. record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef(); recordService.link(record, folderB); - }) - .when(() -> { + recordService.link(record, folderC); // Cut off the record. dispositionService.cutoffDisposableItem(record); + // Ensure the update has been applied to the record. + internalDispositionService.updateNextDispositionAction(record); + }) + .when(() -> { // Unlink the record from folder B. recordService.unlink(record, folderB); }) .then() - .expect(true) + .expect(false) .from(() -> dispositionService.isNextDispositionActionEligible(record)) - .because("Destroy action should be available, as the record should follow its origin disposition schedule."); + .because("Destroy action shouldn't be available, as the record should follow disposition schedule from category C."); } } From 23493ab550e4981930a9c1b69432b1f02fcd37fd Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 10:19:24 +0200 Subject: [PATCH 02/23] Update record disposition action as of date if it changed, to have the same value as next disposition action as of date. --- .../RecordsManagementSearchBehaviour.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 80e3aec4b4..11fc347bce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -510,12 +511,16 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - if (!methodCached("updateDispositionActionProperties", record)) + Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); + // update disposition action as of if it changed + // @since 2.3.1 + // @see https://issues.alfresco.com/jira/browse/RM-4313 + if (!methodCached("updateDispositionActionProperties", record) + || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) { Map props = nodeService.getProperties(record); - DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); @@ -553,6 +558,22 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } } } + + /** + * Check if recordSearchDispositionActionAsOf property has been changed + * + * @param currentDate current as of date value + * @param updatedDate new as of date value + * @return true if the as of date has been changed + */ + private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) + { + if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + { + return true; + } + return currentDate.compareTo(updatedDate) != 0; + } /** * On update of event execution information behaviour\ From 5200597182e8146f13532412507a334bcfdbbfe1 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 14 Oct 2016 18:41:00 +0300 Subject: [PATCH 03/23] RM-4249 - workaround : replaced maxEntries with a positive value (cherry picked from commit 995448081e3b9b54e9fdfaf6087e3d2ef371a65c) --- .../audit/RecordsManagementAuditQueryParameters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java index 4af11575b8..266cfcf3b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java @@ -31,7 +31,7 @@ import org.alfresco.service.namespace.QName; */ public final class RecordsManagementAuditQueryParameters { - private int maxEntries = -1; + private int maxEntries = Integer.MAX_VALUE; private String user; private NodeRef nodeRef; private Date dateFrom; From 71917d6d17dc02bd7d13660e8c772cee9ac58d78 Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 17:08:09 +0200 Subject: [PATCH 04/23] Revert changes and removed cache check. --- .../RecordsManagementSearchBehaviour.java | 84 +++++++------------ 1 file changed, 30 insertions(+), 54 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 11fc347bce..ed3c445788 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -511,68 +510,45 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + Map props = nodeService.getProperties(record); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - // update disposition action as of if it changed - // @since 2.3.1 - // @see https://issues.alfresco.com/jira/browse/RM-4313 - if (!methodCached("updateDispositionActionProperties", record) - || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) + + props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); + props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); + props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + if (daDefinition != null) { - Map props = nodeService.getProperties(record); - - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); - props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); - props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); - if (daDefinition != null) + Period period = daDefinition.getPeriod(); + if (period != null) { - Period period = daDefinition.getPeriod(); - if (period != null) - { - props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); - } - else - { - props.put(PROP_RS_DISPOSITION_PERIOD, null); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); - } + props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); } - - nodeService.setProperties(record, props); - - if (logger.isDebugEnabled()) + else { - logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_NAME)); - logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD)); - logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + props.put(PROP_RS_DISPOSITION_PERIOD, null); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); } } - } - - /** - * Check if recordSearchDispositionActionAsOf property has been changed - * - * @param currentDate current as of date value - * @param updatedDate new as of date value - * @return true if the as of date has been changed - */ - private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) - { - if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + + nodeService.setProperties(record, props); + + if (logger.isDebugEnabled()) { - return true; + logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_NAME)); + logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD)); + logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); } - return currentDate.compareTo(updatedDate) != 0; } /** From 4d511bd0af133439dc9d1059dd75a0ed17cda009 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Tue, 18 Oct 2016 18:28:29 +0300 Subject: [PATCH 05/23] fixed audit unit tests (cherry picked from commit e686da88de04f14b7ef2a63594df7424982e8cbc) --- .../RecordsManagementAuditServiceImplTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java index 3188b2cc65..d2245ed565 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java @@ -162,9 +162,9 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase // "audit.start", "audit.view" and "Update RM Object"; entries = getAuditTrail(3, ADMIN_USER); - assertEquals(entries.get(0).getEvent(), "audit.start"); + assertEquals(entries.get(2).getEvent(), "audit.start"); assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(0).getEvent(), "Update RM Object"); // New "audit.view" event was generated - will be visible on next getAuditTrail(). @@ -176,14 +176,14 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase nodeService.deleteNode(record); List entries = getAuditTrail(5, ADMIN_USER); - assertEquals(entries.get(0).getEvent(), "audit.start"); - assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(4).getEvent(), "audit.start"); assertEquals(entries.get(3).getEvent(), "audit.view"); + assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(1).getEvent(), "audit.view"); // Show the audit contains a reference to the deleted item: - assertEquals(entries.get(4).getEvent(), "Delete RM Object"); - assertEquals(entries.get(4).getNodeRef(), record); + assertEquals(entries.get(0).getEvent(), "Delete RM Object"); + assertEquals(entries.get(0).getNodeRef(), record); return null; } @@ -203,7 +203,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase // show the audit has been updated List entries = getAuditTrail(3, ADMIN_USER); - final RecordsManagementAuditEntry entry = entries.get(2); + final RecordsManagementAuditEntry entry = entries.get(0); assertNotNull(entry); // investigate the contents of the audit entry From 0a423f1660f0a372bd2710003a57d48e538ef21f Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 9 Nov 2016 13:17:00 +0000 Subject: [PATCH 06/23] Update version to 2.3.1. --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-server/pom.xml | 2 +- temp | 0 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 temp diff --git a/pom.xml b/pom.xml index 7d56dd2c18..9ae57a0520 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm-parent pom - 2.3.1-SNAPSHOT + 2.3.1 Alfresco Records Management http://www.alfresco.org/ diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index e88c8062f1..f59d7531ff 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-parent - 2.3.1-SNAPSHOT + 2.3.1 diff --git a/rm-server/pom.xml b/rm-server/pom.xml index 7d347cf2a7..2a3146275f 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -5,7 +5,7 @@ org.alfresco alfresco-rm-parent - 2.3.1-SNAPSHOT + 2.3.1 4.0.0 alfresco-rm-server diff --git a/temp b/temp new file mode 100644 index 0000000000..e69de29bb2 From 1476e389d6b05309d14ecb593689f00da72aad65 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 9 Nov 2016 13:48:25 +0000 Subject: [PATCH 07/23] Update version to 2.3.1.1-SNAPSHOT. --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-server/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9ae57a0520..1a202ae62d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm-parent pom - 2.3.1 + 2.3.1.1-SNAPSHOT Alfresco Records Management http://www.alfresco.org/ diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index f59d7531ff..94d74c0504 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-parent - 2.3.1 + 2.3.1.1-SNAPSHOT diff --git a/rm-server/pom.xml b/rm-server/pom.xml index 2a3146275f..63783bd4c6 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -5,7 +5,7 @@ org.alfresco alfresco-rm-parent - 2.3.1 + 2.3.1.1-SNAPSHOT 4.0.0 alfresco-rm-server From 2377d8e52068743ea73648cd28bfe2fab77da902 Mon Sep 17 00:00:00 2001 From: Mihai Cozma Date: Wed, 9 Nov 2016 17:02:14 +0000 Subject: [PATCH 08/23] Merge branch 'feature/RM-4329_Alfreco_Search_in_colaboration_site_doesn't_work' into 'master' Feature/rm 4329 alfreco search in colaboration site doesn't work See merge request !616 --- .../alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js index 9cb01a588e..32b539f396 100644 --- a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js @@ -30,18 +30,18 @@ // Additional properties will also need rendering in rmsearch.get.json.ftl. var getOriginalDocumentItem = getDocumentItem, getOriginalRepositoryItem = getRepositoryItem; -getDocumentItem = function(siteId, containerId, pathParts, node, populate){ +getDocumentItem = function(siteId, containerId, pathParts, node, populate, highlighting){ // Get original Document item. - var item = getOriginalDocumentItem(siteId, containerId, pathParts, node, populate); + var item = getOriginalDocumentItem(siteId, containerId, pathParts, node, populate, highlighting); item.nodeJSON = appUtils.toJSON(node, true); return item; }; -getRepositoryItem = function(folderPath, node, populate){ +getRepositoryItem = function(folderPath, node, populate, highlighting){ // Get Original Repo item - var item = getOriginalRepositoryItem(folderPath, node, populate); + var item = getOriginalRepositoryItem(folderPath, node, populate, highlighting); if (item.type === "document") { item.nodeJSON = appUtils.toJSON(node, true); From 46230c118128f7c4049c1cfed2cadf24bae1f3fa Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 11 Nov 2016 15:39:37 +0000 Subject: [PATCH 09/23] Remove spurious temp file. --- temp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 temp diff --git a/temp b/temp deleted file mode 100644 index e69de29bb2..0000000000 From a5da3040d75a80dcac1f74ea55e9641043929c3b Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 11 Nov 2016 18:30:14 +0200 Subject: [PATCH 10/23] RM-4357 - defined allowable operations using RM's capabilities --- .../rm-public-rest-context.xml | 1 + .../rm/rest/api/impl/RMNodesImpl.java | 76 ++++++++++++++----- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml index 2f8e766d91..2f92b31328 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml @@ -27,6 +27,7 @@ + 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 b127e2fbe1..66976f5a0b 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 @@ -37,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; 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.fileplan.FilePlanService; @@ -64,6 +65,8 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + /** * Centralizes access to the repository. * @@ -84,6 +87,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes private Repository repositoryHelper; private DictionaryService dictionaryService; private DispositionService dispositionService; + private CapabilityService capabilityService; /** * TODO to remove this after isSpecialNode is made protected in core implementation(REPO-1459) @@ -113,6 +117,11 @@ public class RMNodesImpl extends NodesImpl implements RMNodes this.filePlanService = filePlanService; } + public void setCapabilityService(CapabilityService capabilityService) + { + this.capabilityService = capabilityService; + } + @Override public Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List includeParam, Map mapUserInfo) { @@ -123,26 +132,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes nodeTypeQName = nodeService.getType(nodeRef); } - //TODO to remove this part of code after isSpecialNode will be made protected on core, will not need this anymore since the right allowed operations will be returned from core(REPO-1459). - if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS) && originalNode.getAllowableOperations() != null) - { - List allowableOperations = originalNode.getAllowableOperations(); - List modifiedAllowableOperations = new ArrayList<>(); - modifiedAllowableOperations.addAll(allowableOperations); - - for (String op : allowableOperations) - { - if (op.equals(OP_DELETE) && (isSpecialNode(nodeRef, nodeTypeQName))) - { - // special case: do not return "delete" (as an allowable op) for specific system nodes - modifiedAllowableOperations.remove(op); - } - } - - originalNode.setAllowableOperations((modifiedAllowableOperations.size() > 0 )? modifiedAllowableOperations : null); - } - - RMNodeType type = getType(nodeTypeQName, nodeRef); FileplanComponentNode node = null; if (mapUserInfo == null) @@ -193,9 +182,56 @@ public class RMNodesImpl extends NodesImpl implements RMNodes } } + if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS)) + { + node.setAllowableOperations(getAllowableOperations(nodeRef, type)); + } + return node; } + /** + * Helper method that generates allowable operation for the provided node + * @param nodeRef the node to get the allowable operations for + * @param type the type of the provided nodeRef + * @return a sublist of [{@link Nodes.OP_DELETE}, {@link Nodes.OP_CREATE}, {@link Nodes.OP_UPDATE}] representing the allowable operations for the provided node + */ + private List getAllowableOperations(NodeRef nodeRef, RMNodeType type) + { + List allowableOperations = new ArrayList<>(); + + NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + boolean isFilePlan = nodeRef.equals(filePlan); + boolean isTransferContainer = nodeRef.equals(filePlanService.getTransferContainer(filePlan)); + boolean isUnfiledContainer = nodeRef.equals(filePlanService.getUnfiledContainer(filePlan)); + boolean isHoldsContainer = nodeRef.equals(filePlanService.getHoldContainer(filePlan)) ; + boolean isSpecialContainer = isFilePlan || isTransferContainer || isUnfiledContainer || isHoldsContainer; + + // DELETE + if(!isSpecialContainer && + capabilityService.getCapability("Delete").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + { + allowableOperations.add(OP_DELETE); + } + + // CREATE + if(type != RMNodeType.FILE && + !isFilePlan && + !isTransferContainer && + capabilityService.getCapability("Create").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + { + allowableOperations.add(OP_CREATE); + } + + // UPDATE + if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + { + allowableOperations.add(OP_UPDATE); + } + + return allowableOperations; + } + @Override public NodeRef validateNode(String nodeId) { From dd86bd3cc7695633c7c9a15acf2696103e220baa Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Mon, 14 Nov 2016 18:16:04 +0200 Subject: [PATCH 11/23] RM-4357 - change addChildren capability and updated unit tests --- .../rm/rest/api/impl/RMNodesImpl.java | 2 +- .../rm/rest/api/impl/RMNodesImplUnitTest.java | 97 +++++++++++++------ 2 files changed, 66 insertions(+), 33 deletions(-) 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 66976f5a0b..20c0c2a9bd 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 @@ -218,7 +218,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes if(type != RMNodeType.FILE && !isFilePlan && !isTransferContainer && - capabilityService.getCapability("Create").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) { allowableOperations.add(OP_CREATE); } diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java index 3ae63a99c2..6e0fb649eb 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java @@ -30,7 +30,6 @@ package org.alfresco.rm.rest.api.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -45,6 +44,8 @@ import java.util.ArrayList; import java.util.List; import org.alfresco.model.ContentModel; +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; @@ -74,6 +75,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import net.sf.acegisecurity.vote.AccessDecisionVoter; + /** * Unit Test class for RMNodesImpl. * @@ -103,10 +106,17 @@ public class RMNodesImplUnitTest extends BaseUnitTest @Mock private ServiceRegistry mockedServiceRegistry; + + @Mock + private CapabilityService mockedCapabilityService; @InjectMocks private RMNodesImpl rmNodesImpl; + private Capability deleteCapability; + private Capability createCapability; + private Capability updateCapability; + @Before public void before() { @@ -117,6 +127,12 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedNamespaceService.getPrefixes(any(String.class))).thenReturn(prefixes); when(mockedNamespaceService.getNamespaceURI(any(String.class))).thenReturn(RM_URI); + deleteCapability = mock(Capability.class); + when(mockedCapabilityService.getCapability("Delete")).thenReturn(deleteCapability); + createCapability = mock(Capability.class); + when(mockedCapabilityService.getCapability("FillingPermissionOnly")).thenReturn(createCapability); + updateCapability = mock(Capability.class); + when(mockedCapabilityService.getCapability("Update")).thenReturn(updateCapability); } @Test @@ -160,19 +176,13 @@ public class RMNodesImplUnitTest extends BaseUnitTest setPermissions(nodeRef, AccessStatus.ALLOWED); + when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(nodeRef); Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - assertNotNull(folderOrDocument); - assertTrue(FileplanComponentNode.class.isInstance(folderOrDocument)); - - FileplanComponentNode resultNode = (FileplanComponentNode) folderOrDocument; - assertEquals(false, resultNode.getIsRecordFolder()); - assertEquals(false, resultNode.getIsFile()); - assertEquals(false, resultNode.getIsCategory()); - List allowableOperations = resultNode.getAllowableOperations(); - assertTrue("Create operation should be available for FilePlan.", allowableOperations.contains(RMNodes.OP_CREATE)); - assertTrue("Update operation should be available for FilePlan.", allowableOperations.contains(RMNodes.OP_UPDATE)); - assertFalse("Delete operation should note be available for FilePlan.", allowableOperations.contains(RMNodes.OP_DELETE)); + checksAllowedOperations(folderOrDocument, false, true, false); } @Test @@ -203,15 +213,15 @@ public class RMNodesImplUnitTest extends BaseUnitTest assertEquals(false, resultNode.getIsFile()); assertEquals(false, resultNode.getIsCategory()); List allowableOperations = resultNode.getAllowableOperations(); - assertNull(allowableOperations); + assertEquals(0, allowableOperations.size()); } @Test public void testGetTransferContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_TRANSFER_CONTAINER); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_TRANSFER_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -224,16 +234,22 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(nodeRef); + when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + + when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); + Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checkSpecialContainersAllowedOperations(folderOrDocument); + checksAllowedOperations(folderOrDocument, false, false, false); } @Test public void testGetHoldContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_HOLD_CONTAINER); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_HOLD_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -250,16 +266,22 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(nodeRef); + when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + + when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); + Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checkSpecialContainersAllowedOperations(folderOrDocument); + checksAllowedOperations(folderOrDocument, true, false, false); } @Test public void testGetUnfiledContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -279,8 +301,14 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getUnfiledContainer(filePlanNodeRef)).thenReturn(nodeRef); + when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + + when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); + Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checkSpecialContainersAllowedOperations(folderOrDocument); + checksAllowedOperations(folderOrDocument, true, false, false); } @Test @@ -741,18 +769,23 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedPermissionService.hasPermission(nodeRef, PermissionService.ADD_CHILDREN)).thenReturn(permissionToSet); } - private void checkSpecialContainersAllowedOperations(Node containerNode) + private void checksAllowedOperations(Node containerNode, boolean allowCreate, boolean allowUpdate, boolean allowDelete) { assertNotNull(containerNode); - assertTrue(RecordCategoryNode.class.isInstance(containerNode)); - - RecordCategoryNode resultNode = (RecordCategoryNode) containerNode; - assertEquals(false, resultNode.getIsRecordFolder()); - assertEquals(false, resultNode.getIsFile()); - assertEquals(true, resultNode.getIsCategory()); + assertTrue(FileplanComponentNode.class.isInstance(containerNode)); + FileplanComponentNode resultNode = (FileplanComponentNode) containerNode; List allowableOperations = resultNode.getAllowableOperations(); - assertTrue("Create operation should be available for provided container.", allowableOperations.contains(RMNodes.OP_CREATE)); - assertTrue("Update operation should be available for provided container.", allowableOperations.contains(RMNodes.OP_UPDATE)); - assertFalse("Delete operation should note be available for provided container.", allowableOperations.contains(RMNodes.OP_DELETE)); + + assertEquals("Create operation should " + (allowCreate?"":"not ") + "be available for provided container.", + allowCreate, + allowableOperations.contains(RMNodes.OP_CREATE)); + + assertEquals("Update operation should " + (allowCreate?"":"not ") + "be available for provided container.", + allowUpdate, + allowableOperations.contains(RMNodes.OP_UPDATE)); + + assertEquals("Delete operation should " + (allowCreate?"":"not ") + "be available for provided container.", + allowDelete, + allowableOperations.contains(RMNodes.OP_DELETE)); } } From 14cde7a0f4672f9ea63feb38f4e26ab556c84c74 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Tue, 15 Nov 2016 10:47:11 +0200 Subject: [PATCH 12/23] RM-4357 - added spcial container check for update --- .../source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 20c0c2a9bd..d15ee2aaef 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 @@ -224,7 +224,8 @@ public class RMNodesImpl extends NodesImpl implements RMNodes } // UPDATE - if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + if ( !isTransferContainer && !isUnfiledContainer && !isHoldsContainer && + capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) { allowableOperations.add(OP_UPDATE); } From 7ab2f753ade9804544b641932fb7491fc7937c80 Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Tue, 15 Nov 2016 19:00:48 +0200 Subject: [PATCH 13/23] RM-4293: prevent filePlan and unfiled Record container from behaviour beans, also removed deleteNode method from RMNodesImpl and some unit tests --- .../rm-model-context.xml | 2 + .../model/rma/type/FilePlanType.java | 64 +++++++++- .../model/rma/type/RmSiteType.java | 19 +++ .../rma/type/UnfiledRecordContainerType.java | 35 ++++- .../rm/rest/api/impl/RMNodesImpl.java | 20 --- .../rm/rest/api/impl/RMNodesImplUnitTest.java | 120 ------------------ 6 files changed, 116 insertions(+), 144 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index fe6cedfd6d..8a26e80449 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -76,6 +76,7 @@ + @@ -112,6 +113,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index 3cc8cba850..3fe97f36d0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -37,6 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; @@ -61,10 +62,12 @@ import org.alfresco.service.namespace.QName; public class FilePlanType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy, - NodeServicePolicies.OnDeleteNodePolicy + NodeServicePolicies.OnDeleteNodePolicy, + NodeServicePolicies.BeforeDeleteNodePolicy { private final static List ACCEPTED_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD_CONTAINER, TYPE_TRANSFER_CONTAINER, TYPE_UNFILED_RECORD_CONTAINER); private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY); + private static final String BEHAVIOUR_NAME = "onDeleteFilePlan"; /** file plan service */ private FilePlanService filePlanService; @@ -78,6 +81,8 @@ public class FilePlanType extends BaseBehaviourBean /** file plan role service */ private FilePlanRoleService filePlanRoleService; + private UnfiledRecordContainerType unfilerRecordContainerType; + /** * @return File plan service */ @@ -142,6 +147,31 @@ public class FilePlanType extends BaseBehaviourBean this.filePlanRoleService = filePlanRoleService; } + public void setUnfilerRecordContainerType(UnfiledRecordContainerType unfilerRecordContainerType) + { + this.unfilerRecordContainerType = unfilerRecordContainerType; + } + + + /** + * Disable the behaviours for this transaction + * + */ + public void disable() + { + getBehaviour(BEHAVIOUR_NAME).disable(); + } + + /** + * Enable behaviours for this transaction + * + */ + public void enable() + { + getBehaviour(BEHAVIOUR_NAME).enable(); + } + + /** * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) */ @@ -194,15 +224,43 @@ public class FilePlanType extends BaseBehaviourBean /** * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) */ + @Override @Behaviour ( kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT, + name = BEHAVIOUR_NAME + ) + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived) + { + unfilerRecordContainerType.enable(); + throw new IntegrityException("Operation failed. Deletion of File Plan is not allowed.", null); + } + + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.FIRST_EVENT + ) + public void beforeDeleteNode(NodeRef nodeRef) + { + unfilerRecordContainerType.disable(); + } + + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:onDeleteNode", notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT ) - @Override - public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived) + public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean archived) { // tear down the file plan roles getFilePlanRoleService().tearDownFilePlanRoles(childAssocRef.getChildRef()); + unfilerRecordContainerType.enable(); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 82eb0b57ac..40b7842c08 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -97,6 +97,8 @@ public class RmSiteType extends BaseBehaviourBean /** Authority service */ private AuthorityService authorityService; + private FilePlanType filePlanType; + /** Map of file plan type's key'ed by corresponding site types */ protected Map mapFilePlanType = new HashMap(3); @@ -133,6 +135,11 @@ public class RmSiteType extends BaseBehaviourBean this.authorityService = authorityService; } + public void setFilePlanType(FilePlanType filePlanType) + { + this.filePlanType = filePlanType; + } + /** * Registers a file plan type for a specific site type. * @@ -302,6 +309,7 @@ public class RmSiteType extends BaseBehaviourBean return null; } }); + filePlanType.disable(); } } } @@ -354,4 +362,15 @@ public class RmSiteType extends BaseBehaviourBean throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null); } } + + @Behaviour + ( + kind = BehaviourKind.CLASS, + policy = "alf:onDeleteNode", + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + filePlanType.enable(); + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java index b0b78a9bbb..4c0c1e9df9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java @@ -33,6 +33,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; @@ -47,9 +48,30 @@ import org.alfresco.service.namespace.QName; */ @BehaviourBean(defaultType = "rma:unfiledRecordContainer") public class UnfiledRecordContainerType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnDeleteNodePolicy { + private static final String BEHAVIOUR_NAME = "onDeleteUnfiledRecordContainer"; private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_UNFILED_RECORD_FOLDER, ContentModel.TYPE_CONTENT, TYPE_NON_ELECTRONIC_DOCUMENT); + + /** + * Disable the behaviours for this transaction + * + */ + public void disable() + { + getBehaviour(BEHAVIOUR_NAME).disable(); + } + + /** + * Enable behaviours for this transaction + * + */ + public void enable() + { + getBehaviour(BEHAVIOUR_NAME).enable(); + } + @Override @Behaviour(kind = BehaviourKind.ASSOCIATION) public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) @@ -57,4 +79,15 @@ public class UnfiledRecordContainerType extends BaseBehaviourBean // check the created child is of an accepted type validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES); } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = BEHAVIOUR_NAME + ) + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + throw new IntegrityException("Operation failed. Deletion of Unfiled Record Container is not allowed.", null); + } } 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 b127e2fbe1..97a1bc9e3c 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 @@ -48,8 +48,6 @@ import org.alfresco.rest.api.impl.NodesImpl; import org.alfresco.rest.api.model.Node; import org.alfresco.rest.api.model.UserInfo; import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; -import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; -import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rm.rest.api.RMNodes; import org.alfresco.rm.rest.api.model.FileplanComponentNode; import org.alfresco.rm.rest.api.model.RecordCategoryNode; @@ -380,22 +378,4 @@ public class RMNodesImpl extends NodesImpl implements RMNodes return false; } - - /** - * Overridden this method just in order to use our isSpecialNode method since core method could not be overridden. - * - * TODO remove this after isSpecialNode will be made protected in core(REPO-1459). - */ - @Override - public void deleteNode(String nodeId, Parameters parameters) - { - NodeRef nodeRef = validateOrLookupNode(nodeId, null); - QName nodeType = nodeService.getType(nodeRef); - - if (isSpecialNode(nodeRef, nodeType)) - { - throw new PermissionDeniedException("Cannot delete: " + nodeId); - } - super.deleteNode(nodeId, parameters); - } } diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java index 3ae63a99c2..a584ffc75b 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java @@ -35,9 +35,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.security.InvalidParameterException; @@ -52,8 +49,6 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; import org.alfresco.repo.model.Repository; import org.alfresco.rest.api.model.Node; import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; -import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; -import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rm.rest.api.RMNodes; import org.alfresco.rm.rest.api.model.FileplanComponentNode; import org.alfresco.rm.rest.api.model.RecordCategoryNode; @@ -609,121 +604,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest assertEquals(nodeRef, validateOrLookupNode); } - @Test - public void testDeleteNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - setupCompanyHomeAndPrimaryParent(nodeRef); - - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - verify(mockedFileFolderService, times(1)).delete(nodeRef); - } - - @Test - public void testDeleteFileplanNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as filePlan can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteTransfersContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Trnsfers container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteHoldsContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - - NodeRef transferContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(transferContainerNodeRef); - - when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Holds container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteUnfiledRecordsContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - - NodeRef transferContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(transferContainerNodeRef); - - NodeRef holdContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(holdContainerNodeRef); - - when(mockedFilePlanService.getUnfiledContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Unfiled Records container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - private void setupCompanyHomeAndPrimaryParent(NodeRef nodeRef) { NodeRef companyHomeNodeRef = AlfMock.generateNodeRef(mockedNodeService); From bee71d2dbd6b1d66f850b72bd204cb64eb882cda Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Wed, 16 Nov 2016 15:09:58 +0200 Subject: [PATCH 14/23] RM-4293: created capabilities for deleting transfer container and hold container and restricted the deletion from behaviour beans --- .../rm/fileplancomponents/FilePlanTests.java | 36 ++++++++++++++++++- .../rm-capabilities-fileplan-context.xml | 19 ++++++++++ .../rm-capabilities-group-context.xml | 2 ++ .../rm-model-context.xml | 2 ++ .../model/rma/type/FilePlanType.java | 19 ++++++++++ .../model/rma/type/HoldContainerType.java | 34 +++++++++++++++++- .../model/rma/type/TransferContainerType.java | 19 +++++++++- 7 files changed, 128 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java index 574f4f14bb..c644d61c4e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java @@ -198,7 +198,7 @@ public class FilePlanTests extends BaseRestTest /** * Given that a file plan exists * When I ask the API to delete the file plan - * Then the 403 response code is returned. + * Then the 422 response code is returned. */ @Test ( @@ -217,6 +217,40 @@ public class FilePlanTests extends BaseRestTest // Delete the file plan component filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString()); + // Check the DELETE response status code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + } + + /** + * Given that a file plan exists and I am a non RM user + * When I ask the API to delete the file plan + * Then the 403 response code is returned. + */ + @Test + ( + description = "Check the response code when deleting the special file plan components with non RM user", + dataProviderClass = TestData.class, + dataProvider = "getContainers" + ) + public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception + { + // Create RM Site if doesn't exist + createRMSiteIfNotExists(); + + // Disconnect the current user from the API session + rmSiteAPI.usingRestWrapper().disconnect(); + // Authenticate admin user to Alfresco REST API + restClient.authenticateUser(dataUser.getAdminUser()); + + // Create a random user + UserModel nonRMuser = dataUser.createRandomTestUser("testUser"); + + // Authenticate using the random user + filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser); + + // Delete the file plan component + filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString()); + // Check the DELETE response status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); } diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index e8eeae8602..02a69e2521 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -94,4 +94,23 @@ + + + + + TRANSFER_CONTAINER + + + + + + + + + HOLD_CONTAINER + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml index 91a50ef89d..3b67d92639 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml @@ -25,6 +25,8 @@ + + diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 8a26e80449..aba5909bb3 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -77,6 +77,8 @@ + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index 3fe97f36d0..6d2684b0ce 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -83,6 +83,10 @@ public class FilePlanType extends BaseBehaviourBean private UnfiledRecordContainerType unfilerRecordContainerType; + private TransferContainerType transferContainerType; + + private HoldContainerType holdContainerType; + /** * @return File plan service */ @@ -152,6 +156,15 @@ public class FilePlanType extends BaseBehaviourBean this.unfilerRecordContainerType = unfilerRecordContainerType; } + public void setTransferContainerType(TransferContainerType transferContainerType) + { + this.transferContainerType = transferContainerType; + } + + public void setHoldContainerType(HoldContainerType holdContainerType) + { + this.holdContainerType = holdContainerType; + } /** * Disable the behaviours for this transaction @@ -234,6 +247,8 @@ public class FilePlanType extends BaseBehaviourBean public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived) { unfilerRecordContainerType.enable(); + transferContainerType.enable(); + holdContainerType.enable(); throw new IntegrityException("Operation failed. Deletion of File Plan is not allowed.", null); } @@ -249,6 +264,8 @@ public class FilePlanType extends BaseBehaviourBean public void beforeDeleteNode(NodeRef nodeRef) { unfilerRecordContainerType.disable(); + transferContainerType.disable(); + holdContainerType.disable(); } @Behaviour @@ -262,5 +279,7 @@ public class FilePlanType extends BaseBehaviourBean // tear down the file plan roles getFilePlanRoleService().tearDownFilePlanRoles(childAssocRef.getChildRef()); unfilerRecordContainerType.enable(); + transferContainerType.enable(); + holdContainerType.enable(); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java index 989b92699b..2326b41f64 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java @@ -33,6 +33,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; @@ -49,10 +50,31 @@ import org.springframework.extensions.surf.util.I18NUtil; */ @BehaviourBean(defaultType = "rma:holdContainer") public class HoldContainerType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnCreateNodePolicy, + NodeServicePolicies.OnDeleteNodePolicy { private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container"; private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD); + private static final String DELETE_BEHAVIOUR_NAME = "onDeleteHoldContainer"; + + /** + * Disable the behaviours for this transaction + * + */ + public void disable() + { + getBehaviour(DELETE_BEHAVIOUR_NAME).disable(); + } + + /** + * Enable behaviours for this transaction + * + */ + public void enable() + { + getBehaviour(DELETE_BEHAVIOUR_NAME).enable(); + } /** * On every event @@ -74,6 +96,16 @@ public class HoldContainerType extends BaseBehaviourBean NodeRef nodeRef = childAssocRef.getChildRef(); if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT) == true) { throw new AlfrescoRuntimeException( I18NUtil.getMessage(MSG_ERROR_ADD_CONTENT_CONTAINER)); } + } + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = DELETE_BEHAVIOUR_NAME + ) + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + throw new IntegrityException("Operation failed. Deletion of Hold Container is not allowed.", null); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java index d0fba4ff99..6fb4cca3ef 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java @@ -46,11 +46,15 @@ import org.springframework.extensions.surf.util.I18NUtil; */ @BehaviourBean(defaultType = "rma:transferContainer") public class TransferContainerType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnCreateNodePolicy, + NodeServicePolicies.OnDeleteNodePolicy + { private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container"; private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER = "rm.action.create.transfer.container.child-error-message"; private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferContainer"; + private static final String DELETE_BEHAVIOUR_NAME = "onDeleteTransferContainer"; /** * Disable the behaviours for this transaction @@ -59,6 +63,7 @@ public class TransferContainerType extends BaseBehaviourBean public void disable() { getBehaviour(BEHAVIOUR_NAME).disable(); + getBehaviour(DELETE_BEHAVIOUR_NAME).disable(); } /** @@ -68,6 +73,7 @@ public class TransferContainerType extends BaseBehaviourBean public void enable() { getBehaviour(BEHAVIOUR_NAME).enable(); + getBehaviour(DELETE_BEHAVIOUR_NAME).enable(); } /** @@ -94,4 +100,15 @@ public class TransferContainerType extends BaseBehaviourBean if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT) == true) { throw new AlfrescoRuntimeException( I18NUtil.getMessage(MSG_ERROR_ADD_CONTENT_CONTAINER)); } } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = DELETE_BEHAVIOUR_NAME + ) + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + throw new IntegrityException("Operation failed. Deletion of Transfer Container is not allowed.", null); + } } From abcfede1ae1f5e54cbc04a669b114a93d696863f Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 16 Nov 2016 15:33:11 +0200 Subject: [PATCH 15/23] RM-4357 - updated allowable operations to reflect the edit permissions changes for special containers made in RM-4373 --- .../source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 d15ee2aaef..20c0c2a9bd 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 @@ -224,8 +224,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes } // UPDATE - if ( !isTransferContainer && !isUnfiledContainer && !isHoldsContainer && - capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) + if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) { allowableOperations.add(OP_UPDATE); } From f3626a28a8d7e517db14317e3b44ba5628f01539 Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Wed, 16 Nov 2016 15:40:37 +0200 Subject: [PATCH 16/23] RM-4293: added integration test for testing special containers through java api --- .../test/integration/issue/RM4293Test.java | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java new file mode 100644 index 0000000000..aac6266d89 --- /dev/null +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java @@ -0,0 +1,126 @@ +/* + * #%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.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.node.integrity.IntegrityException; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test for RM-4293 + * + * @author Silviu Dinuta + * @since 2.6 + * + */ +public class RM4293Test extends BaseRMTestCase +{ + public void testDeleteSpecialContainers() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + assertNotNull(holdContainer); + + try + { + fileFolderService.delete(holdContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Hold Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + assertNotNull(transferContainer); + try + { + fileFolderService.delete(transferContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Transfer Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); + assertNotNull(unfiledRecordContainer); + + try + { + fileFolderService.delete(unfiledRecordContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Unfiled Record Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + try + { + fileFolderService.delete(filePlan); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("FilePlan can't be deleted.") + } + return null; + } + }); + } +} From 87f03919227c9bd084f54155e4b8b38964033f0b Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 16 Nov 2016 16:19:16 +0200 Subject: [PATCH 17/23] RM-4357 - updated unit tests --- .../rm/rest/api/impl/RMNodesImplUnitTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java index 6e0fb649eb..abbb8e9aa7 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java @@ -236,12 +236,12 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, false, false, false); + checksAllowedOperations(folderOrDocument, false, true, false); } @Test @@ -268,12 +268,12 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, true, false, false); + checksAllowedOperations(folderOrDocument, true, true, false); } @Test @@ -303,12 +303,12 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_DENIED); + when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, true, false, false); + checksAllowedOperations(folderOrDocument, true, true, false); } @Test From 8d677d6a8d52a659680f98842710051e80553ddb Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Wed, 16 Nov 2016 17:14:00 +0200 Subject: [PATCH 18/23] RM-4293: after discussion with Ana for delete we need filing condition --- .../capability/rm-capabilities-fileplan-context.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index 02a69e2521..676aff4f5c 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -102,6 +102,11 @@ TRANSFER_CONTAINER + + + + + HOLD_CONTAINER + + + + + \ No newline at end of file From 3e1d740d76f269188d598fba162760b557b8ba14 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 16 Nov 2016 22:01:38 +0000 Subject: [PATCH 19/23] RM-4378: Changed @since value from 1.0 to 2.6 --- .../rest/rm/model/fileplancomponents/FilePlanComponent.java | 2 +- .../rm/model/fileplancomponents/FilePlanComponentAlias.java | 2 +- .../rm/model/fileplancomponents/FilePlanComponentEntry.java | 2 +- .../rm/model/fileplancomponents/FilePlanComponentFields.java | 2 +- .../model/fileplancomponents/FilePlanComponentIdNamePair.java | 2 +- .../rest/rm/model/fileplancomponents/FilePlanComponentPath.java | 2 +- .../model/fileplancomponents/FilePlanComponentProperties.java | 2 +- .../rest/rm/model/fileplancomponents/FilePlanComponentType.java | 2 +- .../rm/model/fileplancomponents/FilePlanComponentUserInfo.java | 2 +- .../model/fileplancomponents/FilePlanComponentsCollection.java | 2 +- .../alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java | 2 +- .../src/main/java/org/alfresco/rest/rm/model/site/RMSite.java | 2 +- .../java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java | 2 +- .../main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java | 2 +- .../org/alfresco/rest/rm/requests/FilePlanComponentAPI.java | 2 +- .../src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java | 2 +- .../src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java | 2 +- .../java/org/alfresco/rest/rm/base/AllowableOperations.java | 2 +- .../src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java | 2 +- .../src/test/java/org/alfresco/rest/rm/base/TestData.java | 2 +- .../org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java | 2 +- .../alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java | 2 +- .../alfresco/rest/rm/fileplancomponents/RecordFolderTests.java | 2 +- .../src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java index 6a9f1691a4..0843a5e840 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * POJO for file plan component * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponent { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java index c4ace365e8..e5929014f8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java @@ -17,7 +17,7 @@ import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString; * File plan component alias enumeration * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum FilePlanComponentAlias { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java index 3d3bd42609..70bd836090 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java @@ -21,7 +21,7 @@ import org.alfresco.rest.core.RestModels; * POJO for file plan component entry * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentEntry extends RestModels { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java index 7fc8c356df..9d8415d960 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * File plan component field names constants * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentFields { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java index 019085c12a..a7d5f1f9c3 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for id/name pair * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentIdNamePair { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java index 084b2c08ad..3e75c01396 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * POJO for FilePlanComponent path parameter *
* @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ @JsonIgnoreProperties(ignoreUnknown = true) public class FilePlanComponentPath diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java index 5f40de6f83..a7179e831a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * POJO for file plan component properties * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ //FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed @JsonIgnoreProperties (ignoreUnknown = true) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java index aa4eda6563..498be5e202 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java @@ -17,7 +17,7 @@ import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString; * File plan component type enumeration * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum FilePlanComponentType { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java index 2a79da8b9e..7983cd9250 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for file plan component created by object * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentUserInfo { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java index 0b50a94d56..5cee5e7629 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java @@ -17,7 +17,7 @@ import org.alfresco.rest.core.RestModels; * Handle collection of FilePlanComponents * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentsCollection extends RestModels { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java index ba7fa00564..c96a2bc9f9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java @@ -4,7 +4,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for the review period * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class ReviewPeriod { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java index c68d56bf96..08846558f9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java @@ -19,7 +19,7 @@ import org.alfresco.rest.model.RestSiteModel; * POJO for RM Site component * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSite extends RestSiteModel { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java index c2b57860bf..96b16a678d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.site; * RM Site compliance * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum RMSiteCompliance { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java index 075b9e1b87..4dd9cf918d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java @@ -24,7 +24,7 @@ package org.alfresco.rest.rm.model.site; *} * @author Tuna Aksoy * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSiteFields { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java index de87b72593..a29146e434 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java @@ -33,7 +33,7 @@ import org.springframework.stereotype.Component; * * @author Tuna Aksoy * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ @Component @Scope(value = "prototype") diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java index 44ed0e9c38..11e5ca45ba 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java @@ -31,7 +31,7 @@ import org.springframework.stereotype.Component; * * @author Tuna Aksoy * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ @Component @Scope (value = "prototype") diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java index 49e7a56eb5..462d832ff4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java @@ -17,7 +17,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank; * Utility class for checking parameters * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class ParameterCheck { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java index d11d730c9d..e50a7f07ff 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.base; * List of allowable operations * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class AllowableOperations { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java index 6129987124..089120d436 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java @@ -50,7 +50,7 @@ import org.testng.annotations.BeforeClass; * * @author Kristijan Conkas * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ @Configuration @PropertySource("classpath:default.properties") diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java index 9adde5de57..45acbf1662 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java @@ -27,7 +27,7 @@ import org.testng.annotations.DataProvider; * Test data used in tests * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public interface TestData { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java index 574f4f14bb..3c9bb4b5a2 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java @@ -52,7 +52,7 @@ import org.testng.annotations.Test; * the File Plan CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class FilePlanTests extends BaseRestTest { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java index d1f18bd2eb..2a6c30f329 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java @@ -51,7 +51,7 @@ import org.testng.annotations.Test; * * @author Kristijan Conkas * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class RecordCategoryTest extends BaseRestTest { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java index 0c9b1e8de5..9b0fd45e1a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java @@ -61,7 +61,7 @@ import org.testng.annotations.Test; * the Record Folder CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RecordFolderTests extends BaseRestTest { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java index c3bee9cfab..3919935fac 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java @@ -51,7 +51,7 @@ import org.testng.annotations.Test; * the RM site CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSiteTests extends BaseRestTest { From 1cfc8e93d6fb7f4357f2e07b38c6a29bbdf7d0d7 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 17 Nov 2016 10:26:58 +0200 Subject: [PATCH 20/23] RM-4357 - allow create children for fileplan --- .../source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java | 1 - 1 file changed, 1 deletion(-) 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 20c0c2a9bd..b5bd4267f3 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 @@ -216,7 +216,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes // CREATE if(type != RMNodeType.FILE && - !isFilePlan && !isTransferContainer && capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) { From cad88f867971646aede903edac102bfad970bc07 Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Thu, 17 Nov 2016 10:45:58 +0200 Subject: [PATCH 21/23] RM-4293: review updates --- .../rm-capabilities-fileplan-context.xml | 2 ++ .../model/rma/type/FilePlanType.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index 676aff4f5c..b7d1e33fd6 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -107,6 +107,7 @@
+ + \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index 6d2684b0ce..94c496ac8b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -81,10 +81,19 @@ public class FilePlanType extends BaseBehaviourBean /** file plan role service */ private FilePlanRoleService filePlanRoleService; + /** + * Unfiled Record Container Type behaviour bean + */ private UnfiledRecordContainerType unfilerRecordContainerType; + /** + * Transfer Container Type behaviour bean + */ private TransferContainerType transferContainerType; + /** + * Hold Container Type behaviour bean + */ private HoldContainerType holdContainerType; /** @@ -151,16 +160,25 @@ public class FilePlanType extends BaseBehaviourBean this.filePlanRoleService = filePlanRoleService; } + /** + * @param unfilerRecordContainerType - unfiled record container type behaviour bean + */ public void setUnfilerRecordContainerType(UnfiledRecordContainerType unfilerRecordContainerType) { this.unfilerRecordContainerType = unfilerRecordContainerType; } + /** + * @param transferContainerType - transfer container type behaviour bean + */ public void setTransferContainerType(TransferContainerType transferContainerType) { this.transferContainerType = transferContainerType; } + /** + * @param holdContainerType - hold container type behaviour bean + */ public void setHoldContainerType(HoldContainerType holdContainerType) { this.holdContainerType = holdContainerType; From 4d3703ba100fdd45ac894a162be6a1691b930ac1 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 17 Nov 2016 10:52:00 +0200 Subject: [PATCH 22/23] Revert "Merge branch 'feature/RM-4357_AllowableOperations' into 'master'" This reverts commit 20e9fc986b20cd441ed0d19cb839d59a951e836c, reversing changes made to efe4165c9d71eb2213a89c2e30f3a23e42bc2237. --- .../source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java | 1 + 1 file changed, 1 insertion(+) 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 b5bd4267f3..20c0c2a9bd 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 @@ -216,6 +216,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes // CREATE if(type != RMNodeType.FILE && + !isFilePlan && !isTransferContainer && capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) { From 521a0689a301238be528f2464f03da40f984f9a3 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 17 Nov 2016 10:52:40 +0200 Subject: [PATCH 23/23] Revert "Merge branch 'feature/RM-4357_AllowableOperations' into 'master'" This reverts commit 9b658e2452f2b4c18be08acb9e03eed607b7e2ff, reversing changes made to 3e1d740d76f269188d598fba162760b557b8ba14. --- .../rm-public-rest-context.xml | 1 - .../rm/rest/api/impl/RMNodesImpl.java | 76 ++++----------- .../rm/rest/api/impl/RMNodesImplUnitTest.java | 97 ++++++------------- 3 files changed, 52 insertions(+), 122 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml index 2f92b31328..2f8e766d91 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml @@ -27,7 +27,6 @@ - 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 20c0c2a9bd..b127e2fbe1 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 @@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; 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.fileplan.FilePlanService; @@ -65,8 +64,6 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - /** * Centralizes access to the repository. * @@ -87,7 +84,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes private Repository repositoryHelper; private DictionaryService dictionaryService; private DispositionService dispositionService; - private CapabilityService capabilityService; /** * TODO to remove this after isSpecialNode is made protected in core implementation(REPO-1459) @@ -117,11 +113,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes this.filePlanService = filePlanService; } - public void setCapabilityService(CapabilityService capabilityService) - { - this.capabilityService = capabilityService; - } - @Override public Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List includeParam, Map mapUserInfo) { @@ -132,6 +123,26 @@ public class RMNodesImpl extends NodesImpl implements RMNodes nodeTypeQName = nodeService.getType(nodeRef); } + //TODO to remove this part of code after isSpecialNode will be made protected on core, will not need this anymore since the right allowed operations will be returned from core(REPO-1459). + if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS) && originalNode.getAllowableOperations() != null) + { + List allowableOperations = originalNode.getAllowableOperations(); + List modifiedAllowableOperations = new ArrayList<>(); + modifiedAllowableOperations.addAll(allowableOperations); + + for (String op : allowableOperations) + { + if (op.equals(OP_DELETE) && (isSpecialNode(nodeRef, nodeTypeQName))) + { + // special case: do not return "delete" (as an allowable op) for specific system nodes + modifiedAllowableOperations.remove(op); + } + } + + originalNode.setAllowableOperations((modifiedAllowableOperations.size() > 0 )? modifiedAllowableOperations : null); + } + + RMNodeType type = getType(nodeTypeQName, nodeRef); FileplanComponentNode node = null; if (mapUserInfo == null) @@ -182,56 +193,9 @@ public class RMNodesImpl extends NodesImpl implements RMNodes } } - if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS)) - { - node.setAllowableOperations(getAllowableOperations(nodeRef, type)); - } - return node; } - /** - * Helper method that generates allowable operation for the provided node - * @param nodeRef the node to get the allowable operations for - * @param type the type of the provided nodeRef - * @return a sublist of [{@link Nodes.OP_DELETE}, {@link Nodes.OP_CREATE}, {@link Nodes.OP_UPDATE}] representing the allowable operations for the provided node - */ - private List getAllowableOperations(NodeRef nodeRef, RMNodeType type) - { - List allowableOperations = new ArrayList<>(); - - NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - boolean isFilePlan = nodeRef.equals(filePlan); - boolean isTransferContainer = nodeRef.equals(filePlanService.getTransferContainer(filePlan)); - boolean isUnfiledContainer = nodeRef.equals(filePlanService.getUnfiledContainer(filePlan)); - boolean isHoldsContainer = nodeRef.equals(filePlanService.getHoldContainer(filePlan)) ; - boolean isSpecialContainer = isFilePlan || isTransferContainer || isUnfiledContainer || isHoldsContainer; - - // DELETE - if(!isSpecialContainer && - capabilityService.getCapability("Delete").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) - { - allowableOperations.add(OP_DELETE); - } - - // CREATE - if(type != RMNodeType.FILE && - !isFilePlan && - !isTransferContainer && - capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) - { - allowableOperations.add(OP_CREATE); - } - - // UPDATE - if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED) - { - allowableOperations.add(OP_UPDATE); - } - - return allowableOperations; - } - @Override public NodeRef validateNode(String nodeId) { diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java index abbb8e9aa7..3ae63a99c2 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java @@ -30,6 +30,7 @@ package org.alfresco.rm.rest.api.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -44,8 +45,6 @@ import java.util.ArrayList; import java.util.List; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.capability.Capability; -import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; @@ -75,8 +74,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import net.sf.acegisecurity.vote.AccessDecisionVoter; - /** * Unit Test class for RMNodesImpl. * @@ -106,17 +103,10 @@ public class RMNodesImplUnitTest extends BaseUnitTest @Mock private ServiceRegistry mockedServiceRegistry; - - @Mock - private CapabilityService mockedCapabilityService; @InjectMocks private RMNodesImpl rmNodesImpl; - private Capability deleteCapability; - private Capability createCapability; - private Capability updateCapability; - @Before public void before() { @@ -127,12 +117,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedNamespaceService.getPrefixes(any(String.class))).thenReturn(prefixes); when(mockedNamespaceService.getNamespaceURI(any(String.class))).thenReturn(RM_URI); - deleteCapability = mock(Capability.class); - when(mockedCapabilityService.getCapability("Delete")).thenReturn(deleteCapability); - createCapability = mock(Capability.class); - when(mockedCapabilityService.getCapability("FillingPermissionOnly")).thenReturn(createCapability); - updateCapability = mock(Capability.class); - when(mockedCapabilityService.getCapability("Update")).thenReturn(updateCapability); } @Test @@ -176,13 +160,19 @@ public class RMNodesImplUnitTest extends BaseUnitTest setPermissions(nodeRef, AccessStatus.ALLOWED); - when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(nodeRef); Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, false, true, false); + assertNotNull(folderOrDocument); + assertTrue(FileplanComponentNode.class.isInstance(folderOrDocument)); + + FileplanComponentNode resultNode = (FileplanComponentNode) folderOrDocument; + assertEquals(false, resultNode.getIsRecordFolder()); + assertEquals(false, resultNode.getIsFile()); + assertEquals(false, resultNode.getIsCategory()); + List allowableOperations = resultNode.getAllowableOperations(); + assertTrue("Create operation should be available for FilePlan.", allowableOperations.contains(RMNodes.OP_CREATE)); + assertTrue("Update operation should be available for FilePlan.", allowableOperations.contains(RMNodes.OP_UPDATE)); + assertFalse("Delete operation should note be available for FilePlan.", allowableOperations.contains(RMNodes.OP_DELETE)); } @Test @@ -213,15 +203,15 @@ public class RMNodesImplUnitTest extends BaseUnitTest assertEquals(false, resultNode.getIsFile()); assertEquals(false, resultNode.getIsCategory()); List allowableOperations = resultNode.getAllowableOperations(); - assertEquals(0, allowableOperations.size()); + assertNull(allowableOperations); } @Test public void testGetTransferContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_TRANSFER_CONTAINER); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_TRANSFER_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -234,22 +224,16 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(nodeRef); - when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - - when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); - Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, false, true, false); + checkSpecialContainersAllowedOperations(folderOrDocument); } @Test public void testGetHoldContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_HOLD_CONTAINER); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_HOLD_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -266,22 +250,16 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(nodeRef); - when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - - when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); - Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, true, true, false); + checkSpecialContainersAllowedOperations(folderOrDocument); } @Test public void testGetUnfiledContainerAllowableOperations() throws Exception { NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER); - when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER, ContentModel.TYPE_FOLDER)).thenReturn(true); + when(mockedNodeService.getType(nodeRef)).thenReturn(RecordsManagementModel.TYPE_RECORD_CATEGORY); + when(mockedDictionaryService.isSubClass(RecordsManagementModel.TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER)).thenReturn(true); setupCompanyHomeAndPrimaryParent(nodeRef); @@ -301,14 +279,8 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedFilePlanService.getUnfiledContainer(filePlanNodeRef)).thenReturn(nodeRef); - when(deleteCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(createCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - when(updateCapability.evaluate(nodeRef)).thenReturn(AccessDecisionVoter.ACCESS_GRANTED); - - when(mockedFilePlanService.isFilePlanComponent(nodeRef)).thenReturn(true); - Node folderOrDocument = rmNodesImpl.getFolderOrDocument(nodeRef, null, null, includeParamList, null); - checksAllowedOperations(folderOrDocument, true, true, false); + checkSpecialContainersAllowedOperations(folderOrDocument); } @Test @@ -769,23 +741,18 @@ public class RMNodesImplUnitTest extends BaseUnitTest when(mockedPermissionService.hasPermission(nodeRef, PermissionService.ADD_CHILDREN)).thenReturn(permissionToSet); } - private void checksAllowedOperations(Node containerNode, boolean allowCreate, boolean allowUpdate, boolean allowDelete) + private void checkSpecialContainersAllowedOperations(Node containerNode) { assertNotNull(containerNode); - assertTrue(FileplanComponentNode.class.isInstance(containerNode)); - FileplanComponentNode resultNode = (FileplanComponentNode) containerNode; + assertTrue(RecordCategoryNode.class.isInstance(containerNode)); + + RecordCategoryNode resultNode = (RecordCategoryNode) containerNode; + assertEquals(false, resultNode.getIsRecordFolder()); + assertEquals(false, resultNode.getIsFile()); + assertEquals(true, resultNode.getIsCategory()); List allowableOperations = resultNode.getAllowableOperations(); - - assertEquals("Create operation should " + (allowCreate?"":"not ") + "be available for provided container.", - allowCreate, - allowableOperations.contains(RMNodes.OP_CREATE)); - - assertEquals("Update operation should " + (allowCreate?"":"not ") + "be available for provided container.", - allowUpdate, - allowableOperations.contains(RMNodes.OP_UPDATE)); - - assertEquals("Delete operation should " + (allowCreate?"":"not ") + "be available for provided container.", - allowDelete, - allowableOperations.contains(RMNodes.OP_DELETE)); + assertTrue("Create operation should be available for provided container.", allowableOperations.contains(RMNodes.OP_CREATE)); + assertTrue("Update operation should be available for provided container.", allowableOperations.contains(RMNodes.OP_UPDATE)); + assertFalse("Delete operation should note be available for provided container.", allowableOperations.contains(RMNodes.OP_DELETE)); } }