Search in sources :

Example 26 with Action

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);
}
Also used : Action(org.alfresco.service.cmr.action.Action)

Example 27 with Action

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));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Action(org.alfresco.service.cmr.action.Action) BaseActionUnitTest(org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest) Test(org.junit.Test)

Example 28 with Action

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Action(org.alfresco.service.cmr.action.Action) CreateRecordAction(org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction)

Example 29 with Action

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileToAction(org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction) CreateRecordAction(org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction) Action(org.alfresco.service.cmr.action.Action) Rule(org.alfresco.service.cmr.rule.Rule)

Aggregations

Action (org.alfresco.service.cmr.action.Action)29 NodeRef (org.alfresco.service.cmr.repository.NodeRef)18 ArrayList (java.util.ArrayList)8 Rule (org.alfresco.service.cmr.rule.Rule)7 CreateRecordAction (org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction)6 JSONObject (org.json.JSONObject)6 Serializable (java.io.Serializable)5 FileToAction (org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction)5 HashMap (java.util.HashMap)4 List (java.util.List)4 JSONArray (org.json.JSONArray)4 ActionCondition (org.alfresco.service.cmr.action.ActionCondition)3 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 ActionImpl (org.alfresco.repo.action.ActionImpl)2 CompositeActionImpl (org.alfresco.repo.action.CompositeActionImpl)2 ThumbnailDefinition (org.alfresco.repo.thumbnail.ThumbnailDefinition)2 ThumbnailRegistry (org.alfresco.repo.thumbnail.ThumbnailRegistry)2 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)2 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)2 ActionDefinition (org.alfresco.service.cmr.action.ActionDefinition)2