From 80e6b7aace7aae955586e62918af46a05d205548 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Tue, 30 Apr 2019 14:39:47 +0100 Subject: [PATCH 01/43] Creating hotfix branch --- 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 3ff2e1b1f0..5abb8617da 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 3.0.2-SNAPSHOT + 3.0.1.1-SNAPSHOT Alfresco Records Management http://www.alfresco.org/ diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index f3819b4891..55610d154e 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.2-SNAPSHOT + 3.0.1.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 d45d244d80..e02ff008a4 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.2-SNAPSHOT + 3.0.1.1-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 935a202542..9793907bc9 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 3.0.2-SNAPSHOT + 3.0.1.1-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 76bbb7602f..e8ded87046 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.2-SNAPSHOT + 3.0.1.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 ff7981e582..1fa60b9927 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.2-SNAPSHOT + 3.0.1.1-SNAPSHOT From 81033bbf12dd7172cd47656de530f5ca15829526 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Wed, 13 Nov 2019 15:52:29 +0000 Subject: [PATCH 02/43] Initial patch code to apply disposition fix to records --- .../patch/rm-patch-v24-context.xml | 14 +- .../query/rm-common-SqlMap.xml | 35 ++++- .../org_alfresco_module_rm/version.properties | 2 +- .../v24/RMv24DispositionInheritancePatch.java | 120 ++++++++++++++++++ .../query/NodeRefEntity.java | 77 +++++++++++ .../query/RecordsManagementQueryDAO.java | 11 ++ .../query/RecordsManagementQueryDAOImpl.java | 23 ++++ 7 files changed, 277 insertions(+), 5 deletions(-) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml index e3e843041e..682a3a0331 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml @@ -14,5 +14,17 @@ - + + + + + + + + + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index e3f1c1a89d..2845b537fa 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -7,8 +7,15 @@ - - select count(*) from @@ -19,5 +26,27 @@ prop.string_value = ? - + + + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties index cf2c7c2600..8cce8ad3ce 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties @@ -1,3 +1,3 @@ # RM Schema number -version.rm.schema=2501 +version.rm.schema=2502 diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java new file mode 100644 index 0000000000..dffff5a9a4 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java @@ -0,0 +1,120 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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.patch.v24; + +import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; +import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * RM v2.4 patch that ensures that file plan root containers do not inherited rules, because this is no longer enforced + * in the service code anymore. + *

+ * See https://issues.alfresco.com/jira/browse/RM-3154 + * + * @author Roy Wetherall + * @since 2.4 + */ +public class RMv24DispositionInheritancePatch extends AbstractModulePatch +{ + private static Log logger = LogFactory.getLog(RMv24DispositionInheritancePatch.class); + + private DispositionService dispositionService; + + private RecordService recordService; + + private NodeService nodeService; + + private RecordsManagementQueryDAO recordsManagementQueryDAO; + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO) + { + this.recordsManagementQueryDAO = recordsManagementQueryDAO; + } + + /** + * @see AbstractModulePatch#applyInternal() + *

