mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'origin/master' into feature/APPS-737_SecurityGroupRestAPI
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
<maven.javadoc.skip>false</maven.javadoc.skip>
|
||||
<ags.share>alfresco-governance-services-community-share</ags.share>
|
||||
<ags.repo>alfresco-governance-services-community-repo</ags.repo>
|
||||
<tas.restapi.version>1.38</tas.restapi.version>
|
||||
<tas.restapi.version>1.50</tas.restapi.version>
|
||||
<tas.utility.version>3.0.41</tas.utility.version>
|
||||
<fluent.json.version>2.0.0</fluent.json.version>
|
||||
<jackson.databind.version>2.7.9.1</jackson.databind.version>
|
||||
</properties>
|
||||
@@ -57,11 +58,20 @@
|
||||
<artifactId>restapi</artifactId>
|
||||
<version>${tas.restapi.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>${tas.utility.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@@ -30,6 +30,8 @@ import static lombok.AccessLevel.PROTECTED;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.requests.search.SearchAPI;
|
||||
@@ -46,16 +48,13 @@ import org.alfresco.rest.rm.community.requests.gscore.api.TransferAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.TransferContainerAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* REST API Factory which provides access to the APIs
|
||||
*
|
||||
@@ -68,7 +67,7 @@ public class RestAPIFactory
|
||||
{
|
||||
@Autowired
|
||||
@Getter (value = PROTECTED)
|
||||
private DataUser dataUser;
|
||||
private DataUserAIS dataUser;
|
||||
|
||||
@Resource(name = "RMRestWrapper")
|
||||
@Getter
|
||||
|
@@ -37,6 +37,11 @@ import java.util.UUID;
|
||||
*/
|
||||
public class CommonTestUtils
|
||||
{
|
||||
/**
|
||||
* The default pattern used for the user full name when users are created with tas utility
|
||||
*/
|
||||
public static final String USER_FULLNAME_PATTERN = "FN-%1$s LN-%1$s";
|
||||
|
||||
/** Private constructor to prevent instantiation. */
|
||||
private CommonTestUtils()
|
||||
{
|
||||
|
@@ -47,6 +47,7 @@ import org.alfresco.dataprep.AlfrescoHttpClientFactory;
|
||||
import org.alfresco.dataprep.UserService;
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.core.v0.RMEvents;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.apache.chemistry.opencmis.client.api.CmisObject;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -90,6 +91,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private DataUserAIS dataUser;
|
||||
/**
|
||||
* Get all the configured RM roles.
|
||||
*
|
||||
@@ -192,14 +195,12 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
||||
String adminPassword,
|
||||
String userName,
|
||||
String password,
|
||||
String email,
|
||||
String role,
|
||||
String firstName,
|
||||
String lastName)
|
||||
String role)
|
||||
{
|
||||
if (!userService.userExists(adminUser, adminPassword, userName))
|
||||
{
|
||||
userService.create(adminUser, adminPassword, userName, password, email, firstName, lastName);
|
||||
dataUser.createUser(userName, password);
|
||||
|
||||
}
|
||||
assignRoleToUser(adminUser, adminPassword, userName, role);
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import java.util.HashMap;
|
||||
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.v0.RecordCategoriesAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DispositionScheduleService extends BaseAPI
|
||||
private RecordCategoriesAPI recordCategoriesAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
private DataUserAIS dataUser;
|
||||
|
||||
/**
|
||||
* Helper method for adding a retain after period step
|
||||
|
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEvents;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -54,7 +54,7 @@ public class RMAuditService
|
||||
private RMAuditAPI rmAuditAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
private DataUserAIS dataUser;
|
||||
|
||||
/**
|
||||
* Clear the list of audit entries as admin user.
|
||||
|
@@ -40,6 +40,7 @@ import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -60,7 +61,7 @@ public class RoleService
|
||||
|
||||
@Autowired
|
||||
@Getter (value = PROTECTED)
|
||||
private DataUser dataUser;
|
||||
private DataUserAIS dataUser;
|
||||
|
||||
@Autowired
|
||||
@Getter (value = PROTECTED)
|
||||
|
@@ -75,7 +75,6 @@ import org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
@@ -85,7 +84,7 @@ import org.alfresco.rest.search.SearchNodeModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.v0.SearchAPI;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
@@ -111,7 +110,7 @@ public class BaseRMRestTest extends RestTest
|
||||
|
||||
@Autowired
|
||||
@Getter (value = PROTECTED)
|
||||
private DataUser dataUser;
|
||||
protected DataUserAIS dataUser;
|
||||
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
|
@@ -0,0 +1,20 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- RM v3.5 Patches -->
|
||||
|
||||
<bean id="rm.holdChildAssocPatch"
|
||||
parent="rm.parentModulePatch"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.patch.v35.RMv35HoldNewChildAssocPatch">
|
||||
<property name="description" value="Create new hold child association to link the record to the hold"/>
|
||||
<property name="fixesFromSchema" value="3201" />
|
||||
<property name="fixesToSchema" value="3500"/>
|
||||
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
||||
<property name="filePlanService" ref="filePlanService" />
|
||||
<property name="holdService" ref="holdService" />
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
</bean>
|
||||
</beans>
|
@@ -1,3 +1,3 @@
|
||||
# RM Schema number
|
||||
|
||||
version.rm.schema=3300
|
||||
version.rm.schema=3500
|
||||
|
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 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.module.org_alfresco_module_rm.patch.v35;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* Patch to create new hold child association to link the record to the hold
|
||||
*
|
||||
* See: https://alfresco.atlassian.net/browse/APPS-659
|
||||
*
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public class RMv35HoldNewChildAssocPatch extends AbstractModulePatch
|
||||
{
|
||||
/**
|
||||
* File plan service interface
|
||||
*/
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* Hold service interface.
|
||||
*/
|
||||
private HoldService holdService;
|
||||
|
||||
/**
|
||||
* Interface for public and internal node and store operations.
|
||||
*/
|
||||
private NodeService nodeService;
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
/**
|
||||
* Setter for fileplanservice
|
||||
* @param filePlanService File plan service interface
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for hold service
|
||||
* @param holdService Hold service interface.
|
||||
*/
|
||||
public void setHoldService(HoldService holdService)
|
||||
{
|
||||
this.holdService = holdService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for node service
|
||||
* @param nodeService Interface for public and internal node and store operations.
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public BehaviourFilter getBehaviourFilter()
|
||||
{
|
||||
return behaviourFilter;
|
||||
}
|
||||
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
{
|
||||
this.behaviourFilter = behaviourFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInternal()
|
||||
{
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
|
||||
try
|
||||
{
|
||||
for (NodeRef filePlan : filePlanService.getFilePlans())
|
||||
{
|
||||
for (NodeRef hold : holdService.getHolds(filePlan))
|
||||
{
|
||||
for (ChildAssociationRef ref : nodeService.getChildAssocs(hold))
|
||||
{
|
||||
holdService.removeFromHold(hold, ref.getChildRef());
|
||||
holdService.addToHold(hold, ref.getChildRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 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.module.org_alfresco_module_rm.patch.v35;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyMap;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* RM V3.5 Create new hold child association to link the record to the hold
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public class RMv35HoldNewChildAssocPatchUnitTest
|
||||
{
|
||||
@Mock
|
||||
private FilePlanService mockFilePlanService;
|
||||
|
||||
@Mock
|
||||
private HoldService mockHoldService;
|
||||
|
||||
@Mock
|
||||
private NodeService mockNodeService;
|
||||
|
||||
@Mock
|
||||
private BehaviourFilter mockBehaviourFilter;
|
||||
|
||||
@InjectMocks
|
||||
private RMv35HoldNewChildAssocPatch patch;
|
||||
|
||||
private NodeRef filePlanRef, holdRef, heldItemRef;
|
||||
private Set<NodeRef> fileplans;
|
||||
private List<NodeRef> holds;
|
||||
|
||||
@Mock
|
||||
private ChildAssociationRef childAssociationRef;
|
||||
|
||||
private List<ChildAssociationRef> childAssocs;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
MockitoAnnotations.initMocks(this);
|
||||
filePlanRef = new NodeRef("workspace://SpacesStore/filePlan");
|
||||
holdRef = new NodeRef("workspace://SpacesStore/hold");
|
||||
heldItemRef = new NodeRef("workspace://SpacesStore/heldItem");
|
||||
fileplans = new HashSet<>();
|
||||
fileplans.add(filePlanRef);
|
||||
holds = new ArrayList<>();
|
||||
holds.add(holdRef);
|
||||
childAssocs = new ArrayList<>();
|
||||
childAssocs.add(childAssociationRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test held items are removed from a hold and re-add to make sure the association is correct
|
||||
*/
|
||||
@Test
|
||||
public void testAHoldIsRemovedAndReplacedDuringUpgrade()
|
||||
{
|
||||
when(mockFilePlanService.getFilePlans()).thenReturn(fileplans);
|
||||
when(mockHoldService.getHolds(filePlanRef)).thenReturn(holds);
|
||||
when(childAssociationRef.getChildRef()).thenReturn(heldItemRef);
|
||||
when(mockNodeService.getChildAssocs(holdRef)).thenReturn(childAssocs);
|
||||
patch.applyInternal();
|
||||
verify(mockHoldService, times(1)).removeFromHold(holdRef, heldItemRef);
|
||||
verify(mockHoldService, times(1)).addToHold(holdRef, heldItemRef);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchRunWithSuccessWhenNoHoldChilds()
|
||||
{
|
||||
List<NodeRef> holdList = new ArrayList<>();
|
||||
holdList.add(holdRef);
|
||||
when(childAssociationRef.getChildRef()).thenReturn(heldItemRef);
|
||||
when(mockNodeService.getChildAssocs(holdRef)).thenReturn(new ArrayList<>());
|
||||
patch.applyInternal();
|
||||
|
||||
verify(mockHoldService, times(0)).removeFromHold(holdRef, heldItemRef);
|
||||
verify(mockHoldService, times(0)).addToHold(holdRef, heldItemRef);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchRunWithSuccessWhenNoHolds()
|
||||
{
|
||||
//no holds
|
||||
List<NodeRef> holdList = new ArrayList<>();
|
||||
when(mockFilePlanService.getFilePlans()).thenReturn(fileplans);
|
||||
when(mockHoldService.getHolds(filePlanRef)).thenReturn(holdList);
|
||||
patch.applyInternal();
|
||||
|
||||
verify(mockHoldService, times(0)).removeFromHold(holdRef, heldItemRef);
|
||||
verify(mockHoldService, times(0)).addToHold(holdRef, heldItemRef);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchRunWithSuccessWhenNoFilePlan()
|
||||
{
|
||||
// given
|
||||
doReturn(Collections.EMPTY_SET).when(mockFilePlanService).getFilePlans();
|
||||
|
||||
// when
|
||||
patch.applyInternal();
|
||||
|
||||
// then
|
||||
verifyZeroInteractions(mockHoldService);
|
||||
verify(mockNodeService, times(0)).addAspect(any(NodeRef.class), any(QName.class), anyMap());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user