diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
index 60f0b0e0d6..1270de1af6 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties
@@ -47,3 +47,8 @@ rm.autocompletesuggestion.nodeParameterSuggester.aspectsAndTypes=rma:record,cm:c
# Global RM disposition lifecycle trigger cron job expression
#
rm.dispositionlifecycletrigger.cronexpression=0 0/5 * * * ?
+
+#
+# Indicates whether mandatory properties are checked before completing a record
+#
+rm.completerecord.mandatorypropertiescheck.enabled=true
diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
index f8db542201..0c2cddd8ee 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
@@ -265,7 +265,7 @@
-
+
@@ -384,6 +384,7 @@
+
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
index fc7eb74eb3..82369c4613 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
@@ -54,6 +54,17 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
/** Logger */
private static Log logger = LogFactory.getLog(DeclareRecordAction.class);
+
+ /** check mandatory properties */
+ private boolean checkMandatoryPropertiesEnabled = true;
+
+ /**
+ * @param checkMandatoryPropertiesEnabled true if check mandatory properties is enabled, false otherwise
+ */
+ public void setCheckMandatoryPropertiesEnabled(boolean checkMandatoryPropertiesEnabled)
+ {
+ this.checkMandatoryPropertiesEnabled = checkMandatoryPropertiesEnabled;
+ }
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
@@ -69,7 +80,8 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
{
List missingProperties = new ArrayList(5);
// Aspect not already defined - check mandatory properties then add
- if (mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
+ if (!checkMandatoryPropertiesEnabled ||
+ mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
{
recordService.disablePropertyEditableCheck();
try
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java
index 5019fc9114..f44d4bb753 100755
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/dod/RM1194ExcludeDoDRecordTypesTest.java
@@ -108,7 +108,7 @@ public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements D
assertNotNull(record);
Set aspects = recordService.getRecordMetadataAspects(record);
assertNotNull(aspects);
- assertEquals(1, aspects.size());
+ assertEquals(2, aspects.size());
}
});
}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java
new file mode 100644
index 0000000000..c86a12e277
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/CompleteRecordTest.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2005-2014 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.module.org_alfresco_module_rm.test.integration.record;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+
+/**
+ * Complete record tests.
+ *
+ * @author Roy Wetherall
+ * @since 2.2.1
+ */
+public class CompleteRecordTest extends BaseRMTestCase
+{
+ private static final QName ASPECT_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "recordMetaDataWithProperty");
+ private static final QName PROP_TEST = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customMandatoryProperty");
+
+ /** complete record action */
+ private DeclareRecordAction action;
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
+ */
+ @Override
+ protected void initServices()
+ {
+ super.initServices();
+
+ // get the action
+ action = (DeclareRecordAction)applicationContext.getBean("declareRecord");
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl()
+ */
+ @Override
+ protected void tearDownImpl()
+ {
+ super.tearDownImpl();
+
+ // ensure action is returned to original state
+ action.setCheckMandatoryPropertiesEnabled(true);
+ }
+
+ /**
+ * Given the the application is configured to check for mandatory values before complete
+ * And a filed record is missing mandatory values
+ * When I try to complete the record
+ * Then the missing properties parameter of the action will be populated
+ * And the record will not be complete
+ */
+ public void testCheckForMandatoryValuesMissing() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ private NodeRef record;
+ private RecordsManagementActionResult result;
+
+ public void given()
+ {
+ // enable mandatory parameter check
+ action.setCheckMandatoryPropertiesEnabled(true);
+
+ // create a record
+ record = utils.createRecord(rmFolder, "record.txt", "title");
+
+ // add the record aspect (that has a mandatory property)
+ nodeService.addAspect(record, ASPECT_TEST, null);
+ }
+
+ public void when()
+ {
+ // complete record
+ result = rmActionService.executeRecordsManagementAction(record, "declareRecord");
+ }
+
+ public void then()
+ {
+ assertNotNull(result);
+ assertNotNull(result.getValue());
+ assertFalse(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
+ }
+ });
+ }
+
+ /**
+ * Given the the application is configured to check for mandatory values before complete
+ * And a filed record has all mandatory values
+ * When I try to complete the record
+ * Then the record is completed
+ */
+ public void testCheckForMandatoryValuePresent() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ private NodeRef record;
+ private RecordsManagementActionResult result;
+
+ public void given()
+ {
+ // enable mandatory parameter check
+ action.setCheckMandatoryPropertiesEnabled(true);
+
+ // create a record
+ record = utils.createRecord(rmFolder, "record.txt", "title");
+
+ // add the record aspect (that has a mandatory property)
+ Map properties = new HashMap(1);
+ properties.put(PROP_TEST, "something");
+ nodeService.addAspect(record, ASPECT_TEST, properties);
+ }
+
+ public void when()
+ {
+ // complete record
+ result = rmActionService.executeRecordsManagementAction(record, "declareRecord");
+ }
+
+ public void then()
+ {
+ assertNotNull(result);
+ assertNull(result.getValue());
+ assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
+ }
+ });
+ }
+
+ /**
+ * Given the the application is configured not to check for mandatory values before complete
+ * And a filed record is missing mandatory values
+ * When I try to complete the record
+ * Then the record is completed
+ */
+ public void testDontCheckForMandatoryValuesMissing() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ private NodeRef record;
+ private RecordsManagementActionResult result;
+
+ public void given()
+ {
+ // disable mandatory parameter check
+ action.setCheckMandatoryPropertiesEnabled(false);
+
+ // create a record
+ record = utils.createRecord(rmFolder, "record.txt", "title");
+
+ // add the record aspect (that has a mandatory property)
+ nodeService.addAspect(record, ASPECT_TEST, null);
+ }
+
+ public void when()
+ {
+ // complete record
+ result = rmActionService.executeRecordsManagementAction(record, "declareRecord");
+ }
+
+ public void then()
+ {
+ assertNotNull(result);
+ assertNull(result.getValue());
+ assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
+ }
+ });
+ }
+
+ /**
+ * Given the the application is configured to not to check for mandatory values before complete
+ * And a filed record has all mandatory values
+ * When I try to complete the record
+ * Then the record is completed
+ */
+ public void testDontCheckForMandatoryValuePresent() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ private NodeRef record;
+ private RecordsManagementActionResult result;
+
+ public void given()
+ {
+ // enable mandatory parameter check
+ action.setCheckMandatoryPropertiesEnabled(false);
+
+ // create a record
+ record = utils.createRecord(rmFolder, "record.txt", "title");
+
+ // add the record aspect (that has a mandatory property)
+ Map properties = new HashMap(1);
+ properties.put(PROP_TEST, "something");
+ nodeService.addAspect(record, ASPECT_TEST, properties);
+ }
+
+ public void when()
+ {
+ // complete record
+ result = rmActionService.executeRecordsManagementAction(record, "declareRecord");
+ }
+
+ public void then()
+ {
+ assertNotNull(result);
+ assertNull(result.getValue());
+ assertTrue(nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
+ }
+ });
+ }
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java
index 6e7e7d97c8..241cdc7bd6 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java
@@ -33,7 +33,8 @@ import org.junit.runners.Suite.SuiteClasses;
{
RejectRecordTest.class,
CreateRecordTest.class,
- MoveRecordTest.class
+ MoveRecordTest.class,
+ CompleteRecordTest.class
})
public class RecordTestSuite
{
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java
index 14f5ffa379..aac8a820f7 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordServiceImplTest.java
@@ -95,7 +95,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
{
Set aspects = recordService.getRecordMetadataAspects(filePlan);
assertNotNull(aspects);
- assertEquals(1, aspects.size());
+ assertEquals(2, aspects.size());
assertTrue(aspects.containsAll(getAspectList()));
return null;
diff --git a/rm-server/test/resources/test-context.xml b/rm-server/test/resources/test-context.xml
index 525e861629..a5396c0b50 100644
--- a/rm-server/test/resources/test-context.xml
+++ b/rm-server/test/resources/test-context.xml
@@ -232,5 +232,12 @@
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rm-server/test/resources/test-model.xml b/rm-server/test/resources/test-model.xml
index 6007fd32ae..c35643dd3b 100644
--- a/rm-server/test/resources/test-model.xml
+++ b/rm-server/test/resources/test-model.xml
@@ -49,6 +49,15 @@
+
+
+
+
+ d:text
+ true
+
+
+