+ * Checks for records added to a disposition schedule pre MNT-19967 and applys disposition step and properties + */ + @Override + public void applyInternal() + { + logger.info("***********************recordsManagementQueryDAO.getNodeRefs()***************************"); + logger.info(recordsManagementQueryDAO.getRecordFoldersWithSchedules()); + logger.info("***********************RMv24DispositionInheritancePatch***************************"); + + + List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(); + logger.info("folders: " + folders); + for (NodeRef folder : folders) + { + DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder); + logger.info("schedule: " + schedule); + if (schedule.isRecordLevelDisposition()) + { + List records = recordService.getRecords(folder); + logger.info("records: " + records); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + logger.info("updating record: " + record); + dispositionService.updateNextDispositionAction(record); + } + } + } + } + } +} + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java new file mode 100644 index 0000000000..e61e526763 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java @@ -0,0 +1,77 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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.query; + +/** + * NodeRef Entity - used by {@link RecordsManagementQueryDAOImpl}. + * + * @author Tom Page + * @since 2.5.0.4 + */ +public class NodeRefEntity +{ + private String protocol; + private String identifier; + private String uuid; + + /** + * Default constructor. + */ + public NodeRefEntity() + { + } + + public String getProtocol() + { + return protocol; + } + + public void setProtocol(String protocol) + { + this.protocol = protocol; + } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + + public String getUuid() + { + return uuid; + } + + public void setUuid(String uuid) + { + this.uuid = uuid; + } +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index c0743f604d..f68ce3723a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -27,6 +27,10 @@ package org.alfresco.module.org_alfresco_module_rm.query; +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + /** * Records management query DAO * @@ -46,4 +50,11 @@ public interface RecordsManagementQueryDAO * @return int count */ int getCountRmaIdentifier(String identifierValue); + + /** + * Returns a list of nodeRef for all record folders in the system + * that have the property recordSearchHasDispositionSchedule:true + * @return List of nodeRefs + */ + public List getRecordFoldersWithSchedules(); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 68742ee271..0432e13612 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -27,11 +27,14 @@ package org.alfresco.module.org_alfresco_module_rm.query; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.mybatis.spring.SqlSessionTemplate; @@ -45,6 +48,7 @@ import org.mybatis.spring.SqlSessionTemplate; public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; + private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules"; /** SQL session template */ protected SqlSessionTemplate template; @@ -97,4 +101,23 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, return result; } + /** + * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules() + */ + @Override + public List getRecordFoldersWithSchedules() + { + List entities = template.selectList(SCHEDULED_FOLDERS); + + List results = new ArrayList<>(); + + // convert the entities to NodeRefs + for (NodeRefEntity nodeRefEntity : entities) + { + results.add(new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid())); + } + + return results; + } + } From 1e1209f9874518c010e91248ca075a10159f4821 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Sun, 17 Nov 2019 22:07:31 +0000 Subject: [PATCH 03/43] RM-7051 adding batch code --- .../query/rm-common-SqlMap.xml | 58 ++++++++++++----- .../disposition/DispositionService.java | 8 +++ .../disposition/DispositionServiceImpl.java | 28 ++++++++ .../v24/RMv24DispositionInheritancePatch.java | 65 +++++++++++++------ .../query/NodeRefEntity.java | 11 ++++ .../query/RecordsManagementQueryDAO.java | 15 ++++- .../query/RecordsManagementQueryDAOImpl.java | 34 +++++++++- 7 files changed, 177 insertions(+), 42 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index 2845b537fa..201b68d956 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -8,7 +8,20 @@ + + + + + + + + + + + + + @@ -29,23 +42,36 @@ + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index 4da6fde0dd..2ba7dbcc0e 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -237,6 +237,14 @@ public interface DispositionService */ void updateNextDispositionAction(NodeRef nodeRef); + /** + * Updates the next disposition action + * + * @param nodeRef node reference + * @param DispositionSchedule the schedule to be applied + */ + void updateNextDispositionAction(NodeRef nodeRef, DispositionSchedule dispositionSchedule); + /** * Refreshes the disposition action details of the given node. * diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 32f68c1bb5..78087ffffd 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -954,6 +954,34 @@ public class DispositionServiceImpl extends ServiceBaseImpl { // Get this disposition instructions for the node DispositionSchedule di = getDispositionSchedule(nodeRef); + + updateNextDispositionAction(nodeRef, di); + + return null; + } + + }; + + AuthenticationUtil.runAsSystem(runAsWork); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) + */ + @Override + public void updateNextDispositionAction(final NodeRef nodeRef, final DispositionSchedule di) + { + + + RunAsWork runAsWork = new RunAsWork() + { + /** + * @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork() + */ + @Override + public Void doWork() + { + if (di != null) { // Get the current action node diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java index dffff5a9a4..b1fe090b1b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java @@ -31,11 +31,13 @@ import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagement import java.util.List; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.apache.commons.logging.Log; @@ -52,7 +54,9 @@ import org.apache.commons.logging.LogFactory; */ public class RMv24DispositionInheritancePatch extends AbstractModulePatch { - private static Log logger = LogFactory.getLog(RMv24DispositionInheritancePatch.class); + private static final Log logger = LogFactory.getLog(RMv24DispositionInheritancePatch.class); + + private static final long BATCH_SIZE = 5L; private DispositionService dispositionService; @@ -90,30 +94,51 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch @Override public void applyInternal() { - logger.info("***********************recordsManagementQueryDAO.getNodeRefs()***************************"); - logger.info(recordsManagementQueryDAO.getRecordFoldersWithSchedules()); - logger.info("***********************RMv24DispositionInheritancePatch***************************"); + logger.info("********************Patch start********************"); + int maxNode = recordsManagementQueryDAO.getRecordFoldersWithSchedulesCount(); + logger.info("nodes to update: "+ maxNode); - - List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(); - logger.info("folders: " + folders); - for (NodeRef folder : folders) + for (Long i = 0L; i < maxNode; i += BATCH_SIZE) { - DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder); - logger.info("schedule: " + schedule); - if (schedule.isRecordLevelDisposition()) - { - List records = recordService.getRecords(folder); - logger.info("records: " + records); - for (NodeRef record : records) + final Long finali = i; + int updatedRecords = transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { - if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + public Integer execute() throws Throwable { - logger.info("updating record: " + record); - dispositionService.updateNextDispositionAction(record); + int recordCount = 0; + logger.info("********************Patch start********************"); + logger.info("********************Query start********************"); + logger.info(finali); + logger.info(finali + BATCH_SIZE); + logger.info(recordsManagementQueryDAO.getRecordFoldersWithSchedules(finali, finali + BATCH_SIZE)); + List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(finali, finali + BATCH_SIZE); + logger.info("********************Query end********************"); + for (NodeRef folder : folders) + + { + + DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder); + if (schedule.isRecordLevelDisposition()) + { + List records = recordService.getRecords(folder); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + logger.info("updating record: " + record); + dispositionService.updateNextDispositionAction(record, schedule); + recordCount ++; + } + } + } + } + logger.info("********************Patch end********************"); + return recordCount; } - } - } + }, false, true); + + logger.info("....completed: "+ updatedRecords); } } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java index e61e526763..203a186e45 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java @@ -34,6 +34,7 @@ package org.alfresco.module.org_alfresco_module_rm.query; */ public class NodeRefEntity { + private Long num; private String protocol; private String identifier; private String uuid; @@ -45,6 +46,16 @@ public class NodeRefEntity { } + public Long getNum() + { + return num; + } + + public void setNum(Long num) + { + this.num = num; + } + public String getProtocol() { return protocol; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index f68ce3723a..0c6af0d6f2 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -52,9 +52,18 @@ public interface RecordsManagementQueryDAO int getCountRmaIdentifier(String identifierValue); /** - * Returns a list of nodeRef for all record folders in the system + * Returns a number of nodeRefs for record folders in the system * that have the property recordSearchHasDispositionSchedule:true - * @return List of nodeRefs + * (used for MNT-20864) + * @param start long - the first result row to return + * @param end long - the last result row to return + * @return list of node refs */ - public List getRecordFoldersWithSchedules(); + public List getRecordFoldersWithSchedules(Long start, Long end); + + /** + * Returns the count of record folders with a schedule applied (used for MNT-20864) + * @return the number of record folders with a disposition schedule + */ + public int getRecordFoldersWithSchedulesCount(); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 0432e13612..b761d0bd3b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -49,7 +49,8 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules"; - + private static final String SCHEDULED_FOLDERS_COUNT = "alfresco.query.rm.select_RecordFoldersWithSchedulesCount"; + /** SQL session template */ protected SqlSessionTemplate template; @@ -105,9 +106,16 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules() */ @Override - public List getRecordFoldersWithSchedules() + public List getRecordFoldersWithSchedules(Long start, Long end) { - List entities = template.selectList(SCHEDULED_FOLDERS); + Map params = new HashMap(2); + params.put("dispositionQnameId", qnameDAO.getQName(PROP_RS_HAS_DISPOITION_SCHEDULE) + .getFirst()); + params.put("folderQnameId",qnameDAO.getQName(TYPE_RECORD_FOLDER).getFirst()); + params.put("start", start); + params.put("end", end); + + List entities = template.selectList(SCHEDULED_FOLDERS, params); List results = new ArrayList<>(); @@ -120,4 +128,24 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, return results; } + public int getRecordFoldersWithSchedulesCount() + { + int result = 0; + + Map params = new HashMap(2); + params.put("dispositionQnameId", qnameDAO.getQName(PROP_RS_HAS_DISPOITION_SCHEDULE) + .getFirst()); + params.put("folderQnameId", qnameDAO.getQName(TYPE_RECORD_FOLDER) + .getFirst()); + + Integer count = template.selectOne(SCHEDULED_FOLDERS_COUNT, params); + + if (count != null) + { + result = count; + } + + return result; + } + } From efc5281183121bf6486ba414a7496498e352fb4c Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Sun, 17 Nov 2019 22:20:31 +0000 Subject: [PATCH 04/43] RM-7051 adding batch code --- .../module/org_alfresco_module_rm/query/rm-common-SqlMap.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index 201b68d956..29b744ae05 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -8,14 +8,14 @@ - + - + From 9783335a3b1af002fe99ea6733cb8afc9a9de599 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Mon, 18 Nov 2019 10:55:39 +0000 Subject: [PATCH 05/43] RM-7051 adding code to deal with held records/folders --- .../patch/rm-patch-v24-context.xml | 1 + .../v24/RMv24DispositionInheritancePatch.java | 43 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml index 682a3a0331..475f1d3b39 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml @@ -25,6 +25,7 @@ + \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java index b1fe090b1b..029e4c48fe 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java @@ -28,15 +28,19 @@ package org.alfresco.module.org_alfresco_module_rm.patch.v24; import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE; +import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_FROZEN; +import java.util.ArrayList; import java.util.List; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.hold.HoldService; import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -66,6 +70,8 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch private RecordsManagementQueryDAO recordsManagementQueryDAO; + private BehaviourFilter behaviourFilter; + public void setDispositionService(DispositionService dispositionService) { this.dispositionService = dispositionService; @@ -86,6 +92,11 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch this.recordsManagementQueryDAO = recordsManagementQueryDAO; } + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + /** * @see AbstractModulePatch#applyInternal() *

@@ -94,11 +105,10 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch @Override public void applyInternal() { - logger.info("********************Patch start********************"); - int maxNode = recordsManagementQueryDAO.getRecordFoldersWithSchedulesCount(); - logger.info("nodes to update: "+ maxNode); + int totalFolders = recordsManagementQueryDAO.getRecordFoldersWithSchedulesCount(); + logger.info("Folders to update: "+ totalFolders); - for (Long i = 0L; i < maxNode; i += BATCH_SIZE) + for (Long i = 0L; i < totalFolders; i += BATCH_SIZE) { final Long finali = i; int updatedRecords = transactionService.getRetryingTransactionHelper() @@ -107,17 +117,14 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch public Integer execute() throws Throwable { int recordCount = 0; - logger.info("********************Patch start********************"); - logger.info("********************Query start********************"); - logger.info(finali); - logger.info(finali + BATCH_SIZE); - logger.info(recordsManagementQueryDAO.getRecordFoldersWithSchedules(finali, finali + BATCH_SIZE)); List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(finali, finali + BATCH_SIZE); - logger.info("********************Query end********************"); for (NodeRef folder : folders) - { - + if (LOGGER.isDebugEnabled()) + { + logger.info("Checking folder: " + folder); + } + behaviourFilter.disableBehaviour(folder); DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder); if (schedule.isRecordLevelDisposition()) { @@ -126,19 +133,25 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch { if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) { - logger.info("updating record: " + record); + if (LOGGER.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + behaviourFilter.disableBehaviour(record); dispositionService.updateNextDispositionAction(record, schedule); recordCount ++; + behaviourFilter.enableBehaviour(record); } } } + behaviourFilter.enableBehaviour(folder); } - logger.info("********************Patch end********************"); return recordCount; } }, false, true); - logger.info("....completed: "+ updatedRecords); + logger.info("Records updated: "+ updatedRecords); + logger.info("Updating folders: "+ finali + " to: " +(finali + BATCH_SIZE) + " of "+totalFolders); } } } From 8caf6f8c8d12930b62bce89d2fb4d413ece642c1 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Mon, 18 Nov 2019 14:05:17 +0000 Subject: [PATCH 06/43] RM-7051 updating messaging to report on batch completion --- .../patch/v24/RMv24DispositionInheritancePatch.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java index 029e4c48fe..b08a287f97 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v24/RMv24DispositionInheritancePatch.java @@ -124,10 +124,10 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch { logger.info("Checking folder: " + folder); } - behaviourFilter.disableBehaviour(folder); DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder); if (schedule.isRecordLevelDisposition()) { + behaviourFilter.disableBehaviour(folder); List records = recordService.getRecords(folder); for (NodeRef record : records) { @@ -143,8 +143,8 @@ public class RMv24DispositionInheritancePatch extends AbstractModulePatch behaviourFilter.enableBehaviour(record); } } + behaviourFilter.enableBehaviour(folder); } - behaviourFilter.enableBehaviour(folder); } return recordCount; } From 239f81728672162243f0c0e7b268787ffc008623 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Mon, 18 Nov 2019 23:28:08 +0000 Subject: [PATCH 07/43] RM-7051 updating patch code --- .../model/recordsModel.xml | 5 ++ .../patch/rm-patch-v24-context.xml | 2 + .../query/rm-common-SqlMap.xml | 43 ++++++++++++--- .../model/RecordsManagementModel.java | 1 + .../v24/RMv24DispositionInheritancePatch.java | 55 +++++++++++++++---- 5 files changed, 87 insertions(+), 19 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 8b03748dc2..51300be384 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 @@ -700,6 +700,11 @@ Saved search + + disposition processed + + + Vital Record Definition diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml index 475f1d3b39..3ddc8db447 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml @@ -26,6 +26,8 @@ + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index 29b744ae05..80881da8de 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -15,6 +15,14 @@ + + + + + + + + @@ -44,21 +52,40 @@ + + - - - - - - + \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index 0c6af0d6f2..e49aee431c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -61,9 +61,4 @@ public interface RecordsManagementQueryDAO */ public List getRecordFoldersWithSchedules(Long start, Long end); - /** - * Returns the count of record folders with a schedule applied (used for MNT-20864) - * @return the number of record folders with a disposition schedule - */ - public int getRecordFoldersWithSchedulesCount(); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 333fefe657..1293ddf911 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -48,7 +48,7 @@ import org.mybatis.spring.SqlSessionTemplate; public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; - private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedulesExtended"; + private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules"; private static final String SCHEDULED_FOLDERS_COUNT = "alfresco.query.rm.select_RecordFoldersWithSchedulesCount"; /** SQL session template */ @@ -130,24 +130,4 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, return results; } - public int getRecordFoldersWithSchedulesCount() - { - int result = 0; - - Map params = new HashMap(2); - params.put("dispositionQnameId", qnameDAO.getQName(PROP_RS_HAS_DISPOITION_SCHEDULE) - .getFirst()); - params.put("folderQnameId", qnameDAO.getQName(TYPE_RECORD_FOLDER) - .getFirst()); - - Integer count = template.selectOne(SCHEDULED_FOLDERS_COUNT, params); - - if (count != null) - { - result = count; - } - - return result; - } - } From 7d7946ea0684c7da271ff5f6f522fa206a288dde Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Wed, 20 Nov 2019 10:51:33 +0000 Subject: [PATCH 11/43] RM-7051 running the find records and update as system --- .../schedule/UpdateRecordScheduleGet.java | 90 +++++++++++-------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index effba5a757..211a978e97 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -63,6 +63,7 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.qname.QNameDAO; import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -350,45 +351,56 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record return value; } - - private int updateRecordFolder(final NodeRef recordFolder) + + private int updateRecordFolder(final NodeRef recordFolder) { - return transactionService.getRetryingTransactionHelper() - .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - int recordCount = 0; - - behaviourFilter.disableBehaviour(recordFolder); - if (logger.isDebugEnabled()) - { - logger.info("Checking folder: " + recordFolder); - } - DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); - if (schedule.isRecordLevelDisposition()) - { - List records = recordService.getRecords(recordFolder); - for (NodeRef record : records) - { - if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) - { - if (logger.isDebugEnabled()) - { - logger.info("updating record: " + record); - } - behaviourFilter.disableBehaviour(record); - dispositionService.updateNextDispositionAction(record, schedule); - recordCount ++; - behaviourFilter.enableBehaviour(record); - } - } - } - nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); - behaviourFilter.enableBehaviour(recordFolder); - - return recordCount; - } - }, false, true); + return transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Integer execute() throws Throwable + { + int recordCount = 0; + + behaviourFilter.disableBehaviour(recordFolder); + if (logger.isDebugEnabled()) + { + logger.info("Checking folder: " + recordFolder); + } + recordCount = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Integer doWork() throws Exception + { + DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); + int innerRecordCount = 0; + if (schedule.isRecordLevelDisposition()) + { + + List records = recordService.getRecords(recordFolder); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + if (logger.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + behaviourFilter.disableBehaviour(record); + dispositionService.updateNextDispositionAction(record, schedule); + innerRecordCount++; + behaviourFilter.enableBehaviour(record); + + } + } + + } + return innerRecordCount; + } + }); + nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); + behaviourFilter.enableBehaviour(recordFolder); + return recordCount; + } + }, false, true); } } From 9bf4f1d9d901d24122416b74e322e8af81f3bd23 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Wed, 20 Nov 2019 13:33:35 +0000 Subject: [PATCH 12/43] RM-7051 updating messaging --- .../web/scripts/schedule/UpdateRecordScheduleGet.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index 211a978e97..2eee54ef37 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -97,6 +97,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record private static final String MODEL_STATUS = "responsestatus"; private static final String MODEL_MESSAGE = "message"; private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records with updated disposition instructions."; + private static final String MESSAGE_FOLDER_TEMPLATE = "Updated records in folder {0} with updated disposition instructions."; /** services */ private NodeService nodeService; @@ -170,11 +171,12 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record NodeRef recordFolder = getRecordFolder(req); int processedRecords = 0; - + String message; if (recordFolder != null) { // Process the specified record folder - processedRecords = processedRecords + updateRecordFolder(recordFolder); + updateRecordFolder(recordFolder); + message = MessageFormat.format(MESSAGE_FOLDER_TEMPLATE, recordFolder); } else { @@ -202,10 +204,9 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record break; } } + message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords); } - String message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords); - model.put(MODEL_STATUS, SUCCESS_STATUS); model.put(MODEL_MESSAGE, message); logger.info(message); From bbadc9799e24afb07eb2c1877f42f9706f229fee Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Thu, 21 Nov 2019 01:16:37 +0000 Subject: [PATCH 13/43] RM-7051 simplyfing sql and adding check for links --- .../query/rm-common-SqlMap.xml | 10 ++------- .../query/RecordsManagementQueryDAOImpl.java | 2 -- .../schedule/UpdateRecordScheduleGet.java | 21 +++++++++++-------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index be7f12f03d..2aff927c18 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -9,7 +9,6 @@ - @@ -42,15 +41,10 @@ select alfn.id , alfs.protocol, alfs.identifier, alfn.uuid from alf_node alfn, alf_store alfs - where alfn.id in ( - select node_id - from alf_node_properties - where qname_id = ? - and boolean_value = true - and node_id not in ( + where alfn.id not in ( select node_id from alf_node_aspects - where qname_id = ? )) + where qname_id = ? ) and type_qname_id = ? and alfn.store_id = alfs.id and alfn.id between ? and ? diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 1293ddf911..372e2aede4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -109,8 +109,6 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, public List getRecordFoldersWithSchedules(Long start, Long end) { Map params = new HashMap(2); - params.put("dispositionQnameId", qnameDAO.getQName(PROP_RS_HAS_DISPOITION_SCHEDULE) - .getFirst()); params.put("processed", qnameDAO.getQName(ASPECT_DISPOSITION_PROCESSED) .getFirst()); params.put("folderQnameId",qnameDAO.getQName(TYPE_RECORD_FOLDER).getFirst()); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index 2eee54ef37..86213aff12 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -96,7 +96,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record private static final String SUCCESS_STATUS = "success"; private static final String MODEL_STATUS = "responsestatus"; private static final String MODEL_MESSAGE = "message"; - private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records with updated disposition instructions."; + private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records from {1} folders with updated disposition instructions."; private static final String MESSAGE_FOLDER_TEMPLATE = "Updated records in folder {0} with updated disposition instructions."; /** services */ @@ -204,7 +204,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record break; } } - message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords); + message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords, processedRecordFolders); } model.put(MODEL_STATUS, SUCCESS_STATUS); @@ -374,7 +374,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record { DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); int innerRecordCount = 0; - if (schedule.isRecordLevelDisposition()) + if (schedule != null && schedule.isRecordLevelDisposition()) { List records = recordService.getRecords(recordFolder); @@ -382,14 +382,17 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record { if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) { - if (logger.isDebugEnabled()) + if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) { - logger.info("updating record: " + record); + if (logger.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + behaviourFilter.disableBehaviour(record); + dispositionService.updateNextDispositionAction(record, schedule); + innerRecordCount++; + behaviourFilter.enableBehaviour(record); } - behaviourFilter.disableBehaviour(record); - dispositionService.updateNextDispositionAction(record, schedule); - innerRecordCount++; - behaviourFilter.enableBehaviour(record); } } From 42e6fbdb6a5794e701fb87e8b9dcf42936095ee9 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 21 Nov 2019 13:54:09 +1100 Subject: [PATCH 14/43] Prevent unwanted audit entries appearing when updating the records --- .../schedule/UpdateRecordScheduleGet.java | 84 ++++++++++--------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index 86213aff12..8e9c3c92d5 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -361,48 +361,54 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record public Integer execute() throws Throwable { int recordCount = 0; - - behaviourFilter.disableBehaviour(recordFolder); - if (logger.isDebugEnabled()) + + behaviourFilter.disableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + try { - logger.info("Checking folder: " + recordFolder); + if (logger.isDebugEnabled()) + { + logger.info("Checking folder: " + recordFolder); + } + recordCount = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Integer doWork() throws Exception + { + DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); + int innerRecordCount = 0; + if (schedule != null && schedule.isRecordLevelDisposition()) + { + + List records = recordService.getRecords(recordFolder); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) + { + if (logger.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + + // update record disposition information + dispositionService.updateNextDispositionAction(record, schedule); + innerRecordCount++; + } + } + } + + } + return innerRecordCount; + } + }); + + nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); } - recordCount = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + finally { - @Override - public Integer doWork() throws Exception - { - DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); - int innerRecordCount = 0; - if (schedule != null && schedule.isRecordLevelDisposition()) - { - - List records = recordService.getRecords(recordFolder); - for (NodeRef record : records) - { - if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) - { - if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) - { - if (logger.isDebugEnabled()) - { - logger.info("updating record: " + record); - } - behaviourFilter.disableBehaviour(record); - dispositionService.updateNextDispositionAction(record, schedule); - innerRecordCount++; - behaviourFilter.enableBehaviour(record); - } - - } - } - - } - return innerRecordCount; - } - }); - nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); - behaviourFilter.enableBehaviour(recordFolder); + behaviourFilter.enableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + } return recordCount; } }, false, true); From fbf379d6f2701c55dcce7c06e6db874adef1d938 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Thu, 21 Nov 2019 11:04:35 +0000 Subject: [PATCH 15/43] RM-7051 review comments --- .../model/recordsModel.xml | 3 +- .../query/rm-common-SqlMap.xml | 3 +- .../rm-webscript-context.xml | 4 +- .../rm-updaterecordschedule.get.desc.xml | 8 +- .../disposition/DispositionService.java | 4 +- .../disposition/DispositionServiceImpl.java | 14 +- .../query/RecordsManagementQueryDAO.java | 2 +- .../query/RecordsManagementQueryDAOImpl.java | 10 +- .../schedule/UpdateRecordScheduleGet.java | 173 ++++++++++-------- 9 files changed, 119 insertions(+), 102 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 51300be384..51dd360d23 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 @@ -701,10 +701,9 @@ - disposition processed + Disposition processed - Vital Record Definition diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index 2aff927c18..5314ebe76a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -39,8 +39,7 @@ parameterMap="parameter_folderPatchPaging" resultMap="result_NodeRefEntity"> select alfn.id , alfs.protocol, alfs.identifier, alfn.uuid - from alf_node alfn, - alf_store alfs + from alf_node alfn, alf_store alfs where alfn.id not in ( select node_id from alf_node_aspects 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 30477644fa..0215c04957 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 @@ -666,10 +666,10 @@ - + + parent="webscript"> diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml index 7d1df216f7..8ff54084a0 100644 --- a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml @@ -1,9 +1,9 @@ - Updates Record Schedules based on Hierarchical Disposition Instructions + Updates Record Schedules based on Hierarchical Retention Instructions - URL parameter maxRecordFolders is optional, and represents the maximum number of record folders that should be processed. If not specified maxRecordFolders will be set to 10000
- URL parameter recordFolder is optional, and represents the nodeRef of a record folder who's records should be processed. If specified then maxRecordFolders will be ignored.
+ Updates records schedules by reviewing retention instructions defined within the principle hierarchy.
+ URL parameter maxRecordFolders is optional, and represents the maximum number of record folders that should be processed. If not specified maxRecordFolders will be set to the max value for an integer.
+ URL parameter recordFolder is optional, and represents the nodeRef of a record folder whose records should be processed. If specified then maxRecordFolders will be ignored.
]]>
/api/rm/rm-updateRecordSchedule?maxRecordFolders={maxRecordFolders?}&recordFolder={recordFolder?} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index 2ba7dbcc0e..dccc56df6b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -240,8 +240,8 @@ public interface DispositionService /** * Updates the next disposition action * - * @param nodeRef node reference - * @param DispositionSchedule the schedule to be applied + * @param nodeRef node reference + * @param dispositionSchedule the schedule to be applied */ void updateNextDispositionAction(NodeRef nodeRef, DispositionSchedule dispositionSchedule); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 78087ffffd..e044026c75 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -953,9 +953,9 @@ public class DispositionServiceImpl extends ServiceBaseImpl public Void doWork() { // Get this disposition instructions for the node - DispositionSchedule di = getDispositionSchedule(nodeRef); + DispositionSchedule dispositionSchedule = getDispositionSchedule(nodeRef); - updateNextDispositionAction(nodeRef, di); + updateNextDispositionAction(nodeRef, dispositionSchedule); return null; } @@ -969,7 +969,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) */ @Override - public void updateNextDispositionAction(final NodeRef nodeRef, final DispositionSchedule di) + public void updateNextDispositionAction(final NodeRef nodeRef, final DispositionSchedule dispositionSchedule) { @@ -982,7 +982,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl public Void doWork() { - if (di != null) + if (dispositionSchedule != null) { // Get the current action node NodeRef currentDispositionAction = null; @@ -1001,7 +1001,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); } - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + List dispositionActionDefinitions = dispositionSchedule.getDispositionActionDefinitions(); DispositionActionDefinition currentDispositionActionDefinition = null; DispositionActionDefinition nextDispositionActionDefinition = null; @@ -1017,14 +1017,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl { // Get the current action String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); - currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinition(currentADId); // When the record has multiple disposition schedules the current disposition action may not be found by id // In this case it will be searched by name if(currentDispositionActionDefinition == null) { String currentADName = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION); - currentDispositionActionDefinition = di.getDispositionActionDefinitionByName(currentADName); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinitionByName(currentADName); } // Get the next disposition action diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index e49aee431c..eac96d6f45 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -59,6 +59,6 @@ public interface RecordsManagementQueryDAO * @param end long - the last result row to return * @return list of node refs */ - public List getRecordFoldersWithSchedules(Long start, Long end); + List getRecordFoldersWithSchedules(Long start, Long end); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 372e2aede4..3eb65251e0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -103,15 +103,16 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, } /** - * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules() + * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules(Long, Long) */ @Override public List getRecordFoldersWithSchedules(Long start, Long end) { - Map params = new HashMap(2); + Map params = new HashMap<>(2); params.put("processed", qnameDAO.getQName(ASPECT_DISPOSITION_PROCESSED) .getFirst()); - params.put("folderQnameId",qnameDAO.getQName(TYPE_RECORD_FOLDER).getFirst()); + params.put("folderQnameId", qnameDAO.getQName(TYPE_RECORD_FOLDER) + .getFirst()); params.put("start", start); params.put("end", end); @@ -122,7 +123,8 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, // convert the entities to NodeRefs for (NodeRefEntity nodeRefEntity : entities) { - results.add(new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid())); + results.add( + new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid())); } return results; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index 86213aff12..5f4f15acc5 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -42,6 +42,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ + package org.alfresco.repo.web.scripts.schedule; import java.io.IOException; @@ -86,20 +87,26 @@ import org.springframework.extensions.webscripts.WebScriptResponse; */ public class UpdateRecordScheduleGet extends AbstractWebScript implements RecordsManagementModel { - /** logger */ + /** + * logger + */ private static Log logger = LogFactory.getLog(UpdateRecordScheduleGet.class); - - /** parameters */ + + /** + * parameters + */ private static final String PARAM_MAX_RECORD_FOLDERS = "maxRecordFolders"; private static final String PARAM_RECORD_FOLDER = "recordFolder"; - - private static final String SUCCESS_STATUS = "success"; + + private static final String SUCCESS_STATUS = "success"; private static final String MODEL_STATUS = "responsestatus"; private static final String MODEL_MESSAGE = "message"; private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records from {1} folders with updated disposition instructions."; private static final String MESSAGE_FOLDER_TEMPLATE = "Updated records in folder {0} with updated disposition instructions."; - /** services */ + /** + * services + */ private NodeService nodeService; private DispositionService dispositionService; private RecordService recordService; @@ -108,54 +115,56 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record private BehaviourFilter behaviourFilter; private NodeDAO nodeDAO; private QNameDAO qnameDAO; - - /** service setters */ + + /** + * service setters + */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } - public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO) + public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO) { - this.recordsManagementQueryDAO = recordsManagementQueryDAO; - } - - public void setRecordService(RecordService recordService) - { - this.recordService = recordService; - } + this.recordsManagementQueryDAO = recordsManagementQueryDAO; + } - public void setDispositionService(DispositionService dispositionService) + public void setRecordService(RecordService recordService) { - this.dispositionService = dispositionService; - } - + this.recordService = recordService; + } + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + public void setTransactionService(TransactionService transactionService) { this.transactionService = transactionService; } - - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - public void setNodeDAO(NodeDAO nodeDAO) - { - this.nodeDAO = nodeDAO; - } - public void setQnameDAO(QNameDAO qnameDAO) + public void setBehaviourFilter(BehaviourFilter behaviourFilter) { - this.qnameDAO = qnameDAO; - } - + this.behaviourFilter = behaviourFilter; + } + + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + /** * Build web script model */ protected Map buildModel(WebScriptRequest req, WebScriptResponse res) throws IOException { - Map model = new HashMap(); + Map model = new HashMap<>(); transactionService.getRetryingTransactionHelper() .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -165,7 +174,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record return null; } - },false,true); + }, false, true); int maxRecordFolders = getMaxRecordFolders(req); NodeRef recordFolder = getRecordFolder(req); @@ -174,35 +183,35 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record String message; if (recordFolder != null) { - // Process the specified record folder - updateRecordFolder(recordFolder); + // Process the specified record folder + updateRecordFolder(recordFolder); message = MessageFormat.format(MESSAGE_FOLDER_TEMPLATE, recordFolder); } else { - int processedRecordFolders = 0; - int queryBatchSize = 10000; - Long maxNodeId = nodeDAO.getMaxNodeId(); - for (Long i = 0L; i < maxNodeId; i += queryBatchSize) + int processedRecordFolders = 0; + int queryBatchSize = 10000; + Long maxNodeId = nodeDAO.getMaxNodeId(); + for (Long i = 0L; i < maxNodeId; i += queryBatchSize) { List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(i, i + queryBatchSize); for (NodeRef folder : folders) { - processedRecords = processedRecords + updateRecordFolder(folder); - processedRecordFolders++; - - if (processedRecordFolders >= maxRecordFolders) - { - // stop processing since we have meet our limit - break; - } + processedRecords = processedRecords + updateRecordFolder(folder); + processedRecordFolders++; + + if (processedRecordFolders >= maxRecordFolders) + { + // stop processing since we have meet our limit + break; + } } - + if (processedRecordFolders >= maxRecordFolders) - { - // stop processing since we have meet our limit - break; - } + { + // stop processing since we have meet our limit + break; + } } message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords, processedRecordFolders); } @@ -227,18 +236,19 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record try { - String mimetype = getContainer().getFormatRegistry().getMimeType(req.getAgent(), format); - if (mimetype == null) - { + String mimetype = getContainer().getFormatRegistry() + .getMimeType(req.getAgent(), format); + if (mimetype == null) + { throw new WebScriptException("Web Script format '" + format + "' is not registered"); } // construct model for script / template Status status = new Status(); Cache cache = new Cache(getDescription().getRequiredCache()); - + Map model = buildModel(req, res); - + if (model == null) { return; } model.put("status", status); model.put("cache", cache); @@ -261,7 +271,8 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record String location = status.getLocation(); if (location != null && location.length() > 0) { - if (logger.isDebugEnabled()) logger.debug("Setting location to " + location); + if (logger.isDebugEnabled()) + logger.debug("Setting location to " + location); res.setHeader(WebScriptResponse.HEADER_LOCATION, location); } @@ -275,12 +286,15 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record } if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) { - if (logger.isDebugEnabled()) logger.debug("Rendering JSON callback response: content type=" - + Format.JAVASCRIPT.mimetype() + ", status=" + statusCode + ", callback=" + callback); + if (logger.isDebugEnabled()) + logger.debug( + "Rendering JSON callback response: content type=" + Format.JAVASCRIPT.mimetype() + ", status=" + + statusCode + ", callback=" + callback); // NOTE: special case for wrapping JSON results in a javascript function callback res.setContentType(Format.JAVASCRIPT.mimetype() + ";charset=UTF-8"); - res.getWriter().write((callback + "(")); + res.getWriter() + .write((callback + "(")); } else { @@ -296,7 +310,8 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) { // NOTE: special case for wrapping JSON results in a javascript function callback - res.getWriter().write(")"); + res.getWriter() + .write(")"); } } catch (Throwable e) @@ -318,7 +333,8 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record String templatePath = getDescription().getId() + "." + format; - if (logger.isDebugEnabled()) logger.debug("Rendering template '" + templatePath + "'"); + if (logger.isDebugEnabled()) + logger.debug("Rendering template '" + templatePath + "'"); renderTemplate(templatePath, model, writer); } @@ -333,24 +349,24 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record { value = Integer.parseInt(valueStr); } - catch(NumberFormatException ex) + catch (NumberFormatException ex) { //do nothing here, the value will remain 0L in this case } } return value; - } - + } + protected NodeRef getRecordFolder(WebScriptRequest req) { - String valueStr = req.getParameter(PARAM_RECORD_FOLDER); - NodeRef value = null; - if (StringUtils.isNotBlank(valueStr)) - { - value = new NodeRef(valueStr); - } - - return value; + String valueStr = req.getParameter(PARAM_RECORD_FOLDER); + NodeRef value = null; + if (StringUtils.isNotBlank(valueStr)) + { + value = new NodeRef(valueStr); + } + + return value; } private int updateRecordFolder(final NodeRef recordFolder) @@ -382,7 +398,8 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record { if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) { - if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) + if (recordFolder.equals(nodeService.getPrimaryParent(record) + .getParentRef())) { if (logger.isDebugEnabled()) { From 7fba698dd89f056333caf4b1bbd6ba1ff1a53616 Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 21 Nov 2019 18:15:29 +0000 Subject: [PATCH 16/43] [maven-release-plugin] prepare release V2.5.3.3 --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 4797d209c1..6e30593f25 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.5.3.3-SNAPSHOT + 2.5.3.3 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.5.3 + V2.5.3.3 diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index c61d666c8e..cba0601acb 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.5.3.3-SNAPSHOT + 2.5.3.3 diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 73c9631e3e..1bef20a0df 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.5.3.3-SNAPSHOT + 2.5.3.3 diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 7e79f8c07f..9c4d521566 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.5.3.3-SNAPSHOT + 2.5.3.3 From 3c0a62fa815e13c52c26b2fa6769ff674f558d93 Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Thu, 21 Nov 2019 18:15:33 +0000 Subject: [PATCH 17/43] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 6e30593f25..57eee00ace 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - 2.5.3.3 + -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.5.3.3 + V2.5.3 diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index cba0601acb..a4535a14f7 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.5.3.3 + -SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 1bef20a0df..f71ea772c9 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - 2.5.3.3 + -SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 9c4d521566..311609cbc4 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.5.3.3 + -SNAPSHOT From b6a7b93a527e95b8efc8ca22fee8a23252038c5d Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Fri, 22 Nov 2019 08:55:41 +0000 Subject: [PATCH 18/43] Updating version number after release --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 57eee00ace..37c07218a2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm pom - -SNAPSHOT + 2.5.3.4-SNAPSHOT Alfresco Records Management diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index a4535a14f7..88ba6b6d02 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - -SNAPSHOT + 2.5.3.4-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index f71ea772c9..e820c70be9 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm - -SNAPSHOT + 2.5.3.4-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 311609cbc4..21601dee66 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.5.3.4-SNAPSHOT From 92c8c2db21cf7e8ba4f6676f824160c2b6853532 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Fri, 22 Nov 2019 14:25:27 +0000 Subject: [PATCH 19/43] Merge branch 'hotfix-2.5/RM-7051_Disposition' into 'release/V2.5.3.x' Resolve RM-7051 "Hotfix 2.5/ disposition" See merge request records-management/records-management!1303 Adds web script to ensure all records have correct disposition instructions --- .../model/recordsModel.xml | 4 + .../patch/rm-patch-v24-context.xml | 2 +- .../query/rm-common-SqlMap.xml | 35 +- .../rm-webscript-context.xml | 15 + .../org_alfresco_module_rm/version.properties | 2 +- .../rm-updaterecordschedule.get.desc.xml | 13 + .../rm-updaterecordschedule.get.json.ftl | 30 ++ .../disposition/DispositionService.java | 8 + .../disposition/DispositionServiceImpl.java | 38 +- .../model/RecordsManagementModel.java | 1 + .../query/NodeRefEntity.java | 88 ++++ .../query/RecordsManagementQueryDAO.java | 15 + .../query/RecordsManagementQueryDAOImpl.java | 35 +- .../schedule/UpdateRecordScheduleGet.java | 430 ++++++++++++++++++ 14 files changed, 705 insertions(+), 11 deletions(-) create mode 100644 rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml create mode 100644 rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java 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 8b03748dc2..51dd360d23 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 @@ -700,6 +700,10 @@ Saved search
+ + Disposition processed + + Vital Record Definition diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml index e3e843041e..b2527baa9f 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml @@ -14,5 +14,5 @@ - + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index e3f1c1a89d..5314ebe76a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -7,8 +7,23 @@ - - select count(*) from @@ -19,5 +34,19 @@ prop.string_value = ? - + + + \ No newline at end of file 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 d4f8b73a05..0215c04957 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 @@ -665,4 +665,19 @@ parent="rmBaseWebscript"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties index cf2c7c2600..8cce8ad3ce 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties @@ -1,3 +1,3 @@ # RM Schema number -version.rm.schema=2501 +version.rm.schema=2502 diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml new file mode 100644 index 0000000000..8ff54084a0 --- /dev/null +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml @@ -0,0 +1,13 @@ + + Updates Record Schedules based on Hierarchical Retention Instructions + + URL parameter maxRecordFolders is optional, and represents the maximum number of record folders that should be processed. If not specified maxRecordFolders will be set to the max value for an integer.
+ URL parameter recordFolder is optional, and represents the nodeRef of a record folder whose records should be processed. If specified then maxRecordFolders will be ignored.
+ ]]> +
+ /api/rm/rm-updateRecordSchedule?maxRecordFolders={maxRecordFolders?}&recordFolder={recordFolder?} + argument + admin + required +
\ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl new file mode 100644 index 0000000000..2b395291a4 --- /dev/null +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl @@ -0,0 +1,30 @@ +<#-- + #%L + Alfresco Records Management Module + %% + Copyright (C) 2005 - 2019 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% +--> +{ + "responsestatus" : "${responsestatus?json_string}", + "message" : "${message?json_string}" +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index 4da6fde0dd..dccc56df6b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -237,6 +237,14 @@ public interface DispositionService */ void updateNextDispositionAction(NodeRef nodeRef); + /** + * Updates the next disposition action + * + * @param nodeRef node reference + * @param dispositionSchedule the schedule to be applied + */ + void updateNextDispositionAction(NodeRef nodeRef, DispositionSchedule dispositionSchedule); + /** * Refreshes the disposition action details of the given node. * diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 32f68c1bb5..e044026c75 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -953,8 +953,36 @@ public class DispositionServiceImpl extends ServiceBaseImpl public Void doWork() { // Get this disposition instructions for the node - DispositionSchedule di = getDispositionSchedule(nodeRef); - if (di != null) + DispositionSchedule dispositionSchedule = getDispositionSchedule(nodeRef); + + updateNextDispositionAction(nodeRef, dispositionSchedule); + + return null; + } + + }; + + AuthenticationUtil.runAsSystem(runAsWork); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) + */ + @Override + public void updateNextDispositionAction(final NodeRef nodeRef, final DispositionSchedule dispositionSchedule) + { + + + RunAsWork runAsWork = new RunAsWork() + { + /** + * @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork() + */ + @Override + public Void doWork() + { + + if (dispositionSchedule != null) { // Get the current action node NodeRef currentDispositionAction = null; @@ -973,7 +1001,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); } - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + List dispositionActionDefinitions = dispositionSchedule.getDispositionActionDefinitions(); DispositionActionDefinition currentDispositionActionDefinition = null; DispositionActionDefinition nextDispositionActionDefinition = null; @@ -989,14 +1017,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl { // Get the current action String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); - currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinition(currentADId); // When the record has multiple disposition schedules the current disposition action may not be found by id // In this case it will be searched by name if(currentDispositionActionDefinition == null) { String currentADName = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION); - currentDispositionActionDefinition = di.getDispositionActionDefinitionByName(currentADName); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinitionByName(currentADName); } // Get the next disposition action 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 fc95771ddc..42c5a25fde 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 @@ -281,4 +281,5 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel QName PROP_COUNT = QName.createQName(RM_URI, "count"); QName ASPECT_SAVED_SEARCH = QName.createQName(RM_URI, "savedSearch"); + QName ASPECT_DISPOSITION_PROCESSED = QName.createQName(RM_URI, "dispositionProcessed"); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java new file mode 100644 index 0000000000..203a186e45 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java @@ -0,0 +1,88 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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.query; + +/** + * NodeRef Entity - used by {@link RecordsManagementQueryDAOImpl}. + * + * @author Tom Page + * @since 2.5.0.4 + */ +public class NodeRefEntity +{ + private Long num; + private String protocol; + private String identifier; + private String uuid; + + /** + * Default constructor. + */ + public NodeRefEntity() + { + } + + public Long getNum() + { + return num; + } + + public void setNum(Long num) + { + this.num = num; + } + + public String getProtocol() + { + return protocol; + } + + public void setProtocol(String protocol) + { + this.protocol = protocol; + } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + + public String getUuid() + { + return uuid; + } + + public void setUuid(String uuid) + { + this.uuid = uuid; + } +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index c0743f604d..eac96d6f45 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -27,6 +27,10 @@ package org.alfresco.module.org_alfresco_module_rm.query; +import java.util.List; + +import org.alfresco.service.cmr.repository.NodeRef; + /** * Records management query DAO * @@ -46,4 +50,15 @@ public interface RecordsManagementQueryDAO * @return int count */ int getCountRmaIdentifier(String identifierValue); + + /** + * Returns a number of nodeRefs for record folders in the system + * that have the property recordSearchHasDispositionSchedule:true + * (used for MNT-20864) + * @param start long - the first result row to return + * @param end long - the last result row to return + * @return list of node refs + */ + List getRecordFoldersWithSchedules(Long start, Long end); + } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 68742ee271..3eb65251e0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -27,11 +27,14 @@ package org.alfresco.module.org_alfresco_module_rm.query; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.mybatis.spring.SqlSessionTemplate; @@ -45,7 +48,9 @@ import org.mybatis.spring.SqlSessionTemplate; public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; - + private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules"; + private static final String SCHEDULED_FOLDERS_COUNT = "alfresco.query.rm.select_RecordFoldersWithSchedulesCount"; + /** SQL session template */ protected SqlSessionTemplate template; @@ -97,4 +102,32 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, return result; } + /** + * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules(Long, Long) + */ + @Override + public List getRecordFoldersWithSchedules(Long start, Long end) + { + Map params = new HashMap<>(2); + params.put("processed", qnameDAO.getQName(ASPECT_DISPOSITION_PROCESSED) + .getFirst()); + params.put("folderQnameId", qnameDAO.getQName(TYPE_RECORD_FOLDER) + .getFirst()); + params.put("start", start); + params.put("end", end); + + List entities = template.selectList(SCHEDULED_FOLDERS, params); + + List results = new ArrayList<>(); + + // convert the entities to NodeRefs + for (NodeRefEntity nodeRefEntity : entities) + { + results.add( + new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid())); + } + + return results; + } + } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java new file mode 100644 index 0000000000..ee5c16207e --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -0,0 +1,430 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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% + */ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.repo.web.scripts.schedule; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.transaction.TransactionService; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Format; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Webscript used to update records that are missing their schedule information + * + * @author Roy Wetherall + */ +public class UpdateRecordScheduleGet extends AbstractWebScript implements RecordsManagementModel +{ + /** + * logger + */ + private static Log logger = LogFactory.getLog(UpdateRecordScheduleGet.class); + + /** + * parameters + */ + private static final String PARAM_MAX_RECORD_FOLDERS = "maxRecordFolders"; + private static final String PARAM_RECORD_FOLDER = "recordFolder"; + + private static final String SUCCESS_STATUS = "success"; + private static final String MODEL_STATUS = "responsestatus"; + private static final String MODEL_MESSAGE = "message"; + private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records from {1} folders with updated disposition instructions."; + private static final String MESSAGE_FOLDER_TEMPLATE = "Updated records in folder {0} with updated disposition instructions."; + + /** + * services + */ + private NodeService nodeService; + private DispositionService dispositionService; + private RecordService recordService; + private TransactionService transactionService; + private RecordsManagementQueryDAO recordsManagementQueryDAO; + private BehaviourFilter behaviourFilter; + private NodeDAO nodeDAO; + private QNameDAO qnameDAO; + + /** + * service setters + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO) + { + this.recordsManagementQueryDAO = recordsManagementQueryDAO; + } + + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * Build web script model + */ + protected Map buildModel(WebScriptRequest req, WebScriptResponse res) throws IOException + { + Map model = new HashMap<>(); + transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public String execute() throws Throwable + { + qnameDAO.getOrCreateQName(ASPECT_DISPOSITION_PROCESSED); + return null; + } + + }, false, true); + + int maxRecordFolders = getMaxRecordFolders(req); + NodeRef recordFolder = getRecordFolder(req); + + int processedRecords = 0; + String message; + if (recordFolder != null) + { + // Process the specified record folder + updateRecordFolder(recordFolder); + message = MessageFormat.format(MESSAGE_FOLDER_TEMPLATE, recordFolder); + } + else + { + int processedRecordFolders = 0; + int queryBatchSize = 10000; + Long maxNodeId = nodeDAO.getMaxNodeId(); + for (Long i = 0L; i < maxNodeId; i += queryBatchSize) + { + List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(i, i + queryBatchSize); + for (NodeRef folder : folders) + { + processedRecords = processedRecords + updateRecordFolder(folder); + processedRecordFolders++; + + if (processedRecordFolders >= maxRecordFolders) + { + // stop processing since we have meet our limit + break; + } + } + + if (processedRecordFolders >= maxRecordFolders) + { + // stop processing since we have meet our limit + break; + } + } + message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords, processedRecordFolders); + } + + model.put(MODEL_STATUS, SUCCESS_STATUS); + model.put(MODEL_MESSAGE, message); + logger.info(message); + + return model; + } + + /* + * (non-Javadoc) + * @see org.alfresco.repo.web.scripts.content.StreamContent#execute(org.springframework.extensions.webscripts. + * WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse) + */ + @Override + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + // retrieve requested format + String format = req.getFormat(); + + try + { + String mimetype = getContainer().getFormatRegistry() + .getMimeType(req.getAgent(), format); + if (mimetype == null) + { + throw new WebScriptException("Web Script format '" + format + "' is not registered"); + } + + // construct model for script / template + Status status = new Status(); + Cache cache = new Cache(getDescription().getRequiredCache()); + + Map model = buildModel(req, res); + + if (model == null) { return; } + model.put("status", status); + model.put("cache", cache); + + Map templateModel = createTemplateParameters(req, res, model); + + // render output + int statusCode = status.getCode(); + if (statusCode != HttpServletResponse.SC_OK && !req.forceSuccessStatus()) + { + if (logger.isDebugEnabled()) + { + logger.debug("Force success status header in response: " + req.forceSuccessStatus()); + logger.debug("Setting status " + statusCode); + } + res.setStatus(statusCode); + } + + // apply location + String location = status.getLocation(); + if (location != null && location.length() > 0) + { + if (logger.isDebugEnabled()) + logger.debug("Setting location to " + location); + res.setHeader(WebScriptResponse.HEADER_LOCATION, location); + } + + // apply cache + res.setCache(cache); + + String callback = null; + if (getContainer().allowCallbacks()) + { + callback = req.getJSONCallback(); + } + if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) + { + if (logger.isDebugEnabled()) + logger.debug( + "Rendering JSON callback response: content type=" + Format.JAVASCRIPT.mimetype() + ", status=" + + statusCode + ", callback=" + callback); + + // NOTE: special case for wrapping JSON results in a javascript function callback + res.setContentType(Format.JAVASCRIPT.mimetype() + ";charset=UTF-8"); + res.getWriter() + .write((callback + "(")); + } + else + { + if (logger.isDebugEnabled()) + logger.debug("Rendering response: content type=" + mimetype + ", status=" + statusCode); + + res.setContentType(mimetype + ";charset=UTF-8"); + } + + // render response according to requested format + renderFormatTemplate(format, templateModel, res.getWriter()); + + if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) + { + // NOTE: special case for wrapping JSON results in a javascript function callback + res.getWriter() + .write(")"); + } + } + catch (Throwable e) + { + if (logger.isDebugEnabled()) + { + StringWriter stack = new StringWriter(); + e.printStackTrace(new PrintWriter(stack)); + logger.debug("Caught exception; decorating with appropriate status template : " + stack.toString()); + } + + throw createStatusException(e, req, res); + } + } + + protected void renderFormatTemplate(String format, Map model, Writer writer) + { + format = (format == null) ? "" : format; + + String templatePath = getDescription().getId() + "." + format; + + if (logger.isDebugEnabled()) + logger.debug("Rendering template '" + templatePath + "'"); + + renderTemplate(templatePath, model, writer); + } + + protected int getMaxRecordFolders(WebScriptRequest req) + { + String valueStr = req.getParameter(PARAM_MAX_RECORD_FOLDERS); + int value = Integer.MAX_VALUE; + if (StringUtils.isNotBlank(valueStr)) + { + try + { + value = Integer.parseInt(valueStr); + } + catch (NumberFormatException ex) + { + //do nothing here, the value will remain 0L in this case + } + } + return value; + } + + protected NodeRef getRecordFolder(WebScriptRequest req) + { + String valueStr = req.getParameter(PARAM_RECORD_FOLDER); + NodeRef value = null; + if (StringUtils.isNotBlank(valueStr)) + { + value = new NodeRef(valueStr); + } + + return value; + } + + private int updateRecordFolder(final NodeRef recordFolder) + { + return transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Integer execute() throws Throwable + { + int recordCount = 0; + + behaviourFilter.disableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + try + { + if (logger.isDebugEnabled()) + { + logger.info("Checking folder: " + recordFolder); + } + recordCount = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Integer doWork() throws Exception + { + DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); + int innerRecordCount = 0; + if (schedule != null && schedule.isRecordLevelDisposition()) + { + + List records = recordService.getRecords(recordFolder); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) + { + if (logger.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + + // update record disposition information + dispositionService.updateNextDispositionAction(record, schedule); + innerRecordCount++; + } + } + } + } + return innerRecordCount; + } + }); + nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); + } + finally + { + behaviourFilter.enableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + } + return recordCount; + } + }, false, true); + } +} From 5d3efcc4c440820941823dad8e89a76f1650b805 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Fri, 22 Nov 2019 18:15:24 +0000 Subject: [PATCH 20/43] Merge branch 'hotfix-2.5/RM-7051_Disposition' into 'release/V2.5.3.x' Resolve RM-7051 "Hotfix 2.5/ disposition" See merge request records-management/records-management!1303 Adds web script to ensure all records have correct disposition instructions --- .../model/recordsModel.xml | 4 + .../patch/rm-patch-v24-context.xml | 2 +- .../query/rm-common-SqlMap.xml | 35 +- .../rm-webscript-context.xml | 15 + .../org_alfresco_module_rm/version.properties | 2 +- .../rm-updaterecordschedule.get.desc.xml | 13 + .../rm-updaterecordschedule.get.json.ftl | 30 ++ .../disposition/DispositionService.java | 8 + .../disposition/DispositionServiceImpl.java | 38 +- .../model/RecordsManagementModel.java | 1 + .../query/NodeRefEntity.java | 88 ++++ .../query/RecordsManagementQueryDAO.java | 15 +- .../query/RecordsManagementQueryDAOImpl.java | 35 +- .../schedule/UpdateRecordScheduleGet.java | 430 ++++++++++++++++++ 14 files changed, 705 insertions(+), 11 deletions(-) create mode 100644 rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml create mode 100644 rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java 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 b49c740fb9..911576a784 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 @@ -712,6 +712,10 @@ Saved search
+ + Disposition processed + + Vital Record Definition diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml index e3e843041e..b2527baa9f 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v24-context.xml @@ -14,5 +14,5 @@ - + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index d3b63f4467..d6ebbeca54 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -7,8 +7,23 @@ - - select count(*) from @@ -20,6 +35,21 @@ + + + + \ No newline at end of file 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 d4f8b73a05..0215c04957 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 @@ -665,4 +665,19 @@ parent="rmBaseWebscript"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties index cf2c7c2600..8cce8ad3ce 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties @@ -1,3 +1,3 @@ # RM Schema number -version.rm.schema=2501 +version.rm.schema=2502 diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml new file mode 100644 index 0000000000..8ff54084a0 --- /dev/null +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.desc.xml @@ -0,0 +1,13 @@ + + Updates Record Schedules based on Hierarchical Retention Instructions + + URL parameter maxRecordFolders is optional, and represents the maximum number of record folders that should be processed. If not specified maxRecordFolders will be set to the max value for an integer.
+ URL parameter recordFolder is optional, and represents the nodeRef of a record folder whose records should be processed. If specified then maxRecordFolders will be ignored.
+ ]]> +
+ /api/rm/rm-updateRecordSchedule?maxRecordFolders={maxRecordFolders?}&recordFolder={recordFolder?} + argument + admin + required +
\ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl new file mode 100644 index 0000000000..2b395291a4 --- /dev/null +++ b/rm-community/rm-community-repo/config/alfresco/templates/webscripts/org/alfresco/repository/schedules/rm-updaterecordschedule.get.json.ftl @@ -0,0 +1,30 @@ +<#-- + #%L + Alfresco Records Management Module + %% + Copyright (C) 2005 - 2019 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% +--> +{ + "responsestatus" : "${responsestatus?json_string}", + "message" : "${message?json_string}" +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index 4da6fde0dd..dccc56df6b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -237,6 +237,14 @@ public interface DispositionService */ void updateNextDispositionAction(NodeRef nodeRef); + /** + * Updates the next disposition action + * + * @param nodeRef node reference + * @param dispositionSchedule the schedule to be applied + */ + void updateNextDispositionAction(NodeRef nodeRef, DispositionSchedule dispositionSchedule); + /** * Refreshes the disposition action details of the given node. * diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 32f68c1bb5..e044026c75 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -953,8 +953,36 @@ public class DispositionServiceImpl extends ServiceBaseImpl public Void doWork() { // Get this disposition instructions for the node - DispositionSchedule di = getDispositionSchedule(nodeRef); - if (di != null) + DispositionSchedule dispositionSchedule = getDispositionSchedule(nodeRef); + + updateNextDispositionAction(nodeRef, dispositionSchedule); + + return null; + } + + }; + + AuthenticationUtil.runAsSystem(runAsWork); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#updateNextDispositionAction(NodeRef) + */ + @Override + public void updateNextDispositionAction(final NodeRef nodeRef, final DispositionSchedule dispositionSchedule) + { + + + RunAsWork runAsWork = new RunAsWork() + { + /** + * @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork() + */ + @Override + public Void doWork() + { + + if (dispositionSchedule != null) { // Get the current action node NodeRef currentDispositionAction = null; @@ -973,7 +1001,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); } - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + List dispositionActionDefinitions = dispositionSchedule.getDispositionActionDefinitions(); DispositionActionDefinition currentDispositionActionDefinition = null; DispositionActionDefinition nextDispositionActionDefinition = null; @@ -989,14 +1017,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl { // Get the current action String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); - currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinition(currentADId); // When the record has multiple disposition schedules the current disposition action may not be found by id // In this case it will be searched by name if(currentDispositionActionDefinition == null) { String currentADName = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION); - currentDispositionActionDefinition = di.getDispositionActionDefinitionByName(currentADName); + currentDispositionActionDefinition = dispositionSchedule.getDispositionActionDefinitionByName(currentADName); } // Get the next disposition action 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 600e48d4e5..e1ac53d9a5 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 @@ -282,4 +282,5 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel QName PROP_COUNT = QName.createQName(RM_URI, "count"); QName ASPECT_SAVED_SEARCH = QName.createQName(RM_URI, "savedSearch"); + QName ASPECT_DISPOSITION_PROCESSED = QName.createQName(RM_URI, "dispositionProcessed"); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java new file mode 100644 index 0000000000..203a186e45 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/NodeRefEntity.java @@ -0,0 +1,88 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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.query; + +/** + * NodeRef Entity - used by {@link RecordsManagementQueryDAOImpl}. + * + * @author Tom Page + * @since 2.5.0.4 + */ +public class NodeRefEntity +{ + private Long num; + private String protocol; + private String identifier; + private String uuid; + + /** + * Default constructor. + */ + public NodeRefEntity() + { + } + + public Long getNum() + { + return num; + } + + public void setNum(Long num) + { + this.num = num; + } + + public String getProtocol() + { + return protocol; + } + + public void setProtocol(String protocol) + { + this.protocol = protocol; + } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + + public String getUuid() + { + return uuid; + } + + public void setUuid(String uuid) + { + this.uuid = uuid; + } +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java index ad4a3e2103..ea3a61c6dc 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java @@ -27,9 +27,11 @@ package org.alfresco.module.org_alfresco_module_rm.query; -import java.util.Collection; + +import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; +import java.util.Collection; import org.alfresco.service.namespace.QName; /** @@ -52,6 +54,16 @@ public interface RecordsManagementQueryDAO */ int getCountRmaIdentifier(String identifierValue); + /** + * Returns a number of nodeRefs for record folders in the system + * that have the property recordSearchHasDispositionSchedule:true + * (used for MNT-20864) + * @param start long - the first result row to return + * @param end long - the last result row to return + * @return list of node refs + */ + List getRecordFoldersWithSchedules(Long start, Long end); + /** * Returns whether a given node contains children with one of the given values for the given property * @@ -62,4 +74,5 @@ public interface RecordsManagementQueryDAO * false otherwise */ public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues); + } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 99e05941a5..7c7ac5fc6c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -27,8 +27,10 @@ package org.alfresco.module.org_alfresco_module_rm.query; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -50,8 +52,10 @@ import org.mybatis.spring.SqlSessionTemplate; public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; + private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules"; + private static final String SCHEDULED_FOLDERS_COUNT = "alfresco.query.rm.select_RecordFoldersWithSchedulesCount"; private static final String COUNT_CHILDREN_WITH_PROPERTY_VALUES = "select_CountChildrenWithPropertyValues"; - + /** SQL session template */ protected SqlSessionTemplate template; @@ -115,6 +119,34 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, return result; } + /** + * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules(Long, Long) + */ + @Override + public List getRecordFoldersWithSchedules(Long start, Long end) + { + Map params = new HashMap<>(2); + params.put("processed", qnameDAO.getQName(ASPECT_DISPOSITION_PROCESSED) + .getFirst()); + params.put("folderQnameId", qnameDAO.getQName(TYPE_RECORD_FOLDER) + .getFirst()); + params.put("start", start); + params.put("end", end); + + List entities = template.selectList(SCHEDULED_FOLDERS, params); + + List results = new ArrayList<>(); + + // convert the entities to NodeRefs + for (NodeRefEntity nodeRefEntity : entities) + { + results.add( + new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid())); + } + + return results; + } + @Override public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues) { @@ -150,4 +182,5 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, Long count = template.selectOne(COUNT_CHILDREN_WITH_PROPERTY_VALUES, queryParams); return count > 0; } + } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java new file mode 100644 index 0000000000..ee5c16207e --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -0,0 +1,430 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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% + */ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.repo.web.scripts.schedule; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.transaction.TransactionService; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Format; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; + +/** + * Webscript used to update records that are missing their schedule information + * + * @author Roy Wetherall + */ +public class UpdateRecordScheduleGet extends AbstractWebScript implements RecordsManagementModel +{ + /** + * logger + */ + private static Log logger = LogFactory.getLog(UpdateRecordScheduleGet.class); + + /** + * parameters + */ + private static final String PARAM_MAX_RECORD_FOLDERS = "maxRecordFolders"; + private static final String PARAM_RECORD_FOLDER = "recordFolder"; + + private static final String SUCCESS_STATUS = "success"; + private static final String MODEL_STATUS = "responsestatus"; + private static final String MODEL_MESSAGE = "message"; + private static final String MESSAGE_ALL_TEMPLATE = "Updated {0} records from {1} folders with updated disposition instructions."; + private static final String MESSAGE_FOLDER_TEMPLATE = "Updated records in folder {0} with updated disposition instructions."; + + /** + * services + */ + private NodeService nodeService; + private DispositionService dispositionService; + private RecordService recordService; + private TransactionService transactionService; + private RecordsManagementQueryDAO recordsManagementQueryDAO; + private BehaviourFilter behaviourFilter; + private NodeDAO nodeDAO; + private QNameDAO qnameDAO; + + /** + * service setters + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO) + { + this.recordsManagementQueryDAO = recordsManagementQueryDAO; + } + + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * Build web script model + */ + protected Map buildModel(WebScriptRequest req, WebScriptResponse res) throws IOException + { + Map model = new HashMap<>(); + transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public String execute() throws Throwable + { + qnameDAO.getOrCreateQName(ASPECT_DISPOSITION_PROCESSED); + return null; + } + + }, false, true); + + int maxRecordFolders = getMaxRecordFolders(req); + NodeRef recordFolder = getRecordFolder(req); + + int processedRecords = 0; + String message; + if (recordFolder != null) + { + // Process the specified record folder + updateRecordFolder(recordFolder); + message = MessageFormat.format(MESSAGE_FOLDER_TEMPLATE, recordFolder); + } + else + { + int processedRecordFolders = 0; + int queryBatchSize = 10000; + Long maxNodeId = nodeDAO.getMaxNodeId(); + for (Long i = 0L; i < maxNodeId; i += queryBatchSize) + { + List folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules(i, i + queryBatchSize); + for (NodeRef folder : folders) + { + processedRecords = processedRecords + updateRecordFolder(folder); + processedRecordFolders++; + + if (processedRecordFolders >= maxRecordFolders) + { + // stop processing since we have meet our limit + break; + } + } + + if (processedRecordFolders >= maxRecordFolders) + { + // stop processing since we have meet our limit + break; + } + } + message = MessageFormat.format(MESSAGE_ALL_TEMPLATE, processedRecords, processedRecordFolders); + } + + model.put(MODEL_STATUS, SUCCESS_STATUS); + model.put(MODEL_MESSAGE, message); + logger.info(message); + + return model; + } + + /* + * (non-Javadoc) + * @see org.alfresco.repo.web.scripts.content.StreamContent#execute(org.springframework.extensions.webscripts. + * WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse) + */ + @Override + public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException + { + // retrieve requested format + String format = req.getFormat(); + + try + { + String mimetype = getContainer().getFormatRegistry() + .getMimeType(req.getAgent(), format); + if (mimetype == null) + { + throw new WebScriptException("Web Script format '" + format + "' is not registered"); + } + + // construct model for script / template + Status status = new Status(); + Cache cache = new Cache(getDescription().getRequiredCache()); + + Map model = buildModel(req, res); + + if (model == null) { return; } + model.put("status", status); + model.put("cache", cache); + + Map templateModel = createTemplateParameters(req, res, model); + + // render output + int statusCode = status.getCode(); + if (statusCode != HttpServletResponse.SC_OK && !req.forceSuccessStatus()) + { + if (logger.isDebugEnabled()) + { + logger.debug("Force success status header in response: " + req.forceSuccessStatus()); + logger.debug("Setting status " + statusCode); + } + res.setStatus(statusCode); + } + + // apply location + String location = status.getLocation(); + if (location != null && location.length() > 0) + { + if (logger.isDebugEnabled()) + logger.debug("Setting location to " + location); + res.setHeader(WebScriptResponse.HEADER_LOCATION, location); + } + + // apply cache + res.setCache(cache); + + String callback = null; + if (getContainer().allowCallbacks()) + { + callback = req.getJSONCallback(); + } + if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) + { + if (logger.isDebugEnabled()) + logger.debug( + "Rendering JSON callback response: content type=" + Format.JAVASCRIPT.mimetype() + ", status=" + + statusCode + ", callback=" + callback); + + // NOTE: special case for wrapping JSON results in a javascript function callback + res.setContentType(Format.JAVASCRIPT.mimetype() + ";charset=UTF-8"); + res.getWriter() + .write((callback + "(")); + } + else + { + if (logger.isDebugEnabled()) + logger.debug("Rendering response: content type=" + mimetype + ", status=" + statusCode); + + res.setContentType(mimetype + ";charset=UTF-8"); + } + + // render response according to requested format + renderFormatTemplate(format, templateModel, res.getWriter()); + + if (format.equals(WebScriptResponse.JSON_FORMAT) && callback != null) + { + // NOTE: special case for wrapping JSON results in a javascript function callback + res.getWriter() + .write(")"); + } + } + catch (Throwable e) + { + if (logger.isDebugEnabled()) + { + StringWriter stack = new StringWriter(); + e.printStackTrace(new PrintWriter(stack)); + logger.debug("Caught exception; decorating with appropriate status template : " + stack.toString()); + } + + throw createStatusException(e, req, res); + } + } + + protected void renderFormatTemplate(String format, Map model, Writer writer) + { + format = (format == null) ? "" : format; + + String templatePath = getDescription().getId() + "." + format; + + if (logger.isDebugEnabled()) + logger.debug("Rendering template '" + templatePath + "'"); + + renderTemplate(templatePath, model, writer); + } + + protected int getMaxRecordFolders(WebScriptRequest req) + { + String valueStr = req.getParameter(PARAM_MAX_RECORD_FOLDERS); + int value = Integer.MAX_VALUE; + if (StringUtils.isNotBlank(valueStr)) + { + try + { + value = Integer.parseInt(valueStr); + } + catch (NumberFormatException ex) + { + //do nothing here, the value will remain 0L in this case + } + } + return value; + } + + protected NodeRef getRecordFolder(WebScriptRequest req) + { + String valueStr = req.getParameter(PARAM_RECORD_FOLDER); + NodeRef value = null; + if (StringUtils.isNotBlank(valueStr)) + { + value = new NodeRef(valueStr); + } + + return value; + } + + private int updateRecordFolder(final NodeRef recordFolder) + { + return transactionService.getRetryingTransactionHelper() + .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public Integer execute() throws Throwable + { + int recordCount = 0; + + behaviourFilter.disableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + try + { + if (logger.isDebugEnabled()) + { + logger.info("Checking folder: " + recordFolder); + } + recordCount = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Integer doWork() throws Exception + { + DispositionSchedule schedule = dispositionService.getDispositionSchedule(recordFolder); + int innerRecordCount = 0; + if (schedule != null && schedule.isRecordLevelDisposition()) + { + + List records = recordService.getRecords(recordFolder); + for (NodeRef record : records) + { + if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)) + { + if (recordFolder.equals(nodeService.getPrimaryParent(record).getParentRef())) + { + if (logger.isDebugEnabled()) + { + logger.info("updating record: " + record); + } + + // update record disposition information + dispositionService.updateNextDispositionAction(record, schedule); + innerRecordCount++; + } + } + } + } + return innerRecordCount; + } + }); + nodeService.addAspect(recordFolder, ASPECT_DISPOSITION_PROCESSED, null); + } + finally + { + behaviourFilter.enableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + } + return recordCount; + } + }, false, true); + } +} From 98f04870680618013bc42eda4e738b4f8501d134 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Mon, 25 Nov 2019 08:35:50 +0000 Subject: [PATCH 21/43] Update version.properties --- .../alfresco/module/org_alfresco_module_rm/version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties index 8cce8ad3ce..cf2c7c2600 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/version.properties @@ -1,3 +1,3 @@ # RM Schema number -version.rm.schema=2502 +version.rm.schema=2501 From 18ea7464912705dfa9cb8b478c1c918b56cf69a8 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Tue, 26 Nov 2019 08:50:32 +0200 Subject: [PATCH 22/43] update community dependencies to ones from ACS 6.2.0.ea --- pom.xml | 4 ++-- rm-community/pom.xml | 4 ++-- rm-community/rm-community-repo/Dockerfile | 23 +++++++++++++++++++++-- rm-community/rm-community-repo/pom.xml | 10 +++++----- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index b98b2ad3af..7bc176b4d0 100644 --- a/pom.xml +++ b/pom.xml @@ -531,7 +531,7 @@ alfresco org.alfresco share - 7.8 + 7.9 6.1.0 0.0 @@ -559,7 +559,7 @@ 8080 2.9.9 - 2.9.9.3 + 2.9.10 0.31.0 1.10.19 42.2.6 diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 305784b1cf..029a3b9d72 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -75,8 +75,8 @@ 5.1.8.RELEASE - 6.1.2-ga - 6.1.0 + 6.2.0-ea + 6.2.0-RC4 true diff --git a/rm-community/rm-community-repo/Dockerfile b/rm-community/rm-community-repo/Dockerfile index 37cb97c1bc..6f5ffe3d85 100644 --- a/rm-community/rm-community-repo/Dockerfile +++ b/rm-community/rm-community-repo/Dockerfile @@ -1,4 +1,13 @@ -FROM alfresco/alfresco-content-repository-community:6.1.2-ga +FROM alfresco/alfresco-content-repository-community:6.2.0-ea + +# Default user and group are used to setup permissions for Tomcat process, see parent Dockerfile: Alfresco/acs-community-packaging/docker-alfresco/Dockerfile +ARG GROUPNAME=Alfresco +ARG USERNAME=alfresco +ARG TOMCAT_DIR=/usr/local/tomcat + +# Alfresco user does not have permissions to modify webapps or configuration. Switch to root. +# The access will be fixed after all operations are done. +USER root COPY target/alfresco-governance-services-community-repo-*.amp /usr/local/tomcat/amps/ @@ -10,4 +19,14 @@ COPY target/gs-api-explorer-*.war /usr/local/tomcat/webapps/ ### Unpack gs-api-explorer.war RUN mkdir /usr/local/tomcat/webapps/gs-api-explorer && cd /usr/local/tomcat/webapps/gs-api-explorer && \ - jar -xvf /usr/local/tomcat/webapps/gs-api-explorer-*.war && rm -f /usr/local/tomcat/webapps/gs-api-explorer-*.war \ No newline at end of file + jar -xvf /usr/local/tomcat/webapps/gs-api-explorer-*.war && rm -f /usr/local/tomcat/webapps/gs-api-explorer-*.war + +# All files in the tomcat folder must be owned by root user and Alfresco group as mentioned in the parent Dockerfile +RUN chgrp -R ${GROUPNAME} ${TOMCAT_DIR}/webapps && \ + find ${TOMCAT_DIR}/webapps -type d -exec chmod 0750 {} \; && \ + find ${TOMCAT_DIR}/webapps -type f -exec chmod 0640 {} \; && \ + chmod -R g+r ${TOMCAT_DIR}/webapps && \ + chgrp -R ${GROUPNAME} ${TOMCAT_DIR} + +# Switching back to alfresco user after having added amps files to run the container as non-root +USER alfresco \ No newline at end of file diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 5968476b59..a3df80f420 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -24,11 +24,11 @@ alfresco-platform 9.1-901.jdbc4 alfresco-governance-services-community-repo - - 7.5.1 - 7.33.12 - 7.34.1 - 6.1.0 + + 7.22 + 7.131 + 7.101 + 6.2.0-RC4 alfresco/alfresco-governance-repository-community false From 6b1e06f4aa6684d77ee56841a50896d49c9bf75b Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Tue, 26 Nov 2019 09:11:08 +0200 Subject: [PATCH 23/43] replace the org.apache.commons.lang references to org.apache.commons.lang3 --- .../caveat/RMCaveatConfigComponentImpl.java | 9 ++--- .../caveat/RMListOfValuesConstraint.java | 2 +- .../caveat/ScriptConstraint.java | 2 +- .../action/RMActionExecuterAbstractBase.java | 4 +- .../action/dm/MoveDmRecordAction.java | 2 +- .../action/impl/DestroyAction.java | 2 +- .../action/impl/EditHoldReasonAction.java | 2 +- .../action/impl/FileReportAction.java | 2 +- .../action/impl/RequestInfoAction.java | 2 +- .../action/impl/SplitEmailAction.java | 2 +- .../RecordsManagementAuditServiceImpl.java | 39 ++++++++++--------- .../audit/event/AuditEvent.java | 2 +- .../capability/AbstractCapability.java | 2 +- .../capability/GroupImpl.java | 2 +- .../capability/RMAfterInvocationProvider.java | 2 +- .../capability/RMEntryVoter.java | 2 +- .../dataset/DataSetBase.java | 2 +- .../email/CustomEmailMappingServiceImpl.java | 2 +- .../freeze/FreezeServiceImpl.java | 2 +- .../jscript/app/JSONConversionComponent.java | 2 +- .../model/rma/type/RecordFolderType.java | 2 +- .../RecordsManagementNotificationHelper.java | 2 +- .../record/RecordServiceImpl.java | 4 +- .../record/RecordUtils.java | 2 +- .../RecordableVersionConfigServiceImpl.java | 2 +- .../relationship/RelationshipServiceImpl.java | 2 +- .../generator/DeclarativeReportGenerator.java | 2 +- .../transfer/TransferReportGenerator.java | 2 +- .../role/FilePlanRoleServiceImpl.java | 2 +- .../script/AuditLogPost.java | 2 +- .../script/CustomReferenceDefinitionBase.java | 2 +- .../script/DataSetPost.java | 2 +- .../script/DataSetsGet.java | 2 +- .../script/TransferReportPost.java | 25 ++++++------ .../script/admin/RMEventBase.java | 2 +- .../script/admin/RmEventsPost.java | 2 +- .../script/admin/RmRoleDelete.java | 2 +- .../admin/RoleDeclarativeWebScript.java | 2 +- .../script/capability/CapabilitiesGet.java | 2 +- .../script/hold/HoldsGet.java | 2 +- .../script/slingshot/RMSearchGet.java | 4 +- .../FilePlanPermissionServiceImpl.java | 2 +- .../transfer/TransferServiceImpl.java | 2 +- .../util/RMParameterCheck.java | 2 +- .../version/RecordableVersionServiceImpl.java | 2 +- .../parameter/DateParameterProcessor.java | 2 +- .../parameter/NodeParameterProcessor.java | 2 +- .../impl/ExtendedPermissionServiceImpl.java | 4 +- .../RmDictionaryWebServiceUtils.java | 2 +- .../scripts/roles/AbstractRmAuthorities.java | 2 +- .../scripts/roles/DynamicAuthoritiesGet.java | 5 +-- .../RmSubstitutionSuggestionsGet.java | 2 +- .../api/impl/FilePlanComponentsApiUtils.java | 2 +- .../rm/rest/api/model/UploadInfo.java | 2 +- .../requestInfo/RequestInfoUtils.java | 2 +- .../test/integration/issue/RM1914Test.java | 2 +- .../test/integration/issue/RM4804Test.java | 2 +- .../legacy/action/FileReportActionTest.java | 2 +- .../jscript/JSONConversionComponentTest.java | 2 +- .../legacy/service/ReportServiceImplTest.java | 2 +- .../test/util/CommonRMTestUtils.java | 2 +- ...ExtendedPermissionServiceImplUnitTest.java | 2 +- 62 files changed, 100 insertions(+), 102 deletions(-) diff --git a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java index 079e5944a9..77f07fbbb3 100644 --- a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java +++ b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.caveat; -import static org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace; +import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace; import java.io.File; import java.io.InputStream; @@ -44,6 +44,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import net.sf.acegisecurity.AccessDeniedException; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; @@ -81,8 +82,6 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.json.JSONObject; -import net.sf.acegisecurity.AccessDeniedException; - /** * RM Caveat Config component impl * @@ -1042,7 +1041,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon sb.append("' to the JSONObject 'listMembers' '"); sb.append(listMembers); sb.append("': "); - sb.append(getFullStackTrace(error)); + sb.append(getStackTrace(error)); throw new AlfrescoRuntimeException(sb.toString()); } } @@ -1061,7 +1060,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon sb.append("' to the JSONObject 'configJSONObject' '"); sb.append(configJSONObject); sb.append("': "); - sb.append(getFullStackTrace(error)); + sb.append(getStackTrace(error)); throw new AlfrescoRuntimeException(sb.toString()); } } diff --git a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java index a3e03633d8..6b6392e4cf 100644 --- a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java +++ b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMListOfValuesConstraint.java @@ -39,7 +39,7 @@ import org.alfresco.service.cmr.dictionary.ConstraintException; import org.alfresco.service.cmr.i18n.MessageLookup; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.TypeConversionException; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java index 3e815afe1e..f982d64938 100644 --- a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java +++ b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Set; import org.alfresco.service.cmr.security.AuthorityService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java index 95d5a24161..b95992db39 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.action; -import static org.apache.commons.lang.StringUtils.leftPad; +import static org.apache.commons.lang3.StringUtils.leftPad; import java.io.Serializable; import java.util.HashSet; @@ -683,7 +683,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe * * @return padded string or the original if already at >= len characters * - * @deprecated As of 2.1, replaced by {@link org.apache.commons.lang.StringUtils#leftPad(String, int)} + * @deprecated As of 2.1, replaced by {@link org.apache.commons.lang3.StringUtils#leftPad(String, int)} */ @Deprecated protected String padString(String s, int len) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java index fb65327c18..24a4326005 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/MoveDmRecordAction.java @@ -37,7 +37,7 @@ import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java index c7aee5f05b..1cf101301c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java @@ -43,7 +43,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.version.Version; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Destroy action. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java index 7eb3c05e9d..02661a5865 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditHoldReasonAction.java @@ -31,7 +31,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java index 5b1b0e7539..46ed9fec50 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileReportAction.java @@ -42,7 +42,7 @@ import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java index d78f65f985..35022d36d6 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java @@ -45,7 +45,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.QName; import org.alfresco.workflow.RMWorkflowModel; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java index 5606f27424..a5abd3d9ab 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.action.impl; -import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isBlank; import java.io.IOException; import java.io.InputStream; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 4321ac0c09..f30f93e59b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -33,6 +33,7 @@ import static org.alfresco.model.ContentModel.PROP_USERNAME; import static org.alfresco.module.org_alfresco_module_rm.audit.event.UserGroupMembershipUtils.PARENT_GROUP; import static org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model.TYPE_DOD_5015_SITE; import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME; +import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4; import static org.apache.commons.lang3.StringUtils.isBlank; import java.io.BufferedWriter; @@ -91,8 +92,8 @@ import org.alfresco.util.PropertyCheck; import org.alfresco.util.PropertyMap; import org.alfresco.util.TempFileProvider; import org.alfresco.util.transaction.TransactionListenerAdapter; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; @@ -1343,29 +1344,29 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean writer.write("From:"); writer.write(""); Date from = params.getDateFrom(); - writer.write(from == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(from.toString())); + writer.write(from == null ? "<Not Set>" : escapeHtml4(from.toString())); writer.write(""); writer.write("To:"); writer.write(""); Date to = params.getDateTo(); - writer.write(to == null ? "<Not Set>" : StringEscapeUtils.escapeHtml(to.toString())); + writer.write(to == null ? "<Not Set>" : escapeHtml4(to.toString())); writer.write(""); writer.write("Property:"); writer.write(""); QName prop = params.getProperty(); - writer.write(prop == null ? "All" : StringEscapeUtils.escapeHtml(getPropertyLabel(prop))); + writer.write(prop == null ? "All" : escapeHtml4(getPropertyLabel(prop))); writer.write(""); writer.write("User:"); writer.write(""); - writer.write(params.getUser() == null ? "All" : StringEscapeUtils.escapeHtml(params.getUser())); + writer.write(params.getUser() == null ? "All" : escapeHtml4(params.getUser())); writer.write(""); writer.write("Event:"); writer.write(""); - writer.write(params.getEvent() == null ? "All" : StringEscapeUtils.escapeHtml(getAuditEventLabel(params.getEvent()))); + writer.write(params.getEvent() == null ? "All" : escapeHtml4(getAuditEventLabel(params.getEvent()))); writer.write("\n"); writer.write("\n"); @@ -1407,26 +1408,26 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean writer.write("

