From e11bef00bb661df4dbff8a2c2865d5db04113985 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Fri, 4 May 2018 15:46:30 +0100 Subject: [PATCH 01/22] Search changes, adding support for search by reason key and 'other source' names --- .../rm-webscript-context.xml | 11 ++ .../slingshot/ClassificationReasonsUtil.java | 86 ++++++++++ .../slingshot/ClassificationSourcesUtil.java | 120 +++++++++++++ .../script/slingshot/RMSearchGet.java | 32 ++++ .../script/slingshot/SearchUtil.java | 98 +++++++++++ .../ClassificationReasonsUtilUnitTest.java | 128 ++++++++++++++ .../ClassificationSourcesUtilUnitTest.java | 161 ++++++++++++++++++ 7 files changed, 636 insertions(+) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationReasonsUtil.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtil.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java create mode 100644 rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationReasonsUtilUnitTest.java create mode 100644 rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 3c3d0ccf20..f95804c684 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -467,12 +467,23 @@ + + + + + + + + + + . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.model.ContentModel.PROP_NAME; +import static org.alfresco.service.namespace.QName.createQName; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; + +/** + * Method to replace the plain text classification reason id with the correct nodeRef during record search + * @author Ross Gale + * @since 2.7 + */ +public class ClassificationReasonsUtil extends SearchUtil +{ + + public static final String CR_URI = "http://www.alfresco.org/model/securitymarks/1.0"; + public static final QName CLASSIFICATION_REASONS_CONTAINER = createQName(CR_URI,"classificationReasonsContainer"); + public static final QName PROP_CLASSIFICATION_REASON_CODE = createQName(CR_URI, "classificationReasonCode"); + public static final String REASONS_KEY = "clf:classificationReasons:"; + + /** + * Replace plain text reason id with nodeRef + * @param searchQuery String e.g. clf:classificationReasons:1.4(a) + * @return String e.g. clf:classificationReasons:5cc6d344-fa94-4370-9c81-d947b7e8f2ac + */ + public String replaceReasonWithNodeRef(String searchQuery) + { + List queries = new ArrayList<>(Arrays.asList(searchQuery.split(" "))); + StringBuilder stringBuilder = new StringBuilder(); + for (String queryToEdit : queries) + { + if(queryToEdit.contains(REASONS_KEY)) + { + for (String reasonId : retrieveAllNodeIds(getRootContainer(CLASSIFICATION_REASONS_CONTAINER))) + { + NodeRef reasonNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, reasonId); + Map properties = nodeService.getProperties(reasonNodeRef); + if (queryToEdit.equals(REASONS_KEY + properties.get(PROP_CLASSIFICATION_REASON_CODE).toString()) || + queryToEdit.equals(REASONS_KEY +"\""+ properties.get(PROP_CLASSIFICATION_REASON_CODE).toString() + "\"")) + { + queryToEdit = REASONS_KEY + properties.get(PROP_NAME).toString(); + break; + } + } + } + stringBuilder.append(queryToEdit).append(" "); + } + return stringBuilder.toString(); + } + + +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtil.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtil.java new file mode 100644 index 0000000000..8f9a534db1 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtil.java @@ -0,0 +1,120 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + + +import static org.alfresco.model.ContentModel.PROP_NODE_UUID; +import static org.alfresco.service.namespace.QName.createQName; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; + +/** + * Method to replace the plain text classification source name with all possible nodeRefs during record search + * @author Ross Gale + * @since 2.7 + */ +public class ClassificationSourcesUtil extends SearchUtil +{ + + + public static final String CS_URI = "http://www.alfresco.org/model/classificationsources/1.0"; + public static final QName CLASSIFICATION_SOURCES_CONTAINER = createQName(CS_URI, "classificationSourcesContainer"); + public static final QName PROP_CLASSIFICATION_SOURCE_NAME = createQName(CS_URI, "classificationSourceName"); + public static final String SOURCES_KEY = "cs:appliedSources:"; + public static final String START = "start"; + public static final String END = "end"; + + /** + * Replace plain text source name with all matching nodeRefs + * + * @param searchQuery String e.g. clf:classificationReasons:"Other source" + * @return String e.g. (cs:appliedSources:5cc6d344-fa94-4370-9c81-d947b7e8f2ac OR cs:appliedSources:47afd476-358f-4007-a35e-8f83adb06523) + */ + public String replaceSourceNameWithNodeRef(String searchQuery) + { + Pattern pattern = Pattern.compile("cs:appliedSources:\"[^\"]*\""); + Matcher matcher = pattern.matcher(searchQuery); + StringBuilder builder = new StringBuilder(searchQuery); + Map> index = new HashMap<>(); + int count = 0; + //create a map of where the strings to replace are + while(matcher.find()) + { + index.put(count, new HashMap<>()); + index.get(count).put(START,matcher.start()); + index.get(count).put(END, matcher.end()); + count++; + } + //Go through the string in reverse and replace the plain text reference with nodeIds + for(int i = index.size(); i > 0; i--) + { + Map element = index.get(i-1); + int start = element.get(START); + int end = element.get(END); + builder.replace(start, end, replaceSingleInstance(searchQuery.substring(start, end))); + } + + return builder.toString(); + } + + private String replaceSingleInstance(String str) + { + StringBuilder stringBuilder = new StringBuilder(); + if (str.contains(SOURCES_KEY)) + { + boolean multipleResults = false; + stringBuilder.append('('); + for (String sourceId : retrieveAllNodeIds(getRootContainer(CLASSIFICATION_SOURCES_CONTAINER))) + { + NodeRef reasonNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sourceId); + Map properties = nodeService.getProperties(reasonNodeRef); + if (str.equals(SOURCES_KEY + "\"" + properties.get(PROP_CLASSIFICATION_SOURCE_NAME).toString() + "\"")) + { + if (multipleResults) + { + stringBuilder.append(" OR "); + } + stringBuilder.append(SOURCES_KEY + "\"" + properties.get(PROP_NODE_UUID).toString() + "\""); + //Sources create a node each time even if all the details are the same this will allow multiple nodeIds to be added for a single string + multipleResults = true; + } + } + } + stringBuilder.append(')'); + return stringBuilder.toString(); + } + + +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java index e8ac49ff96..1755209997 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java @@ -27,6 +27,9 @@ package org.alfresco.module.org_alfresco_module_rm.script.slingshot; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.REASONS_KEY; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.SOURCES_KEY; + import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -103,6 +106,12 @@ public class RMSearchGet extends DeclarativeWebScript /** Utility class for record categories */ private RecordCategoryUtil recordCategoryUtil; + /** Utility class for classification reasons (enterprise only) */ + private ClassificationReasonsUtil classificationReasonsUtil; + + /** Utility class for classification sources (enterprise only) */ + private ClassificationSourcesUtil classificationSourcesUtil; + /** * @param recordsManagementSearchService records management search service */ @@ -159,6 +168,16 @@ public class RMSearchGet extends DeclarativeWebScript this.recordCategoryUtil = recordCategoryUtil; } + public void setClassificationReasonsUtil(ClassificationReasonsUtil classificationReasonsUtil) + { + this.classificationReasonsUtil = classificationReasonsUtil; + } + + public void setClassificationSourcesUtil(ClassificationSourcesUtil classificationSourcesUtil) + { + this.classificationSourcesUtil = classificationSourcesUtil; + } + /** * @param personService person service */ @@ -198,6 +217,19 @@ public class RMSearchGet extends DeclarativeWebScript String filters = req.getParameter(PARAM_FILTERS); // TODO this is optional + //Replace any plain text reason ids with the appropriate node reference + if(query.contains(REASONS_KEY)) + { + query = classificationReasonsUtil.replaceReasonWithNodeRef(query); + } + + //replace any plain test other source titles with appropriate node ref + if(query.contains(SOURCES_KEY)) + { + query = classificationSourcesUtil.replaceSourceNameWithNodeRef(query); + } + + // Convert into a rm search parameter object RecordsManagementSearchParameters searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java new file mode 100644 index 0000000000..e088a559eb --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java @@ -0,0 +1,98 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.model.ContentModel.ASSOC_CHILDREN; +import static org.alfresco.model.ContentModel.TYPE_CONTAINER; +import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; + + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Parent class for records search utilities + * @author Ross Gale + * @since 2.7 + */ +public class SearchUtil +{ + /** + * Node service + */ + protected NodeService nodeService; + + /** + * Setter for node service + * @param nodeService Node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Use a container node ref and return the nodeIds of the contents + * @param nodeRef container + * @return list of nodeIds + */ + protected Set retrieveAllNodeIds(NodeRef nodeRef) + { + List childAssocRefs = nodeService.getChildAssocs(nodeRef); + return childAssocRefs.stream().map(assoc -> assoc.getChildRef().getId()).collect(Collectors.toSet()); + } + + /** + * Helper method to get the classification reason root container. + * The method creates the container if it doesn't already exist. + * + * @return reference to the classification reason root container + */ + protected NodeRef getRootContainer(QName container) + { + NodeRef rootNodeRef = nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE); + List assocRefs = nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, container); + + if (assocRefs.size() == 0) + { + return nodeService.createNode(rootNodeRef, ASSOC_CHILDREN, container, TYPE_CONTAINER).getChildRef(); + } else if (assocRefs.size() != 1) + { + throw new AlfrescoRuntimeException("Only one container is allowed."); + } else + { + return assocRefs.iterator().next().getChildRef(); + } + } +} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationReasonsUtilUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationReasonsUtilUnitTest.java new file mode 100644 index 0000000000..ac0dac5d03 --- /dev/null +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationReasonsUtilUnitTest.java @@ -0,0 +1,128 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.model.ContentModel.ASSOC_CHILDREN; +import static org.alfresco.model.ContentModel.PROP_NAME; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.CLASSIFICATION_REASONS_CONTAINER; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.PROP_CLASSIFICATION_REASON_CODE; +import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Ross Gale + * @since 2.7 + */ +public class ClassificationReasonsUtilUnitTest +{ + + @Mock + private NodeService nodeService; + + @Mock + private ChildAssociationRef childAssociationRef; + + @Mock + private ChildAssociationRef reason; + + @Mock + private Map properties; + + @InjectMocks + private ClassificationReasonsUtil classificationReasonsUtil; + + private NodeRef childNodeRef; + + @Before + public void setUp() + { + MockitoAnnotations.initMocks(this); + NodeRef rootNodeRef = new NodeRef("workspace://SpacesStore/rootNodeRef"); + NodeRef containerNodeRef = new NodeRef("workspace://SpacesStore/containerNodeRef"); + childNodeRef = new NodeRef("workspace://SpacesStore/childNodeRef"); + List assocRefs = new ArrayList<>(); + List childAssocRefs = new ArrayList<>(); + assocRefs.add(childAssociationRef); + childAssocRefs.add(reason); + when(reason.getChildRef()).thenReturn(childNodeRef); + when(nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE)).thenReturn(rootNodeRef); + when(nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, CLASSIFICATION_REASONS_CONTAINER)).thenReturn(assocRefs); + when(childAssociationRef.getChildRef()).thenReturn(containerNodeRef); + when(nodeService.getChildAssocs(containerNodeRef)).thenReturn(childAssocRefs); + } + + /** + * Check no modifications are made to non matching parts of the query string + */ + @Test + public void testNoChangeMadeToStringIfKeyNotFound() + { + String stringToTest = "noChangeMadeToString"; + assertEquals("Change made to string",stringToTest, classificationReasonsUtil.replaceReasonWithNodeRef(stringToTest).trim()); + } + + /** + * Check no modifications made if the plain text parameter doesn't have a stored match + */ + @Test + public void testNoChangeMadeToStringIfMatchNotFound() + { + when(nodeService.getProperties(childNodeRef)).thenReturn(properties); + when(properties.get(PROP_CLASSIFICATION_REASON_CODE)).thenReturn("not a match!"); + String stringToTest = "clf:classificationReasons:noChangeMadeToString"; + assertEquals("Change made to string", stringToTest, classificationReasonsUtil.replaceReasonWithNodeRef(stringToTest).trim()); + } + + /** + * Check the query is updated correctly when a match is found + */ + @Test + public void testChangeMadeToStringIfMatchFound() + { + when(nodeService.getProperties(childNodeRef)).thenReturn(properties); + when(properties.get(PROP_CLASSIFICATION_REASON_CODE)).thenReturn("stringToChange"); + when(properties.get(PROP_NAME)).thenReturn("newString"); + String stringToTest = "clf:classificationReasons:stringToChange"; + assertEquals("No change made to string", "clf:classificationReasons:newString", classificationReasonsUtil.replaceReasonWithNodeRef(stringToTest).trim()); + } +} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java new file mode 100644 index 0000000000..2e914354a9 --- /dev/null +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java @@ -0,0 +1,161 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import static org.alfresco.model.ContentModel.ASSOC_CHILDREN; +import static org.alfresco.model.ContentModel.PROP_NODE_UUID; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.PROP_CLASSIFICATION_REASON_CODE; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.CLASSIFICATION_SOURCES_CONTAINER; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.PROP_CLASSIFICATION_SOURCE_NAME; +import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.SOURCES_KEY; +import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Ross Gale + * @since 2.7 + */ +public class ClassificationSourcesUtilUnitTest +{ + + @Mock + private NodeService nodeService; + + @Mock + private ChildAssociationRef childAssociationRef; + + @Mock + private ChildAssociationRef source, secondSource; + + @Mock + private Map properties; + + @Mock + private Map secondSetOfProperties; + + @InjectMocks + private ClassificationSourcesUtil classificationSourcesUtil; + + private List childAssocRefs; + + private NodeRef childNodeRef; + + private NodeRef childNodeRef2; + + @Before + public void setUp() + { + MockitoAnnotations.initMocks(this); + NodeRef rootNodeRef = new NodeRef("workspace://SpacesStore/rootNodeRef"); + NodeRef containerNodeRef = new NodeRef("workspace://SpacesStore/containerNodeRef"); + childNodeRef = new NodeRef("workspace://SpacesStore/childNodeRef"); + childNodeRef2 = new NodeRef("workspace://SpacesStore/childNodeRef2"); + List assocRefs = new ArrayList<>(); + childAssocRefs = new ArrayList<>(); + assocRefs.add(childAssociationRef); + childAssocRefs.add(source); + when(source.getChildRef()).thenReturn(childNodeRef); + when(nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE)).thenReturn(rootNodeRef); + when(nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, CLASSIFICATION_SOURCES_CONTAINER)).thenReturn(assocRefs); + when(childAssociationRef.getChildRef()).thenReturn(containerNodeRef); + when(nodeService.getChildAssocs(containerNodeRef)).thenReturn(childAssocRefs); + } + + /** + * Check no modifications are made to non matching parts of the query string + */ + @Test + public void testNoChangeMadeToStringIfKeyNotFound() + { + String stringToTest = "noChangeMadeToString"; + assertEquals("Change made to string",stringToTest, classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); + } + + /** + * Check no modifications made if the plain text parameter doesn't have a stored match + */ + @Test + public void testNoChangeMadeToStringIfMatchNotFound() + { + when(nodeService.getProperties(childNodeRef)).thenReturn(properties); + when(properties.get(PROP_CLASSIFICATION_REASON_CODE)).thenReturn("not a match!"); + String stringToTest = SOURCES_KEY + "noChangeMadeToString"; + assertEquals("Change made to string", stringToTest, classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); + } + + /** + * Check the query is updated correctly when a match is found + */ + @Test + public void testChangeMadeToStringIfMatchFound() + { + when(nodeService.getProperties(childNodeRef)).thenReturn(properties); + when(properties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); + when(properties.get(PROP_NODE_UUID)).thenReturn("newString"); + String stringToTest = SOURCES_KEY + "\"stringToChange\""; + assertEquals("No change made to string", "(cs:appliedSources:\"newString\")", classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); + } + + /** + * Check the query is updated correctly when multiple matches are found + * + * This is required as the source name isn't unique to the container. + */ + @Test + public void testChangeMadeToStringIfMultipleMatchesFound() + { + childAssocRefs.add(secondSource); + when(secondSource.getChildRef()).thenReturn(childNodeRef2); + when(nodeService.getProperties(childNodeRef)).thenReturn(properties); + when(nodeService.getProperties(childNodeRef2)).thenReturn(secondSetOfProperties); + when(properties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); + when(properties.get(PROP_NODE_UUID)).thenReturn("newString"); + when(secondSetOfProperties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); + when(secondSetOfProperties.get(PROP_NODE_UUID)).thenReturn("secondNewString"); + String stringToTest = SOURCES_KEY + "\"stringToChange\""; + String actual = classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest); + assertTrue(actual.contains("cs:appliedSources:\"newString\"")); + assertTrue(actual.contains("cs:appliedSources:\"secondNewString\"")); + } +} \ No newline at end of file From e9d42bfeef7768b548d81ec8ddaee478f45c246e Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Wed, 9 May 2018 14:29:12 +0100 Subject: [PATCH 02/22] search fields added --- .../rm-webscript-context.xml | 5 - .../slingshot/ClassificationSourcesUtil.java | 120 ------------- .../script/slingshot/RMSearchGet.java | 16 -- .../ClassificationSourcesUtilUnitTest.java | 161 ------------------ 4 files changed, 302 deletions(-) delete mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtil.java delete mode 100644 rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index f95804c684..c922181ba7 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -468,7 +468,6 @@ - @@ -479,10 +478,6 @@ - - - . - * #L% - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - - -import static org.alfresco.model.ContentModel.PROP_NODE_UUID; -import static org.alfresco.service.namespace.QName.createQName; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; - -/** - * Method to replace the plain text classification source name with all possible nodeRefs during record search - * @author Ross Gale - * @since 2.7 - */ -public class ClassificationSourcesUtil extends SearchUtil -{ - - - public static final String CS_URI = "http://www.alfresco.org/model/classificationsources/1.0"; - public static final QName CLASSIFICATION_SOURCES_CONTAINER = createQName(CS_URI, "classificationSourcesContainer"); - public static final QName PROP_CLASSIFICATION_SOURCE_NAME = createQName(CS_URI, "classificationSourceName"); - public static final String SOURCES_KEY = "cs:appliedSources:"; - public static final String START = "start"; - public static final String END = "end"; - - /** - * Replace plain text source name with all matching nodeRefs - * - * @param searchQuery String e.g. clf:classificationReasons:"Other source" - * @return String e.g. (cs:appliedSources:5cc6d344-fa94-4370-9c81-d947b7e8f2ac OR cs:appliedSources:47afd476-358f-4007-a35e-8f83adb06523) - */ - public String replaceSourceNameWithNodeRef(String searchQuery) - { - Pattern pattern = Pattern.compile("cs:appliedSources:\"[^\"]*\""); - Matcher matcher = pattern.matcher(searchQuery); - StringBuilder builder = new StringBuilder(searchQuery); - Map> index = new HashMap<>(); - int count = 0; - //create a map of where the strings to replace are - while(matcher.find()) - { - index.put(count, new HashMap<>()); - index.get(count).put(START,matcher.start()); - index.get(count).put(END, matcher.end()); - count++; - } - //Go through the string in reverse and replace the plain text reference with nodeIds - for(int i = index.size(); i > 0; i--) - { - Map element = index.get(i-1); - int start = element.get(START); - int end = element.get(END); - builder.replace(start, end, replaceSingleInstance(searchQuery.substring(start, end))); - } - - return builder.toString(); - } - - private String replaceSingleInstance(String str) - { - StringBuilder stringBuilder = new StringBuilder(); - if (str.contains(SOURCES_KEY)) - { - boolean multipleResults = false; - stringBuilder.append('('); - for (String sourceId : retrieveAllNodeIds(getRootContainer(CLASSIFICATION_SOURCES_CONTAINER))) - { - NodeRef reasonNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sourceId); - Map properties = nodeService.getProperties(reasonNodeRef); - if (str.equals(SOURCES_KEY + "\"" + properties.get(PROP_CLASSIFICATION_SOURCE_NAME).toString() + "\"")) - { - if (multipleResults) - { - stringBuilder.append(" OR "); - } - stringBuilder.append(SOURCES_KEY + "\"" + properties.get(PROP_NODE_UUID).toString() + "\""); - //Sources create a node each time even if all the details are the same this will allow multiple nodeIds to be added for a single string - multipleResults = true; - } - } - } - stringBuilder.append(')'); - return stringBuilder.toString(); - } - - -} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java index 1755209997..ca66efefee 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java @@ -28,7 +28,6 @@ package org.alfresco.module.org_alfresco_module_rm.script.slingshot; import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.REASONS_KEY; -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.SOURCES_KEY; import java.io.Serializable; import java.io.UnsupportedEncodingException; @@ -109,9 +108,6 @@ public class RMSearchGet extends DeclarativeWebScript /** Utility class for classification reasons (enterprise only) */ private ClassificationReasonsUtil classificationReasonsUtil; - /** Utility class for classification sources (enterprise only) */ - private ClassificationSourcesUtil classificationSourcesUtil; - /** * @param recordsManagementSearchService records management search service */ @@ -173,11 +169,6 @@ public class RMSearchGet extends DeclarativeWebScript this.classificationReasonsUtil = classificationReasonsUtil; } - public void setClassificationSourcesUtil(ClassificationSourcesUtil classificationSourcesUtil) - { - this.classificationSourcesUtil = classificationSourcesUtil; - } - /** * @param personService person service */ @@ -223,13 +214,6 @@ public class RMSearchGet extends DeclarativeWebScript query = classificationReasonsUtil.replaceReasonWithNodeRef(query); } - //replace any plain test other source titles with appropriate node ref - if(query.contains(SOURCES_KEY)) - { - query = classificationSourcesUtil.replaceSourceNameWithNodeRef(query); - } - - // Convert into a rm search parameter object RecordsManagementSearchParameters searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService); diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java deleted file mode 100644 index 2e914354a9..0000000000 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/ClassificationSourcesUtilUnitTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2018 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * - - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - - * 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 . - * #L% - */ -package org.alfresco.module.org_alfresco_module_rm.script.slingshot; - -import static org.alfresco.model.ContentModel.ASSOC_CHILDREN; -import static org.alfresco.model.ContentModel.PROP_NODE_UUID; -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.PROP_CLASSIFICATION_REASON_CODE; -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.CLASSIFICATION_SOURCES_CONTAINER; -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.PROP_CLASSIFICATION_SOURCE_NAME; -import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationSourcesUtil.SOURCES_KEY; -import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * @author Ross Gale - * @since 2.7 - */ -public class ClassificationSourcesUtilUnitTest -{ - - @Mock - private NodeService nodeService; - - @Mock - private ChildAssociationRef childAssociationRef; - - @Mock - private ChildAssociationRef source, secondSource; - - @Mock - private Map properties; - - @Mock - private Map secondSetOfProperties; - - @InjectMocks - private ClassificationSourcesUtil classificationSourcesUtil; - - private List childAssocRefs; - - private NodeRef childNodeRef; - - private NodeRef childNodeRef2; - - @Before - public void setUp() - { - MockitoAnnotations.initMocks(this); - NodeRef rootNodeRef = new NodeRef("workspace://SpacesStore/rootNodeRef"); - NodeRef containerNodeRef = new NodeRef("workspace://SpacesStore/containerNodeRef"); - childNodeRef = new NodeRef("workspace://SpacesStore/childNodeRef"); - childNodeRef2 = new NodeRef("workspace://SpacesStore/childNodeRef2"); - List assocRefs = new ArrayList<>(); - childAssocRefs = new ArrayList<>(); - assocRefs.add(childAssociationRef); - childAssocRefs.add(source); - when(source.getChildRef()).thenReturn(childNodeRef); - when(nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE)).thenReturn(rootNodeRef); - when(nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, CLASSIFICATION_SOURCES_CONTAINER)).thenReturn(assocRefs); - when(childAssociationRef.getChildRef()).thenReturn(containerNodeRef); - when(nodeService.getChildAssocs(containerNodeRef)).thenReturn(childAssocRefs); - } - - /** - * Check no modifications are made to non matching parts of the query string - */ - @Test - public void testNoChangeMadeToStringIfKeyNotFound() - { - String stringToTest = "noChangeMadeToString"; - assertEquals("Change made to string",stringToTest, classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); - } - - /** - * Check no modifications made if the plain text parameter doesn't have a stored match - */ - @Test - public void testNoChangeMadeToStringIfMatchNotFound() - { - when(nodeService.getProperties(childNodeRef)).thenReturn(properties); - when(properties.get(PROP_CLASSIFICATION_REASON_CODE)).thenReturn("not a match!"); - String stringToTest = SOURCES_KEY + "noChangeMadeToString"; - assertEquals("Change made to string", stringToTest, classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); - } - - /** - * Check the query is updated correctly when a match is found - */ - @Test - public void testChangeMadeToStringIfMatchFound() - { - when(nodeService.getProperties(childNodeRef)).thenReturn(properties); - when(properties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); - when(properties.get(PROP_NODE_UUID)).thenReturn("newString"); - String stringToTest = SOURCES_KEY + "\"stringToChange\""; - assertEquals("No change made to string", "(cs:appliedSources:\"newString\")", classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest)); - } - - /** - * Check the query is updated correctly when multiple matches are found - * - * This is required as the source name isn't unique to the container. - */ - @Test - public void testChangeMadeToStringIfMultipleMatchesFound() - { - childAssocRefs.add(secondSource); - when(secondSource.getChildRef()).thenReturn(childNodeRef2); - when(nodeService.getProperties(childNodeRef)).thenReturn(properties); - when(nodeService.getProperties(childNodeRef2)).thenReturn(secondSetOfProperties); - when(properties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); - when(properties.get(PROP_NODE_UUID)).thenReturn("newString"); - when(secondSetOfProperties.get(PROP_CLASSIFICATION_SOURCE_NAME)).thenReturn("stringToChange"); - when(secondSetOfProperties.get(PROP_NODE_UUID)).thenReturn("secondNewString"); - String stringToTest = SOURCES_KEY + "\"stringToChange\""; - String actual = classificationSourcesUtil.replaceSourceNameWithNodeRef(stringToTest); - assertTrue(actual.contains("cs:appliedSources:\"newString\"")); - assertTrue(actual.contains("cs:appliedSources:\"secondNewString\"")); - } -} \ No newline at end of file From 17fa36314e80066a9d0e7b595430091d345648af Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Mon, 14 May 2018 13:49:38 +0100 Subject: [PATCH 03/22] [maven-release-plugin] prepare release V2.7.b --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index b6ef6d47be..d1eb212bdb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.1-SNAPSHOT + 2.7.b Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.0 + V2.7.b diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 9537d46a7d..33186d28df 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 630c15608d..ee0fd6cbc6 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/pom.xml b/rm-community/pom.xml index af2b7ee9ec..733389b2fa 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 8de405183e..cc9896923f 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index bb55ff6dd1..b2761ab1cd 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.b From 03210fc70970f16f2801c0b71f4be32aef15746e Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Mon, 14 May 2018 13:49:40 +0100 Subject: [PATCH 04/22] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d1eb212bdb..ccc7d886e7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.b + -SNAPSHOT Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.b + V2.7.0 diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 33186d28df..2bd7f13c68 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + -SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index ee0fd6cbc6..56b56b5943 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.b + -SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 733389b2fa..dc0bf74551 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + -SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index cc9896923f..a69b3a1dc6 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.b + -SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index b2761ab1cd..59c2c7a206 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.b + -SNAPSHOT From 894adf7add8a28b32871212c1eac4f51a22e36b1 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Mon, 14 May 2018 14:02:34 +0100 Subject: [PATCH 05/22] Revert "[maven-release-plugin] prepare for next development iteration" This reverts commit 03210fc70970f16f2801c0b71f4be32aef15746e. --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index ccc7d886e7..d1eb212bdb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - -SNAPSHOT + 2.7.b Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.0 + V2.7.b diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 2bd7f13c68..33186d28df 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - -SNAPSHOT + 2.7.b diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 56b56b5943..ee0fd6cbc6 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - -SNAPSHOT + 2.7.b diff --git a/rm-community/pom.xml b/rm-community/pom.xml index dc0bf74551..733389b2fa 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - -SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index a69b3a1dc6..cc9896923f 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - -SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index 59c2c7a206..b2761ab1cd 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - -SNAPSHOT + 2.7.b From 663ffd38c269c12c3dcafd678542a7c5345ca337 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Mon, 14 May 2018 14:02:36 +0100 Subject: [PATCH 06/22] Revert "[maven-release-plugin] prepare release V2.7.b" This reverts commit 17fa36314e80066a9d0e7b595430091d345648af. --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d1eb212bdb..b6ef6d47be 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.b + 2.7.1-SNAPSHOT Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.b + V2.7.0 diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 33186d28df..9537d46a7d 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index ee0fd6cbc6..630c15608d 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 733389b2fa..af2b7ee9ec 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index cc9896923f..8de405183e 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index b2761ab1cd..bb55ff6dd1 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT From 2575dc64adb43d31893ebc9b910c7961654e1b33 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Tue, 15 May 2018 10:12:03 +0100 Subject: [PATCH 07/22] RM-6318 code review changes --- .../script/slingshot/SearchUtil.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java index e088a559eb..84c5b9a61d 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/SearchUtil.java @@ -43,6 +43,7 @@ import org.alfresco.service.namespace.QName; /** * Parent class for records search utilities + * * @author Ross Gale * @since 2.7 */ @@ -55,6 +56,7 @@ public class SearchUtil /** * Setter for node service + * * @param nodeService Node service */ public void setNodeService(NodeService nodeService) @@ -64,6 +66,7 @@ public class SearchUtil /** * Use a container node ref and return the nodeIds of the contents + * * @param nodeRef container * @return list of nodeIds */ @@ -84,13 +87,15 @@ public class SearchUtil NodeRef rootNodeRef = nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE); List assocRefs = nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, container); - if (assocRefs.size() == 0) + if (assocRefs.isEmpty()) { return nodeService.createNode(rootNodeRef, ASSOC_CHILDREN, container, TYPE_CONTAINER).getChildRef(); - } else if (assocRefs.size() != 1) + } + else if (assocRefs.size() != 1) { throw new AlfrescoRuntimeException("Only one container is allowed."); - } else + } + else { return assocRefs.iterator().next().getChildRef(); } From 57201319d1d5be10be0f899ea231fe40ea349aa5 Mon Sep 17 00:00:00 2001 From: Roxana Lucanu-Ghetu Date: Wed, 16 May 2018 11:03:32 +0300 Subject: [PATCH 08/22] RM-6320 Added Declassification Review properties in records search --- .../model/recordsModel.xml | 13 ++++++ .../disposition/DispositionActionImpl.java | 40 +++++++++++++++++++ .../model/RecordsManagementModel.java | 2 + 3 files changed, 55 insertions(+) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml index dc0e5277b3..a8ef0ea7bf 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml @@ -1132,6 +1132,19 @@ false + + d:date + true + + + d:text + true + + true + false + false + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java index 2e5a12664f..9d59693d28 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java @@ -35,11 +35,13 @@ import java.util.List; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RMSearchGet; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -328,6 +330,11 @@ public class DispositionActionImpl implements DispositionAction, props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue); services.getNodeService().setProperties(eventNodeRef, props); + if (eventName.equals("declassification_review")) + { + setDeclassificationReview(eventNodeRef, completedAtValue, completedByValue); + } + // Check to see if the events eligible property needs to be updated updateEventEligible(); @@ -518,4 +525,37 @@ public class DispositionActionImpl implements DispositionAction, return eligible; } + + /** + * Sets declassification review authority and date on records and record folder + * + * @param eventNodeRef Declassification review event node ref + * @param completedAtValue Declassification review authority + * @param completedByValue Declassification review date + */ + private void setDeclassificationReview(NodeRef eventNodeRef, Date completedAtValue, String completedByValue) + { + NodeRef nextDispositionActionNodeRef = services.getNodeService().getPrimaryParent(eventNodeRef).getParentRef(); + NodeRef nodeRef = services.getNodeService().getPrimaryParent(nextDispositionActionNodeRef).getParentRef(); + + Map nodeProps = services.getNodeService().getProperties(nodeRef); + nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue); + nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue); + services.getNodeService().setProperties(nodeRef, nodeProps); + + // check if the node is a record folder then set the declassification review on the records also + if (services.getNodeService().getType(nodeRef).equals(RecordsManagementModel.TYPE_RECORD_FOLDER)) + { + // get all the records inside the record folder + List records = services.getNodeService().getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef child : records) + { + NodeRef recordNodeRef = child.getChildRef(); + Map recordProps = services.getNodeService().getProperties(recordNodeRef); + recordProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue); + recordProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue); + services.getNodeService().setProperties(recordNodeRef, recordProps); + } + } + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java index f7211b7d33..e7f23fb9c9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java @@ -247,6 +247,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule"); QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions"); QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority"); + QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT = QName.createQName(RM_URI, "recordSearchDeclassificationReviewCompletedAt"); + QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY = QName.createQName(RM_URI, "recordSearchDeclassificationReviewCompletedBy"); /** @depreacted as of 2.2, because disposable items can now be in multiple holds */ @Deprecated QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason"); From ee96ccd8572ba89b298d4bd2590eb4e562fbc454 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 16 May 2018 11:55:14 +0100 Subject: [PATCH 09/22] RM-6302: Add Edi tFunctionality To Disposition Schedule: automation tests --- .../org/alfresco/rest/core/v0/BaseAPI.java | 2 +- .../alfresco/rest/v0/RecordCategoriesAPI.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index e3a37ff998..66c1cdf37d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -662,7 +662,7 @@ public abstract class BaseAPI RETENTION_GHOST, RETENTION_ELIGIBLE_FIRST_EVENT, RETENTION_EVENTS, - + COMBINE_DISPOSITION_STEP_CONDITIONS } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index 34ff344f92..57f2368f56 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -35,6 +35,7 @@ import java.util.Map; import org.alfresco.rest.core.v0.BaseAPI; import org.apache.http.HttpResponse; import org.json.JSONObject; +import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -51,6 +52,8 @@ public class RecordCategoriesAPI extends BaseAPI private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class); private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue"; private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions"; + private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule"; + /** * Creates a retention schedule for the category given as parameter @@ -71,6 +74,21 @@ public class RecordCategoriesAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); } + /** + * Get the disposition schedule nodeRef + * + * @param user + * @param password + * @param categoryName + * @return the disposition schedule nodeRef + */ + public String getDispositionScheduleNodeRef(String user, String password, String categoryName) + { + String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); + JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef)); + return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), ""); + } + /** * Sets retention schedule authority and instructions, also if it is applied to records or folders * @@ -109,6 +127,34 @@ public class RecordCategoriesAPI extends BaseAPI addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); addPropertyToRequest(requestParams, "events", properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); + addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); + + return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); + } + + /** + * Creates a retention schedule for a given category with added event + + * @param user + * @param password + * @param categoryName + * @param properties + * @param events + * @return The HTTP Response. + */ + public HttpResponse addDispositionScheduleSteps(String user, String password, String categoryName, Map properties, String events) + { + String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); + + JSONObject requestParams = new JSONObject(); + addPropertyToRequest(requestParams, "name", properties, RETENTION_SCHEDULE.NAME); + addPropertyToRequest(requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION); + addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); + addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); + addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); + requestParams.append("events", events); + addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); From 6ce336d32e0ea4c3d57bc203ac4d7400510a76ab Mon Sep 17 00:00:00 2001 From: Roxana Lucanu-Ghetu Date: Wed, 16 May 2018 15:35:43 +0300 Subject: [PATCH 10/22] RM-6320 Code review changes. --- .../model/recordsModel.xml | 4 ++-- .../disposition/DispositionActionImpl.java | 20 ++++++++++--------- .../model/RecordsManagementModel.java | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml index a8ef0ea7bf..d23a9f7b37 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml @@ -1132,11 +1132,11 @@ false - + d:date true - + d:text true diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java index 9d59693d28..c8d474cac8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionActionImpl.java @@ -330,6 +330,7 @@ public class DispositionActionImpl implements DispositionAction, props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue); services.getNodeService().setProperties(eventNodeRef, props); + // check a specific event from rmEventConfigBootstrap.json if (eventName.equals("declassification_review")) { setDeclassificationReview(eventNodeRef, completedAtValue, completedByValue); @@ -537,11 +538,7 @@ public class DispositionActionImpl implements DispositionAction, { NodeRef nextDispositionActionNodeRef = services.getNodeService().getPrimaryParent(eventNodeRef).getParentRef(); NodeRef nodeRef = services.getNodeService().getPrimaryParent(nextDispositionActionNodeRef).getParentRef(); - - Map nodeProps = services.getNodeService().getProperties(nodeRef); - nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue); - nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue); - services.getNodeService().setProperties(nodeRef, nodeProps); + setPropsOnContent(nodeRef, completedAtValue, completedByValue); // check if the node is a record folder then set the declassification review on the records also if (services.getNodeService().getType(nodeRef).equals(RecordsManagementModel.TYPE_RECORD_FOLDER)) @@ -551,11 +548,16 @@ public class DispositionActionImpl implements DispositionAction, for (ChildAssociationRef child : records) { NodeRef recordNodeRef = child.getChildRef(); - Map recordProps = services.getNodeService().getProperties(recordNodeRef); - recordProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue); - recordProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue); - services.getNodeService().setProperties(recordNodeRef, recordProps); + setPropsOnContent(recordNodeRef, completedAtValue, completedByValue); } } } + + private void setPropsOnContent(NodeRef nodeRef, Date completedAtValue, String completedByValue) + { + Map nodeProps = services.getNodeService().getProperties(nodeRef); + nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue); + nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue); + services.getNodeService().setProperties(nodeRef, nodeProps); + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java index e7f23fb9c9..0b77311cf4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java @@ -247,8 +247,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule"); QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions"); QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority"); - QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT = QName.createQName(RM_URI, "recordSearchDeclassificationReviewCompletedAt"); - QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY = QName.createQName(RM_URI, "recordSearchDeclassificationReviewCompletedBy"); + QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT = QName.createQName(RM_URI, "declassificationReviewCompletedAt"); + QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY = QName.createQName(RM_URI, "declassificationReviewCompletedBy"); /** @depreacted as of 2.2, because disposable items can now be in multiple holds */ @Deprecated QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason"); From 2dc13476b2d5184c59f25fe350446ca6211db982 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 16 May 2018 18:22:28 +0100 Subject: [PATCH 11/22] RM-6302: Add Edi tFunctionality To Disposition Schedule: automation tests --- .../alfresco/rest/v0/RecordCategoriesAPI.java | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index 57f2368f56..6a3caed2cc 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -35,7 +35,6 @@ import java.util.Map; import org.alfresco.rest.core.v0.BaseAPI; import org.apache.http.HttpResponse; import org.json.JSONObject; -import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -126,34 +125,11 @@ public class RecordCategoriesAPI extends BaseAPI addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); - addPropertyToRequest(requestParams, "events", properties, RETENTION_SCHEDULE.RETENTION_EVENTS); - addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); - addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); - - return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); - } - - /** - * Creates a retention schedule for a given category with added event - - * @param user - * @param password - * @param categoryName - * @param properties - * @param events - * @return The HTTP Response. - */ - public HttpResponse addDispositionScheduleSteps(String user, String password, String categoryName, Map properties, String events) - { - String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); - - JSONObject requestParams = new JSONObject(); - addPropertyToRequest(requestParams, "name", properties, RETENTION_SCHEDULE.NAME); - addPropertyToRequest(requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION); - addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); - addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); - addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); - requestParams.append("events", events); + String events = getPropertyValue(properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + if(!events.equals("")) + { + requestParams.append("events", events); + } addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); From 61ef40ab07ec4c3fd6ff5c98c6ebc95319369855 Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 17 May 2018 11:49:13 +0100 Subject: [PATCH 12/22] [maven-release-plugin] prepare release V2.7.b --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index e91a141ffe..d1eb212bdb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 3.0.0-SNAPSHOT + 2.7.b Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - HEAD + V2.7.b diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 1033c353a4..33186d28df 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.0-SNAPSHOT + 2.7.b diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 36080c3d8e..ee0fd6cbc6 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 3.0.0-SNAPSHOT + 2.7.b diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 9e3e1d0779..733389b2fa 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.0-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 0f2cb1c749..cc9896923f 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 3.0.0-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index cded13c0aa..b2761ab1cd 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 3.0.0-SNAPSHOT + 2.7.b From 61e7a1553f87d5d28b59bfb08b8392dc2f036109 Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 17 May 2018 11:49:15 +0100 Subject: [PATCH 13/22] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d1eb212bdb..9c1f9499ae 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.b + 2.7.1-SNAPSHOT Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.b + HEAD diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 33186d28df..9537d46a7d 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index ee0fd6cbc6..630c15608d 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 733389b2fa..af2b7ee9ec 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index cc9896923f..8de405183e 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index b2761ab1cd..bb55ff6dd1 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT From fcc63ab10db653500b9fe30fbefe57f3db9ff2a5 Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 17 May 2018 13:53:55 +0100 Subject: [PATCH 14/22] [maven-release-plugin] prepare release V2.7.b --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 9c1f9499ae..d1eb212bdb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.1-SNAPSHOT + 2.7.b Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - HEAD + V2.7.b diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 9537d46a7d..33186d28df 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 630c15608d..ee0fd6cbc6 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/pom.xml b/rm-community/pom.xml index af2b7ee9ec..733389b2fa 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 8de405183e..cc9896923f 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.b diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index bb55ff6dd1..b2761ab1cd 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.b From 613265383dc106c06c747e00e3bab073490e050f Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 17 May 2018 13:53:57 +0100 Subject: [PATCH 15/22] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d1eb212bdb..9c1f9499ae 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.b + 2.7.1-SNAPSHOT Alfresco Records Management @@ -24,7 +24,7 @@ scm:git:https://git.alfresco.com/records-management/records-management.git scm:git:https://git.alfresco.com/records-management/records-management.git https://git.alfresco.com/records-management/records-management - V2.7.b + HEAD diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 33186d28df..9537d46a7d 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index ee0fd6cbc6..630c15608d 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 733389b2fa..af2b7ee9ec 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index cc9896923f..8de405183e 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index b2761ab1cd..bb55ff6dd1 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.b + 2.7.1-SNAPSHOT From 271883b1c726bf3ec8544cb11b83a998a578512a Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 18 May 2018 06:51:02 +0100 Subject: [PATCH 16/22] Update version to V2.7.0.1-SNAPSHOT. --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index e91a141ffe..23d477d21e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT Alfresco Records Management diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 1033c353a4..496465be48 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 36080c3d8e..ce2e06b574 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 9e3e1d0779..ff1f35ec79 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 0f2cb1c749..1c15e72cf8 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index cded13c0aa..ddf33cf85c 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 3.0.0-SNAPSHOT + 2.7.0.1-SNAPSHOT From 2408e4144ac2eaf10d6cd8fb8a478d5d0017d8c1 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 18 May 2018 17:45:38 +0300 Subject: [PATCH 17/22] RM-6320 Automated tests for Declassification review for records and record folders --- .../org/alfresco/rest/core/v0/BaseAPI.java | 31 +++++ .../FilePlanComponentFields.java | 2 + .../rest/v0/RMRolesAndActionsAPI.java | 54 +++++++- .../java/org/alfresco/rest/v0/SearchAPI.java | 23 ++++ .../service/DispositionScheduleService.java | 124 ++++++++++++++++++ .../rm/community/base/BaseRMRestTest.java | 2 +- 6 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index 66c1cdf37d..e87c7a21b2 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -674,6 +674,8 @@ public abstract class BaseAPI CUT_OFF("cutoff"), UNDO_CUT_OFF("undoCutoff"), TRANSFER("transfer"), + COMPLETE_EVENT("completeEvent"), + UNDO_EVENT("undoEvent"), DESTROY("destroy"); String action; @@ -688,6 +690,35 @@ public abstract class BaseAPI } } + public enum RM_EVENTS + { + ABOLISHED("abolished", "Abolished"), + ALL_ALLOWANCES_GRANTED_ARE_TERMINATED("all_allowances_granted_are_terminated", "All Allowances Granted are Terminated"), + CASE_CLOSED("case_closed", "Case Closed"), + DECLASSIFICATION_REVIEW("declassification_review", "Declassification Review"), + OBSOLETE("obsolete", "Obsolete"), + NO_LONGER_NEEDED("no_longer_needed", "No Longer Needed"), + STUDY_COMPLETE("study_complete", "Study Complete"); + String eventName; + String eventDisplayLabel; + + RM_EVENTS(String eventName, String eventDisplayLabel) + { + this.eventName = eventName; + this.eventDisplayLabel = eventDisplayLabel; + } + + public String getEventName() + { + return eventName; + } + + public String getEventDisplayLabel() + { + return eventDisplayLabel; + } + } + public enum PermissionType { SET_READ, diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java index 2fbbf3cc15..4732c28a17 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java @@ -58,6 +58,8 @@ public class FilePlanComponentFields public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME = "rma:recordSearchDispositionActionName"; public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE = "rma:recordSearchDispositionEventsEligible"; public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS = "rma:recordSearchDispositionInstructions"; + public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_BY = "rma:declassificationReviewCompletedBy"; + public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_AT = "rma:declassificationReviewCompletedAt"; /** File plan properties */ diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index 61de24b76c..c222dd1fb2 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -325,9 +325,9 @@ public class RMRolesAndActionsAPI extends BaseAPI /** * Perform an action on the record folder * - * @param user the user closing the folder + * @param user the user executing the action * @param password the user's password - * @param contentName the record folder name + * @param contentName the content name * @param date the date to be updated * @return The HTTP response. */ @@ -349,6 +349,56 @@ public class RMRolesAndActionsAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); } + /** + * Complete an event on the record/record folder + * + * @param user the user executing the action + * @param password the user's password + * @param contentName the content name + * @param event the event to be completed + * @param date the date to be updated + * @return The HTTP response. + */ + public HttpResponse completeEvent(String user, String password, String contentName, RM_EVENTS event, ZonedDateTime date) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName); + JSONObject requestParams = new JSONObject(); + requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction()); + requestParams.put("nodeRef", recNodeRef); + date = (date != null) ? date : ZonedDateTime.now(); + String formattedDate = date.format(DateTimeFormatter.ISO_INSTANT); + requestParams.put("params", new JSONObject() + .put("eventName", event.getEventName()) + .put("eventCompletedBy", user) + .put("eventCompletedAt", new JSONObject() + .put("iso8601", formattedDate) + ) + ); + + return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); + } + + /** + * Undo an event on the record/record folder + * + * @param user the user executing the action + * @param password the user's password + * @param contentName the content name + * @param event the event to be completed + * @return The HTTP response. + */ + public HttpResponse undoEvent(String user, String password, String contentName, RM_EVENTS event) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName); + JSONObject requestParams = new JSONObject(); + requestParams.put("name", RM_ACTIONS.UNDO_EVENT.getAction()); + requestParams.put("nodeRef", recNodeRef); + requestParams.put("params", new JSONObject() + .put("eventName", event.getEventName())); + + return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); + } + /** * Deletes every item in the given container * diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java index f462f06cdf..62c0ba697f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java @@ -66,6 +66,9 @@ public class SearchAPI extends BaseAPI /** RM document search filters */ private static final String RM_DEFAULT_RECORD_FILTERS = "records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false"; + /** RM all content search filters */ + private static final String RM_DEFAULT_CONTENT_FILTERS = + "records/true,undeclared/true,vital/false,folders/true,categories/true,frozen/false,cutoff/false"; /** * Perform search request on search endpoint as a user. @@ -139,6 +142,26 @@ public class SearchAPI extends BaseAPI return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_RECORD_FILTERS, sortby)); } + /** + * Search as a user for content on site "rm" matching query, using SearchAPI.RM_DEFAULT_CONTENT_FILTERS and sorted + * by sortby + *
+ * If more fine-grained control of search parameters is required, use rmSearch() directly. + * @param username + * @param password + * @param query + * @param sortby + * @return list of record names + */ + public List searchForRmContentAsUser( + String username, + String password, + String query, + String sortby) + { + return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_CONTENT_FILTERS, sortby)); + } + /** * Generic faceted search. * @param username diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java new file mode 100644 index 0000000000..c414e16b2c --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -0,0 +1,124 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + * #L% + */ +package org.alfresco.rest.v0.service; + + +import java.util.HashMap; + +import org.alfresco.rest.core.v0.BaseAPI; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.v0.RecordCategoriesAPI; +import org.alfresco.utility.data.DataUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Service for different disposition schedule actions + * + * @author jcule + * @since 2.7.0.1 + */ +@Service +public class DispositionScheduleService extends BaseAPI +{ + @Autowired + private RecordCategoriesAPI recordCategoriesAPI; + + @Autowired + private DataUser dataUser; + + /** + * Helper method for adding a cut off after period step + * + * @param categoryName the category in whose schedule the step will be added + * @param period + * @return + */ + public void addCutOffAfterPeriodStep(String categoryName, String period) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step"); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method for adding a cut off after an event occurs step + * + * @param categoryName the category in whose schedule the step will be added + * @param events + */ + public void addCutOffAfterEventStep(String categoryName, String events) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_EVENTS, events); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after event step"); + + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method for accession step properties + * + * @param timeOrEvent + * @param events + * @param period + * @param periodProperty + * @param combineConditions + * @return + */ + public void addAccessionStep(String categoryName, Boolean timeOrEvent, String events, String period, String + periodProperty, Boolean combineConditions) + { + HashMap accessionStep = new HashMap<>(); + accessionStep.put(RETENTION_SCHEDULE.NAME, "accession"); + accessionStep.put(RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS, Boolean.toString(combineConditions)); + accessionStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + accessionStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty); + if (!timeOrEvent) + { + accessionStep.put(RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT, Boolean.toString(timeOrEvent)); + } + accessionStep.put(RETENTION_SCHEDULE.RETENTION_EVENTS, events); + accessionStep.put(RETENTION_SCHEDULE.DESCRIPTION, + "Accession step with time and event conditions."); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, accessionStep); + } + + /** + * Helper method to create retention schedule with general fields for the given category as admin + * and apply it to the records + * + * @param categoryName + * @param appliedToRecords + */ + public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords) + { + recordCategoriesAPI.createRetentionSchedule(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName); + String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef( + dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName); + + HashMap retentionScheduleGeneralFields = new HashMap<>(); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority"); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions"); + recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields, + appliedToRecords); + + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index 5de8128200..29b06b488f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -696,7 +696,7 @@ public class BaseRMRestTest extends RestTest } } - results = searchApi.searchForRecordsAsUser(user.getUsername(), user.getPassword(), term, sortby); + results = searchApi.searchForRmContentAsUser(user.getUsername(), user.getPassword(), term, sortby); if (!results.isEmpty() && results.containsAll(expectedResults)) { break; From 8d1179907cbd4e5daf545446ba34cc80ec5913c9 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 May 2018 11:08:50 +0300 Subject: [PATCH 18/22] fix license --- .../service/DispositionScheduleService.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java index c414e16b2c..a541c0d571 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -4,9 +4,24 @@ * %% * Copyright (C) 2005 - 2018 Alfresco Software Limited * %% - * License rights for this program may be obtained from Alfresco Software, Ltd. - * pursuant to a written agreement and any use of this program without such an - * agreement is prohibited. + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . * #L% */ package org.alfresco.rest.v0.service; From a77cfe9ac5ca65fac3ccdc2c489725aeebadbf6e Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 May 2018 11:20:24 +0300 Subject: [PATCH 19/22] javadoc updates --- .../main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java | 2 +- .../alfresco/rest/v0/service/DispositionScheduleService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index c222dd1fb2..abaf11debd 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -384,7 +384,7 @@ public class RMRolesAndActionsAPI extends BaseAPI * @param user the user executing the action * @param password the user's password * @param contentName the content name - * @param event the event to be completed + * @param event the event to be undone * @return The HTTP response. */ public HttpResponse undoEvent(String user, String password, String contentName, RM_EVENTS event) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java index a541c0d571..e5265f69ac 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -86,7 +86,7 @@ public class DispositionScheduleService extends BaseAPI } /** - * Helper method for accession step properties + * Helper method for adding an accession step * * @param timeOrEvent * @param events From 86320dbdd2476b26a94939c6ff5d76792b12361c Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 May 2018 11:58:17 +0300 Subject: [PATCH 20/22] reverted version changes --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 9c1f9499ae..23d477d21e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT Alfresco Records Management diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 9537d46a7d..496465be48 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 630c15608d..ce2e06b574 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-automation - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index af2b7ee9ec..ff1f35ec79 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 8de405183e..1c15e72cf8 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index bb55ff6dd1..ddf33cf85c 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-rm-community - 2.7.1-SNAPSHOT + 2.7.0.1-SNAPSHOT From 26a346ee8f4bbed2ec974816d2543fc77a762050 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 May 2018 15:50:56 +0300 Subject: [PATCH 21/22] code review changes --- .../org/alfresco/rest/core/v0/BaseAPI.java | 29 ------------------- .../org/alfresco/rest/core/v0/RMEvents.java | 23 +++++++++++++++ .../rest/v0/RMRolesAndActionsAPI.java | 14 +++++---- .../java/org/alfresco/rest/v0/SearchAPI.java | 8 ++--- 4 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index e87c7a21b2..935dcc151c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -690,35 +690,6 @@ public abstract class BaseAPI } } - public enum RM_EVENTS - { - ABOLISHED("abolished", "Abolished"), - ALL_ALLOWANCES_GRANTED_ARE_TERMINATED("all_allowances_granted_are_terminated", "All Allowances Granted are Terminated"), - CASE_CLOSED("case_closed", "Case Closed"), - DECLASSIFICATION_REVIEW("declassification_review", "Declassification Review"), - OBSOLETE("obsolete", "Obsolete"), - NO_LONGER_NEEDED("no_longer_needed", "No Longer Needed"), - STUDY_COMPLETE("study_complete", "Study Complete"); - String eventName; - String eventDisplayLabel; - - RM_EVENTS(String eventName, String eventDisplayLabel) - { - this.eventName = eventName; - this.eventDisplayLabel = eventDisplayLabel; - } - - public String getEventName() - { - return eventName; - } - - public String getEventDisplayLabel() - { - return eventDisplayLabel; - } - } - public enum PermissionType { SET_READ, diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java new file mode 100644 index 0000000000..bf1d724f65 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java @@ -0,0 +1,23 @@ +package org.alfresco.rest.core.v0; + +public enum RMEvents +{ + ABOLISHED("abolished"), + ALL_ALLOWANCES_GRANTED_ARE_TERMINATED("all_allowances_granted_are_terminated"), + CASE_CLOSED("case_closed"), + DECLASSIFICATION_REVIEW("declassification_review"), + OBSOLETE("obsolete"), + NO_LONGER_NEEDED("no_longer_needed"), + STUDY_COMPLETE("study_complete"); + private String eventName; + + RMEvents(String eventName) + { + this.eventName = eventName; + } + + public String getEventName() + { + return eventName; + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index abaf11debd..122ab88bef 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -35,6 +35,7 @@ import static org.testng.AssertJUnit.fail; import java.io.IOException; import java.text.MessageFormat; +import java.time.Instant; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; @@ -46,6 +47,7 @@ import org.alfresco.dataprep.AlfrescoHttpClientFactory; import org.alfresco.dataprep.ContentService; import org.alfresco.dataprep.UserService; import org.alfresco.rest.core.v0.BaseAPI; +import org.alfresco.rest.core.v0.RMEvents; import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.commons.httpclient.HttpStatus; import org.apache.http.HttpResponse; @@ -354,19 +356,19 @@ public class RMRolesAndActionsAPI extends BaseAPI * * @param user the user executing the action * @param password the user's password - * @param contentName the content name + * @param nodeName the node name * @param event the event to be completed * @param date the date to be updated * @return The HTTP response. */ - public HttpResponse completeEvent(String user, String password, String contentName, RM_EVENTS event, ZonedDateTime date) + public HttpResponse completeEvent(String user, String password, String nodeName, RMEvents event, Instant date) { - String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName); + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, nodeName); JSONObject requestParams = new JSONObject(); requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction()); requestParams.put("nodeRef", recNodeRef); - date = (date != null) ? date : ZonedDateTime.now(); - String formattedDate = date.format(DateTimeFormatter.ISO_INSTANT); + date = (date != null) ? date : Instant.now(); + String formattedDate = DateTimeFormatter.ISO_INSTANT.format(date); requestParams.put("params", new JSONObject() .put("eventName", event.getEventName()) .put("eventCompletedBy", user) @@ -387,7 +389,7 @@ public class RMRolesAndActionsAPI extends BaseAPI * @param event the event to be undone * @return The HTTP response. */ - public HttpResponse undoEvent(String user, String password, String contentName, RM_EVENTS event) + public HttpResponse undoEvent(String user, String password, String contentName, RMEvents event) { String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName); JSONObject requestParams = new JSONObject(); diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java index 62c0ba697f..2e91ee2928 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java @@ -66,8 +66,8 @@ public class SearchAPI extends BaseAPI /** RM document search filters */ private static final String RM_DEFAULT_RECORD_FILTERS = "records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false"; - /** RM all content search filters */ - private static final String RM_DEFAULT_CONTENT_FILTERS = + /** RM all nodes search filters */ + private static final String RM_DEFAULT_NODES_FILTERS = "records/true,undeclared/true,vital/false,folders/true,categories/true,frozen/false,cutoff/false"; /** @@ -143,7 +143,7 @@ public class SearchAPI extends BaseAPI } /** - * Search as a user for content on site "rm" matching query, using SearchAPI.RM_DEFAULT_CONTENT_FILTERS and sorted + * Search as a user for content on site "rm" matching query, using SearchAPI.RM_DEFAULT_NODES_FILTERS and sorted * by sortby *
* If more fine-grained control of search parameters is required, use rmSearch() directly. @@ -159,7 +159,7 @@ public class SearchAPI extends BaseAPI String query, String sortby) { - return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_CONTENT_FILTERS, sortby)); + return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_NODES_FILTERS, sortby)); } /** From 8b43c08ecfd19758387f15b6324ae67b0090d16a Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 May 2018 16:03:34 +0300 Subject: [PATCH 22/22] added license --- .../org/alfresco/rest/core/v0/RMEvents.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java index bf1d724f65..a63fa5b903 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/RMEvents.java @@ -1,3 +1,29 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ package org.alfresco.rest.core.v0; public enum RMEvents