RM-1502: on moving a folder to RM: recordSearchDispositionAuthority & recordSearchDispositionInstructions are empty

RM-1521: Failed to Upload New Version if updated rule to Declare as Record is set




git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@75191 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2014-06-29 07:09:18 +00:00
parent 4ceda4baf5
commit 63d0b4732e
4 changed files with 276 additions and 135 deletions

View File

@@ -45,6 +45,7 @@ import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.TransactionalResourceHelper;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -145,11 +146,20 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
this.recordService = recordService; this.recordService = recordService;
} }
/** Java behaviour */ /** on add search aspect behaviour */
private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT);
/** disposition action behaviours */
private JavaBehaviour jbDispositionActionCreate = new JavaBehaviour(this, "dispositionActionCreate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionActionCreate = new JavaBehaviour(this, "dispositionActionCreate", NotificationFrequency.TRANSACTION_COMMIT);
private JavaBehaviour jbDispositionActionPropertiesUpdate = new JavaBehaviour(this, "dispositionActionPropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionActionPropertiesUpdate = new JavaBehaviour(this, "dispositionActionPropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT);
/** disposition lifecycle behaviours */
private JavaBehaviour jbDispositionLifeCycleAspect = new JavaBehaviour(this, "onAddDispositionLifecycleAspect", NotificationFrequency.TRANSACTION_COMMIT);
/** disposition schedule behaviours */
private JavaBehaviour jbDispositionSchedulePropertiesUpdate = new JavaBehaviour(this, "dispositionSchedulePropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionSchedulePropertiesUpdate = new JavaBehaviour(this, "dispositionSchedulePropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT);
/** event update behaviours */
private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT);
private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT);
@@ -160,7 +170,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
jbDispositionActionPropertiesUpdate, jbDispositionActionPropertiesUpdate,
jbDispositionSchedulePropertiesUpdate, jbDispositionSchedulePropertiesUpdate,
jbEventExecutionUpdate, jbEventExecutionUpdate,
jbEventExecutionDelete jbEventExecutionDelete,
jbDispositionLifeCycleAspect
}; };
/** /**
@@ -199,6 +210,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
ASPECT_RM_SEARCH, ASPECT_RM_SEARCH,
onAddSearchAspect); onAddSearchAspect);
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
ASPECT_DISPOSITION_LIFECYCLE,
jbDispositionLifeCycleAspect);
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
ASPECT_RECORD, ASPECT_RECORD,
@@ -356,6 +372,29 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
}); });
} }
/**
* On addition of the disposition lifecycle aspect
* @param nodeRef
* @param aspectTypeQName
*/
public void onAddDispositionLifecycleAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
{
@Override
public Void doWork()
{
if (nodeService.exists(nodeRef) && nodeService.hasAspect(nodeRef, ASPECT_RECORD))
{
applySearchAspect(nodeRef);
setupDispositionScheduleProperties(nodeRef);
}
return null;
}
});
}
/** /**
* On create record folder behaviour implmentation * On create record folder behaviour implmentation
* *
@@ -386,6 +425,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
* @param recordOrFolder node reference of record or record folder * @param recordOrFolder node reference of record or record folder
*/ */
private void setupDispositionScheduleProperties(NodeRef recordOrFolder) private void setupDispositionScheduleProperties(NodeRef recordOrFolder)
{
if (!methodCached("setupDispositionScheduleProperties", recordOrFolder))
{ {
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder); DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder);
if (ds == null) if (ds == null)
@@ -404,6 +445,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
" to: " + (ds != null)); " to: " + (ds != null));
} }
} }
}
/** /**
* On disposition action create behaviour implementation * On disposition action create behaviour implementation
@@ -430,6 +472,28 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
} }
} }
/**
* Helper method to determine whether a method has been called in this transaction
* already, or not.
* <P>
* Prevents work if we get unexpected behaviours firing.
*
* @param method method name (can be any unique string)
* @return boolean true if already called in this transaction, false otherwise
*/
private boolean methodCached(String method, NodeRef nodeRef)
{
boolean result = true;
Set<String> methods = TransactionalResourceHelper.getSet("rm.seachrollup.methodCache");
String key = method + "|" + nodeRef;
if (!methods.contains(key))
{
result = false;
methods.add(key);
}
return result;
}
/** /**
* On update disposition action properties behaviour implementation * On update disposition action properties behaviour implementation
* *
@@ -437,6 +501,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
* @param dispositionAction disposition action * @param dispositionAction disposition action
*/ */
private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction)
{
if (!methodCached("updateDispositionActionProperties", record))
{ {
Map<QName, Serializable> props = nodeService.getProperties(record); Map<QName, Serializable> props = nodeService.getProperties(record);
@@ -478,6 +544,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION));
} }
} }
}
/** /**
* On update of event execution information behaviour\ * On update of event execution information behaviour\
@@ -548,6 +615,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
* @param da disposition action * @param da disposition action
*/ */
private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da) private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da)
{
if (!methodCached("setupDispositionActionEvents", nodeRef))
{ {
if (da != null) if (da != null)
{ {
@@ -571,6 +640,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
} }
} }
} }
}
/** /**
* On add search aspect behaviour implementation. * On add search aspect behaviour implementation.
@@ -658,6 +728,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
* @param nodeRef node reference * @param nodeRef node reference
*/ */
private void updateVitalRecordDefinitionValues(NodeRef nodeRef) private void updateVitalRecordDefinitionValues(NodeRef nodeRef)
{
if (!methodCached("updateVitalRecordDefinitionValues", nodeRef))
{ {
// ensure the folder itself reflects the correct details // ensure the folder itself reflects the correct details
applySearchAspect(nodeRef); applySearchAspect(nodeRef);
@@ -673,6 +745,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
setVitalRecordDefintionDetails(record); setVitalRecordDefintionDetails(record);
} }
} }
}
/** /**
* Helper method to set vital record definition details. * Helper method to set vital record definition details.
@@ -680,6 +753,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
* @param nodeRef node reference * @param nodeRef node reference
*/ */
private void setVitalRecordDefintionDetails(NodeRef nodeRef) private void setVitalRecordDefintionDetails(NodeRef nodeRef)
{
if (!methodCached("setVitalRecordDefinitionDetails", nodeRef))
{ {
VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef); VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef);
@@ -704,6 +779,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null); nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null);
} }
} }
}
/** /**
* Updates the disposition schedule properties * Updates the disposition schedule properties

View File

@@ -228,7 +228,8 @@ public class RecordAspect extends AbstractDisposableItem
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
{ {
// check the records parent has actually changed // check the records parent has actually changed
if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef())) if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef()) &&
isFilePlanComponent(oldChildAssocRef.getParentRef()))
{ {
final NodeRef record = newChildAssocRef.getChildRef(); final NodeRef record = newChildAssocRef.getChildRef();
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()

View File

@@ -21,7 +21,6 @@ package org.alfresco.repo.rule;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -157,10 +156,11 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
*/ */
@Override @Override
public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules) public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules)
{
if (nodeService.exists(nodeRef))
{ {
QName typeQName = nodeService.getType(nodeRef); QName typeQName = nodeService.getType(nodeRef);
if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
if (nodeService.exists(nodeRef) && shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
{ {
// check if this is a rm rule on a rm artifact // check if this is a rm rule on a rm artifact
if (filePlanService.isFilePlanComponent(nodeRef) && if (filePlanService.isFilePlanComponent(nodeRef) &&
@@ -195,6 +195,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
} }
} }
} }
}
/** /**
* Indicates whether the rule is a file plan component * Indicates whether the rule is a file plan component
@@ -243,7 +244,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) ||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) ||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) ||
(ContentModel.TYPE_CONTENT.equals(typeQName) && !recordService.isFiled(nodeRef))); !recordService.isFiled(nodeRef));
} }
return result; return result;
} }

View File

@@ -43,6 +43,12 @@ public class MoveRecordTest extends BaseRMTestCase
{ {
private static final String OTHER_EVENT = "abolished"; private static final String OTHER_EVENT = "abolished";
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
/** /**
* Given a record is filed in a event disposition and moved then the * Given a record is filed in a event disposition and moved then the
* record no longer has any disposition. * record no longer has any disposition.
@@ -184,6 +190,9 @@ public class MoveRecordTest extends BaseRMTestCase
assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
assertTrue(((List<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(OTHER_EVENT)); assertTrue(((List<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)).contains(OTHER_EVENT));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY));
assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE));
} }
}); });
@@ -266,13 +275,67 @@ public class MoveRecordTest extends BaseRMTestCase
assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME)); assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF)); assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
assertNull(((List<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS))); assertNull(((List<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS)));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_INSTRUCTIONS));
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOITION_AUTHORITY));
assertTrue((Boolean)nodeService.getProperty(record, PROP_RS_HAS_DISPOITION_SCHEDULE));
} }
}); });
}
/**
* See https://issues.alfresco.com/jira/browse/RM-1502
*/
public void testMoveDMtoRM()
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
NodeRef destinationCategory;
NodeRef destinationRecordFolder;
public void given()
{
// destination category
destinationCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
DispositionSchedule dis = utils.createBasicDispositionSchedule(destinationCategory, GUID.generate(), GUID.generate(), true, false);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(dis, adParams);
destinationRecordFolder = recordFolderService.createRecordFolder(destinationCategory, GUID.generate());
}
public void when() throws Exception
{
// move document to record folder
fileFolderService.move(dmDocument, destinationRecordFolder, null);
}
public void then()
{
// check for the lifecycle aspect
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_DISPOSITION_LIFECYCLE));
// check the disposition action details
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(dmDocument);
assertNotNull(dispositionAction);
assertNotNull(CutOffAction.NAME, dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate());
assertTrue(dispositionService.isNextDispositionActionEligible(dmDocument));
assertNull(dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME));
// check the search aspect details
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RM_SEARCH));
assertEquals(CutOffAction.NAME, nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_ACTION_AS_OF));
assertNull(((List<String>)nodeService.getProperty(dmDocument, PROP_RS_DISPOSITION_EVENTS)));
assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_INSTRUCTIONS));
assertNotNull(nodeService.getProperty(dmDocument, PROP_RS_DISPOITION_AUTHORITY));
assertTrue((Boolean)nodeService.getProperty(dmDocument, PROP_RS_HAS_DISPOITION_SCHEDULE));
}
});
} }
// TODO moveRecordNoDisToEventDis // TODO moveRecordNoDisToEventDis
// TODO moveRecordRecordDisToFolderDis // TODO moveRecordRecordDisToFolderDis
} }