RM-1096, RM-1097: Refactored CloseRecordFolderAction, CreateDispositionScheduleAction and CutOffAction

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58002 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-11-19 16:36:33 +00:00
parent 1934f2e91f
commit cc00d9b5f0
13 changed files with 83 additions and 60 deletions

View File

@@ -102,7 +102,7 @@ public interface RecordsManagementService
/**
* @since 2.0
* @deprecated As of 2.2, see {@link DispositionService#isCutoff(NodeRef)}
* @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)}
*/
boolean isCutoff(NodeRef nodeRef);

View File

@@ -626,12 +626,12 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
}
/**
* @deprecated As of 2.2, see {@link DispositionService#isCutoff(NodeRef)}
* @deprecated As of 2.2, see {@link DispositionService#isDisposableItemCutoff(NodeRef)}
*/
@Override
public boolean isCutoff(NodeRef nodeRef)
{
return getDispositionService().isCutoff(nodeRef);
return getDispositionService().isDisposableItemCutoff(nodeRef);
}
/**

View File

@@ -41,7 +41,7 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
{
if (eligibleForAction(actionedUponNodeRef) == true)
{
recordFolderService.closeFolder(actionedUponNodeRef);
recordFolderService.closeRecordFolder(actionedUponNodeRef);
}
}

View File

@@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstrac
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Create disposition schedule action
@@ -31,6 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBase
{
/** I18N */
private static final String MSG_NODE_NOT_RECORD_CATEGORY = "rm.action.node-not-record-category";
/** file plan service */
private FilePlanService filePlanService;
@@ -48,14 +52,34 @@ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBas
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
if (filePlanService.isRecordCategory(actionedUponNodeRef) == true)
if (eligibleForAction(actionedUponNodeRef) == true)
{
// Create the disposition schedule
dispositionService.createDispositionSchedule(actionedUponNodeRef, null);
}
else
{
throw new AlfrescoRuntimeException("The disposition schedule could not be created, because the actioned upon node was not a record category.");
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_RECORD_CATEGORY, actionedUponNodeRef));
}
}
/**
* Helper method to check the actioned upon node reference to decide to execute the action
* The preconditions are:
* - The node must exist
* - The node must not be a record category
*
* @param actionedUponNodeRef node reference
* @return Return true if the node reference passes all the preconditions for executing the action, false otherwise
*/
private boolean eligibleForAction(NodeRef actionedUponNodeRef)
{
boolean result = false;
if (nodeService.exists(actionedUponNodeRef) == true &&
filePlanService.isRecordCategory(actionedUponNodeRef) == true)
{
result = true;
}
return result;
}
}

View File

@@ -18,16 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Cut off disposition action
@@ -45,21 +38,16 @@ public class CutOffAction extends RMDispositionActionExecuterAbstractBase
@Override
protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder)
{
// Close folder
Boolean isClosed = (Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED);
if (Boolean.FALSE.equals(isClosed) == true)
{
nodeService.setProperty(recordFolder, PROP_IS_CLOSED, true);
}
// Close the record folder
recordFolderService.closeRecordFolder(recordFolder);
// Mark the folder as cut off
doCutOff(recordFolder);
dispositionService.cutoffDisposableItem(recordFolder);
// Mark all the declared children of the folder as cut off
List<NodeRef> records = recordService.getRecords(recordFolder);
for (NodeRef record : records)
for (NodeRef record : recordService.getRecords(recordFolder))
{
doCutOff(record);
dispositionService.cutoffDisposableItem(record);
}
}
@@ -70,22 +58,6 @@ public class CutOffAction extends RMDispositionActionExecuterAbstractBase
protected void executeRecordLevelDisposition(Action action, NodeRef record)
{
// Mark the record as cut off
doCutOff(record);
}
/**
* Marks the record or record folder as cut off, calculating the cut off date.
*
* @param nodeRef node reference
*/
private void doCutOff(NodeRef nodeRef)
{
if (nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF) == false)
{
// Apply the cut off aspect and set cut off date
Map<QName, Serializable> cutOffProps = new HashMap<QName, Serializable>(1);
cutOffProps.put(PROP_CUT_OFF_DATE, new Date());
nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps);
}
dispositionService.cutoffDisposableItem(record);
}
}

View File

