mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
RM-6941 added slf4j and test [ags]
This commit is contained in:
@@ -45,4 +45,4 @@ rm.action.create.transfer.container.child-error-message=You can't create items i
|
||||
rm.action.create.transfer.child-error-message=You can't create items in Transfer Folders.
|
||||
rm.action.create.record.folder.child-error-message=You can only create records in record folders and this was a {0}.
|
||||
rm.action.transfer-non-editable=You can't edit transfer folder or container metadata.
|
||||
rm.action.node.frozen.error-message=Unable to perform action {0} because node is frozen or has frozen children.
|
||||
rm.action.node.frozen.error-message=Unable to perform action {0} because the node is frozen or has frozen children.
|
||||
|
@@ -80,7 +80,7 @@
|
||||
<property name="searchService" ref="searchService" />
|
||||
<property name="personService" ref="personService" />
|
||||
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
||||
<property name="freezeService" ref="freezeService"/>
|
||||
<property name="freezeService" ref="freezeService"/>
|
||||
<property name="batchSize" value="${rm.dispositionlifecycletrigger.batchsize}"/>
|
||||
</bean>
|
||||
|
||||
|
@@ -953,6 +953,7 @@
|
||||
org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService.hasFrozenChildren=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService.getFreezeDate=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService.getFreezeInitiator=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService.isFrozenOrHasFrozenChildren=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService.*=RM_DENY
|
||||
]]>
|
||||
</value>
|
||||
|
@@ -141,6 +141,11 @@
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -54,10 +54,9 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Slf4j
|
||||
public class RecordsManagementActionServiceImpl implements RecordsManagementActionService {
|
||||
/**
|
||||
* I18N
|
||||
*/
|
||||
public class RecordsManagementActionServiceImpl implements RecordsManagementActionService
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NOT_DEFINED = "rm.action.not-defined";
|
||||
private static final String MSG_NO_IMPLICIT_NODEREF = "rm.action.no-implicit-noderef";
|
||||
private static final String MSG_NODE_FROZEN = "rm.action.node.frozen.error-message";
|
||||
@@ -70,19 +69,13 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
|
||||
private Map<String, RecordsManagementAction> dispositionActions = new HashMap<>(5);
|
||||
|
||||
/**
|
||||
* Policy component
|
||||
*/
|
||||
/** Policy component */
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/**
|
||||
* Node service
|
||||
*/
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Policy delegates
|
||||
*/
|
||||
/** Policy delegates */
|
||||
private ClassPolicyDelegate<BeforeRMActionExecution> beforeRMActionExecutionDelegate;
|
||||
private ClassPolicyDelegate<OnRMActionExecution> onRMActionExecutionDelegate;
|
||||
|
||||
@@ -94,7 +87,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @param freezeService freeze service
|
||||
*/
|
||||
public void setFreezeService(FreezeService freezeService) {
|
||||
public void setFreezeService(FreezeService freezeService)
|
||||
{
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
@@ -103,21 +97,24 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
*/
|
||||
private List<String> retentionActions;
|
||||
|
||||
public void setRetentionActions(List<String> retentionActions) {
|
||||
public void setRetentionActions(List<String> retentionActions)
|
||||
{
|
||||
this.retentionActions = retentionActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Policy component
|
||||
*/
|
||||
protected PolicyComponent getPolicyComponent() {
|
||||
protected PolicyComponent getPolicyComponent()
|
||||
{
|
||||
return this.policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node Service
|
||||
*/
|
||||
protected NodeService getNodeService() {
|
||||
protected NodeService getNodeService()
|
||||
{
|
||||
return this.nodeService;
|
||||
}
|
||||
|
||||
@@ -126,23 +123,26 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
*
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent) {
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node service
|
||||
*
|
||||
* @param nodeService node service
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService) {
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise RM action service
|
||||
*/
|
||||
public void init() {
|
||||
public void init()
|
||||
{
|
||||
// Register the various policies
|
||||
beforeRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(BeforeRMActionExecution.class);
|
||||
onRMActionExecutionDelegate = getPolicyComponent().registerClassPolicy(OnRMActionExecution.class);
|
||||
@@ -151,18 +151,23 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#register(org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction)
|
||||
*/
|
||||
public void register(RecordsManagementAction rmAction) {
|
||||
if (!rmActions.containsKey(rmAction.getName())) {
|
||||
public void register(RecordsManagementAction rmAction)
|
||||
{
|
||||
if (!rmActions.containsKey(rmAction.getName()))
|
||||
{
|
||||
rmActions.put(rmAction.getName(), rmAction);
|
||||
|
||||
if (rmAction.isDispositionAction()) {
|
||||
if (rmAction.isDispositionAction())
|
||||
{
|
||||
dispositionActions.put(rmAction.getName(), rmAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(RecordsManagementActionCondition rmCondition) {
|
||||
if (!rmConditions.containsKey(rmCondition.getBeanName())) {
|
||||
public void register(RecordsManagementActionCondition rmCondition)
|
||||
{
|
||||
if (!rmConditions.containsKey(rmCondition.getBeanName()))
|
||||
{
|
||||
rmConditions.put(rmCondition.getBeanName(), rmCondition);
|
||||
}
|
||||
}
|
||||
@@ -170,11 +175,12 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* Invoke beforeRMActionExecution policy
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters) {
|
||||
protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef);
|
||||
// execute policy for node type and aspects
|
||||
@@ -185,11 +191,12 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* Invoke onRMActionExecution policy
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters) {
|
||||
protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(getNodeService(), nodeRef);
|
||||
// execute policy for node type and aspects
|
||||
@@ -200,7 +207,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActions()
|
||||
*/
|
||||
public List<RecordsManagementAction> getRecordsManagementActions() {
|
||||
public List<RecordsManagementAction> getRecordsManagementActions()
|
||||
{
|
||||
List<RecordsManagementAction> result = new ArrayList<>(this.rmActions.size());
|
||||
result.addAll(this.rmActions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
@@ -210,7 +218,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActionConditions()
|
||||
*/
|
||||
@Override
|
||||
public List<RecordsManagementActionCondition> getRecordsManagementActionConditions() {
|
||||
public List<RecordsManagementActionCondition> getRecordsManagementActionConditions()
|
||||
{
|
||||
List<RecordsManagementActionCondition> result = new ArrayList<>(rmConditions.size());
|
||||
result.addAll(rmConditions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
@@ -223,10 +232,12 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
* @return List of records management action
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public List<RecordsManagementAction> getDispositionActions(NodeRef nodeRef) {
|
||||
public List<RecordsManagementAction> getDispositionActions(NodeRef nodeRef)
|
||||
{
|
||||
List<RecordsManagementAction> result = new ArrayList<>(this.rmActions.size());
|
||||
|
||||
for (RecordsManagementAction action : this.rmActions.values()) {
|
||||
for (RecordsManagementAction action : this.rmActions.values())
|
||||
{
|
||||
// TODO check the permissions on the action ...
|
||||
}
|
||||
|
||||
@@ -236,7 +247,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionActions()
|
||||
*/
|
||||
public List<RecordsManagementAction> getDispositionActions() {
|
||||
public List<RecordsManagementAction> getDispositionActions()
|
||||
{
|
||||
List<RecordsManagementAction> result = new ArrayList<>(dispositionActions.size());
|
||||
result.addAll(dispositionActions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
@@ -245,47 +257,54 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionAction(java.lang.String)
|
||||
*/
|
||||
public RecordsManagementAction getDispositionAction(String name) {
|
||||
public RecordsManagementAction getDispositionAction(String name)
|
||||
{
|
||||
return dispositionActions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementAction(java.lang.String)
|
||||
*/
|
||||
public RecordsManagementAction getRecordsManagementAction(String name) {
|
||||
public RecordsManagementAction getRecordsManagementAction(String name)
|
||||
{
|
||||
return this.rmActions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name) {
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name)
|
||||
{
|
||||
return executeRecordsManagementAction(nodeRef, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String)
|
||||
*/
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name) {
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name)
|
||||
{
|
||||
return executeRecordsManagementAction(nodeRefs, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map<String, Serializable> parameters) {
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
log.debug("Executing record management action on " + nodeRef);
|
||||
log.debug(" actionName = " + name);
|
||||
log.debug(" parameters = " + parameters);
|
||||
|
||||
RecordsManagementAction rmAction = this.rmActions.get(name);
|
||||
if (rmAction == null) {
|
||||
if (rmAction == null)
|
||||
{
|
||||
String msg = I18NUtil.getMessage(MSG_NOT_DEFINED, name);
|
||||
log.warn(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(nodeRef) && retentionActions.contains(name.toLowerCase())) {
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(nodeRef) && retentionActions.contains(name.toLowerCase()))
|
||||
{
|
||||
String msg = I18NUtil.getMessage(MSG_NODE_FROZEN, name);
|
||||
|
||||
log.debug(msg);
|
||||
@@ -296,7 +315,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
// Execute action
|
||||
invokeBeforeRMActionExecution(nodeRef, name, parameters);
|
||||
RecordsManagementActionResult result = rmAction.execute(nodeRef, parameters);
|
||||
if (getNodeService().exists(nodeRef)) {
|
||||
if (getNodeService().exists(nodeRef))
|
||||
{
|
||||
invokeOnRMActionExecution(nodeRef, name, parameters);
|
||||
}
|
||||
|
||||
@@ -306,15 +326,18 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#executeRecordsManagementAction(java.lang.String, java.util.Map)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(String name, Map<String, Serializable> parameters) {
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
RecordsManagementAction rmAction = rmActions.get(name);
|
||||
|
||||
NodeRef implicitTargetNode = rmAction.getImplicitTargetNodeRef();
|
||||
if (implicitTargetNode == null) {
|
||||
if (implicitTargetNode == null)
|
||||
{
|
||||
String msg = I18NUtil.getMessage(MSG_NO_IMPLICIT_NODEREF, name);
|
||||
log.warn(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return this.executeRecordsManagementAction(implicitTargetNode, name, parameters);
|
||||
}
|
||||
}
|
||||
@@ -322,10 +345,12 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name, Map<String, Serializable> parameters) {
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// Execute the action on each node in the list
|
||||
Map<NodeRef, RecordsManagementActionResult> results = new HashMap<>(nodeRefs.size());
|
||||
for (NodeRef nodeRef : nodeRefs) {
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
RecordsManagementActionResult result = executeRecordsManagementAction(nodeRef, name, parameters);
|
||||
results.put(nodeRef, result);
|
||||
}
|
||||
|
@@ -66,20 +66,15 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
public class FreezeServiceImpl extends ServiceBaseImpl
|
||||
implements FreezeService,
|
||||
RecordsManagementModel {
|
||||
/**
|
||||
* I18N
|
||||
*/
|
||||
RecordsManagementModel
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_HOLD_NAME = "rm.hold.name";
|
||||
|
||||
/**
|
||||
* File Plan Service
|
||||
*/
|
||||
/** File Plan Service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* Hold service
|
||||
*/
|
||||
/** Hold service */
|
||||
private HoldService holdService;
|
||||
|
||||
/**
|
||||
@@ -398,10 +393,13 @@ public class FreezeServiceImpl extends ServiceBaseImpl
|
||||
* @return <code>true</code> if the node is frozen or has frozen children, <code>false</code> otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isFrozenOrHasFrozenChildren(NodeRef nodeRef) {
|
||||
if (recordFolderService.isRecordFolder(nodeRef)) {
|
||||
public boolean isFrozenOrHasFrozenChildren(NodeRef nodeRef)
|
||||
{
|
||||
if (recordFolderService.isRecordFolder(nodeRef))
|
||||
{
|
||||
return isFrozen(nodeRef) || hasFrozenChildren(nodeRef);
|
||||
} else if (recordService.isRecord(nodeRef)) {
|
||||
} else if (recordService.isRecord(nodeRef))
|
||||
{
|
||||
return isFrozen(nodeRef);
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
|
@@ -59,46 +59,31 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
@Slf4j
|
||||
public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecuter {
|
||||
/**
|
||||
* batching properties
|
||||
*/
|
||||
|
||||
/** batching properties */
|
||||
private int batchSize;
|
||||
public static final int DEFAULT_BATCH_SIZE = 500;
|
||||
private static final String MSG_NODE_FROZEN = "rm.action.node.frozen.error-message";
|
||||
|
||||
/**
|
||||
* list of disposition actions to automatically execute
|
||||
*/
|
||||
/** list of disposition actions to automatically execute */
|
||||
private List<String> dispositionActions;
|
||||
|
||||
/**
|
||||
* query string
|
||||
*/
|
||||
/** query string */
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* records management action service
|
||||
*/
|
||||
/** records management action service */
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/**
|
||||
* node service
|
||||
*/
|
||||
/** node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* search service
|
||||
*/
|
||||
/** search service */
|
||||
private SearchService searchService;
|
||||
|
||||
/**
|
||||
* person service
|
||||
*/
|
||||
/** person service */
|
||||
private PersonService personService;
|
||||
|
||||
/**
|
||||
* Freeze Service
|
||||
*/
|
||||
/** freeze service */
|
||||
private FreezeService freezeService;
|
||||
|
||||
/**
|
||||
@@ -113,32 +98,37 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
*
|
||||
* @param dispositionActions disposition actions
|
||||
*/
|
||||
public void setDispositionActions(List<String> dispositionActions) {
|
||||
public void setDispositionActions(List<String> dispositionActions)
|
||||
{
|
||||
this.dispositionActions = dispositionActions;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize) {
|
||||
public void setBatchSize(int batchSize)
|
||||
{
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordsManagementActionService records management action service
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) {
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService) {
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchService search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService) {
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
@@ -147,18 +137,24 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
*
|
||||
* @return job query string
|
||||
*/
|
||||
protected String getQuery() {
|
||||
if (query == null) {
|
||||
protected String getQuery()
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("TYPE:\"rma:dispositionAction\" AND ");
|
||||
sb.append("(@rma\\:dispositionAction:(");
|
||||
|
||||
boolean bFirst = true;
|
||||
for (String dispositionAction : dispositionActions) {
|
||||
if (bFirst) {
|
||||
for (String dispositionAction : dispositionActions)
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" OR ");
|
||||
}
|
||||
|
||||
@@ -182,11 +178,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#execute()
|
||||
*/
|
||||
@Override
|
||||
public void executeImpl() {
|
||||
try {
|
||||
public void executeImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
log.debug("Job Starting");
|
||||
|
||||
if (dispositionActions == null || dispositionActions.isEmpty()) {
|
||||
if (dispositionActions == null || dispositionActions.isEmpty())
|
||||
{
|
||||
log.debug("Job Finished as disposition action is empty");
|
||||
return;
|
||||
}
|
||||
@@ -194,14 +193,16 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
boolean hasMore = true;
|
||||
int skipCount = 0;
|
||||
|
||||
if (batchSize < 1) {
|
||||
if (batchSize < 1)
|
||||
{
|
||||
log.debug("Invalid value for batch size: " + batchSize + " default value used instead.");
|
||||
batchSize = DEFAULT_BATCH_SIZE;
|
||||
}
|
||||
|
||||
log.trace("Using batch size of " + batchSize);
|
||||
|
||||
while (hasMore) {
|
||||
while (hasMore)
|
||||
{
|
||||
SearchParameters params = new SearchParameters();
|
||||
params.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
params.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
|
||||
@@ -219,12 +220,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
log.debug("Processing " + resultNodes.size() + " nodes");
|
||||
|
||||
// process search results
|
||||
if (!resultNodes.isEmpty()) {
|
||||
if (!resultNodes.isEmpty())
|
||||
{
|
||||
executeAction(resultNodes);
|
||||
}
|
||||
}
|
||||
log.debug("Job Finished");
|
||||
} catch (AlfrescoRuntimeException exception) {
|
||||
} catch (AlfrescoRuntimeException exception)
|
||||
{
|
||||
log.debug(exception.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -234,39 +237,47 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
*
|
||||
* @param actionNodes - the disposition actions to execute
|
||||
*/
|
||||
private void executeAction(final List<NodeRef> actionNodes) {
|
||||
private void executeAction(final List<NodeRef> actionNodes)
|
||||
{
|
||||
RetryingTransactionCallback<Boolean> processTranCB = () -> {
|
||||
for (NodeRef actionNode : actionNodes) {
|
||||
if (!nodeService.exists(actionNode)) {
|
||||
for (NodeRef actionNode : actionNodes)
|
||||
{
|
||||
if (!nodeService.exists(actionNode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dispAction = (String) nodeService.getProperty(actionNode, PROP_DISPOSITION_ACTION);
|
||||
|
||||
// Run disposition action
|
||||
if (dispAction == null || !dispositionActions.contains(dispAction)) {
|
||||
if (dispAction == null || !dispositionActions.contains(dispAction))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ChildAssociationRef parent = nodeService.getPrimaryParent(actionNode);
|
||||
if (!parent.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION)) {
|
||||
if (!parent.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Map<String, Serializable> props = Map.of(PARAM_NO_ERROR_CHECK, false);
|
||||
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(parent.getParentRef())) {
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(parent.getParentRef()))
|
||||
{
|
||||
log.debug(I18NUtil.getMessage(MSG_NODE_FROZEN, dispAction));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
// execute disposition action
|
||||
recordsManagementActionService
|
||||
.executeRecordsManagementAction(parent.getParentRef(), dispAction, props);
|
||||
.executeRecordsManagementAction(parent.getParentRef(), dispAction, props);
|
||||
|
||||
log.debug("Processed action: " + dispAction + "on" + parent);
|
||||
|
||||
} catch (AlfrescoRuntimeException exception) {
|
||||
} catch (AlfrescoRuntimeException exception)
|
||||
{
|
||||
log.debug(exception.getMessage());
|
||||
|
||||
}
|
||||
|
@@ -41,11 +41,13 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
public class FreezeServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
private List<NodeRef> holdAssocs;
|
||||
|
||||
@Override
|
||||
protected boolean isRecordTest() {
|
||||
protected boolean isRecordTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,12 +56,15 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
*
|
||||
* @deprecated as of 2.2
|
||||
*/
|
||||
public void testFreezeService() throws Exception {
|
||||
public void testFreezeService() throws Exception
|
||||
{
|
||||
|
||||
|
||||
doTestInTransaction(new Test<Void>() {
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
public Void run() throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(recordOne));
|
||||
assertTrue(recordService.isRecord(recordTwo));
|
||||
assertTrue(recordService.isRecord(recordThree));
|
||||
@@ -122,25 +127,30 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
assertNotNull(holdAssocs);
|
||||
assertEquals(2, holdAssocs.size());
|
||||
|
||||
for (NodeRef hold : holdAssocs) {
|
||||
for (NodeRef hold : holdAssocs)
|
||||
{
|
||||
String reason = holdService.getHoldReason(hold);
|
||||
if (reason.equals("Freeze a set of nodes")) {
|
||||
if (reason.equals("Freeze a set of nodes"))
|
||||
{
|
||||
assertEquals(newHold, hold);
|
||||
frozenNodes = holdService.getHeld(hold);
|
||||
assertNotNull(frozenNodes);
|
||||
assertEquals(3, frozenNodes.size());
|
||||
} else if (reason.equals("NewFreezeReason")) {
|
||||
} else if (reason.equals("NewFreezeReason"))
|
||||
{
|
||||
frozenNodes = holdService.getHeld(hold);
|
||||
assertNotNull(frozenNodes);
|
||||
assertEquals(1, frozenNodes.size());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check the nodes are frozen
|
||||
final List<NodeRef> testRecords = Arrays.asList(new NodeRef[]{recordOne, recordTwo, recordThree});
|
||||
for (NodeRef nr : testRecords) {
|
||||
final List<NodeRef> testRecords = Arrays.asList(new NodeRef[] { recordOne, recordTwo, recordThree });
|
||||
for (NodeRef nr : testRecords)
|
||||
{
|
||||
assertTrue(freezeService.isFrozen(nr));
|
||||
assertNotNull(freezeService.getFreezeDate(nr));
|
||||
assertNotNull(freezeService.getFreezeInitiator(nr));
|
||||
@@ -152,17 +162,21 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
holdAssocs = holdService.getHolds(filePlan);
|
||||
assertNotNull(holdAssocs);
|
||||
assertEquals(2, holdAssocs.size());
|
||||
for (NodeRef hold : holdAssocs) {
|
||||
for (NodeRef hold : holdAssocs)
|
||||
{
|
||||
String reason = holdService.getHoldReason(hold);
|
||||
if (reason.equals("Freeze a set of nodes")) {
|
||||
if (reason.equals("Freeze a set of nodes"))
|
||||
{
|
||||
frozenNodes = holdService.getHeld(hold);
|
||||
assertNotNull(frozenNodes);
|
||||
assertEquals(2, frozenNodes.size());
|
||||
} else if (reason.equals("NewFreezeReason")) {
|
||||
} else if (reason.equals("NewFreezeReason"))
|
||||
{
|
||||
frozenNodes = holdService.getHeld(hold);
|
||||
assertNotNull(frozenNodes);
|
||||
assertEquals(1, frozenNodes.size());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The reason '" + reason + "' was not found in the existing holds.");
|
||||
}
|
||||
}
|
||||
@@ -180,9 +194,11 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
}
|
||||
});
|
||||
//Splitting transaction to fix onCreateNodePolicy issue where there was a node not found exception
|
||||
doTestInTransaction(new Test<Void>() {
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
public Void run() throws Exception
|
||||
{
|
||||
// Relinquish the first hold
|
||||
NodeRef holdNodeRef = holdAssocs.iterator().next();
|
||||
holdService.deleteHold(holdNodeRef);
|
||||
@@ -230,9 +246,11 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
}
|
||||
});
|
||||
//Splitting transaction to fix onCreateNodePolicy issue where there was a node not found exception
|
||||
doTestInTransaction(new Test<Void>() {
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
public Void run() throws Exception
|
||||
{
|
||||
// Relinquish the first hold
|
||||
holdService.deleteHold(holdAssocs.iterator().next());
|
||||
|
||||
@@ -247,10 +265,12 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>() {
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
NodeRef hold101 = holdService.createHold(filePlan, "freezename 101", "FreezeReason", null);
|
||||
public Void run() throws Exception
|
||||
{
|
||||
NodeRef hold101 = holdService.createHold(filePlan, "freezename 103", "FreezeReason", null);
|
||||
// Freeze a record folder
|
||||
assertNotNull(hold101);
|
||||
holdService.addToHold(hold101, rmFolder);
|
||||
@@ -260,14 +280,16 @@ public class FreezeServiceImplTest extends BaseRMTestCase {
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>() {
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
NodeRef hold101 = holdService.createHold(filePlan, "freezename 101", "FreezeReason", null);
|
||||
public Void run() throws Exception
|
||||
{
|
||||
NodeRef hold101 = holdService.createHold(filePlan, "freezename 104", "FreezeReason", null);
|
||||
// Freeze a record inside a record folder
|
||||
assertNotNull(hold101);
|
||||
holdService.addToHold(hold101, recordThree);
|
||||
assertTrue(recordService.isRecord(rmFolder));
|
||||
assertTrue(recordService.isRecord(recordThree));
|
||||
assertTrue(freezeService.isFrozenOrHasFrozenChildren(rmFolder));
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user