mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Revert "Merge branch 'feature/RM-5416_REST_API_Tests_for_Folder_Classification_1' into 'master'"
This reverts merge request !569
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.base;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
@@ -34,14 +33,11 @@ import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_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.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
||||
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.UserRoles.ROLE_RM_USER;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||
@@ -55,7 +51,6 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.dataprep.ContentService;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestAPIFactory;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
@@ -70,12 +65,8 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||
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;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -94,21 +85,13 @@ import lombok.Getter;
|
||||
public class BaseRMRestTest extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
@Getter (value = PROTECTED)
|
||||
private RestAPIFactory restAPIFactory;
|
||||
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
@Getter (value = PROTECTED)
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
private ContentService contentService;
|
||||
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
|
||||
/**
|
||||
* Asserts the given status code
|
||||
*
|
||||
@@ -133,22 +116,22 @@ public class BaseRMRestTest extends RestTest
|
||||
@DataProvider(name = "validRootContainers")
|
||||
public String[][] getValidRootContainers() throws Exception
|
||||
{
|
||||
return new String[][] {
|
||||
// an arbitrary record folder
|
||||
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE },
|
||||
// unfiled records root
|
||||
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
|
||||
// an arbitrary unfiled records folder
|
||||
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
|
||||
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(),
|
||||
UNFILED_RECORD_FOLDER_TYPE } };
|
||||
return new String[][]
|
||||
{
|
||||
// an arbitrary record folder
|
||||
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE},
|
||||
// unfiled records root
|
||||
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE},
|
||||
// an arbitrary unfiled records folder
|
||||
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(), UNFILED_RECORD_FOLDER_TYPE }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.rest.RestTest#checkServerHealth()
|
||||
*/
|
||||
@Override
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@BeforeClass (alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception
|
||||
{
|
||||
// Create RM Site if not exist
|
||||
@@ -156,7 +139,8 @@ public class BaseRMRestTest extends RestTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create the RM Site via the POST request if the site doesn't exist
|
||||
* Helper method to create the RM Site via the POST request
|
||||
* if the site doesn't exist
|
||||
*/
|
||||
public void createRMSiteIfNotExists() throws Exception
|
||||
{
|
||||
@@ -220,12 +204,10 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle)
|
||||
throws Exception
|
||||
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle) throws Exception
|
||||
{
|
||||
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
|
||||
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel,
|
||||
FILE_PLAN_ALIAS);
|
||||
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,12 +220,10 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created {@link RecordCategoryChild}
|
||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||
*/
|
||||
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name,
|
||||
String type) throws Exception
|
||||
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name, String type) throws Exception
|
||||
{
|
||||
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
|
||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel,
|
||||
recordCategoryId);
|
||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel, recordCategoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,8 +235,7 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created {@link RecordCategoryChild}
|
||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||
*/
|
||||
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type)
|
||||
throws Exception
|
||||
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type) throws Exception
|
||||
{
|
||||
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type);
|
||||
}
|
||||
@@ -299,8 +278,7 @@ public class BaseRMRestTest extends RestTest
|
||||
public RecordCategoryChild createFolder(UserModel user, String recordCategoryId, String name) throws Exception
|
||||
{
|
||||
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
|
||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel,
|
||||
recordCategoryId);
|
||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel, recordCategoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,18 +297,16 @@ public class BaseRMRestTest extends RestTest
|
||||
/**
|
||||
* Helper method to create child unfiled record folder
|
||||
*
|
||||
* @param user The user under whose privileges this structure is going to be created
|
||||
*@param user The user under whose privileges this structure is going to be created
|
||||
* @param parentId The id of the parent folder
|
||||
* @param nodeType The child type
|
||||
* @return The created folder
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName,
|
||||
String nodeType) throws Exception
|
||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
||||
{
|
||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user)
|
||||
.createUnfiledRecordFolderChild(childModel, parentId);
|
||||
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(childModel, parentId);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
return child;
|
||||
@@ -344,8 +320,7 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created folder
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType)
|
||||
throws Exception
|
||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType) throws Exception
|
||||
{
|
||||
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
|
||||
}
|
||||
@@ -360,16 +335,14 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created chid
|
||||
* @throws Exception on unsuccessful child creation
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName,
|
||||
String nodeType) throws Exception
|
||||
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
||||
{
|
||||
UnfiledContainerChild child = null;
|
||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||
|
||||
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
||||
{
|
||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId,
|
||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -389,8 +362,7 @@ public class BaseRMRestTest extends RestTest
|
||||
* @return The created chid
|
||||
* @throws Exception on unsuccessful child creation
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType)
|
||||
throws Exception
|
||||
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType) throws Exception
|
||||
{
|
||||
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
|
||||
}
|
||||
@@ -405,9 +377,11 @@ public class BaseRMRestTest extends RestTest
|
||||
protected RecordFolder closeFolder(String folderId) throws Exception
|
||||
{
|
||||
RecordFolder recordFolderModel = RecordFolder.builder()
|
||||
.properties(RecordFolderProperties.builder().isClosed(true).build()).build();
|
||||
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel,
|
||||
folderId);
|
||||
.properties(RecordFolderProperties.builder()
|
||||
.isClosed(true)
|
||||
.build())
|
||||
.build();
|
||||
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel, folderId);
|
||||
assertStatusCode(OK);
|
||||
|
||||
return updateRecordFolder;
|
||||
@@ -494,68 +468,4 @@ public class BaseRMRestTest extends RestTest
|
||||
{
|
||||
return getFilePlanAsUser(getAdminUser(), componentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a folder
|
||||
*
|
||||
* @param siteModel
|
||||
* @param folder
|
||||
*/
|
||||
public void deleteFolder(SiteModel siteModel, FolderModel folder)
|
||||
{
|
||||
contentService.deleteTree(getAdminUser().getUsername(), getAdminUser().getPassword(), siteModel.getId(),
|
||||
folder.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an electronic record
|
||||
*
|
||||
* @param parentId the id of the parent
|
||||
* @param name the name of the record
|
||||
* @return the created record
|
||||
* @throws Exception
|
||||
*/
|
||||
public Record createElectronicRecord(String parentId, String name) throws Exception
|
||||
{
|
||||
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
|
||||
Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
|
||||
return recordFolderAPI.createRecord(recordModel, parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record folder
|
||||
*
|
||||
* @param recordFolderId the id of the record folder to delete
|
||||
*/
|
||||
public void deleteRecordFolder(String recordFolderId)
|
||||
{
|
||||
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
|
||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record category
|
||||
*
|
||||
* @param recordCategoryId the id of the record category to delete
|
||||
*/
|
||||
public void deleteRecordCategory(String recordCategoryId)
|
||||
{
|
||||
RecordCategoryAPI recordCategoryAPI = restAPIFactory.getRecordCategoryAPI();
|
||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign filling permission on a record category and give the user RM_USER role
|
||||
*
|
||||
* @param user the user to assign the permission to
|
||||
* @param categoryId the id of the category to assign permissions for
|
||||
* @throws Exception
|
||||
*/
|
||||
public void assignFillingPermissionsOnCategory(UserModel user, String categoryId) throws Exception
|
||||
{
|
||||
getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, PERMISSION_FILING);
|
||||
rmRolesAndActionsAPI.assignUserToRole(dataUser.getAdminUser().getUsername(),
|
||||
dataUser.getAdminUser().getPassword(), user.getUsername(), ROLE_RM_USER);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user