mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'merge-2.6/RM-5733_portingFix' into 'release/V2.6'
RM-5733 porting fix - cherry picked commit a2f515a6 See merge request records-management/records-management!1352
This commit is contained in:
@@ -253,7 +253,7 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
|||||||
{
|
{
|
||||||
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
|
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
|
||||||
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
|
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
|
||||||
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition, false);
|
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -268,11 +268,9 @@ public interface DispositionService
|
|||||||
*
|
*
|
||||||
* @param nodeRef The node which the schedule applies to.
|
* @param nodeRef The node which the schedule applies to.
|
||||||
* @param dispositionActionDefinition The definition of the disposition action.
|
* @param dispositionActionDefinition The definition of the disposition action.
|
||||||
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
|
|
||||||
* @return The new "disposition as of" date.
|
* @return The new "disposition as of" date.
|
||||||
*/
|
*/
|
||||||
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition);
|
||||||
boolean allowContextFromAsOf);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the origin disposition schedule for the record, not the calculated one
|
* Gets the origin disposition schedule for the record, not the calculated one
|
||||||
|
@@ -139,7 +139,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
/**
|
/**
|
||||||
* Set the dictionary service
|
* Set the dictionary service
|
||||||
*
|
*
|
||||||
* @param dictionaryServic the dictionary service
|
* @param dictionaryService the dictionary service
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
@@ -246,7 +246,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0);
|
DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0);
|
||||||
|
|
||||||
// initialise the details of the next disposition action
|
// initialise the details of the next disposition action
|
||||||
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition, true);
|
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +451,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED))
|
if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED))
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
||||||
if (childAssocs.size() != 0)
|
if (!childAssocs.isEmpty())
|
||||||
{
|
{
|
||||||
ChildAssociationRef firstChildAssocRef = childAssocs.get(0);
|
ChildAssociationRef firstChildAssocRef = childAssocs.get(0);
|
||||||
result = firstChildAssocRef.getChildRef();
|
result = firstChildAssocRef.getChildRef();
|
||||||
@@ -474,7 +474,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
if (nodeService.exists(dsNodeRef))
|
if (nodeService.exists(dsNodeRef))
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> assocs = this.nodeService.getParentAssocs(dsNodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> assocs = this.nodeService.getParentAssocs(dsNodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
||||||
if (assocs.size() != 0)
|
if (!assocs.isEmpty())
|
||||||
{
|
{
|
||||||
if (assocs.size() != 1)
|
if (assocs.size() != 1)
|
||||||
{
|
{
|
||||||
@@ -534,7 +534,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
*
|
*
|
||||||
* @param isRecordLevelDisposition
|
* @param isRecordLevelDisposition
|
||||||
* @param rmContainer
|
* @param rmContainer
|
||||||
* @param root
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<NodeRef> getDisposableItemsImpl(boolean isRecordLevelDisposition, NodeRef rmContainer)
|
private List<NodeRef> getDisposableItemsImpl(boolean isRecordLevelDisposition, NodeRef rmContainer)
|
||||||
@@ -598,13 +597,13 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
// Check whether there is already a disposition schedule object present
|
// Check whether there is already a disposition schedule object present
|
||||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
|
||||||
if (assocs.size() == 0)
|
if (assocs.isEmpty())
|
||||||
{
|
{
|
||||||
DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef);
|
DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef);
|
||||||
if (currentDispositionSchdule != null)
|
if (currentDispositionSchdule != null)
|
||||||
{
|
{
|
||||||
List<NodeRef> items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef);
|
List<NodeRef> items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef);
|
||||||
if (items.size() != 0)
|
if (!items.isEmpty())
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Can not create a retention schedule if there are disposable items already under the control of an other retention schedule");
|
throw new AlfrescoRuntimeException("Can not create a retention schedule if there are disposable items already under the control of an other retention schedule");
|
||||||
}
|
}
|
||||||
@@ -686,7 +685,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
* Updates the given disposition action definition belonging to the given disposition
|
* Updates the given disposition action definition belonging to the given disposition
|
||||||
* schedule.
|
* schedule.
|
||||||
*
|
*
|
||||||
* @param schedule The DispositionSchedule the action belongs to
|
|
||||||
* @param actionDefinition The DispositionActionDefinition to update
|
* @param actionDefinition The DispositionActionDefinition to update
|
||||||
* @param actionDefinitionParams Map of parameters to use to update the action definition
|
* @param actionDefinitionParams Map of parameters to use to update the action definition
|
||||||
* @return The updated DispositionActionDefinition
|
* @return The updated DispositionActionDefinition
|
||||||
@@ -713,12 +711,11 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
*
|
*
|
||||||
* @param nodeRef node reference
|
* @param nodeRef node reference
|
||||||
* @param dispositionActionDefinition disposition action definition
|
* @param dispositionActionDefinition disposition action definition
|
||||||
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
|
|
||||||
*/
|
*/
|
||||||
private DispositionAction initialiseDispositionAction(final NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
private DispositionAction initialiseDispositionAction(final NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
||||||
if (childAssocs != null && childAssocs.size() > 0)
|
if (childAssocs != null && !childAssocs.isEmpty())
|
||||||
{
|
{
|
||||||
return new DispositionActionImpl(serviceRegistry, childAssocs.get(0).getChildRef());
|
return new DispositionActionImpl(serviceRegistry, childAssocs.get(0).getChildRef());
|
||||||
}
|
}
|
||||||
@@ -726,7 +723,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
// Create the properties
|
// Create the properties
|
||||||
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||||
|
|
||||||
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition, allowContextFromAsOf);
|
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition);
|
||||||
|
|
||||||
// Set the property values
|
// Set the property values
|
||||||
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
|
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
|
||||||
@@ -787,12 +784,10 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
*
|
*
|
||||||
* @param nodeRef The node which the schedule applies to.
|
* @param nodeRef The node which the schedule applies to.
|
||||||
* @param dispositionActionDefinition The definition of the disposition action.
|
* @param dispositionActionDefinition The definition of the disposition action.
|
||||||
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
|
|
||||||
* @return The new "disposition as of" date.
|
* @return The new "disposition as of" date.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
|
||||||
boolean allowContextFromAsOf)
|
|
||||||
{
|
{
|
||||||
// Calculate the asOf date
|
// Calculate the asOf date
|
||||||
Date asOfDate = null;
|
Date asOfDate = null;
|
||||||
@@ -803,13 +798,28 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
// Get the period properties value
|
// Get the period properties value
|
||||||
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
|
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
|
||||||
if (periodProperty != null && (allowContextFromAsOf
|
if (periodProperty != null)
|
||||||
|| !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)))
|
{
|
||||||
|
if (RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty))
|
||||||
|
{
|
||||||
|
DispositionAction lastCompletedDispositionAction = getLastCompletedDispostionAction(nodeRef);
|
||||||
|
if (lastCompletedDispositionAction != null)
|
||||||
|
{
|
||||||
|
contextDate = lastCompletedDispositionAction.getCompletedAt();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
|
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
|
||||||
// when the value of the period property is set
|
// when the value of the period property is set
|
||||||
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
||||||
@@ -910,7 +920,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
NodeRef result = null;
|
NodeRef result = null;
|
||||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
||||||
if (assocs.size() != 0)
|
if (!assocs.isEmpty())
|
||||||
{
|
{
|
||||||
result = assocs.get(0).getChildRef();
|
result = assocs.get(0).getChildRef();
|
||||||
}
|
}
|
||||||
@@ -1031,7 +1041,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE))
|
if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE))
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION);
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION);
|
||||||
if (assocs.size() > 0)
|
if (!assocs.isEmpty())
|
||||||
{
|
{
|
||||||
currentDispositionAction = assocs.get(0).getChildRef();
|
currentDispositionAction = assocs.get(0).getChildRef();
|
||||||
}
|
}
|
||||||
@@ -1086,7 +1096,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null);
|
nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition, false);
|
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,14 +1169,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule);
|
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule);
|
||||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule);
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule);
|
||||||
if (assocs != null && assocs.size() > 0)
|
if (assocs != null && !assocs.isEmpty())
|
||||||
{
|
{
|
||||||
for (ChildAssociationRef assoc : assocs)
|
for (ChildAssociationRef assoc : assocs)
|
||||||
{
|
{
|
||||||
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
||||||
{
|
{
|
||||||
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
|
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
|
||||||
return calculateAsOfDate(record, actionDefinition, true);
|
return calculateAsOfDate(record, actionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1381,14 +1391,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
recordOrFolder = folder;
|
recordOrFolder = folder;
|
||||||
}
|
}
|
||||||
DispositionAction firstDispositionAction = initialiseDispositionAction(recordOrFolder, firstDispositionActionDef, true);
|
DispositionAction firstDispositionAction = initialiseDispositionAction(recordOrFolder, firstDispositionActionDef);
|
||||||
newAction = firstDispositionAction.getNodeRef();
|
newAction = firstDispositionAction.getNodeRef();
|
||||||
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
||||||
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
||||||
}
|
}
|
||||||
else if (firstDispositionActionDef.getPeriod() != null)
|
else if (firstDispositionActionDef.getPeriod() != null)
|
||||||
{
|
{
|
||||||
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef, true);
|
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef);
|
||||||
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
||||||
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
||||||
{
|
{
|
||||||
|
@@ -102,7 +102,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
|
|||||||
when(mockAction.getName()).thenReturn("mockAction");
|
when(mockAction.getName()).thenReturn("mockAction");
|
||||||
// Set up the disposition service to return a known "disposition as of" date.
|
// Set up the disposition service to return a known "disposition as of" date.
|
||||||
Date asOfDate = new Date();
|
Date asOfDate = new Date();
|
||||||
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, false))
|
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition))
|
||||||
.thenReturn(asOfDate);
|
.thenReturn(asOfDate);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
@@ -160,7 +160,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
|
|||||||
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
|
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
|
||||||
// Set up the expected "as of" date.
|
// Set up the expected "as of" date.
|
||||||
Date newAsOfDate = new Date(123456789000L);
|
Date newAsOfDate = new Date(123456789000L);
|
||||||
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition, false)).thenReturn(newAsOfDate);
|
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition)).thenReturn(newAsOfDate);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
action.executeImpl(mockAction, definitionNode);
|
action.executeImpl(mockAction, definitionNode);
|
||||||
|
@@ -82,7 +82,7 @@ public class DispositionServiceImplUnitTest
|
|||||||
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
|
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, true);
|
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition);
|
||||||
|
|
||||||
assertEquals("Unexpected calculation for 'as of' date", nextDate, asOfDate);
|
assertEquals("Unexpected calculation for 'as of' date", nextDate, asOfDate);
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class DispositionServiceImplUnitTest
|
|||||||
when(mockDispositionActionDefinition.getPeriod()).thenReturn(null);
|
when(mockDispositionActionDefinition.getPeriod()).thenReturn(null);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, true);
|
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition);
|
||||||
|
|
||||||
assertNull("It should not be possible to determine the 'as of' date.", asOfDate);
|
assertNull("It should not be possible to determine the 'as of' date.", asOfDate);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user