From d816d1dbb95a9c5d6a209303ac3b7b85a9a14cfa Mon Sep 17 00:00:00 2001 From: Jelena Cule Date: Thu, 1 Mar 2018 22:37:45 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Revert=20"Merge=20branch=20'feature/RM-6107?= =?UTF-8?q?=5F=5FViewAndAddExemptionUI=5Fsm'=20into=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts merge request !877 --- .../model/rma/type/RmSiteType.java | 24 +++- .../test/integration/issue/MNT19114Test.java | 111 ------------------ .../model/rma/type/RmSiteTypeUnitTest.java | 6 +- 3 files changed, 25 insertions(+), 116 deletions(-) delete mode 100644 rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 21451873bd..753d21c9f3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -40,6 +40,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; @@ -58,6 +59,7 @@ import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.namespace.QName; import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyMap; +import org.springframework.extensions.surf.util.I18NUtil; import com.google.common.collect.Sets; @@ -314,8 +316,7 @@ public class RmSiteType extends BaseBehaviourBean /** * Add the limitation of creating only one rma:filePlan or one dod:filePlan depending on the type of rm site. - * Let multiple cm:folder type be created under rm site. - * + * Also added the limitation of crating two cm:folder type under rm site. * * Other than this nothing can be created under rm site nodeRef * @@ -343,6 +344,25 @@ public class RmSiteType extends BaseBehaviourBean }); } + /** + * Overridden this because in this case we need to have multiple cm:folder types but not more than two of them. + * The two mentioned folders are created when rm site is created and one of them is Saved Searches and the other surf-config folder. + After that creation of cm:folder should not be allowed under rm site node + * + */ + @Override + protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List acceptedUniqueChildType, + List acceptedMultipleChildType) throws IntegrityException + { + super.validateNewChildAssociation(parent, child, acceptedUniqueChildType, acceptedMultipleChildType); + + // check the user is not trying to create more than 2 folders that are created by default. + if(nodeService.getChildAssocs(parent, Sets.newHashSet(ContentModel.TYPE_FOLDER)).size() > 2) + { + throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null); + } + } + @Behaviour ( kind = BehaviourKind.CLASS, diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java deleted file mode 100644 index a502b01e82..0000000000 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2018 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * - - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; - -import static org.alfresco.repo.site.SiteServiceImpl.getSiteContainer; -import static org.alfresco.util.GUID.generate; - -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteVisibility; - -/** - * Test class for MNT 19114, wiki page can not be created under RM site - */ -public class MNT19114Test extends BaseRMTestCase -{ - public static final String PARENT_NODE = "RMSite"; - public static final String DOCUMENT_LIBRARY_FOLDER_TYPE = "documentLibrary"; - public static final String SURF_CONFIG_FOLDER_TYPE = "surfConfigFolder"; - public static final String WIKI_PAGE_FOLDER_TYPE = "wikiPage"; - - @Override - protected boolean isRMSiteTest() - { - return true; - } - - /** - * Given a RM site and two folder type children - * When creating a third folder type child as a Wiki page - * The page will be created and no exception will be thrown. - */ - public void testCreateWikiPageInRmSite() throws Exception - { - doBehaviourDrivenTest(new BehaviourDrivenTest() - { - NodeRef wikiPage; - - public void given() - { - // Creating a Records Management site - siteService.createSite("rmSite", PARENT_NODE, generate(), generate(), SiteVisibility.PUBLIC, TYPE_RM_SITE); - - // Adding two immediate folder type children - getSiteContainer( - PARENT_NODE, - DOCUMENT_LIBRARY_FOLDER_TYPE, - true, - siteService, - transactionService, - taggingService); - getSiteContainer( - PARENT_NODE, - SURF_CONFIG_FOLDER_TYPE, - true, - siteService, - transactionService, - taggingService); - } - - public void when() throws Exception - { - - wikiPage = getSiteContainer( - PARENT_NODE, - WIKI_PAGE_FOLDER_TYPE, - true, - siteService, - transactionService, - taggingService); - - } - - public void then() throws Exception - { - // Check if the new folder type wiki page has been created - assertEquals(true, nodeService.exists(wikiPage)); - } - - public void after() - { - siteService.deleteSite(PARENT_NODE); - } - }); - } -} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java index 04a3e3a1d7..d7718d00a6 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java @@ -32,8 +32,6 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; -import com.google.common.collect.Sets; - import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; @@ -51,6 +49,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import com.google.common.collect.Sets; + /** * Unit test for RmSiteType * @@ -151,7 +151,7 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model * Given that we try to add more than two cm:folder to rm site, * Then IntegrityException is thrown. */ - @Test + @Test(expected = IntegrityException.class) public void testAddMoreThanTwhoFolderTypeToRmSite() { NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true); From 04af88ee51b81bf57d08b23ef99ed61d195444be Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Mon, 5 Mar 2018 15:29:05 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"Revert=20"Merge=20branch=20'featu?= =?UTF-8?q?re/RM-6107=5F=5FViewAndAddExemptionUI=5Fsm'=20into=E2=80=A6""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d816d1dbb95a9c5d6a209303ac3b7b85a9a14cfa. --- .../model/rma/type/RmSiteType.java | 24 +--- .../test/integration/issue/MNT19114Test.java | 111 ++++++++++++++++++ .../model/rma/type/RmSiteTypeUnitTest.java | 6 +- 3 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 753d21c9f3..21451873bd 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -40,7 +40,6 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; @@ -59,7 +58,6 @@ import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.namespace.QName; import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyMap; -import org.springframework.extensions.surf.util.I18NUtil; import com.google.common.collect.Sets; @@ -316,7 +314,8 @@ public class RmSiteType extends BaseBehaviourBean /** * Add the limitation of creating only one rma:filePlan or one dod:filePlan depending on the type of rm site. - * Also added the limitation of crating two cm:folder type under rm site. + * Let multiple cm:folder type be created under rm site. + * * * Other than this nothing can be created under rm site nodeRef * @@ -344,25 +343,6 @@ public class RmSiteType extends BaseBehaviourBean }); } - /** - * Overridden this because in this case we need to have multiple cm:folder types but not more than two of them. - * The two mentioned folders are created when rm site is created and one of them is Saved Searches and the other surf-config folder. - After that creation of cm:folder should not be allowed under rm site node - * - */ - @Override - protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List acceptedUniqueChildType, - List acceptedMultipleChildType) throws IntegrityException - { - super.validateNewChildAssociation(parent, child, acceptedUniqueChildType, acceptedMultipleChildType); - - // check the user is not trying to create more than 2 folders that are created by default. - if(nodeService.getChildAssocs(parent, Sets.newHashSet(ContentModel.TYPE_FOLDER)).size() > 2) - { - throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null); - } - } - @Behaviour ( kind = BehaviourKind.CLASS, diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java new file mode 100644 index 0000000000..a502b01e82 --- /dev/null +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/MNT19114Test.java @@ -0,0 +1,111 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import static org.alfresco.repo.site.SiteServiceImpl.getSiteContainer; +import static org.alfresco.util.GUID.generate; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.site.SiteInfo; +import org.alfresco.service.cmr.site.SiteVisibility; + +/** + * Test class for MNT 19114, wiki page can not be created under RM site + */ +public class MNT19114Test extends BaseRMTestCase +{ + public static final String PARENT_NODE = "RMSite"; + public static final String DOCUMENT_LIBRARY_FOLDER_TYPE = "documentLibrary"; + public static final String SURF_CONFIG_FOLDER_TYPE = "surfConfigFolder"; + public static final String WIKI_PAGE_FOLDER_TYPE = "wikiPage"; + + @Override + protected boolean isRMSiteTest() + { + return true; + } + + /** + * Given a RM site and two folder type children + * When creating a third folder type child as a Wiki page + * The page will be created and no exception will be thrown. + */ + public void testCreateWikiPageInRmSite() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + NodeRef wikiPage; + + public void given() + { + // Creating a Records Management site + siteService.createSite("rmSite", PARENT_NODE, generate(), generate(), SiteVisibility.PUBLIC, TYPE_RM_SITE); + + // Adding two immediate folder type children + getSiteContainer( + PARENT_NODE, + DOCUMENT_LIBRARY_FOLDER_TYPE, + true, + siteService, + transactionService, + taggingService); + getSiteContainer( + PARENT_NODE, + SURF_CONFIG_FOLDER_TYPE, + true, + siteService, + transactionService, + taggingService); + } + + public void when() throws Exception + { + + wikiPage = getSiteContainer( + PARENT_NODE, + WIKI_PAGE_FOLDER_TYPE, + true, + siteService, + transactionService, + taggingService); + + } + + public void then() throws Exception + { + // Check if the new folder type wiki page has been created + assertEquals(true, nodeService.exists(wikiPage)); + } + + public void after() + { + siteService.deleteSite(PARENT_NODE); + } + }); + } +} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java index d7718d00a6..04a3e3a1d7 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java @@ -32,6 +32,8 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; +import com.google.common.collect.Sets; + import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; @@ -49,8 +51,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import com.google.common.collect.Sets; - /** * Unit test for RmSiteType * @@ -151,7 +151,7 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model * Given that we try to add more than two cm:folder to rm site, * Then IntegrityException is thrown. */ - @Test(expected = IntegrityException.class) + @Test public void testAddMoreThanTwhoFolderTypeToRmSite() { NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);