use of org.alfresco.service.cmr.action.Action in project records-management by Alfresco.
the class RMActionExecuterAbstractBase method execute.
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#execute(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
*/
public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map<String, Serializable> parameters) {
// Create the action
Action action = this.actionService.createAction(name);
action.setParameterValues(parameters);
// disable model security whilst we execute the RM rule
modelSecurityService.disable();
try {
// Execute the action
actionService.executeAction(action, filePlanComponent);
} finally {
modelSecurityService.enable();
}
// Get the result
Object value = action.getParameterValue(ActionExecuterAbstractBase.PARAM_RESULT);
return new RecordsManagementActionResult(value);
}
use of org.alfresco.service.cmr.action.Action in project records-management by Alfresco.
the class UnlinkFromActionUnitTest method nodeNotRecord.
/**
* Given that actioned upon node is not a record
* When the action is executed
* Then nothing happens
*/
@Test
public void nodeNotRecord() {
NodeRef notRecord = generateCmContent(generateText());
doReturn(true).when(mockedNodeService).exists(notRecord);
doReturn(false).when(mockedNodeService).hasAspect(notRecord, ASPECT_PENDING_DELETE);
action.executeImpl(mock(Action.class), notRecord);
verify(mockedRecordService, never()).unlink(any(NodeRef.class), any(NodeRef.class));
}
use of org.alfresco.service.cmr.action.Action in project records-management by Alfresco.
the class RecordableVersionConfigActionTest method testRecordableVersionConfigAction.
public void testRecordableVersionConfigAction() {
// Uncommented due to the failures on bamboo. Also this is related to RM-1758
/*
doTestInTransaction(new Test<Void>()
{
final NodeRef document1 = fileFolderService.create(dmFolder, "aDocument", ContentModel.TYPE_CONTENT).getNodeRef();
public Void run()
{
Action action = actionService.createAction(NAME);
action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString());
actionService.executeAction(action, document1);
return null;
}
public void test(Void result) throws Exception
{
Serializable version = nodeService.getProperty(document1, PROP_RECORDABLE_VERSION_POLICY);
assertNotNull(version);
assertEquals(MAJOR_ONLY.toString(), (String) version);
};
},
dmCollaborator);
*/
doTestInTransaction(new Test<Void>() {
public Void run() {
Action action = actionService.createAction(NAME);
action.setParameterValue(PARAM_VERSION, ALL.toString());
actionService.executeAction(action, dmFolder);
return null;
}
public void test(Void result) throws Exception {
assertNull(nodeService.getProperty(dmFolder, PROP_RECORDABLE_VERSION_POLICY));
}
}, dmCollaborator);
doTestInTransaction(new Test<Void>() {
final NodeRef document2 = fileFolderService.create(dmFolder, "another document", ContentModel.TYPE_CONTENT).getNodeRef();
public Void run() {
Action action = actionService.createAction(NAME);
action.setParameterValue(PARAM_VERSION, NONE.toString());
actionService.executeAction(action, document2);
return null;
}
public void test(Void result) throws Exception {
assertNull(nodeService.getProperty(document2, PROP_RECORDABLE_VERSION_POLICY));
}
}, dmCollaborator);
doTestInTransaction(new Test<Void>() {
final NodeRef document3 = fileFolderService.create(dmFolder, "testfile.txt", ContentModel.TYPE_CONTENT).getNodeRef();
public Void run() {
Action createAction = actionService.createAction(CreateRecordAction.NAME);
createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
actionService.executeAction(createAction, document3);
Action action = actionService.createAction(NAME);
action.setParameterValue(PARAM_VERSION, MAJOR_ONLY.toString());
actionService.executeAction(action, document3);
return null;
}
public void test(Void result) throws Exception {
assertNull(nodeService.getProperty(document3, PROP_RECORDABLE_VERSION_POLICY));
}
}, dmCollaborator);
}
use of org.alfresco.service.cmr.action.Action in project records-management by Alfresco.
the class RM2192Test method testAccessToRecordAfterDeclaring.
public void testAccessToRecordAfterDeclaring() {
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
folder = fileFolderService.create(documentLibrary2, generate(), TYPE_FOLDER).getNodeRef();
Action createAction = actionService.createAction(CreateRecordAction.NAME);
createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
Rule declareRule = new Rule();
declareRule.setRuleType(INBOUND);
declareRule.setTitle(generate());
declareRule.setAction(createAction);
declareRule.setExecuteAsynchronously(true);
declareRule.applyToChildren(true);
ruleService.saveRule(folder, declareRule);
Action fileAction = actionService.createAction(FileToAction.NAME);
fileAction.setParameterValue(FileToAction.PARAM_PATH, PATH);
fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true);
Rule fileRule = new Rule();
fileRule.setRuleType(INBOUND);
fileRule.setTitle(generate());
fileRule.setAction(fileAction);
fileRule.setExecuteAsynchronously(true);
ruleService.saveRule(unfiledContainer, fileRule);
return null;
}
@Override
public void test(Void result) throws Exception {
assertFalse(ruleService.getRules(folder).isEmpty());
assertFalse(ruleService.getRules(unfiledContainer).isEmpty());
}
});
doTestInTransaction(new Test<Void>() {
NodeRef document;
@Override
public Void run() {
document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
return null;
}
@Override
public void test(Void result) throws InterruptedException {
Thread.sleep(10000);
assertEquals(permissionService.hasPermission(document, READ_RECORDS), ALLOWED);
assertTrue(recordService.isFiled(document));
assertNotNull(converter.toJSON(document, true));
}
}, user);
}
Aggregations