mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +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.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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,6 +209,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
|
||||||
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"),
|
||||||
@@ -355,7 +371,30 @@ 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
|
||||||
*
|
*
|
||||||
@@ -387,21 +426,24 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
*/
|
*/
|
||||||
private void setupDispositionScheduleProperties(NodeRef recordOrFolder)
|
private void setupDispositionScheduleProperties(NodeRef recordOrFolder)
|
||||||
{
|
{
|
||||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder);
|
if (!methodCached("setupDispositionScheduleProperties", recordOrFolder))
|
||||||
if (ds == null)
|
{
|
||||||
{
|
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder);
|
||||||
nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, false);
|
if (ds == null)
|
||||||
}
|
{
|
||||||
else
|
nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, false);
|
||||||
{
|
}
|
||||||
nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, true);
|
else
|
||||||
setDispositionScheduleProperties(recordOrFolder, ds);
|
{
|
||||||
}
|
nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, true);
|
||||||
|
setDispositionScheduleProperties(recordOrFolder, ds);
|
||||||
if (logger.isDebugEnabled())
|
}
|
||||||
{
|
|
||||||
logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder +
|
if (logger.isDebugEnabled())
|
||||||
" to: " + (ds != null));
|
{
|
||||||
|
logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder +
|
||||||
|
" to: " + (ds != null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +471,28 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null);
|
nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
@@ -438,45 +502,48 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
*/
|
*/
|
||||||
private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction)
|
private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props = nodeService.getProperties(record);
|
if (!methodCached("updateDispositionActionProperties", 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));
|
|
||||||
|
|
||||||
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
|
||||||
if (daDefinition != null)
|
|
||||||
{
|
{
|
||||||
Period period = daDefinition.getPeriod();
|
Map<QName, Serializable> props = nodeService.getProperties(record);
|
||||||
if (period != null)
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
||||||
|
if (daDefinition != null)
|
||||||
{
|
{
|
||||||
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
|
Period period = daDefinition.getPeriod();
|
||||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
nodeService.setProperties(record, props);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
props.put(PROP_RS_DISPOSITION_PERIOD, null);
|
logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " +
|
||||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeService.setProperties(record, props);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -549,25 +616,28 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
*/
|
*/
|
||||||
private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da)
|
private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da)
|
||||||
{
|
{
|
||||||
if (da != null)
|
if (!methodCached("setupDispositionActionEvents", nodeRef))
|
||||||
{
|
{
|
||||||
List<String> eventNames = null;
|
if (da != null)
|
||||||
List<EventCompletionDetails> eventsList = da.getEventCompletionDetails();
|
|
||||||
if (eventsList.size() > 0)
|
|
||||||
{
|
{
|
||||||
eventNames = new ArrayList<String>(eventsList.size());
|
List<String> eventNames = null;
|
||||||
for (EventCompletionDetails event : eventsList)
|
List<EventCompletionDetails> eventsList = da.getEventCompletionDetails();
|
||||||
|
if (eventsList.size() > 0)
|
||||||
{
|
{
|
||||||
eventNames.add(event.getEventName());
|
eventNames = new ArrayList<String>(eventsList.size());
|
||||||
|
for (EventCompletionDetails event : eventsList)
|
||||||
|
{
|
||||||
|
eventNames.add(event.getEventName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the property
|
||||||
|
nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Set rma:recordSearchDispositionEvents for node " + nodeRef + " to: " + eventNames);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set the property
|
|
||||||
nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Set rma:recordSearchDispositionEvents for node " + nodeRef + " to: " + eventNames);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,18 +729,21 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
*/
|
*/
|
||||||
private void updateVitalRecordDefinitionValues(NodeRef nodeRef)
|
private void updateVitalRecordDefinitionValues(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
// ensure the folder itself reflects the correct details
|
if (!methodCached("updateVitalRecordDefinitionValues", nodeRef))
|
||||||
applySearchAspect(nodeRef);
|
|
||||||
setVitalRecordDefintionDetails(nodeRef);
|
|
||||||
|
|
||||||
List<NodeRef> records = recordService.getRecords(nodeRef);
|
|
||||||
for (NodeRef record : records)
|
|
||||||
{
|
{
|
||||||
// Apply the search aspect
|
// ensure the folder itself reflects the correct details
|
||||||
applySearchAspect(record);
|
applySearchAspect(nodeRef);
|
||||||
|
setVitalRecordDefintionDetails(nodeRef);
|
||||||
// Set the vital record definition details
|
|
||||||
setVitalRecordDefintionDetails(record);
|
List<NodeRef> records = recordService.getRecords(nodeRef);
|
||||||
|
for (NodeRef record : records)
|
||||||
|
{
|
||||||
|
// Apply the search aspect
|
||||||
|
applySearchAspect(record);
|
||||||
|
|
||||||
|
// Set the vital record definition details
|
||||||
|
setVitalRecordDefintionDetails(record);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,27 +754,30 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
|||||||
*/
|
*/
|
||||||
private void setVitalRecordDefintionDetails(NodeRef nodeRef)
|
private void setVitalRecordDefintionDetails(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef);
|
if (!methodCached("setVitalRecordDefinitionDetails", nodeRef))
|
||||||
|
|
||||||
if (vrd != null && vrd.isEnabled() && vrd.getReviewPeriod() != null)
|
|
||||||
{
|
{
|
||||||
// Set the property values
|
VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef);
|
||||||
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, vrd.getReviewPeriod().getPeriodType());
|
|
||||||
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, vrd.getReviewPeriod().getExpression());
|
if (vrd != null && vrd.isEnabled() && vrd.getReviewPeriod() != null)
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
{
|
||||||
logger.debug("Set rma:recordSearchVitalRecordReviewPeriod for node " + nodeRef + " to: " +
|
// Set the property values
|
||||||
vrd.getReviewPeriod().getPeriodType());
|
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, vrd.getReviewPeriod().getPeriodType());
|
||||||
logger.debug("Set rma:recordSearchVitalRecordReviewPeriodExpression for node " + nodeRef + " to: " +
|
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, vrd.getReviewPeriod().getExpression());
|
||||||
vrd.getReviewPeriod().getExpression());
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Set rma:recordSearchVitalRecordReviewPeriod for node " + nodeRef + " to: " +
|
||||||
|
vrd.getReviewPeriod().getPeriodType());
|
||||||
|
logger.debug("Set rma:recordSearchVitalRecordReviewPeriodExpression for node " + nodeRef + " to: " +
|
||||||
|
vrd.getReviewPeriod().getExpression());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Clear the vital record properties
|
||||||
|
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, null);
|
||||||
|
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Clear the vital record properties
|
|
||||||
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, null);
|
|
||||||
nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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>()
|
||||||
|
@@ -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;
|
||||||
@@ -158,40 +157,42 @@ 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)
|
||||||
{
|
{
|
||||||
QName typeQName = nodeService.getType(nodeRef);
|
if (nodeService.exists(nodeRef))
|
||||||
|
|
||||||
if (nodeService.exists(nodeRef) && shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
|
|
||||||
{
|
{
|
||||||
// check if this is a rm rule on a rm artifact
|
QName typeQName = nodeService.getType(nodeRef);
|
||||||
if (filePlanService.isFilePlanComponent(nodeRef) &&
|
if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
|
||||||
isFilePlanComponentRule(rule))
|
|
||||||
{
|
{
|
||||||
// ignore and
|
// check if this is a rm rule on a rm artifact
|
||||||
if (!isIgnoredType(typeQName))
|
if (filePlanService.isFilePlanComponent(nodeRef) &&
|
||||||
{
|
isFilePlanComponentRule(rule))
|
||||||
if (runAsAdmin)
|
{
|
||||||
{
|
// ignore and
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
if (!isIgnoredType(typeQName))
|
||||||
{
|
{
|
||||||
@Override
|
if (runAsAdmin)
|
||||||
public Void doWork()
|
{
|
||||||
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
|
@Override
|
||||||
return null;
|
public Void doWork()
|
||||||
}
|
{
|
||||||
}, AuthenticationUtil.getAdminUserName());
|
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
|
||||||
}
|
return null;
|
||||||
else
|
}
|
||||||
{
|
}, AuthenticationUtil.getAdminUserName());
|
||||||
// run as current user
|
}
|
||||||
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
|
else
|
||||||
}
|
{
|
||||||
}
|
// run as current user
|
||||||
}
|
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
// just execute the rule as the current user
|
}
|
||||||
super.executeRule(rule, nodeRef, executedRules);
|
else
|
||||||
|
{
|
||||||
|
// just execute the rule as the current user
|
||||||
|
super.executeRule(rule, nodeRef, executedRules);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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.
|
||||||
@@ -183,7 +189,10 @@ public class MoveRecordTest extends BaseRMTestCase
|
|||||||
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
|
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
|
||||||
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));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -265,14 +274,68 @@ public class MoveRecordTest extends BaseRMTestCase
|
|||||||
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
|
assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
|
||||||
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));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO moveRecordNoDisToEventDis
|
/**
|
||||||
|
* 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
|
// TODO moveRecordRecordDisToFolderDis
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user