mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-596: A records manager can create a rule that automatically files an unfiled record.
* initial action implementation added * can handle relative name paths to find destination record folder * unit test * TODO .. expose in UI git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@46609 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -60,9 +60,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="actionProxy" abstract="true">
|
<bean id="actionProxy" abstract="true"/>
|
||||||
|
|
||||||
|
<!-- Base security intercepter bean for action 'allow' -->
|
||||||
|
<bean id="allow_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor" parent="actionSecurity">
|
||||||
|
<property name="objectDefinitionSource">
|
||||||
|
<value>
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW
|
||||||
|
org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<!-- Cutoff action -->
|
<!-- Cutoff action -->
|
||||||
|
|
||||||
@@ -92,7 +102,7 @@
|
|||||||
|
|
||||||
<!-- UnCutoff action -->
|
<!-- UnCutoff action -->
|
||||||
|
|
||||||
<bean id="unCutoff_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="unCutoff_proxy" parent="rmProxyAction">
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="unCutoff"/>
|
<ref bean="unCutoff"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -117,7 +127,7 @@
|
|||||||
|
|
||||||
<!-- Destroy -->
|
<!-- Destroy -->
|
||||||
|
|
||||||
<bean id="destroy_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="destroy_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="destroy"/>
|
<ref bean="destroy"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -152,32 +162,20 @@
|
|||||||
<!-- retain -->
|
<!-- retain -->
|
||||||
<!-- No permissoin?? : allow -->
|
<!-- No permissoin?? : allow -->
|
||||||
|
|
||||||
<bean id="retain_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="retain_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="retain"/>
|
<bean id="retain" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RetainAction" parent="rmAction" depends-on="rmFileRecordsCapability"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="interceptorNames">
|
<property name="interceptorNames">
|
||||||
<list>
|
<list>
|
||||||
<idref bean="retain_security"/>
|
<idref bean="allow_security"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="retain_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor" parent="actionSecurity">
|
|
||||||
<property name="objectDefinitionSource">
|
|
||||||
<value>
|
|
||||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW
|
|
||||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW
|
|
||||||
org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="retain" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RetainAction" parent="rmAction" depends-on="rmFileRecordsCapability"/>
|
|
||||||
|
|
||||||
<!-- open record folder -->
|
<!-- open record folder -->
|
||||||
|
|
||||||
<bean id="openRecordFolder_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="openRecordFolder_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="openRecordFolder"/>
|
<ref bean="openRecordFolder"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -202,7 +200,7 @@
|
|||||||
|
|
||||||
<!-- close record folder -->
|
<!-- close record folder -->
|
||||||
|
|
||||||
<bean id="closeRecordFolder_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="closeRecordFolder_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="closeRecordFolder"/>
|
<ref bean="closeRecordFolder"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -227,7 +225,7 @@
|
|||||||
|
|
||||||
<!-- reviewed -->
|
<!-- reviewed -->
|
||||||
|
|
||||||
<bean id="reviewed_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="reviewed_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="reviewed"/>
|
<ref bean="reviewed"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -252,7 +250,7 @@
|
|||||||
|
|
||||||
<!-- declare record -->
|
<!-- declare record -->
|
||||||
|
|
||||||
<bean id="declareRecord_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="declareRecord_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="declareRecord"/>
|
<ref bean="declareRecord"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -278,7 +276,7 @@
|
|||||||
|
|
||||||
<!-- undeclare record -->
|
<!-- undeclare record -->
|
||||||
|
|
||||||
<bean id="undeclareRecord_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="undeclareRecord_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="undeclareRecord"/>
|
<ref bean="undeclareRecord"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -304,7 +302,7 @@
|
|||||||
|
|
||||||
<!-- Freeze record -->
|
<!-- Freeze record -->
|
||||||
|
|
||||||
<bean id="freeze_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="freeze_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="freeze"/>
|
<ref bean="freeze"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -329,7 +327,7 @@
|
|||||||
|
|
||||||
<!-- Unfreeze record -->
|
<!-- Unfreeze record -->
|
||||||
|
|
||||||
<bean id="unfreeze_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="unfreeze_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="unfreeze"/>
|
<ref bean="unfreeze"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -354,7 +352,7 @@
|
|||||||
|
|
||||||
<!-- Relinquish Hold Action-->
|
<!-- Relinquish Hold Action-->
|
||||||
|
|
||||||
<bean id="relinquishHold_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="relinquishHold_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="relinquishHold"/>
|
<ref bean="relinquishHold"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -369,7 +367,7 @@
|
|||||||
|
|
||||||
<!-- Edit hold reason -->
|
<!-- Edit hold reason -->
|
||||||
|
|
||||||
<bean id="editHoldReason_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="editHoldReason_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="editHoldReason"/>
|
<ref bean="editHoldReason"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -394,7 +392,7 @@
|
|||||||
|
|
||||||
<!-- Edit review as of date -->
|
<!-- Edit review as of date -->
|
||||||
|
|
||||||
<bean id="editReviewAsOfDate_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="editReviewAsOfDate_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="editReviewAsOfDate"/>
|
<ref bean="editReviewAsOfDate"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -419,7 +417,7 @@
|
|||||||
|
|
||||||
<!-- Edit disposition action as of date -->
|
<!-- Edit disposition action as of date -->
|
||||||
|
|
||||||
<bean id="editDispositionActionAsOfDate_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="editDispositionActionAsOfDate_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="editDispositionActionAsOfDate"/>
|
<ref bean="editDispositionActionAsOfDate"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -445,7 +443,7 @@
|
|||||||
<!-- broadcast vital record definition -->
|
<!-- broadcast vital record definition -->
|
||||||
<!-- bound to policy: allow -->
|
<!-- bound to policy: allow -->
|
||||||
|
|
||||||
<bean id="broadcastVitalRecordDefinition_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="broadcastVitalRecordDefinition_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="broadcastVitalRecordDefinition"/>
|
<ref bean="broadcastVitalRecordDefinition"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -472,7 +470,7 @@
|
|||||||
<!-- broadcast disposition action definition update -->
|
<!-- broadcast disposition action definition update -->
|
||||||
<!-- bound to policy: allow -->
|
<!-- bound to policy: allow -->
|
||||||
|
|
||||||
<bean id="broadcastDispositionActionDefinitionUpdate_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="broadcastDispositionActionDefinitionUpdate_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="broadcastDispositionActionDefinitionUpdate"/>
|
<ref bean="broadcastDispositionActionDefinitionUpdate"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -502,7 +500,7 @@
|
|||||||
|
|
||||||
<!-- complete event -->
|
<!-- complete event -->
|
||||||
|
|
||||||
<bean id="completeEvent_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="completeEvent_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="completeEvent"/>
|
<ref bean="completeEvent"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -528,7 +526,7 @@
|
|||||||
|
|
||||||
<!-- undo event -->
|
<!-- undo event -->
|
||||||
|
|
||||||
<bean id="undoEvent_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="undoEvent_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="undoEvent"/>
|
<ref bean="undoEvent"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -554,7 +552,7 @@
|
|||||||
|
|
||||||
<!-- transfer -->
|
<!-- transfer -->
|
||||||
|
|
||||||
<bean id="transfer_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="transfer_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="transfer"/>
|
<ref bean="transfer"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -581,7 +579,7 @@
|
|||||||
|
|
||||||
<!-- Transfer complete -->
|
<!-- Transfer complete -->
|
||||||
|
|
||||||
<bean id="transferComplete_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="transferComplete_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="transferComplete"/>
|
<ref bean="transferComplete"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -597,7 +595,7 @@
|
|||||||
|
|
||||||
<!-- accession -->
|
<!-- accession -->
|
||||||
|
|
||||||
<bean id="accession_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="accession_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="accession"/>
|
<ref bean="accession"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -624,7 +622,7 @@
|
|||||||
|
|
||||||
<!-- Accession complete -->
|
<!-- Accession complete -->
|
||||||
|
|
||||||
<bean id="accessionComplete_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="accessionComplete_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="accessionComplete"/>
|
<ref bean="accessionComplete"/>
|
||||||
</property>
|
</property>
|
||||||
@@ -639,21 +637,18 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Split Email -->
|
<!-- Split Email -->
|
||||||
<bean id="splitEmail" class="org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction" parent="rmAction">
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="splitEmail_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="splitEmail_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target" ref="splitEmail"/>
|
||||||
<ref bean="splitEmail"/>
|
</bean>
|
||||||
</property>
|
|
||||||
|
<bean id="splitEmail" class="org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction" parent="rmAction">
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Create disposition schedule -->
|
<!-- Create disposition schedule -->
|
||||||
|
|
||||||
<bean id="createDispositionSchedule_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="createDispositionSchedule_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target" ref="createDispositionSchedule"/>
|
||||||
<ref bean="createDispositionSchedule"/>
|
|
||||||
</property>
|
|
||||||
<property name="interceptorNames">
|
<property name="interceptorNames">
|
||||||
<list>
|
<list>
|
||||||
<idref bean="createDispositionSchedule_security"/>
|
<idref bean="createDispositionSchedule_security"/>
|
||||||
@@ -677,26 +672,32 @@
|
|||||||
|
|
||||||
<!-- Reject record -->
|
<!-- Reject record -->
|
||||||
|
|
||||||
<bean id="reject_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
<bean id="reject_proxy" parent="rmProxyAction" >
|
||||||
<property name="target">
|
<property name="target" ref="reject"/>
|
||||||
<ref bean="reject"/>
|
|
||||||
</property>
|
|
||||||
<property name="interceptorNames">
|
<property name="interceptorNames">
|
||||||
<list>
|
<list>
|
||||||
<idref bean="reject_security"/>
|
<idref bean="allow_security"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="reject_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor" parent="actionSecurity">
|
<bean id="reject" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RejectAction" parent="rmAction" />
|
||||||
<property name="objectDefinitionSource">
|
|
||||||
<value>
|
|
||||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW
|
<!-- File To -->
|
||||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW
|
|
||||||
org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW
|
<bean id="fileTo_proxy" parent="rmProxyAction">
|
||||||
</value>
|
<property name="target" ref="fileTo"/>
|
||||||
|
<property name="interceptorNames">
|
||||||
|
<list>
|
||||||
|
<idref bean="allow_security"/>
|
||||||
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="reject" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RejectAction" parent="rmAction" />
|
<bean id="fileTo" class="org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction" parent="rmAction">
|
||||||
|
<property name="fileFolderService" ref="FileFolderService"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -0,0 +1,113 @@
|
|||||||
|
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File To action implementation.
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class FileToAction extends RMActionExecuterAbstractBase
|
||||||
|
{
|
||||||
|
public static final String NAME = "fileTo";
|
||||||
|
|
||||||
|
public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder";
|
||||||
|
public static final String PARAM_PATH = "path";
|
||||||
|
|
||||||
|
private FileFolderService fileFolderService;
|
||||||
|
|
||||||
|
public void setFileFolderService(FileFolderService fileFolderService)
|
||||||
|
{
|
||||||
|
this.fileFolderService = fileFolderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||||
|
{
|
||||||
|
if (recordService.isFiled(actionedUponNodeRef) == false)
|
||||||
|
{
|
||||||
|
// first look to see if the destination record folder has been specified
|
||||||
|
NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER);
|
||||||
|
if (recordFolder == null)
|
||||||
|
{
|
||||||
|
// get the reference to the record folder based on the relative path
|
||||||
|
recordFolder = resolvePath(action, actionedUponNodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recordFolder == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, because the destination record folder could not be determined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recordsManagementService.isRecordFolder(recordFolder) == true)
|
||||||
|
{
|
||||||
|
// TODO .. what if a record of the same name already exists in the destination record folder??
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileFolderService.move(actionedUponNodeRef, recordFolder, null);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException fileNotFound)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, because the move operation failed.", fileNotFound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, becuase the destination was not a record folder.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, because the actioned upon node is not an unfiled record.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef resolvePath(Action action, NodeRef actionedUponNodeRef)
|
||||||
|
{
|
||||||
|
// TODO we could provide a parameter to override the file plan as the path context
|
||||||
|
|
||||||
|
// the file plan node always provides the context
|
||||||
|
NodeRef context = recordsManagementService.getFilePlan(actionedUponNodeRef);
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, because the path resolution context could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// assume by default the result is the context
|
||||||
|
NodeRef result = context;
|
||||||
|
|
||||||
|
// look for the path parameter
|
||||||
|
String path = (String)action.getParameterValue(PARAM_PATH);
|
||||||
|
if (path != null && path.isEmpty() == false)
|
||||||
|
{
|
||||||
|
String[] pathValues = StringUtils.tokenizeToStringArray(path, "/", false, true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileInfo fileInfo = fileFolderService.resolveNamePath(context, new ArrayList<String>(Arrays.asList(pathValues)));
|
||||||
|
result = fileInfo.getNodeRef();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException fileNotFound)
|
||||||
|
{
|
||||||
|
// TODO .. handle this exception by possibly creating the missing record folder ???
|
||||||
|
|
||||||
|
throw new AlfrescoRuntimeException("Unable to execute file to action, because destination path could not be resolved.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.action.CreateRecordActionTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.action.FileToActionTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.action.HideRecordActionTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.action.RejectActionTest;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RM test suite
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class ActionTestSuite extends TestSuite
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates the test suite
|
||||||
|
*
|
||||||
|
* @return the test suite
|
||||||
|
*/
|
||||||
|
public static Test suite()
|
||||||
|
{
|
||||||
|
TestSuite suite = new TestSuite();
|
||||||
|
suite.addTestSuite(CreateRecordActionTest.class);
|
||||||
|
suite.addTestSuite(HideRecordActionTest.class);
|
||||||
|
suite.addTestSuite(RejectActionTest.class);
|
||||||
|
suite.addTestSuite(FileToActionTest.class);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,209 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.action;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileTo action unit test
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class FileToActionTest extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
private static final String PATH = "rmcontainer/rmfolder";
|
||||||
|
private static final String PATH2 = "/rmcontainer/rmfolder";
|
||||||
|
|
||||||
|
protected ActionService dmActionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initServices()
|
||||||
|
{
|
||||||
|
super.initServices();
|
||||||
|
dmActionService = (ActionService) applicationContext.getBean("ActionService");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isCollaborationSiteTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUserTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileToNodeRef()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// create record from document
|
||||||
|
recordService.createRecord(filePlan, dmDocument);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertFalse(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the unfiled container the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(filePlanService.getUnfiledContainer(filePlan), parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, dmCollaborator);
|
||||||
|
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
|
||||||
|
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(unfiledContainer, RMPermissionModel.FILING));
|
||||||
|
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(rmFolder, RMPermissionModel.FILING));
|
||||||
|
|
||||||
|
Capability capability = capabilityService.getCapability("FileToRecords");
|
||||||
|
assertNotNull(capability);
|
||||||
|
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(dmDocument));
|
||||||
|
|
||||||
|
// set parameters
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(FileToAction.PARAM_DESTINATION_RECORD_FOLDER, rmFolder);
|
||||||
|
|
||||||
|
// execute file-to action
|
||||||
|
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertTrue(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the record folder the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(rmFolder, parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, rmAdminName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileToPath()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// create record from document
|
||||||
|
recordService.createRecord(filePlan, dmDocument);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertFalse(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the unfiled container the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(filePlanService.getUnfiledContainer(filePlan), parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, dmCollaborator);
|
||||||
|
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// set parameters
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(FileToAction.PARAM_PATH, PATH);
|
||||||
|
|
||||||
|
// execute file-to action
|
||||||
|
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertTrue(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the record folder the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(rmFolder, parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, rmAdminName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileToPath2()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// create record from document
|
||||||
|
recordService.createRecord(filePlan, dmDocument);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertFalse(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the unfiled container the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(filePlanService.getUnfiledContainer(filePlan), parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, dmCollaborator);
|
||||||
|
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
// set parameters
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(FileToAction.PARAM_PATH, PATH2);
|
||||||
|
|
||||||
|
// execute file-to action
|
||||||
|
actionService.executeRecordsManagementAction(dmDocument, FileToAction.NAME, params);
|
||||||
|
|
||||||
|
// check things have gone according to plan
|
||||||
|
assertTrue(recordService.isRecord(dmDocument));
|
||||||
|
assertTrue(recordService.isFiled(dmDocument));
|
||||||
|
|
||||||
|
// is the record folder the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument).getParentRef();
|
||||||
|
assertEquals(rmFolder, parent);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, rmAdminName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -428,11 +428,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
// declare a record
|
// declare a record
|
||||||
utils.declareRecord(recordDeclaredOne);
|
utils.declareRecord(recordDeclaredOne);
|
||||||
utils.declareRecord(recordDeclaredTwo);
|
utils.declareRecord(recordDeclaredTwo);
|
||||||
|
|
||||||
// unfiled container
|
|
||||||
unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
|
|
||||||
assertNotNull(unfiledContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unfiled container
|
||||||
|
unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
|
||||||
|
assertNotNull(unfiledContainer);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.getAdminUserName());
|
||||||
@@ -546,6 +546,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
{
|
{
|
||||||
filePlanPermissionService.setPermission(filePlan, user, FILING);
|
filePlanPermissionService.setPermission(filePlan, user, FILING);
|
||||||
filePlanPermissionService.setPermission(rmContainer, user, FILING);
|
filePlanPermissionService.setPermission(rmContainer, user, FILING);
|
||||||
|
filePlanPermissionService.setPermission(unfiledContainer, user, FILING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user