mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -45,6 +45,7 @@ import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
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.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -145,11 +146,20 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/** Java behaviour */
|
||||
/** on add search aspect behaviour */
|
||||
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 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);
|
||||
|
||||
/** event update behaviours */
|
||||
private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT);
|
||||
private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT);
|
||||
|
||||
@@ -160,7 +170,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
jbDispositionActionPropertiesUpdate,
|
||||
jbDispositionSchedulePropertiesUpdate,
|
||||
jbEventExecutionUpdate,
|
||||
jbEventExecutionDelete
|
||||
jbEventExecutionDelete,
|
||||
jbDispositionLifeCycleAspect
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -199,6 +210,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
ASPECT_RM_SEARCH,
|
||||
onAddSearchAspect);
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
||||
ASPECT_DISPOSITION_LIFECYCLE,
|
||||
jbDispositionLifeCycleAspect);
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
||||
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
|
||||
*
|
||||
@@ -386,6 +425,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
* @param recordOrFolder node reference of record or record folder
|
||||
*/
|
||||
private void setupDispositionScheduleProperties(NodeRef recordOrFolder)
|
||||
{
|
||||
if (!methodCached("setupDispositionScheduleProperties", recordOrFolder))
|
||||
{
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder);
|
||||
if (ds == null)
|
||||
@@ -404,6 +445,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
" to: " + (ds != null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -437,6 +501,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
* @param dispositionAction disposition action
|
||||
*/
|
||||
private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction)
|
||||
{
|
||||
if (!methodCached("updateDispositionActionProperties", record))
|
||||
{
|
||||
Map<QName, Serializable> props = nodeService.getProperties(record);
|
||||
|
||||
@@ -478,6 +544,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On update of event execution information behaviour\
|
||||
@@ -548,6 +615,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
* @param da disposition action
|
||||
*/
|
||||
private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da)
|
||||
{
|
||||
if (!methodCached("setupDispositionActionEvents", nodeRef))
|
||||
{
|
||||
if (da != null)
|
||||
{
|
||||
@@ -571,6 +640,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On add search aspect behaviour implementation.
|
||||
@@ -658,6 +728,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
* @param nodeRef node reference
|
||||
*/
|
||||
private void updateVitalRecordDefinitionValues(NodeRef nodeRef)
|
||||
{
|
||||
if (!methodCached("updateVitalRecordDefinitionValues", nodeRef))
|
||||
{
|
||||
// ensure the folder itself reflects the correct details
|
||||
applySearchAspect(nodeRef);
|
||||
@@ -673,6 +745,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
setVitalRecordDefintionDetails(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set vital record definition details.
|
||||
@@ -680,6 +753,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
* @param nodeRef node reference
|
||||
*/
|
||||
private void setVitalRecordDefintionDetails(NodeRef nodeRef)
|
||||
{
|
||||
if (!methodCached("setVitalRecordDefinitionDetails", 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the disposition schedule properties
|
||||
|
@@ -228,7 +228,8 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
||||
{
|
||||
// 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();
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||
|
@@ -21,7 +21,6 @@ package org.alfresco.repo.rule;
|
||||
import java.util.HashSet;
|
||||
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.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
@@ -157,10 +156,11 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
|
||||
*/
|
||||
@Override
|
||||
public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules)
|
||||
{
|
||||
if (nodeService.exists(nodeRef))
|
||||
{
|
||||
QName typeQName = nodeService.getType(nodeRef);
|
||||
|
||||
if (nodeService.exists(nodeRef) && shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
|
||||
if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
|
||||
{
|
||||
// check if this is a rm rule on a rm artifact
|
||||
if (filePlanService.isFilePlanComponent(nodeRef) &&
|
||||
@@ -195,6 +195,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) ||
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) ||
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) ||
|
||||
(ContentModel.TYPE_CONTENT.equals(typeQName) && !recordService.isFiled(nodeRef)));
|
||||
!recordService.isFiled(nodeRef));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -43,6 +43,12 @@ public class MoveRecordTest extends BaseRMTestCase
|
||||
{
|
||||
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
|
||||
* 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));
|
||||
assertNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
|
||||
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));
|
||||
assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
|
||||
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 moveRecordRecordDisToFolderDis
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user