mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/V2.2 to BRANCHES/V2.3:
99087: Upgrade Alfresco version to 4.2.4.6 99088: RM-2026: Unable to complete historical records when mandatory meta-data missing 99089: Merged HEAD to V2.2: 89735: RM-1677- No items error for RM Admin if record was declared from moderated/private site git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@112663 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -58,7 +58,7 @@ rm.record.contributors.group.enabled=false
|
||||
# record contributors group, default value 'RECORD_CONTRIBUTORS'
|
||||
rm.record.contributors.group.name=RECORD_CONTRIBUTORS
|
||||
|
||||
## Indicates whether mandatory properties are checked before completing a record
|
||||
# Indicates whether mandatory properties are checked before completing a record
|
||||
#
|
||||
rm.completerecord.mandatorypropertiescheck.enabled=true
|
||||
|
||||
|
@@ -265,7 +265,7 @@
|
||||
</bean>
|
||||
|
||||
<!-- retain -->
|
||||
<!-- No permissoin?? : allow -->
|
||||
<!-- No permission?? : allow -->
|
||||
|
||||
<bean id="retain_proxy" parent="rmProxyAction" >
|
||||
<property name="target">
|
||||
@@ -384,6 +384,7 @@
|
||||
|
||||
<bean id="declareRecord" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
<property name="checkMandatoryPropertiesEnabled" value="${rm.completerecord.mandatorypropertiescheck.enabled}"/>
|
||||
</bean>
|
||||
|
||||
<!-- undeclare record -->
|
||||
|
@@ -55,6 +55,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<String> missingProperties = new ArrayList<String>(5);
|
||||
// Aspect not already defined - check mandatory properties then add
|
||||
if (mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
|
||||
if (!checkMandatoryPropertiesEnabled ||
|
||||
mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
|
||||
{
|
||||
getRecordService().disablePropertyEditableCheck();
|
||||
try
|
||||
|
@@ -365,6 +365,23 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the display path.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return String display path
|
||||
*/
|
||||
private String getDisplayPath(final NodeRef nodeRef)
|
||||
{
|
||||
return AuthenticationUtil.runAs(new RunAsWork<String>()
|
||||
{
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
return PathUtil.getDisplayPath(nodeService.getPath(nodeRef), true);
|
||||
}
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set the RM node values
|
||||
*
|
||||
|
@@ -108,7 +108,7 @@ public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements D
|
||||
assertNotNull(record);
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(record);
|
||||
assertNotNull(aspects);
|
||||
assertEquals(1, aspects.size());
|
||||
assertEquals(2, aspects.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<QName, Serializable> properties = new HashMap<QName, Serializable>(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<QName, Serializable> properties = new HashMap<QName, Serializable>(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));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -34,6 +34,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
RejectRecordTest.class,
|
||||
CreateRecordTest.class,
|
||||
MoveRecordTest.class,
|
||||
CompleteRecordTest.class,
|
||||
HideInplaceRecordTest.class,
|
||||
MoveInplaceRecordTest.class,
|
||||
ViewRecordTest.class,
|
||||
|
@@ -93,7 +93,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(filePlan);
|
||||
assertNotNull(aspects);
|
||||
assertEquals(1, aspects.size());
|
||||
assertEquals(2, aspects.size());
|
||||
assertTrue(aspects.containsAll(getAspectList()));
|
||||
|
||||
return null;
|
||||
|
@@ -217,6 +217,13 @@
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="testRecordMetadataWithPropertyAspectBootstrap" parent="recordMetadataAspectBootstrap">
|
||||
<property name="recordMetadataAspects">
|
||||
<map>
|
||||
<entry key="rmt:recordMetaDataWithProperty" value="rma:filePlan" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="Search" class="org.alfresco.repo.management.subsystems.SwitchableApplicationContextFactory" parent="abstractPropertyBackedBean">
|
||||
<property name="autoStart">
|
||||
|
@@ -55,6 +55,15 @@
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
<aspect name="rmt:recordMetaDataWithProperty">
|
||||
<properties>
|
||||
<property name="rmt:customMandatoryProperty">
|
||||
<type>d:text</type>
|
||||
<mandatory>true</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
|
||||
</model>
|
Reference in New Issue
Block a user