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,10 +60,20 @@
|
||||
</property>
|
||||
</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>
|
||||
|
||||
|
||||
<!-- Cutoff action -->
|
||||
|
||||
|
||||
@@ -92,7 +102,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="unCutoff"/>
|
||||
</property>
|
||||
@@ -117,7 +127,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="destroy"/>
|
||||
</property>
|
||||
@@ -152,32 +162,20 @@
|
||||
<!-- retain -->
|
||||
<!-- 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">
|
||||
<ref bean="retain"/>
|
||||
<bean id="retain" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RetainAction" parent="rmAction" depends-on="rmFileRecordsCapability"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="retain_security"/>
|
||||
<idref bean="allow_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</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 -->
|
||||
|
||||
<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">
|
||||
<ref bean="openRecordFolder"/>
|
||||
</property>
|
||||
@@ -202,7 +200,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="closeRecordFolder"/>
|
||||
</property>
|
||||
@@ -227,7 +225,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="reviewed"/>
|
||||
</property>
|
||||
@@ -252,7 +250,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="declareRecord"/>
|
||||
</property>
|
||||
@@ -278,7 +276,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="undeclareRecord"/>
|
||||
</property>
|
||||
@@ -304,7 +302,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="freeze"/>
|
||||
</property>
|
||||
@@ -329,7 +327,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="unfreeze"/>
|
||||
</property>
|
||||
@@ -354,7 +352,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="relinquishHold"/>
|
||||
</property>
|
||||
@@ -369,7 +367,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="editHoldReason"/>
|
||||
</property>
|
||||
@@ -394,7 +392,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="editReviewAsOfDate"/>
|
||||
</property>
|
||||
@@ -419,7 +417,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="editDispositionActionAsOfDate"/>
|
||||
</property>
|
||||
@@ -445,7 +443,7 @@
|
||||
<!-- broadcast vital record definition -->
|
||||
<!-- 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">
|
||||
<ref bean="broadcastVitalRecordDefinition"/>
|
||||
</property>
|
||||
@@ -472,7 +470,7 @@
|
||||
<!-- broadcast disposition action definition update -->
|
||||
<!-- 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">
|
||||
<ref bean="broadcastDispositionActionDefinitionUpdate"/>
|
||||
</property>
|
||||
@@ -502,7 +500,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="completeEvent"/>
|
||||
</property>
|
||||
@@ -528,7 +526,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="undoEvent"/>
|
||||
</property>
|
||||
@@ -554,7 +552,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="transfer"/>
|
||||
</property>
|
||||
@@ -581,7 +579,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="transferComplete"/>
|
||||
</property>
|
||||
@@ -597,7 +595,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="accession"/>
|
||||
</property>
|
||||
@@ -624,7 +622,7 @@
|
||||
|
||||
<!-- 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">
|
||||
<ref bean="accessionComplete"/>
|
||||
</property>
|
||||
@@ -639,21 +637,18 @@
|
||||
</bean>
|
||||
|
||||
<!-- Split Email -->
|
||||
<bean id="splitEmail" class="org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction" parent="rmAction">
|
||||
|
||||
<bean id="splitEmail_proxy" parent="rmProxyAction" >
|
||||
<property name="target" ref="splitEmail"/>
|
||||
</bean>
|
||||
|
||||
<bean id="splitEmail_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="splitEmail"/>
|
||||
</property>
|
||||
<bean id="splitEmail" class="org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction" parent="rmAction">
|
||||
</bean>
|
||||
|
||||
<!-- Create disposition schedule -->
|
||||
|
||||
<bean id="createDispositionSchedule_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="createDispositionSchedule"/>
|
||||
</property>
|
||||
<bean id="createDispositionSchedule_proxy" parent="rmProxyAction" >
|
||||
<property name="target" ref="createDispositionSchedule"/>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="createDispositionSchedule_security"/>
|
||||
@@ -677,26 +672,32 @@
|
||||
|
||||
<!-- Reject record -->
|
||||
|
||||
<bean id="reject_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="reject"/>
|
||||
</property>
|
||||
<bean id="reject_proxy" parent="rmProxyAction" >
|
||||
<property name="target" ref="reject"/>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="reject_security"/>
|
||||
<idref bean="allow_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="reject_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>
|
||||
<bean id="reject" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RejectAction" parent="rmAction" />
|
||||
|
||||
|
||||
<!-- File To -->
|
||||
|
||||
<bean id="fileTo_proxy" parent="rmProxyAction">
|
||||
<property name="target" ref="fileTo"/>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="allow_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</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>
|
@@ -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,12 +428,12 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
// declare a record
|
||||
utils.declareRecord(recordDeclaredOne);
|
||||
utils.declareRecord(recordDeclaredTwo);
|
||||
}
|
||||
|
||||
// unfiled container
|
||||
unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
|
||||
assertNotNull(unfiledContainer);
|
||||
}
|
||||
}
|
||||
},
|
||||
AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
@@ -546,6 +546,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
{
|
||||
filePlanPermissionService.setPermission(filePlan, user, FILING);
|
||||
filePlanPermissionService.setPermission(rmContainer, user, FILING);
|
||||
filePlanPermissionService.setPermission(unfiledContainer, user, FILING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user