@@ -32,7 +32,7 @@ public class CutoffCapabilityCondition extends AbstractCapabilityCondition
@Override
public boolean evaluate(NodeRef nodeRef)
{
return dispositionService.isCutoff(nodeRef);
return dispositionService.isDisposableItemCutoff(nodeRef);
}
}

View File

@@ -201,14 +201,23 @@ public interface DispositionService
DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef);
/**
* Indicates whether the item is cutoff or not.
* Indicates whether the disposable item (records, record folders) is cutoff or not.
*
* @param nodeRef node reference
* @return boolean true if the item is cutoff, false otherwise
* @return boolean true if the disposable item is cutoff, false otherwise
*
* @since 2.0
*/
boolean isCutoff(NodeRef nodeRef);
boolean isDisposableItemCutoff(NodeRef nodeRef);
/**
* Marks the disposable item (record or record folder) as cut off, calculating the cut off date
*
* @param nodeRef node reference
*
* @since 2.2
*/
void cutoffDisposableItem(NodeRef nodeRef);
/**
* Updates the next disposition action

View File

@@ -837,10 +837,10 @@ public class DispositionServiceImpl implements
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isCutoff(NodeRef)
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItemCutoff(NodeRef)
*/
@Override
public boolean isCutoff(NodeRef nodeRef)
public boolean isDisposableItemCutoff(NodeRef nodeRef)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
return nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF);
@@ -969,4 +969,21 @@ public class DispositionServiceImpl implements
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#cutoffDisposableItem(NodeRef)
*/
@Override
public void cutoffDisposableItem(NodeRef nodeRef)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
if (isDisposableItemCutoff(nodeRef) == false)
{
// Apply the cut off aspect and set cut off date
Map<QName, Serializable> cutOffProps = new HashMap<QName, Serializable>(1);
cutOffProps.put(PROP_CUT_OFF_DATE, new Date());
nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps);
}
}
}

View File

@@ -38,6 +38,6 @@ public class CutoffEvaluator extends BaseEvaluator
@Override
protected boolean evaluateImpl(NodeRef nodeRef)
{
return (dispositionService.isCutoff(nodeRef) == isCutoff);
return (dispositionService.isDisposableItemCutoff(nodeRef) == isCutoff);
}
}

View File

@@ -148,11 +148,11 @@ public interface RecordFolderService
// TODO rename to getContainedRecords(NodeRef recordFolder);
/**
* Closes the folder. If the given node reference is a record the parent will be retrieved and processed.
* Closes the record folder. If the given node reference is a record the parent will be retrieved and processed.
*
* @param nodeRef the record folder node reference
*
*
* @since 2.2
*/
void closeFolder(NodeRef nodeRef);
void closeRecordFolder(NodeRef nodeRef);
}

View File

@@ -168,7 +168,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
// ensure nothing is being added to a closed record folder
NodeRef recordFolder = childAssocRef.getParentRef();
Boolean isClosed = (Boolean) this.nodeService.getProperty(recordFolder, PROP_IS_CLOSED);
Boolean isClosed = (Boolean) nodeService.getProperty(recordFolder, PROP_IS_CLOSED);
if (isClosed != null && Boolean.TRUE.equals(isClosed) == true)
{
throw new AlfrescoRuntimeException("You can't add new items to a closed record folder.");
@@ -247,7 +247,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED));
}
return ((Boolean)this.nodeService.getProperty(nodeRef, PROP_IS_CLOSED)).booleanValue();
return ((Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED)).booleanValue();
}
@Override
@@ -347,7 +347,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
List<NodeRef> result = new ArrayList<NodeRef>(1);
if (recordService.isRecord(record) == true)
{
List<ChildAssociationRef> assocs = this.nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
List<ChildAssociationRef> assocs = nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
NodeRef parent = assoc.getParentRef();
@@ -361,10 +361,10 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#closeFolder(NodeRef)
* @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#closeRecordFolder(NodeRef)
*/
@Override
public void closeFolder(NodeRef nodeRef)
public void closeRecordFolder(NodeRef nodeRef)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
@@ -379,8 +379,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
if (isRecordFolder(nodeRef) == true)
{
Boolean isClosed = (Boolean) nodeService.getProperty(nodeRef, PROP_IS_CLOSED);
if (Boolean.FALSE.equals(isClosed) == true)
if (isRecordFolderClosed(nodeRef) == false)
{
nodeService.setProperty(nodeRef, PROP_IS_CLOSED, true);
}