From 2a2bc883e8f69b9bda1758249dfb5f6f5ea456d9 Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Mon, 31 Aug 2020 17:31:01 +0300 Subject: [PATCH 1/5] added class to interact with Amazon S3 --- .travis.yml | 2 +- .../org/alfresco/rest/core/RMRestProperties.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4714b39982..fd914e96ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,7 +107,7 @@ jobs: - bash scripts/create-worm-bucket.sh - bash scripts/start-compose.sh "${ENTERPRISE_SHARE_PATH}/docker-compose-worm-support-rest.yml" - bash scripts/waitForAlfrescoToStart.sh - script: mvn -B test -pl :alfresco-governance-services-automation-enterprise-rest-api -DsuiteXmlFile=wormTestSuite.xml -Dskip.automationtests=false + script: mvn -B test -pl :alfresco-governance-services-automation-enterprise-rest-api -DsuiteXmlFile=wormTestSuite.xml -Dskip.automationtests=false -Ds3.accessKey=${AWS_ACCESS_KEY_ID} -Ds3.secretKey=${AWS_SECRET_ACCESS_KEY} -Ds3.bucketName=${S3_BUCKET2_NAME} -Ds3.bucketRegion=${S3_BUCKET_REGION} after_script: bash scripts/cleanup.sh after_failure: docker ps -a | grep '_alfresco_1' | awk '{print $1}' | xargs docker logs | tail -5000 diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java index b5ffec459a..29deb88610 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java @@ -59,4 +59,16 @@ public class RMRestProperties extends RestProperties @Value ("${docker.host}") private String dockerHost; + + @Value ("${s3.accessKey}") + private String s3AccessKey; + + @Value ("${s3.secretKey}") + private String s3SecretKey; + + @Value ("${s3.bucketName}") + private String s3BucketName; + + @Value ("${s3.bucketRegion}") + private String s3BucketRegion; } From 4b42afa11e7ff8073fe680b2c1d7c5681aa4a23c Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Tue, 1 Sep 2020 17:10:48 +0300 Subject: [PATCH 2/5] set s3 properties only in automation enterprise module --- .../org/alfresco/rest/core/RMRestProperties.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java index 29deb88610..b5ffec459a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java @@ -59,16 +59,4 @@ public class RMRestProperties extends RestProperties @Value ("${docker.host}") private String dockerHost; - - @Value ("${s3.accessKey}") - private String s3AccessKey; - - @Value ("${s3.secretKey}") - private String s3SecretKey; - - @Value ("${s3.bucketName}") - private String s3BucketName; - - @Value ("${s3.bucketRegion}") - private String s3BucketRegion; } From da3724ec9d51ac64773270850ae6b46d514c02e1 Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Wed, 2 Sep 2020 10:10:17 +0300 Subject: [PATCH 3/5] APPS-455: Support for Adding to S3 Legal Holds on WORM-Locked Records - Added ObjectLockS3Service to mirror the service exposed in S3 - Added default implementation for the case when S3 connector is not installed - Added dependency to Frozen and WormLock aspects which will be used for conditioning adding/removing to legal hold --- .../rm-model-context.xml | 5 +++ .../connector/worm/ObjectLockS3Service.java | 35 ++++++++++++++++ .../worm/ObjectLockS3ServiceDefaultImpl.java | 41 +++++++++++++++++++ .../model/rma/aspect/FrozenAspect.java | 14 +++++++ 4 files changed, 95 insertions(+) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 9119c2f01c..49e9343d4a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -157,6 +157,9 @@ + + @@ -173,6 +176,8 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java new file mode 100644 index 0000000000..ff8dce3075 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java @@ -0,0 +1,35 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2020 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.integrations.connector.worm; + +import org.alfresco.service.cmr.repository.NodeRef; + +public interface ObjectLockS3Service +{ + void setObjectLegalHold(NodeRef nodeRef, boolean enabled); +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java new file mode 100644 index 0000000000..ad7b74cd99 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java @@ -0,0 +1,41 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2020 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.integrations.connector.worm; + + +import org.alfresco.service.cmr.repository.NodeRef; + +public class ObjectLockS3ServiceDefaultImpl implements ObjectLockS3Service +{ + @Override + public void setObjectLegalHold(NodeRef nodeRef, boolean enabled) + { + // do nothing + // s3 not installed, method not supported + } +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java index da67bea63b..c82b09b66d 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java @@ -36,6 +36,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.integrations.connector.worm.ObjectLockS3Service; import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.util.PropertyModificationAllowedCheck; @@ -77,6 +78,11 @@ public class FrozenAspect extends BaseBehaviourBean /** freeze service */ protected FreezeService freezeService; + /** + * Object lock S3 service + */ + private ObjectLockS3Service objectLockS3Service; + /** * Utility class for property modification */ @@ -90,6 +96,14 @@ public class FrozenAspect extends BaseBehaviourBean this.freezeService = freezeService; } + /** + * @param objectLockS3Service service + */ + public void setObjectLockS3Service(ObjectLockS3Service objectLockS3Service) + { + this.objectLockS3Service = objectLockS3Service; + } + /** * Setter for property modification check utility * @param propertyModificationAllowedCheck Utility class for property modification From ca5414dbc9fb2b026cfe2bbe0c70732e60158d1b Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Wed, 2 Sep 2020 14:56:58 +0300 Subject: [PATCH 4/5] APPS-455: Support for Adding to S3 Legal Holds on WORM-Locked Records - Moved Object Lock S3 Service classes to enterprise project - Removed ObjectLockS3Service reference from FrozenAspect located in the community project, will be used only in WormLockAspect --- .../rm-model-context.xml | 5 --- .../connector/worm/ObjectLockS3Service.java | 35 ---------------- .../worm/ObjectLockS3ServiceDefaultImpl.java | 41 ------------------- .../model/rma/aspect/FrozenAspect.java | 14 ------- 4 files changed, 95 deletions(-) delete mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java delete mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 49e9343d4a..9119c2f01c 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -157,9 +157,6 @@ - - @@ -176,8 +173,6 @@ - diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java deleted file mode 100644 index ff8dce3075..0000000000 --- a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3Service.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2020 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.integrations.connector.worm; - -import org.alfresco.service.cmr.repository.NodeRef; - -public interface ObjectLockS3Service -{ - void setObjectLegalHold(NodeRef nodeRef, boolean enabled); -} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java deleted file mode 100644 index ad7b74cd99..0000000000 --- a/rm-community/rm-community-repo/source/java/org/alfresco/integrations/connector/worm/ObjectLockS3ServiceDefaultImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2020 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.integrations.connector.worm; - - -import org.alfresco.service.cmr.repository.NodeRef; - -public class ObjectLockS3ServiceDefaultImpl implements ObjectLockS3Service -{ - @Override - public void setObjectLegalHold(NodeRef nodeRef, boolean enabled) - { - // do nothing - // s3 not installed, method not supported - } -} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java index c82b09b66d..da67bea63b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspect.java @@ -36,7 +36,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.alfresco.integrations.connector.worm.ObjectLockS3Service; import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.util.PropertyModificationAllowedCheck; @@ -78,11 +77,6 @@ public class FrozenAspect extends BaseBehaviourBean /** freeze service */ protected FreezeService freezeService; - /** - * Object lock S3 service - */ - private ObjectLockS3Service objectLockS3Service; - /** * Utility class for property modification */ @@ -96,14 +90,6 @@ public class FrozenAspect extends BaseBehaviourBean this.freezeService = freezeService; } - /** - * @param objectLockS3Service service - */ - public void setObjectLockS3Service(ObjectLockS3Service objectLockS3Service) - { - this.objectLockS3Service = objectLockS3Service; - } - /** * Setter for property modification check utility * @param propertyModificationAllowedCheck Utility class for property modification From ef4f3a506b692e521ad2e9a75837f21131152d3c Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Fri, 4 Sep 2020 10:14:44 +0300 Subject: [PATCH 5/5] code review comments --- .../org/alfresco/rest/rm/community/base/BaseRMRestTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 afd58ae54a..3a39086362 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 @@ -533,7 +533,7 @@ public class BaseRMRestTest extends RestTest * @return the created record * @throws Exception */ - public Record createElectronicRecord(String parentId, String name) throws Exception + public Record createElectronicRecord(String parentId, String name) { return createElectronicRecord(parentId, name ,null); } @@ -547,7 +547,7 @@ public class BaseRMRestTest extends RestTest * @return the created record * @throws Exception */ - public Record createElectronicRecord(String parentId, String name, UserModel user) throws Exception + public Record createElectronicRecord(String parentId, String name, UserModel user) { RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user); Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();