[APPS-2019] Add Undeletable and Unmovable Aspects to Data Dictionary and its Level 1 sub-folders (#2705)

* [force] Force release for 2024-06-09.

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] Added Undeletable and Unmovable Aspect to Data Dictionary Folder

* [APPS-2019] [ags] [tas] Added Integration Test Cases

* [APPS-2019] [ags] [tas] Added fix for restricting the move folder for Data Dictionary

* [APPS-2019] [ags] [tas] Added fix for restricting the move folder for Data Dictionary

* Added Undeletable and Unmovable Aspects to Data Dictionary Folder

* [APPS-2019] Updated Integration Test Cases

* [APPS-2019] [ags] [tas] Added fix for restricting the move folder for Data Dictionary

* [APPS-2019] [ags] [tas] Added fix for restricting the move folder for Data Dictionary

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

* [APPS-2019] [ags] [tas] Addressed review comments

---------

Co-authored-by: Alfresco CI User <build@alfresco.com>
This commit is contained in:
Suneet Gupta
2024-06-27 10:05:57 +05:30
committed by GitHub
parent 76be8d2bec
commit abeaff52e8
17 changed files with 200 additions and 11 deletions

View File

@@ -76,7 +76,8 @@ import org.junit.runners.Suite;
org.alfresco.repo.activities.SiteActivityTestCaseSensitivity.class,
org.alfresco.repo.activities.feed.cleanup.FeedCleanerTestCaseSensitivity.class,
org.alfresco.repo.activities.SiteActivityTestCaseInsensitivity.class,
org.alfresco.repo.admin.registry.RegistryServiceImplTest.class
org.alfresco.repo.admin.registry.RegistryServiceImplTest.class,
org.alfresco.repo.bootstrap.DataDictionaryFolderTest.class
})
public class AppContext01TestSuite
{

View File

@@ -0,0 +1,124 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2024 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 <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.bootstrap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.test.junitrules.ApplicationContextInit;
import org.alfresco.util.test.junitrules.WellKnownNodes;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import java.util.List;
public class DataDictionaryFolderTest extends BaseSpringTest
{
@ClassRule
private static final ApplicationContextInit APP_CONTEXT_INIT = new ApplicationContextInit();
private static final String DATA_DICTIONARY = "Data Dictionary";
@Rule
private WellKnownNodes wellKnownNodes = new WellKnownNodes(APP_CONTEXT_INIT);
private NodeService nodeService;
@Before
public void before()
{
ServiceRegistry serviceRegistry = (ServiceRegistry) this.applicationContext.getBean("ServiceRegistry");
this.nodeService = serviceRegistry.getNodeService();
}
@Test
public void testDataDictionaryFolderIsUndeletable()
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// get the company_home
NodeRef companyHomeRef = wellKnownNodes.getCompanyHome();
// get the Data Dictionary
NodeRef dataDictionaryRef = nodeService.getChildByName(companyHomeRef, ContentModel.ASSOC_CONTAINS, DATA_DICTIONARY);
assertTrue(nodeService.hasAspect(dataDictionaryRef, ContentModel.ASPECT_UNDELETABLE));
List<ChildAssociationRef> chilAssocsList = nodeService.getChildAssocs(dataDictionaryRef);
chilAssocsList.stream()
.map(ChildAssociationRef::getChildRef)
.forEach(childNodeRef -> {
assertTrue(nodeService.hasAspect(childNodeRef, ContentModel.ASPECT_UNDELETABLE));
try
{
nodeService.deleteNode(childNodeRef);
}
catch (Exception ex)
{
assertTrue(ex.getMessage().contains("deletion is not allowed"));
}
});
}
@Test
public void testDataDictionaryFolderIsUnmovable()
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// get the company_home
NodeRef companyHomeRef = wellKnownNodes.getCompanyHome();
// get the Data Dictionary
NodeRef dataDictionaryRef = nodeService.getChildByName(companyHomeRef, ContentModel.ASSOC_CONTAINS, DATA_DICTIONARY);
assertTrue(nodeService.hasAspect(dataDictionaryRef, ContentModel.ASPECT_UNMOVABLE));
List<ChildAssociationRef> chilAssocsList = nodeService.getChildAssocs(dataDictionaryRef);
chilAssocsList.stream()
.map(ChildAssociationRef::getChildRef)
.forEach(childNodeRef -> {
assertTrue(nodeService.hasAspect(childNodeRef, ContentModel.ASPECT_UNMOVABLE));
NodeRef folderRef = nodeService.createNode(
companyHomeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName("testDeleteAndRestore-folder2-" + System.currentTimeMillis()),
ContentModel.TYPE_FOLDER
).getChildRef();
try
{
nodeService.moveNode(childNodeRef, folderRef, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);
}
catch (Exception ex)
{
assertTrue(ex.getMessage().contains("move is not allowed"));
}
});
}
}