"); writer.write("Timestamp:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getTimestamp().toString())); + writer.write(escapeHtml4(entry.getTimestamp().toString())); writer.write(""); writer.write("User:"); writer.write(""); writer.write(entry.getFullName() != null ? - StringEscapeUtils.escapeHtml(entry.getFullName()) : - StringEscapeUtils.escapeHtml(entry.getUserName())); + escapeHtml4(entry.getFullName()) : + escapeHtml4(entry.getUserName())); writer.write(""); if (entry.getUserRole() != null && entry.getUserRole().length() > 0) { writer.write("Role:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getUserRole())); + writer.write(escapeHtml4(entry.getUserRole())); writer.write(""); } if (entry.getEvent() != null && entry.getEvent().length() > 0) { writer.write("Event:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(getAuditEventLabel(entry.getEvent()))); + writer.write(escapeHtml4(getAuditEventLabel(entry.getEvent()))); writer.write("\n"); } writer.write("
\n"); @@ -1435,14 +1436,14 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { writer.write("Identifier:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getIdentifier())); + writer.write(escapeHtml4(entry.getIdentifier())); writer.write(""); } if (entry.getNodeType() != null && entry.getNodeType().length() > 0) { writer.write("Type:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(entry.getNodeType())); + writer.write(escapeHtml4(entry.getNodeType())); writer.write(""); } if (entry.getPath() != null && entry.getPath().length() > 0) @@ -1458,7 +1459,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean writer.write("Location:"); writer.write(""); - writer.write(StringEscapeUtils.escapeHtml(displayPath)); + writer.write(escapeHtml4(displayPath)); writer.write(""); } writer.write("\n"); @@ -1486,17 +1487,17 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean if(DataTypeDefinition.MLTEXT.equals(propDataType)) { - writer.write(values.getFirst() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getFirst()).getDefaultValue())); + writer.write(values.getFirst() == null ? "<none>" : escapeHtml4(convertToMlText((Map) values.getFirst()).getDefaultValue())); writer.write(""); - writer.write(values.getSecond() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getSecond()).getDefaultValue())); + writer.write(values.getSecond() == null ? "<none>" : escapeHtml4(convertToMlText((Map) values.getSecond()).getDefaultValue())); } else { Serializable oldValue = values.getFirst(); - writer.write(oldValue == null ? "<none>" : StringEscapeUtils.escapeHtml(oldValue.toString())); + writer.write(oldValue == null ? "<none>" : escapeHtml4(oldValue.toString())); writer.write(""); Serializable newValue = values.getSecond(); - writer.write(newValue == null ? "<none>" : StringEscapeUtils.escapeHtml(newValue.toString())); + writer.write(newValue == null ? "<none>" : escapeHtml4(newValue.toString())); } writer.write(""); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java index 098e864ff9..89a04a1932 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java @@ -31,7 +31,7 @@ import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java index 06f73edbbc..5fe1fef8a8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java @@ -31,7 +31,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; import net.sf.acegisecurity.vote.AccessDecisionVoter; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java index 9533cfb599..91e0f3e2ab 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/GroupImpl.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.capability; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java index 44d168b8f1..e59a7971b5 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java @@ -64,7 +64,7 @@ import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.PermissionEvaluationMode; import org.alfresco.service.cmr.search.ResultSet; import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java index c0b6b54c5b..1b7e496402 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java @@ -44,7 +44,7 @@ import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelp import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespacePrefixResolver; import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java index 7e3e919c73..1b2de65178 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetBase.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.dataset; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; public class DataSetBase implements DataSet diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java index e025f2c042..b51af05807 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java @@ -53,7 +53,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java index 762e3188fb..dd4a40e6a4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java @@ -53,7 +53,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 1c7c3db3bd..42604e6d0b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -67,7 +67,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.PathUtil; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java index 3d65ed4828..5aa75397f9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java @@ -51,7 +51,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java index 25b2d2266d..4352f5ed82 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java @@ -58,7 +58,7 @@ import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index eeeac2b6fe..9fe8e80959 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -122,8 +122,8 @@ import org.alfresco.util.EqualsHelper; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyMap; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.extensions.surf.util.I18NUtil; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java index c682bdbc52..d542e656f8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java @@ -32,7 +32,7 @@ import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagement import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_ORIGIONAL_NAME; import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName; import static org.alfresco.util.ParameterCheck.mandatory; -import static org.apache.commons.lang.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.Serializable; import java.util.HashMap; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java index 37c207942f..dfcdbe533a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/recordableversion/RecordableVersionConfigServiceImpl.java @@ -30,7 +30,7 @@ package org.alfresco.module.org_alfresco_module_rm.recordableversion; import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy.NONE; import static org.alfresco.util.ParameterCheck.mandatory; import static org.alfresco.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.ArrayList; import java.util.List; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java index 315d8a01d9..538cce9bf1 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/relationship/RelationshipServiceImpl.java @@ -30,7 +30,7 @@ package org.alfresco.module.org_alfresco_module_rm.relationship; import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_FROZEN; import static org.alfresco.util.ParameterCheck.mandatory; import static org.alfresco.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isBlank; import java.util.HashSet; import java.util.List; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java index 2043736369..be7a9d3f86 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/DeclarativeReportGenerator.java @@ -54,7 +54,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.TemplateService; import org.alfresco.service.namespace.QName; import org.alfresco.util.UrlUtil; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java index 8de4d9297c..def3735794 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/report/generator/transfer/TransferReportGenerator.java @@ -43,7 +43,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Transfer report generator. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java index c7515ee39b..7523b3cbce 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java @@ -54,7 +54,7 @@ import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java index 29dc0ea1a6..83fca08bed 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogPost.java @@ -37,7 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServi import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java index 4b6f445b5a..e3ced00b96 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionBase.java @@ -28,7 +28,7 @@ package org.alfresco.module.org_alfresco_module_rm.script; import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; -import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isBlank; import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName; import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java index d8c3533da4..078f8dab8c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetPost.java @@ -35,7 +35,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Cache; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java index 2ee57b7e40..69076bf689 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/DataSetsGet.java @@ -37,7 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java index fe2fc9fdcb..e8c40fb096 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java @@ -27,6 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.script; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -39,8 +40,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletResponse; - import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; @@ -56,7 +55,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.util.TempFileProvider; -import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; @@ -292,7 +291,7 @@ public class TransferReportPost extends BaseTransferWebScript writer.write(""); writer.write(""); writer.write(""); writer.write(""); writer.write("
Transfer Date:"); Date transferDate = (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED); - writer.write(StringEscapeUtils.escapeHtml(transferDate.toString())); + writer.write(StringEscapeUtils.escapeHtml4(transferDate.toString())); writer.write("
Transfer Location:"); if (isAccession) @@ -301,16 +300,16 @@ public class TransferReportPost extends BaseTransferWebScript } else { - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(transferNode, RecordsManagementModel.PROP_TRANSFER_LOCATION))); } writer.write("
Performed By:"); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATOR))); writer.write("
Disposition Authority:"); - writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : ""); + writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml4(dispositionAuthority) : ""); writer.write("
\n"); writer.write("

Transferred Items

\n"); @@ -361,10 +360,10 @@ public class TransferReportPost extends BaseTransferWebScript throws IOException { writer.write(""); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(folderNode, ContentModel.PROP_NAME))); writer.write(" (Unique Folder Identifier: "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER))); writer.write(")\n"); @@ -399,10 +398,10 @@ public class TransferReportPost extends BaseTransferWebScript { writer.write("
\n"); writer.write(" "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(recordNode, ContentModel.PROP_NAME))); writer.write(" (Unique Record Identifier: "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER))); writer.write(")"); @@ -410,10 +409,10 @@ public class TransferReportPost extends BaseTransferWebScript { Date declaredOn = (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT); writer.write(" declared by "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml4((String)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_BY))); writer.write(" on "); - writer.write(StringEscapeUtils.escapeHtml(declaredOn.toString())); + writer.write(StringEscapeUtils.escapeHtml4(declaredOn.toString())); } writer.write("\n
\n"); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java index b8b7fa6335..a810038f3e 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.script.admin; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.springframework.extensions.webscripts.DeclarativeWebScript; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java index b8593872b1..37702b8f50 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java @@ -35,7 +35,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; import org.alfresco.util.GUID; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java index a676a43647..66fd26a8ff 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java @@ -31,7 +31,7 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java index 5088e2d1e2..4f5842c7d0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RoleDeclarativeWebScript.java @@ -39,7 +39,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.WebScriptRequest; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java index 9c0294f14e..86d550619a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java @@ -41,7 +41,7 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.AccessStatus; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java index 9338651dce..dd2b4bf0aa 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldsGet.java @@ -43,7 +43,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.PermissionService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; 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 2a697560fa..bbddba1c7c 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 @@ -53,8 +53,8 @@ import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.extensions.webscripts.Cache; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java index 2d420cc8fc..be49e8bd1f 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java @@ -34,7 +34,7 @@ import static org.alfresco.repo.policy.annotation.BehaviourKind.CLASS; import static org.alfresco.repo.security.authentication.AuthenticationUtil.getSystemUserName; import static org.alfresco.service.cmr.security.OwnableService.NO_OWNER; import static org.alfresco.util.ParameterCheck.mandatory; -import static org.apache.commons.lang.BooleanUtils.isTrue; +import static org.apache.commons.lang3.BooleanUtils.isTrue; import java.io.Serializable; import java.util.HashMap; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java index 35191df6e9..b361619e08 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java @@ -55,7 +55,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; import org.springframework.extensions.surf.util.ParameterCheck; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMParameterCheck.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMParameterCheck.java index bd3d5c4385..1601879179 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMParameterCheck.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMParameterCheck.java @@ -27,7 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.util; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Utility class that contains validation not present in {@link org.alfresco.util.ParameterCheck}. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java index fd6f643b87..270e9d6544 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/version/RecordableVersionServiceImpl.java @@ -64,7 +64,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyMap; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java index 49d7768fb6..12c4e5419c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/DateParameterProcessor.java @@ -34,7 +34,7 @@ import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Date parameter processor. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java index a68b2eee74..8049cd1e17 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/action/parameter/NodeParameterProcessor.java @@ -45,7 +45,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; /** * Node parameter processor. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java index 2e4a966d35..625e5b3ac8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImpl.java @@ -27,7 +27,7 @@ package org.alfresco.repo.security.permissions.impl; -import static org.apache.commons.lang.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.Serializable; import java.util.Arrays; @@ -57,7 +57,7 @@ import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.util.Pair; import org.alfresco.util.PropertyCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.context.ApplicationEvent; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java index 69bd27b9fb..1916fbf0c2 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/dictionary/RmDictionaryWebServiceUtils.java @@ -29,7 +29,7 @@ package org.alfresco.repo.web.scripts.dictionary; import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java index 6db2310545..9da2caa91f 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/AbstractRmAuthorities.java @@ -31,7 +31,7 @@ import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.script.admin.RoleDeclarativeWebScript; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java index f74cacae1e..158bdde85b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java @@ -44,6 +44,7 @@ */ package org.alfresco.repo.web.scripts.roles; +import javax.servlet.http.HttpServletResponse; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -58,8 +59,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.servlet.http.HttpServletResponse; - import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority; @@ -79,7 +78,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.Pair; import org.alfresco.util.TempFileProvider; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.AbstractWebScript; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java index d25c901888..02bc549cf5 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java @@ -44,7 +44,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java index 472d079ef8..b57a63be19 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java @@ -100,7 +100,7 @@ import org.alfresco.service.cmr.usage.ContentQuotaException; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java index c42cdece4e..c5e2209509 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java @@ -31,7 +31,7 @@ import java.util.Map; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.surf.util.Content; import org.springframework.extensions.webscripts.servlet.FormData; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java index 4e9e794a79..d8f2d3c7d7 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java @@ -42,7 +42,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.util.ParameterCheck; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Util class for the request info workflow diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java index c3b966bea5..f0b7ad097e 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java @@ -42,7 +42,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; /** diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java index 49182c6568..e02e35d8ae 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java @@ -43,7 +43,7 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.GUID; diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java index db8d68c447..9ff9f1e835 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/action/FileReportActionTest.java @@ -33,7 +33,7 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.extensions.webscripts.GUID; /** diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java index 496efdb032..057e996557 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java @@ -32,7 +32,7 @@ import java.io.Serializable; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.repo.jscript.app.JSONConversionComponent; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.json.JSONException; import org.json.JSONObject; diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java index f11cee7467..a8c70e4662 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/ReportServiceImplTest.java @@ -46,7 +46,7 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * Report service implementation unit test. diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java index 692ac87edc..84f95f1718 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java @@ -65,7 +65,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.context.ApplicationContext; /** diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java index a10a6637cc..f6e229df89 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/repo/security/permissions/impl/ExtendedPermissionServiceImplUnitTest.java @@ -50,7 +50,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.util.Pair; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; From f9e165446732566a8d75ee918004c14c0e84463b Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Tue, 26 Nov 2019 09:27:49 +0200 Subject: [PATCH 24/43] update the docker dependencies on community to ACS 6.2.0.ea --- rm-community/rm-community-repo/.env | 9 ++- .../rm-community-repo/docker-compose.yml | 57 ++++++++++++++++++- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/rm-community/rm-community-repo/.env b/rm-community/rm-community-repo/.env index 909bd225ba..ddacb71a60 100644 --- a/rm-community/rm-community-repo/.env +++ b/rm-community/rm-community-repo/.env @@ -1,3 +1,6 @@ -SOLR6_TAG=1.1.1 -POSTGRES_TAG=10.1 -ACTIVEMQ_TAG=5.15.6 \ No newline at end of file +TRANSFORMERS_TAG=2.1.0-RC3 +SOLR6_TAG=1.3.0.1 +POSTGRES_TAG=11.4 +ACTIVEMQ_TAG=5.15.8 +LEGACY_TRANSFORM_SERVICE_ENABLED=true +LOCAL_TRANSFORM_SERVICE_ENABLED=true \ No newline at end of file diff --git a/rm-community/rm-community-repo/docker-compose.yml b/rm-community/rm-community-repo/docker-compose.yml index 44fffaf8a5..43b57b2e33 100644 --- a/rm-community/rm-community-repo/docker-compose.yml +++ b/rm-community/rm-community-repo/docker-compose.yml @@ -28,15 +28,68 @@ services: -Dshare.host=localhost -Daos.baseUrlOverwrite=http://localhost:8080/alfresco/aos -Dmessaging.broker.url=\"failover:(tcp://activemq:61616)?timeout=3000&jms.useCompression=true\" + + -Dlocal.transform.service.enabled=${LOCAL_TRANSFORM_SERVICE_ENABLED} + -DlocalTransform.pdfrenderer.url=http://alfresco-pdf-renderer:8090/ + -DlocalTransform.imagemagick.url=http://imagemagick:8090/ + -DlocalTransform.libreoffice.url=http://libreoffice:8090/ + -DlocalTransform.tika.url=http://tika:8090/ + -DlocalTransform.misc.url=http://transform-misc:8090/ + + -Dlegacy.transform.service.enabled=${LEGACY_TRANSFORM_SERVICE_ENABLED} + -Dalfresco-pdf-renderer.url=http://alfresco-pdf-renderer:8090/ + -Djodconverter.url=http://libreoffice:8090/ + -Dimg.url=http://imagemagick:8090/ + -Dtika.url=http://tika:8090/ + -Dtransform.misc.url=http://transform-misc:8090/ + + -Dimap.server.port=1143 + -Dftp.port=1221 + -Dcors.enabled=true + -Dcors.allowed.origins=http://localhost:4200 " ports: - 8080:8080 - 8000:8000 - - 445:445 - - 143:143 + - 143:1143 - "21:21" - "30000-30099:30000-30099" + alfresco-pdf-renderer: + image: alfresco/alfresco-pdf-renderer:${TRANSFORMERS_TAG} + environment: + JAVA_OPTS: " -Xms256m -Xmx256m" + ports: + - 8090:8090 + + imagemagick: + image: alfresco/alfresco-imagemagick:${TRANSFORMERS_TAG} + environment: + JAVA_OPTS: " -Xms256m -Xmx256m" + ports: + - 8091:8090 + + libreoffice: + image: alfresco/alfresco-libreoffice:${TRANSFORMERS_TAG} + environment: + JAVA_OPTS: " -Xms256m -Xmx256m" + ports: + - 8092:8090 + + tika: + image: alfresco/alfresco-tika:${TRANSFORMERS_TAG} + environment: + JAVA_OPTS: " -Xms256m -Xmx256m" + ports: + - 8093:8090 + + transform-misc: + image: alfresco/alfresco-transform-misc:${TRANSFORMERS_TAG} + environment: + JAVA_OPTS: " -Xms256m -Xmx256m" + ports: + - 8094:8090 + postgres: image: library/postgres:${POSTGRES_TAG} environment: From d449052a951631d65f39f584cc3ef53045d4ff23 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Tue, 26 Nov 2019 10:18:29 +0200 Subject: [PATCH 25/43] replace the ARGs parameter from Dockerfile --- rm-community/rm-community-repo/Dockerfile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/rm-community/rm-community-repo/Dockerfile b/rm-community/rm-community-repo/Dockerfile index 6f5ffe3d85..b3ae58d66f 100644 --- a/rm-community/rm-community-repo/Dockerfile +++ b/rm-community/rm-community-repo/Dockerfile @@ -1,10 +1,6 @@ +### Apply AGS community repo AMP to ACS image FROM alfresco/alfresco-content-repository-community:6.2.0-ea -# Default user and group are used to setup permissions for Tomcat process, see parent Dockerfile: Alfresco/acs-community-packaging/docker-alfresco/Dockerfile -ARG GROUPNAME=Alfresco -ARG USERNAME=alfresco -ARG TOMCAT_DIR=/usr/local/tomcat - # Alfresco user does not have permissions to modify webapps or configuration. Switch to root. # The access will be fixed after all operations are done. USER root @@ -22,11 +18,11 @@ RUN mkdir /usr/local/tomcat/webapps/gs-api-explorer && cd /usr/local/tomcat/weba jar -xvf /usr/local/tomcat/webapps/gs-api-explorer-*.war && rm -f /usr/local/tomcat/webapps/gs-api-explorer-*.war # All files in the tomcat folder must be owned by root user and Alfresco group as mentioned in the parent Dockerfile -RUN chgrp -R ${GROUPNAME} ${TOMCAT_DIR}/webapps && \ - find ${TOMCAT_DIR}/webapps -type d -exec chmod 0750 {} \; && \ - find ${TOMCAT_DIR}/webapps -type f -exec chmod 0640 {} \; && \ - chmod -R g+r ${TOMCAT_DIR}/webapps && \ - chgrp -R ${GROUPNAME} ${TOMCAT_DIR} +RUN chgrp -R Alfresco /usr/local/tomcat/webapps && \ + find /usr/local/tomcat/webapps -type d -exec chmod 0750 {} \; && \ + find /usr/local/tomcat/webapps -type f -exec chmod 0640 {} \; && \ + chmod -R g+r /usr/local/tomcat/webapps && \ + chgrp -R Alfresco /usr/local/tomcat # Switching back to alfresco user after having added amps files to run the container as non-root USER alfresco \ No newline at end of file From 7ca293d8158087428a04501e9bc2ebfc9189a4aa Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Tue, 26 Nov 2019 16:05:47 +0200 Subject: [PATCH 26/43] update min version ACS version for the text context --- .../test/resources/alfresco/version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/test/resources/alfresco/version.properties b/rm-community/rm-community-repo/test/resources/alfresco/version.properties index 6f6c5e6e79..2046c8d69a 100644 --- a/rm-community/rm-community-repo/test/resources/alfresco/version.properties +++ b/rm-community/rm-community-repo/test/resources/alfresco/version.properties @@ -4,7 +4,7 @@ # Version label version.major=6 -version.minor=1 +version.minor=2 version.revision=0 version.label= From 2b7541b501e394f2a6ba9b99464fbba676dadbde Mon Sep 17 00:00:00 2001 From: Roxana Lucanu Date: Tue, 26 Nov 2019 21:57:35 +0200 Subject: [PATCH 27/43] RM-7060 Reapply search aspect when filing/moving --- .../RecordsManagementSearchBehaviour.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 9ba27e2447..d7963c18c3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -49,9 +49,12 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourKind; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.transaction.TransactionalResourceHelper; @@ -73,7 +76,8 @@ import org.apache.commons.logging.LogFactory; * @author Roy Wetherall * @since 1.0 */ -public class RecordsManagementSearchBehaviour implements RecordsManagementModel +public class RecordsManagementSearchBehaviour implements RecordsManagementModel, + NodeServicePolicies.OnMoveNodePolicy { /** logger */ private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class); @@ -172,6 +176,9 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT); + /** on move record or record folder behavior */ + private JavaBehaviour jbMoveNode = new JavaBehaviour(this, "onMoveNode", NotificationFrequency.TRANSACTION_COMMIT); + /** Array of behaviours related to disposition schedule artifacts */ private JavaBehaviour[] jbDispositionBehaviours = { @@ -243,6 +250,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ASPECT_VITAL_RECORD_DEFINITION, new JavaBehaviour(this, "vitalRecordDefintionUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT)); + + this.policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), + ASPECT_FILE_PLAN_COMPONENT, + jbMoveNode); } /** @@ -907,4 +919,37 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel return results; } + + /** + * Record and record folder move behavior + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) + public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) + { + // check the parent has actually changed + if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef())) + { + final NodeRef recordOrFolder = newChildAssocRef.getChildRef(); + final boolean isRecordOrFolder = recordService.isRecord(recordOrFolder) || recordFolderService.isRecordFolder(recordOrFolder); + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + @Override + public Void doWork() + { + if (nodeService.exists(recordOrFolder) && isRecordOrFolder) + { + applySearchAspect(recordOrFolder); + } + return null; + } + }); + } + } } From 23300d09cded8fcab64ebdd340818b7bdd53f012 Mon Sep 17 00:00:00 2001 From: Roxana Lucanu Date: Wed, 27 Nov 2019 11:28:32 +0200 Subject: [PATCH 28/43] RM-7060 Fix integration tests --- .../test/integration/record/MoveRecordTest.java | 2 +- .../test/integration/recordfolder/MoveRecordFolderTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java index 727af89284..6df3aaaea1 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveRecordTest.java @@ -120,7 +120,7 @@ public class MoveRecordTest extends BaseRMTestCase assertNull(dispositionService.getNextDispositionAction(record)); // check the search aspect properties - assertFalse(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); + assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH)); } }); diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java index e8b26622ea..81f5d08633 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java @@ -218,7 +218,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase assertNull(dispositionService.getNextDispositionAction(recordFolder)); // check the search aspect properties - assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); + assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH)); } }); } From 947b62d4a6aba48bba05c6d0f92bd8a6f3010aef Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 27 Nov 2019 15:23:28 +0200 Subject: [PATCH 29/43] changes for ACS 6.2.0.ga --- pom.xml | 2 +- rm-community/pom.xml | 4 ++-- rm-community/rm-community-repo/.env | 4 ++-- rm-community/rm-community-repo/Dockerfile | 2 +- rm-community/rm-community-repo/docker-compose.yml | 2 ++ rm-community/rm-community-repo/pom.xml | 8 ++++---- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 7bc176b4d0..dac2e7c47b 100644 --- a/pom.xml +++ b/pom.xml @@ -532,7 +532,7 @@ org.alfresco share 7.9 - 6.1.0 + 6.2.0 0.0 diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 029a3b9d72..05f7fbd645 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -75,8 +75,8 @@ 5.1.8.RELEASE - 6.2.0-ea - 6.2.0-RC4 + 6.2.0-ga + 6.2.0 true diff --git a/rm-community/rm-community-repo/.env b/rm-community/rm-community-repo/.env index ddacb71a60..06ce42f8df 100644 --- a/rm-community/rm-community-repo/.env +++ b/rm-community/rm-community-repo/.env @@ -1,5 +1,5 @@ -TRANSFORMERS_TAG=2.1.0-RC3 -SOLR6_TAG=1.3.0.1 +TRANSFORMERS_TAG=2.1.0 +SOLR6_TAG=1.4.0 POSTGRES_TAG=11.4 ACTIVEMQ_TAG=5.15.8 LEGACY_TRANSFORM_SERVICE_ENABLED=true diff --git a/rm-community/rm-community-repo/Dockerfile b/rm-community/rm-community-repo/Dockerfile index b3ae58d66f..da6cc9da4c 100644 --- a/rm-community/rm-community-repo/Dockerfile +++ b/rm-community/rm-community-repo/Dockerfile @@ -1,5 +1,5 @@ ### Apply AGS community repo AMP to ACS image -FROM alfresco/alfresco-content-repository-community:6.2.0-ea +FROM alfresco/alfresco-content-repository-community:6.2.0-ga # Alfresco user does not have permissions to modify webapps or configuration. Switch to root. # The access will be fixed after all operations are done. diff --git a/rm-community/rm-community-repo/docker-compose.yml b/rm-community/rm-community-repo/docker-compose.yml index 43b57b2e33..2447b4d396 100644 --- a/rm-community/rm-community-repo/docker-compose.yml +++ b/rm-community/rm-community-repo/docker-compose.yml @@ -110,6 +110,8 @@ services: - SOLR_SOLR_PORT=8983 #Create the default alfresco and archive cores - SOLR_CREATE_ALFRESCO_DEFAULTS=alfresco,archive + #HTTP by default + - ALFRESCO_SECURE_COMMS=none ports: - 8083:8983 #Browser port diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index a3df80f420..518d1b549e 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -24,11 +24,11 @@ alfresco-platform 9.1-901.jdbc4 alfresco-governance-services-community-repo - + 7.22 - 7.131 - 7.101 - 6.2.0-RC4 + 7.134.1 + 7.107.1 + 6.2.0 alfresco/alfresco-governance-repository-community false From 5ef599bdca7bf27586d8185ede3195ef8f1b47b7 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 28 Nov 2019 01:09:21 +0000 Subject: [PATCH 30/43] RM-7064 check permissions for delete node --- .../hold/HoldServiceImpl.java | 33 ++++++++++++------- .../hold/HoldServiceImplUnitTest.java | 16 +++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java index 258d3124b6..b684d55ae3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java @@ -43,7 +43,6 @@ import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; -import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; @@ -241,6 +240,8 @@ public class HoldServiceImpl extends ServiceBaseImpl { if (nodeService.exists(hold) && isHold(hold)) { + checkPermissionsForDeleteHold(hold); + RunAsWork work = new RunAsWork() { @Override @@ -531,6 +532,26 @@ public class HoldServiceImpl extends ServiceBaseImpl throw new AlfrescoRuntimeException("Can't delete hold, because passed node is not a hold. (hold=" + hold.toString() + ")"); } + checkPermissionsForDeleteHold(hold); + + invokeBeforeDeleteHold(hold); + + String holdName = (String) nodeService.getProperty(hold, PROP_NAME); + Set classQNames = getTypeAndApsects(hold); + + // delete the hold node + nodeService.deleteNode(hold); + + invokeOnDeleteHold(holdName, classQNames); + } + + /** + * Helper method to check if user has correct permissions to delete hold + * + * @param hold hold to be deleted + */ + private void checkPermissionsForDeleteHold(NodeRef hold) + { List held = AuthenticationUtil.runAsSystem(new RunAsWork>() { @Override @@ -579,16 +600,6 @@ public class HoldServiceImpl extends ServiceBaseImpl } throw new AccessDeniedException(I18NUtil.getMessage(MSG_ERR_HOLD_PERMISSION_DETAILED_ERROR) + sb.toString()); } - - invokeBeforeDeleteHold(hold); - - String holdName = (String) nodeService.getProperty(hold, PROP_NAME); - Set classQNames = getTypeAndApsects(hold); - - // delete the hold node - nodeService.deleteNode(hold); - - invokeOnDeleteHold(holdName, classQNames); } /** diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java index d070548983..bdfdd33c95 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java @@ -88,6 +88,7 @@ public class HoldServiceImplUnitTest extends BaseUnitTest private static final String HOLD_NAME = "holdname"; private static final String HOLD_REASON = "holdreason"; private static final String HOLD_DESCRIPTION = "holddescription"; + private static final String GENERIC_ERROR_MSG = "any error message text"; protected NodeRef holdContainer; protected NodeRef hold; @@ -319,6 +320,21 @@ public class HoldServiceImplUnitTest extends BaseUnitTest // TODO check interactions with policy component!!! } + @Test (expected = AlfrescoRuntimeException.class) + public void deleteHoldNoPermissionsOnContent() + { + mockPoliciesForDeleteHold(); + + ChildAssociationRef childAssociationRef = generateChildAssociationRef(hold, record); + when(mockedNodeService.getChildAssocs(hold, ASSOC_FROZEN_CONTENT, RegexQNamePattern.MATCH_ALL)) + .thenReturn(Collections.singletonList(childAssociationRef)); + + when(mockedPermissionService.hasPermission(record, RMPermissionModel.FILING)).thenReturn(AccessStatus.DENIED); + when(mockedNodeService.getProperty(record, ContentModel.PROP_NAME)).thenThrow(new AccessDeniedException(GENERIC_ERROR_MSG)); + + holdService.beforeDeleteNode(hold); + } + @Test (expected = IntegrityException.class) public void addToHoldNotAHold() { From 2af88d968316ededa7d6f8d9fd9684bf3680fe1b Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 28 Nov 2019 16:15:52 +0200 Subject: [PATCH 31/43] fix testFillingPermissionOnSourceAndTarget --- .../security/rm-method-security.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties index 1cc4f3e5c2..8c9bd9a7e8 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties @@ -38,7 +38,7 @@ rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildByName rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildrenByName=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPrimaryParent=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createAssociation=RM.Assoc.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=Assoc.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=RM.Assoc.0.1 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getTargetAssocs=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getSourceAssocs=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAssoc=RM.Read.0 From 9576d34f50d6bc82bc271407fd254dd1a5f755f2 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 28 Nov 2019 17:07:20 +0000 Subject: [PATCH 32/43] RM-7068 updates from review --- .../org_alfresco_module_rm/hold/HoldServiceImpl.java | 9 +-------- .../hold/HoldServiceImplUnitTest.java | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java index b684d55ae3..7187d9b894 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java @@ -552,14 +552,7 @@ public class HoldServiceImpl extends ServiceBaseImpl */ private void checkPermissionsForDeleteHold(NodeRef hold) { - List held = AuthenticationUtil.runAsSystem(new RunAsWork>() - { - @Override - public List doWork() - { - return getHeld(hold); - } - }); + List held = AuthenticationUtil.runAsSystem(() -> getHeld(hold)); List heldNames = new ArrayList<>(); for (NodeRef nodeRef : held) diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java index bdfdd33c95..3ec15d149d 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java @@ -320,7 +320,7 @@ public class HoldServiceImplUnitTest extends BaseUnitTest // TODO check interactions with policy component!!! } - @Test (expected = AlfrescoRuntimeException.class) + @Test (expected = AccessDeniedException.class) public void deleteHoldNoPermissionsOnContent() { mockPoliciesForDeleteHold(); From ddd9c5f360760332b0d3f4245346d6e49e70cee7 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Mon, 2 Dec 2019 10:50:35 +0200 Subject: [PATCH 33/43] remove the content property as ContentPropertyRestrictionInterceptor will not allow update of content via nodeService.addProperties --- .../integration/version/DeclareAsRecordVersionTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java index ef4fa3658c..f561c6a980 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java @@ -36,6 +36,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; import org.alfresco.repo.version.VersionModel; +import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.VersionType; @@ -82,6 +83,10 @@ public class DeclareAsRecordVersionTest extends RecordableVersionsBaseTest versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); + //remove the content property as ContentPropertyRestrictionInterceptor will not allow update of + // content property via NodeService.addProperties + nodeService.removeProperty(dmDocument, ContentModel.PROP_CONTENT); + // create version versionService.createVersion(dmDocument, versionProperties); @@ -184,7 +189,9 @@ public class DeclareAsRecordVersionTest extends RecordableVersionsBaseTest versionProperties = new HashMap<>(2); versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION); versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - + //remove the content property as ContentPropertyRestrictionInterceptor will not allow update of + // content property via NodeService.addProperties + nodeService.removeProperty(customDocument, PROP_CONTENT); // create version versionService.createVersion(customDocument, versionProperties); From 6f3bf7adb9a351e4c9a28d4051d9b72f600e0600 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Mon, 2 Dec 2019 15:52:31 +0200 Subject: [PATCH 34/43] changes to address code review comments --- rm-community/rm-community-repo/Dockerfile | 5 ++--- rm-community/rm-community-repo/docker-compose.yml | 11 ++++------- .../version/DeclareAsRecordVersionTest.java | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/rm-community/rm-community-repo/Dockerfile b/rm-community/rm-community-repo/Dockerfile index da6cc9da4c..3baa1cdb53 100644 --- a/rm-community/rm-community-repo/Dockerfile +++ b/rm-community/rm-community-repo/Dockerfile @@ -18,11 +18,10 @@ RUN mkdir /usr/local/tomcat/webapps/gs-api-explorer && cd /usr/local/tomcat/weba jar -xvf /usr/local/tomcat/webapps/gs-api-explorer-*.war && rm -f /usr/local/tomcat/webapps/gs-api-explorer-*.war # All files in the tomcat folder must be owned by root user and Alfresco group as mentioned in the parent Dockerfile -RUN chgrp -R Alfresco /usr/local/tomcat/webapps && \ +RUN chgrp -R Alfresco /usr/local/tomcat && \ find /usr/local/tomcat/webapps -type d -exec chmod 0750 {} \; && \ find /usr/local/tomcat/webapps -type f -exec chmod 0640 {} \; && \ - chmod -R g+r /usr/local/tomcat/webapps && \ - chgrp -R Alfresco /usr/local/tomcat + chmod -R g+r /usr/local/tomcat/webapps # Switching back to alfresco user after having added amps files to run the container as non-root USER alfresco \ No newline at end of file diff --git a/rm-community/rm-community-repo/docker-compose.yml b/rm-community/rm-community-repo/docker-compose.yml index 2447b4d396..b238557bbc 100644 --- a/rm-community/rm-community-repo/docker-compose.yml +++ b/rm-community/rm-community-repo/docker-compose.yml @@ -22,7 +22,9 @@ services: -Dindex.subsystem.name=solr6 -Dalfresco.restApi.basicAuthScheme=true -Dimap.server.enabled=true + -Dimap.server.port=1143 -Dftp.enabled=true + -Dftp.port=1221 -Dftp.dataPortFrom=30000 -Dftp.dataPortTo=30099 -Dshare.host=localhost @@ -42,17 +44,12 @@ services: -Dimg.url=http://imagemagick:8090/ -Dtika.url=http://tika:8090/ -Dtransform.misc.url=http://transform-misc:8090/ - - -Dimap.server.port=1143 - -Dftp.port=1221 - -Dcors.enabled=true - -Dcors.allowed.origins=http://localhost:4200 " ports: - 8080:8080 - 8000:8000 - - 143:1143 - - "21:21" + - 1143:1143 + - "21:1221" - "30000-30099:30000-30099" alfresco-pdf-renderer: diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java index f561c6a980..b3d30d73eb 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/version/DeclareAsRecordVersionTest.java @@ -36,7 +36,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService; import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionServiceImpl; import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.VersionType; From 47670b03e00e1929ae1a453af9b42081bec204c1 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Tue, 3 Dec 2019 06:15:03 +0000 Subject: [PATCH 35/43] RM-7064 Fix unit tests after review updates --- .../hold/HoldServiceImpl.java | 2 - .../hold/HoldServiceImplUnitTest.java | 44 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java index 7187d9b894..f59072cc20 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java @@ -532,8 +532,6 @@ public class HoldServiceImpl extends ServiceBaseImpl throw new AlfrescoRuntimeException("Can't delete hold, because passed node is not a hold. (hold=" + hold.toString() + ")"); } - checkPermissionsForDeleteHold(hold); - invokeBeforeDeleteHold(hold); String holdName = (String) nodeService.getProperty(hold, PROP_NAME); diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java index 3ec15d149d..ddf8d9be9e 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java @@ -593,51 +593,53 @@ public class HoldServiceImplUnitTest extends BaseUnitTest } /** - * test delete hold throws exception for failed read permission check for content + * test before delete node throws exception for failed read permission check for content */ @Test (expected = AccessDeniedException.class) - public void testDeleteHoldThrowsExceptionForActiveContentWithoutReadPermission() + public void testBeforeDeleteNodeThrowsExceptionForActiveContentWithoutReadPermission() { NodeRef heldContent = generateNodeRef(TYPE_CONTENT); - List holds = createListOfHoldAssociations(heldContent); + mockPoliciesForExistingHoldWithHeldItems(hold, heldContent); - when(mockedNodeService.getChildAssocs(hold, ASSOC_FROZEN_CONTENT, RegexQNamePattern.MATCH_ALL)).thenReturn(holds); + // mocks for held content + when(mockedRecordService.isRecord(heldContent)).thenReturn(false); + when(mockedRecordFolderService.isRecordFolder(heldContent)).thenReturn(false); when(mockedPermissionService.hasPermission(heldContent, PermissionService.READ)).thenReturn(AccessStatus.DENIED); when(mockedNodeService.getProperty(heldContent, ContentModel.PROP_NAME)).thenReturn("foo"); - holdService.deleteHold(hold); + holdService.beforeDeleteNode(hold); } /** - * test delete hold throws exception for failed read permission check for records + * test before delete node throws exception for failed read permission check for records */ @Test (expected = AccessDeniedException.class) - public void testDeleteHoldThrowsExceptionForARecordWithoutReadPermission() + public void testBeforeDeleteNodeThrowsExceptionForARecordWithoutReadPermission() { NodeRef heldContent = generateNodeRef(); - List holds = createListOfHoldAssociations(heldContent); + mockPoliciesForExistingHoldWithHeldItems(hold, heldContent); - when(mockedNodeService.getChildAssocs(hold, ASSOC_FROZEN_CONTENT, RegexQNamePattern.MATCH_ALL)).thenReturn(holds); when(mockedRecordService.isRecord(heldContent)).thenThrow(new AccessDeniedException("")); - holdService.deleteHold(hold); + holdService.beforeDeleteNode(hold); } /** - * test delete hold throws exception for failed file permission check for records + * test before delete node throws exception for failed file permission check for records */ @Test (expected = AccessDeniedException.class) - public void testDeleteHoldThrowsExceptionForARecordWithoutFilePermission() + public void testBeforeDeleteNodeThrowsExceptionForARecordWithoutFilePermission() { NodeRef heldContent = generateNodeRef(); - List holds = createListOfHoldAssociations(heldContent); - when(mockedNodeService.getChildAssocs(hold, ASSOC_FROZEN_CONTENT, RegexQNamePattern.MATCH_ALL)).thenReturn(holds); + mockPoliciesForExistingHoldWithHeldItems(hold, heldContent); + + // mocks for held record when(mockedRecordService.isRecord(heldContent)).thenReturn(true); when(mockedPermissionService.hasPermission(heldContent, RMPermissionModel.FILING)).thenReturn(AccessStatus.DENIED); when(mockedNodeService.getProperty(heldContent, ContentModel.PROP_NAME)).thenReturn("foo"); - holdService.deleteHold(hold); + holdService.beforeDeleteNode(hold); } /** @@ -671,6 +673,18 @@ public class HoldServiceImplUnitTest extends BaseUnitTest return holds; } + /** + * mocks for existing hold with held items + */ + private void mockPoliciesForExistingHoldWithHeldItems(NodeRef hold, NodeRef heldContent) + { + when(mockedNodeService.exists(hold)).thenReturn(true); + when(holdService.isHold(hold)).thenReturn(true); + + List holds = createListOfHoldAssociations(heldContent); + when(mockedNodeService.getChildAssocs(hold, ASSOC_FROZEN_CONTENT, RegexQNamePattern.MATCH_ALL)).thenReturn(holds); + } + /** * mocks policies for create hold */ From 4de8b50e4df8eec287abe373b4f40b8052c00b37 Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Wed, 4 Dec 2019 14:01:54 +0000 Subject: [PATCH 36/43] RM-7051 updating code to deal with held content after 3.2 change --- .../rm-webscript-context.xml | 2 ++ .../schedule/UpdateRecordScheduleGet.java | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) 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 0f854c64ee..afdcdee66d 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 @@ -694,6 +694,8 @@ + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index ee5c16207e..40bcbac32e 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -59,6 +59,8 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour; +import org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.FrozenAspect; import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.repo.domain.node.NodeDAO; @@ -115,7 +117,8 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record private BehaviourFilter behaviourFilter; private NodeDAO nodeDAO; private QNameDAO qnameDAO; - + private FrozenAspect frozenAspect; + private RecordsManagementSearchBehaviour recordsManagementSearchBehaviour; /** * service setters */ @@ -159,6 +162,16 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record this.qnameDAO = qnameDAO; } + public void setFrozenAspect(FrozenAspect frozenAspect) + { + this.frozenAspect = frozenAspect; + } + + public void setRecordsManagementSearchBehaviour(RecordsManagementSearchBehaviour recordsManagementSearchBehaviour) + { + this.recordsManagementSearchBehaviour = recordsManagementSearchBehaviour; + } + /** * Build web script model */ @@ -377,8 +390,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record public Integer execute() throws Throwable { int recordCount = 0; - - behaviourFilter.disableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + frozenAspect.disableOnPropUpdateFrozenAspect(); try { if (logger.isDebugEnabled()) @@ -409,6 +421,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record // update record disposition information dispositionService.updateNextDispositionAction(record, schedule); + recordsManagementSearchBehaviour.onAddDispositionLifecycleAspect(record,null); innerRecordCount++; } } @@ -421,7 +434,7 @@ public class UpdateRecordScheduleGet extends AbstractWebScript implements Record } finally { - behaviourFilter.enableBehaviour(ASPECT_FILE_PLAN_COMPONENT); + frozenAspect.enableOnPropUpdateFrozenAspect(); } return recordCount; } From 4fd3f7356eb575d8bbd7ea698795ee7c2a9b949f Mon Sep 17 00:00:00 2001 From: Ramona Popa Date: Thu, 5 Dec 2019 07:34:25 +0000 Subject: [PATCH 37/43] RM-7069: Display of the location is not consistent in all audit reports - made display of location and timestamp consistent --- .../audit/RecordsManagementAuditServiceImpl.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/audit/RecordsManagementAuditServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 770d05d3b1..2fb0ec62ac 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -137,6 +137,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean protected static final String RM_AUDIT_SNIPPET_CHANGES = "/changes"; protected static final String RM_AUDIT_SNIPPET_BEFORE = "/before"; protected static final String RM_AUDIT_SNIPPET_AFTER = "/after"; + protected static final String RM_AUDIT_DOCUMENT_LIBRARY_PATH = "/documentLibrary"; protected static final String RM_AUDIT_DATA_PERSON_FULLNAME = "/RM/event/person/fullName"; protected static final String RM_AUDIT_DATA_PERSON_ROLES = "/RM/event/person/roles"; @@ -1461,11 +1462,15 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { // we need to strip off the first part of the path String path = entry.getPath(); - String displayPath = path; - int idx = path.indexOf('/', 1); + String displayPath; + int idx = path.indexOf(RM_AUDIT_DOCUMENT_LIBRARY_PATH); if (idx != -1) { - displayPath = "/File Plan" + path.substring(idx); + displayPath = path.substring(idx + RM_AUDIT_DOCUMENT_LIBRARY_PATH.length()); + } + else + { + displayPath = path; } writer.write("Location:"); From 0a27d49a7d6fcd06ad2fc51c730bd327c18be05a Mon Sep 17 00:00:00 2001 From: Ramona Popa Date: Thu, 5 Dec 2019 13:07:21 +0000 Subject: [PATCH 38/43] RM-7092: Broken link for Add to / Remove from user group events - removed link in audit list for user groups events --- .../audit/RecordsManagementAuditServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index c37ae2642d..9868b4261d 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -1618,29 +1618,33 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean case "Delete Person": nodeName = getNodeName(entry.getBeforeProperties(), PROP_USERNAME); - json.put("deletePerson", true); + json.put("noAvailableLink", true); break; case "Create User Group": nodeName = getNodeName(entry.getAfterProperties(), PROP_AUTHORITY_DISPLAY_NAME, PROP_AUTHORITY_NAME); + json.put("noAvailableLink", true); break; case "Delete User Group": nodeName = getNodeName(entry.getBeforeProperties(), PROP_AUTHORITY_DISPLAY_NAME, PROP_AUTHORITY_NAME); + json.put("noAvailableLink", true); break; case "Add To User Group": nodeName = getNodeName(entry.getAfterProperties(), PARENT_GROUP); + json.put("noAvailableLink", true); break; case "Remove From User Group": nodeName = getNodeName(entry.getBeforeProperties(), PARENT_GROUP); + json.put("noAvailableLink", true); break; case "Delete RM Object": case "Delete Hold": nodeName = entry.getNodeName(); - json.put("deleteObject", true); + json.put("noAvailableLink", true); break; default: From e9b8fdd52eb9b8ac4e70e153f6266562ad9e2283 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 9 Dec 2019 16:57:31 +0200 Subject: [PATCH 39/43] Check rma:recordSearch aspect is still present after records filing --- .../FilePlanComponentAspects.java | 11 + .../rm/community/base/BaseRMRestTest.java | 2 +- .../rest/rm/community/base/TestData.java | 5 - .../rm/community/hold/AddToHoldsTests.java | 3 +- .../community/hold/RemoveFromHoldsTests.java | 2 +- .../community/records/FileRecordsTests.java | 436 +++++++----------- 6 files changed, 192 insertions(+), 267 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAspects.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAspects.java index c78f23711c..99e6b36043 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAspects.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAspects.java @@ -34,6 +34,11 @@ package org.alfresco.rest.rm.community.model.fileplancomponents; */ public class FilePlanComponentAspects { + /** Private constructor to prevent instantiation. */ + private FilePlanComponentAspects() + { + } + // aspect present on completed records public static final String ASPECTS_COMPLETED_RECORD = "rma:declaredRecord"; @@ -42,4 +47,10 @@ public class FilePlanComponentAspects // aspect present on vital records public static final String ASPECTS_VITAL_RECORD = "rma:vitalRecord"; + + // Frozen aspect + public static final String FROZEN_ASPECT = "rma:frozen"; + + // recordSearch aspect + public static final String RECORD_SEARCH_ASPECT = "rma:recordSearch"; } 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 037c6ce73d..a0224139a6 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 @@ -818,7 +818,7 @@ public class BaseRMRestTest extends RestTest */ protected boolean hasAspect(String nodeId, String aspectName) throws Exception { - return hasAspect(toFileModel(nodeId),aspectName); + return hasAspect(toFileModel(nodeId), aspectName); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java index 38e27a327d..3b9b15add2 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java @@ -107,9 +107,4 @@ public interface TestData * The default hold reason */ String HOLD_REASON = "Active content to be reviewed for the CASE McDermott, FINRA "; - - /** - * Frozen aspect - */ - String FROZEN_ASPECT = "rma:frozen"; } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java index 3803749525..80ee836651 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java @@ -26,12 +26,13 @@ */ package org.alfresco.rest.rm.community.hold; -import static org.alfresco.rest.rm.community.base.TestData.FROZEN_ASPECT; + import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java index 78146056c3..38ac5c0163 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java @@ -28,9 +28,9 @@ package org.alfresco.rest.rm.community.hold; import static java.util.Arrays.asList; -import static org.alfresco.rest.rm.community.base.TestData.FROZEN_ASPECT; import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java index 98a7963406..54f76cf099 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java @@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.RECORD_SEARCH_ASPECT; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; @@ -41,7 +42,7 @@ import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.record.Record; @@ -50,10 +51,10 @@ import org.alfresco.rest.rm.community.model.record.RecordContent; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; -import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; import org.alfresco.utility.report.Bug; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -67,19 +68,35 @@ import org.testng.annotations.Test; public class FileRecordsTests extends BaseRMRestTest { private UnfiledContainerChild electronicRecord = UnfiledContainerChild.builder() - .name(ELECTRONIC_RECORD_NAME) - .nodeType(CONTENT_TYPE) - .content(RecordContent.builder().mimeType("text/plain").build()) - .build(); + .name(ELECTRONIC_RECORD_NAME) + .nodeType(CONTENT_TYPE) + .content(RecordContent.builder().mimeType("text/plain").build()) + .build(); private UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder() - .properties(UnfiledContainerChildProperties.builder() - .description(NONELECTRONIC_RECORD_NAME) - .title("Title") - .build()) - .name(NONELECTRONIC_RECORD_NAME) - .nodeType(NON_ELECTRONIC_RECORD_TYPE) - .build(); + .properties(UnfiledContainerChildProperties.builder() + .description(NONELECTRONIC_RECORD_NAME) + .title("Title") + .build()) + .name(NONELECTRONIC_RECORD_NAME) + .nodeType(NON_ELECTRONIC_RECORD_TYPE) + .build(); + + private String targetFolderId, folderToLink, closedFolderId, unfiledRecordFolderId; + + @BeforeClass (alwaysRun = true) + public void setupFileRecordsTests() throws Exception + { + // create 3 record folders and close one of them + targetFolderId = createCategoryFolderInFilePlan().getId(); + folderToLink = createCategoryFolderInFilePlan().getId(); + closedFolderId = createCategoryFolderInFilePlan().getId(); + closeFolder(closedFolderId); + + //create one unfiled record folder + unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, + "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(); + } /** * Invalid containers where electronic and non-electronic records can be filed @@ -98,66 +115,62 @@ public class FileRecordsTests extends BaseRMRestTest }; } + /** + * Returns the ids of unfiled electronic and non-electronic records from Unfiled Records container + */ + @DataProvider (name = "unfiledRecordsFromUnfiledRecordsContainer") + public Object[][] getRecordsFromUnfiledRecordsContainer() + { + UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); + UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, + UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); + UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); + + return new String[][] { + { recordElectronic.getId()}, + { recordNonElect.getId()} + }; + } + + /** + * Returns the ids of unfiled electronic and non-electronic records from an Unfiled Record Folder + */ + @DataProvider (name = "unfiledRecordsFromUnfiledRecordFolder") + public Object[][] getRecordsFromUnfiledRecordFolder() + { + UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); + UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); + UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId); + + return new String[][] { + { recordElectronic.getId()}, + { recordNonElect.getId()} + }; + } + /** * Given an unfiled record in the root unfiled record container * And an open record folder * When I file the unfiled record into the record folder * Then the record is filed */ - @Test - public void fileRecordIntoExistingFolderFromUnfiledContainer() throws Exception + @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer") + public void fileRecordFromUnfiledContainerToOpenFolder(String unfiledRecordId) throws Exception { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - - // create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - - // create records - UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); - UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, - createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); - UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // file the record to the folder created + Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId); // check the response status assertStatusCode(CREATED); // check the parent id for the record returned - assertEquals(recordFiled.getParentId(),folderId); + assertEquals(recordFiled.getParentId(), targetFolderId); - // check the record is filed into the record folder - RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); - assertTrue(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); + // check the record is filed to the record folder + assertTrue(isRecordChildOfRecordFolder(unfiledRecordId, targetFolderId), unfiledRecordId + " is not filed to " + targetFolderId); // check the record doesn't exist into unfiled record container - assertFalse(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); - - // file the non-electronic record into the folder created - Record nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); - // check the response status code - assertStatusCode(CREATED); - // check the parent id for the record returned - assertEquals(nonElectRecordFiled.getParentId(), folderId); - - // check the record is added into the record folder - assertTrue(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); - - // check the record doesn't exist into unfiled record container - assertFalse(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); + assertFalse(isRecordChildOfUnfiledContainer(unfiledRecordId), unfiledRecordId + " exists in Unfiled Records"); + assertTrue(hasAspect(unfiledRecordId, RECORD_SEARCH_ASPECT), "recordSearch aspect is lost after filing!"); } /** @@ -166,62 +179,23 @@ public class FileRecordsTests extends BaseRMRestTest * When I file the unfiled record into the record folder * Then the record is filed */ - @Test - public void fileRecordIntoExistingFolderFromUnfiledRecordFolder() throws Exception + @Test (dataProvider = "unfiledRecordsFromUnfiledRecordFolder") + public void fileRecordFromUnfiledRecordFolderToOpenFolder(String unfiledRecordId) throws Exception { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - - // create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - - // create records - UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); - - String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(); - - UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); - UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId); - - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // file the record to the folder created + Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId); // check the response status assertStatusCode(CREATED); // check the parent id for the record returned - assertEquals(recordFiled.getParentId(),folderId); + assertEquals(recordFiled.getParentId(), targetFolderId); - // check the record is filed into the record folder - RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); - assertTrue(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); + // check the record is filed to the record folder + assertTrue(isRecordChildOfRecordFolder(unfiledRecordId, targetFolderId), unfiledRecordId + " is not filed to " + targetFolderId); // check the record doesn't exist into unfiled record folder - assertFalse(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); - - // file the non-electronic record into the folder created - Record nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); - // check the response status code - assertStatusCode(CREATED); - // check the parent id for the record returned - assertEquals(nonElectRecordFiled.getParentId(), folderId); - - // check the record is added into the record folder - assertTrue(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); - - // check the record doesn't exist into unfiled record folder - assertFalse(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); + assertFalse(isRecordChildOfUnfiledRecordFolder(unfiledRecordId), + unfiledRecordId + " exists in " + unfiledRecordFolderId); + assertTrue(hasAspect(unfiledRecordId, RECORD_SEARCH_ASPECT), "recordSearch aspect is lost after filing!"); } /** @@ -231,55 +205,19 @@ public class FileRecordsTests extends BaseRMRestTest * Then I get an unsupported operation exception * */ - @Test - public void fileRecordIntoCloseFolderFromUnfiledContainer() throws Exception + @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer") + public void fileRecordFromUnfiledContainerToClosedFolder(String unfiledRecordId) { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - - // create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - closeFolder(folderId); - // create records - UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); - - UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); - UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // file the record to the closed record folder + fileRecordToFolder(unfiledRecordId, closedFolderId); // check the response status assertStatusCode(FORBIDDEN); - // check the record is not filed into the record folder - RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); - assertFalse(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); + // check the record is not filed to the record folder + assertFalse(isRecordChildOfRecordFolder(unfiledRecordId, closedFolderId), unfiledRecordId + " is filed to " + closedFolderId); // check the record exist into unfiled record container - assertTrue(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); - - // file the non-electronic record into the folder created - recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); - // check the response status code - assertStatusCode(FORBIDDEN); - - // check the record is not added into the record folder - assertFalse(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); - - // check the record exist into unfiled record container - assertTrue(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) - .getEntries().stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); + assertTrue(isRecordChildOfUnfiledContainer(unfiledRecordId), unfiledRecordId + " doesn't exist in Unfiled Records"); } /** @@ -289,56 +227,20 @@ public class FileRecordsTests extends BaseRMRestTest * Then I get an unsupported operation exception * */ - @Test - public void fileRecordIntoCloseFolderFromUnfiledRecordFolder() throws Exception + @Test(dataProvider = "unfiledRecordsFromUnfiledRecordFolder") + public void fileRecordFromUnfiledRecordFolderToClosedFolder(String unfiledRecordId) { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - - // create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - closeFolder(folderId); - // create records - UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); - - String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(); - UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); - UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId); - - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // file the record into the closed folder created + fileRecordToFolder(unfiledRecordId, closedFolderId); // check the response status assertStatusCode(FORBIDDEN); // check the record is not filed into the record folder - RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); - assertFalse(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); + assertFalse(isRecordChildOfRecordFolder(unfiledRecordId, closedFolderId), unfiledRecordId + " is filed to " + closedFolderId); // check the record exist into unfiled record folder - assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId()))); - - // file the non-electronic record into the folder created - recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); - // check the response status code - assertStatusCode(FORBIDDEN); - - // check the record is not added into the record folder - assertFalse(recordFolderAPI.getRecordFolderChildren(folderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); - - // check the record exist into unfiled record folder - assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) - .getEntries().stream() - .anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId()))); + assertTrue(isRecordChildOfUnfiledRecordFolder(unfiledRecordId), + unfiledRecordId + " doesn't exist in " + unfiledRecordFolderId); } /** @@ -347,71 +249,34 @@ public class FileRecordsTests extends BaseRMRestTest * When I file the filed record into the record folder * Then the record is filed in both locations */ - @Test - @Bug(id="RM-4578") - public void linkRecordInto() throws Exception + @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer") + @Bug (id = "RM-4578") + public void linkRecordInto(String unfiledRecordId) { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - - // create a record folder - String parentFolderId = createCategoryFolderInFilePlan().getId(); - - // create records - UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); - UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); - UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(parentFolderId).build(); - Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); - Record nonElectronicFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); + // file the record to the open folder created + Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId); // check the response status assertStatusCode(CREATED); - // create the second folder - String folderToLink = createCategoryFolderInFilePlan().getId(); - recordBodyFile = RecordBodyFile.builder().targetParentId(folderToLink).build(); - - // check the response status + // link the record to the second folder + Record recordLink = fileRecordToFolder(unfiledRecordId, folderToLink); assertStatusCode(CREATED); - // link the electronic record - Record recordLink = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); - assertTrue(recordLink.getParentId().equals(parentFolderId)); - // check the response status code - assertStatusCode(CREATED); - // link the nonelectronic record - Record nonElectronicLink = recordsAPI.fileRecord(recordBodyFile, nonElectronicFiled.getId()); - assertStatusCode(CREATED); - assertTrue(nonElectronicLink.getParentId().equals(parentFolderId)); + assertTrue(recordLink.getParentId().equals(targetFolderId)); // check the record is added into the record folder RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); - assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && - c.getEntry().getParentId().equals(parentFolderId))); + assertTrue(recordFolderAPI.getRecordFolderChildren(targetFolderId) + .getEntries() + .stream() + .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && + c.getEntry().getParentId().equals(targetFolderId))); - // check the record doesn't exist into unfiled record container + // check the record has a link in the second folder assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink) - .getEntries().stream() - .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && - c.getEntry().getParentId().equals(parentFolderId) && - !c.getEntry().getParentId().equals(folderToLink))); - // check the record is added into the record folder - assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId) - .getEntries() - .stream() - .anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId()) && - c.getEntry().getParentId().equals(parentFolderId))); - - // check the record doesn't exist into unfiled record container - assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink) - .getEntries().stream() - .anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId()) && - c.getEntry().getParentId().equals(parentFolderId) && - !c.getEntry().getParentId().equals(folderToLink))); + .getEntries().stream() + .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && + c.getEntry().getParentId().equals(targetFolderId) && + !c.getEntry().getParentId().equals(folderToLink))); } /** @@ -425,24 +290,77 @@ public class FileRecordsTests extends BaseRMRestTest dataProvider = "invalidContainersToFile", description = "File the unfiled record to the container that is not a record folder" ) - public void invalidContainerToFile(String containerId) throws Exception + public void invalidContainerToFile(String containerId) { - // get API instances - RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); - // create records UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - // file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(containerId).build(); - recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // file the records to a container that is not a record folder + fileRecordToFolder(recordElectronic.getId(), containerId); assertStatusCode(BAD_REQUEST); - recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); - // check the response status + fileRecordToFolder(recordNonElect.getId(), containerId); assertStatusCode(BAD_REQUEST); } + + /** + * Files the given record in the target record folder. + * + * @param recordId the id of the record to be filed + * @param targetFolderId the id of the target record folder + */ + private Record fileRecordToFolder(String recordId, String targetFolderId) + { + RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(targetFolderId).build(); + return getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordId); + } + + /** + * Returns whether any child of the record folder match the provided record + * + * @param recordId the record id + * @param recordFolderId the record folder id + * @return true if any child of the record folder match the provided record, false otherwise + */ + private boolean isRecordChildOfRecordFolder(String recordId, String recordFolderId) + { + return getRestAPIFactory().getRecordFolderAPI() + .getRecordFolderChildren(recordFolderId) + .getEntries() + .stream() + .anyMatch(c -> c.getEntry().getId().equals(recordId)); + } + + /** + * Returns whether any child of the unfiled record folder match the provided record + * + * @param recordId the record id + * @return true if any child of the unfiled record folder match the provided record, false otherwise + */ + private boolean isRecordChildOfUnfiledRecordFolder(String recordId) + { + return getRestAPIFactory().getUnfiledRecordFoldersAPI() + .getUnfiledRecordFolderChildren(unfiledRecordFolderId) + .getEntries() + .stream() + .anyMatch(c -> c.getEntry().getId().equals(recordId)); + } + + /** + * Returns whether any child of the unfiled container match the provided record + * + * @param recordId the record id + * @return true if any child of the unfiled container match the provided record, false otherwise + */ + private boolean isRecordChildOfUnfiledContainer(String recordId) + { + return getRestAPIFactory().getUnfiledContainersAPI() + .getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) + .getEntries() + .stream() + .anyMatch(c -> c.getEntry().getId().equals(recordId)); + } } From 530db41df983a7f337dda1921798392790ca5633 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Dec 2019 10:58:10 +0200 Subject: [PATCH 40/43] Check rma:recordSearch aspect is still present after record move --- .../community/records/MoveRecordsTests.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/MoveRecordsTests.java diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/MoveRecordsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/MoveRecordsTests.java new file mode 100644 index 0000000000..fbc5017632 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/MoveRecordsTests.java @@ -0,0 +1,63 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2019 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.rm.community.records; + +import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.RECORD_SEARCH_ASPECT; +import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy; +import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.OK; +import static org.testng.Assert.assertTrue; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.test.AlfrescoTest; +import org.testng.annotations.Test; + +/** + * Move records tests + * + * @author Claudia Agache + * @since 3.3 + */ +public class MoveRecordsTests extends BaseRMRestTest +{ + @Test (description = "rma:recordSearch aspect is reapplied after record move") + @AlfrescoTest (jira = "RM-7060") + public void moveRecord() throws Exception + { + String parentFolderId = createCategoryFolderInFilePlan().getId(); + String targetFolderId = createCategoryFolderInFilePlan().getId(); + String electronicRecordId = createElectronicRecord(parentFolderId, ELECTRONIC_RECORD_NAME).getId(); + STEP("Move record from one folder to the other"); + getRestAPIFactory().getNodeAPI(toContentModel(electronicRecordId)).move(createBodyForMoveCopy(targetFolderId)); + assertStatusCode(OK); + + STEP("Check the record still has rma:recordSearch aspect."); + assertTrue(hasAspect(electronicRecordId, RECORD_SEARCH_ASPECT), "recordSearch aspect is lost after move!"); + } +} From a265ca54098b7c76c90cdb321842d7368a1474af Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Tue, 10 Dec 2019 10:41:12 +0000 Subject: [PATCH 41/43] RM-7051 replacing string utils ref --- .../repo/web/scripts/schedule/UpdateRecordScheduleGet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java index 40bcbac32e..58dfed9ba6 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/schedule/UpdateRecordScheduleGet.java @@ -71,7 +71,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.transaction.TransactionService; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.AbstractWebScript; From 6c1015e9c93cb2b7d3b8a42a01bae80ca436fe6d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Dec 2019 16:16:49 +0200 Subject: [PATCH 42/43] RM-7093 Update item location to include the provenience site --- .../rest/rm/community/audit/AuditAddToHoldTests.java | 6 +++--- .../rm/community/audit/AuditRemoveFromHoldTests.java | 6 +++--- .../org/alfresco/rest/rm/community/utils/RMSiteUtil.java | 1 + .../audit/RecordsManagementAuditServiceImpl.java | 9 ++++----- .../audit/extractor/NamePathDataExtractor.java | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java index 0d63ac5002..6a291f1e87 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java @@ -32,6 +32,7 @@ import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD; import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH; import static org.alfresco.utility.Utility.buildPath; import static org.alfresco.utility.Utility.removeLastSlash; import static org.alfresco.utility.data.RandomData.getRandomName; @@ -129,14 +130,13 @@ public class AuditAddToHoldTests extends BaseRMRestTest @DataProvider (name = "validNodesForAddToHold") public Object[][] getValidNodesForAddToHold() throws Exception { - String documentLibrary = "/documentLibrary"; FileModel contentToBeAdded = dataContent.usingAdmin().usingSite(privateSite) .createContent(CMISUtil.DocumentType.TEXT_PLAIN); RecordCategoryChild recordFolderToBeAdded = createRecordFolder(recordCategory.getId(), PREFIX + "recFolderToBeAdded"); Record recordToBeAdded = createElectronicRecord(recordFolder.getId(), PREFIX + "record"); - String recordFolderPath = removeLastSlash(buildPath(documentLibrary, recordCategory.getName(), + String recordFolderPath = removeLastSlash(buildPath(FILE_PLAN_PATH, recordCategory.getName(), recordFolderToBeAdded.getName())); - String recordPath = removeLastSlash(buildPath(documentLibrary, recordCategory.getName(), + String recordPath = removeLastSlash(buildPath(FILE_PLAN_PATH, recordCategory.getName(), recordFolder.getName(), recordToBeAdded.getName())); String contentPath = "/Company Home" + contentToBeAdded.getCmisLocation(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java index 7fa655f79b..2aa77a25ff 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java @@ -32,6 +32,7 @@ import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD; import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH; import static org.alfresco.utility.Utility.buildPath; import static org.alfresco.utility.Utility.removeLastSlash; import static org.alfresco.utility.data.RandomData.getRandomName; @@ -144,10 +145,9 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest @DataProvider (name = "validNodesForRemoveFromHold") public Object[][] getValidNodesForRemoveFromHold() { - String documentLibrary = "/documentLibrary"; - String recordFolderPath = removeLastSlash(buildPath(documentLibrary, recordCategory.getName(), + String recordFolderPath = removeLastSlash(buildPath(FILE_PLAN_PATH, recordCategory.getName(), heldRecordFolder.getName())); - String recordPath = removeLastSlash(buildPath(documentLibrary, recordCategory.getName(), + String recordPath = removeLastSlash(buildPath(FILE_PLAN_PATH, recordCategory.getName(), recordFolder.getName(), heldRecord.getName())); String contentPath = "/Company Home" + heldContent.getCmisLocation(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java index 80062165ca..52e9eeadd7 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java @@ -49,6 +49,7 @@ public class RMSiteUtil public static final String RM_ID = "rm"; public static final String RM_TITLE = "Records Management"; public static final String RM_DESCRIPTION = "Records Management Site"; + public static final String FILE_PLAN_PATH = "/rm/documentLibrary"; /** * Creates an RM Site model for the given compliance, title and description diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 9868b4261d..72cb924a53 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -93,7 +93,6 @@ import org.alfresco.util.PropertyCheck; import org.alfresco.util.PropertyMap; import org.alfresco.util.TempFileProvider; import org.alfresco.util.transaction.TransactionListenerAdapter; -import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -138,7 +137,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean protected static final String RM_AUDIT_SNIPPET_CHANGES = "/changes"; protected static final String RM_AUDIT_SNIPPET_BEFORE = "/before"; protected static final String RM_AUDIT_SNIPPET_AFTER = "/after"; - protected static final String RM_AUDIT_DOCUMENT_LIBRARY_PATH = "/documentLibrary"; + protected static final String RM_AUDIT_SITES_PATH = "/Sites"; protected static final String RM_AUDIT_DATA_PERSON_FULLNAME = "/RM/event/person/fullName"; protected static final String RM_AUDIT_DATA_PERSON_ROLES = "/RM/event/person/roles"; @@ -1464,10 +1463,10 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean // we need to strip off the first part of the path String path = entry.getPath(); String displayPath; - int idx = path.indexOf(RM_AUDIT_DOCUMENT_LIBRARY_PATH); + int idx = path.indexOf(RM_AUDIT_SITES_PATH); if (idx != -1) { - displayPath = path.substring(idx + RM_AUDIT_DOCUMENT_LIBRARY_PATH.length()); + displayPath = path.substring(idx + RM_AUDIT_SITES_PATH.length()); } else { @@ -1481,7 +1480,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean } writer.write("\n"); - if (entry.getChangedProperties() != null) + if (entry.getChangedProperties() != null && !entry.getChangedProperties().isEmpty()) { writer.write(""); writer.write(""); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java index 2aba0a894f..b68bc01837 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java @@ -135,7 +135,8 @@ public final class NamePathDataExtractor extends AbstractDataExtractor { // Get path from the RM root List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - + NodeRef filePlan = filePlanService.getFilePlan(nodeRef); + nodeRefPath.add(0, nodeService.getPrimaryParent(filePlan).getParentRef()); for (NodeRef pathNodeRef : nodeRefPath) { String name = (String) nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); From 3f6487571de03f18ec2bfebff620aa60efafff64 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 12 Dec 2019 12:06:49 +0200 Subject: [PATCH 43/43] review comments --- .../alfresco/rest/rm/community/records/FileRecordsTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java index 54f76cf099..08a6f7f829 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/FileRecordsTests.java @@ -53,6 +53,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; +import org.alfresco.test.AlfrescoTest; import org.alfresco.utility.report.Bug; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -93,7 +94,7 @@ public class FileRecordsTests extends BaseRMRestTest closedFolderId = createCategoryFolderInFilePlan().getId(); closeFolder(closedFolderId); - //create one unfiled record folder + // create one unfiled record folder unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(); } @@ -156,6 +157,7 @@ public class FileRecordsTests extends BaseRMRestTest * Then the record is filed */ @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer") + @AlfrescoTest (jira = "RM-7060") public void fileRecordFromUnfiledContainerToOpenFolder(String unfiledRecordId) throws Exception { // file the record to the folder created @@ -180,6 +182,7 @@ public class FileRecordsTests extends BaseRMRestTest * Then the record is filed */ @Test (dataProvider = "unfiledRecordsFromUnfiledRecordFolder") + @AlfrescoTest (jira = "RM-7060") public void fileRecordFromUnfiledRecordFolderToOpenFolder(String unfiledRecordId) throws Exception { // file the record to the folder created
PropertyPrevious ValueNew Value