mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4488 (Refactor REST API Automation test code according to the latest changes)
This commit is contained in:
@@ -38,8 +38,6 @@ import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
@@ -49,10 +47,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class RMSite extends RMModelRequest
|
||||
{
|
||||
// FIXME!!!
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
@@ -163,7 +157,6 @@ public class RMSite extends RMModelRequest
|
||||
*/
|
||||
public boolean existsRMSite() throws Exception
|
||||
{
|
||||
getRMRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
getSite();
|
||||
return getRMRestWrapper().getStatusCode().equals(OK.toString());
|
||||
}
|
||||
|
@@ -28,14 +28,21 @@ package org.alfresco.rest.rm.community.requests;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
|
||||
import org.alfresco.dataprep.AlfrescoHttpClient;
|
||||
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
|
||||
import org.alfresco.dataprep.UserService;
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -47,12 +54,15 @@ import org.springframework.stereotype.Component;
|
||||
* @since 2.6
|
||||
*/
|
||||
// FIXME: As of December 2016 there is no v1-style API for managing RM users and users'
|
||||
// roles. Until such APIs have become available, methods in this class are just proxies to
|
||||
// roles/permissions. Until such APIs have become available, methods in this class are just proxies to
|
||||
// "old-style" API calls.
|
||||
@Component
|
||||
@Scope (value = "prototype")
|
||||
public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
{
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -83,4 +93,61 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add permission on a component to user
|
||||
* @param component {@link FilePlanComponent} on which permission should be given
|
||||
* @param user {@link UserModel} for a user to be granted permission
|
||||
* @param permission {@link UserPermissions} to be granted
|
||||
*/
|
||||
public void addUserPermission(FilePlanComponentModel component, UserModel user, String permission)
|
||||
{
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
|
||||
JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
.addObject()
|
||||
.add("authority", user.getUsername())
|
||||
.add("role", permission)
|
||||
.end()
|
||||
.getJson();
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
// execute an "old-style" API call
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.auth().basic(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", component.getId())
|
||||
.log().all()
|
||||
.when()
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param userName FIXME!!!
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public boolean createUser(String userName)
|
||||
{
|
||||
return userService.create(dataUser.getAdminUser().getUsername(),
|
||||
dataUser.getAdminUser().getPassword(),
|
||||
userName,
|
||||
"password",
|
||||
"default@alfresco.com",
|
||||
userName,
|
||||
userName);
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.base;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
@@ -35,26 +33,16 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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.UNFILED_RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFilePlanComponentModel;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
|
||||
import org.alfresco.dataprep.AlfrescoHttpClient;
|
||||
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponents;
|
||||
import org.alfresco.rest.rm.community.requests.RMSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
@@ -79,31 +67,26 @@ public class BaseRestTest extends RestTest
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
|
||||
private RMSite rmSite;
|
||||
|
||||
private FilePlanComponents filePlanComponents;
|
||||
|
||||
protected RMSite getRMSiteAPI()
|
||||
{
|
||||
if (rmSite == null)
|
||||
{
|
||||
rmSite = getRmRestWrapper().withIGCoreAPI().usingRMSite();
|
||||
}
|
||||
return getRMSiteAPI(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
return rmSite;
|
||||
protected RMSite getRMSiteAPI(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel);
|
||||
return getRmRestWrapper().withIGCoreAPI().usingRMSite();
|
||||
}
|
||||
|
||||
protected FilePlanComponents getFilePlanComponentsAPI()
|
||||
{
|
||||
if (filePlanComponents == null)
|
||||
{
|
||||
filePlanComponents = getRmRestWrapper().withIGCoreAPI().usingFilePlanComponents();
|
||||
}
|
||||
return getFilePlanComponentsAPI(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
return filePlanComponents;
|
||||
protected FilePlanComponents getFilePlanComponentsAPI(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel);
|
||||
return getRmRestWrapper().withIGCoreAPI().usingFilePlanComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,11 +97,6 @@ public class BaseRestTest extends RestTest
|
||||
return this.rmRestWrapper;
|
||||
}
|
||||
|
||||
// Constants
|
||||
public static final String RM_ID = "rm";
|
||||
public static final String RM_TITLE = "Records Management";
|
||||
public static final String RM_DESCRIPTION = "Records Management Site";
|
||||
|
||||
/** Valid root containers where electronic and non-electronic records can be created */
|
||||
@DataProvider(name = "validRootContainers")
|
||||
public Object[][] getValidRootContainers() throws Exception
|
||||
@@ -126,9 +104,9 @@ public class BaseRestTest extends RestTest
|
||||
return new Object[][]
|
||||
{
|
||||
// an arbitrary record folder
|
||||
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS) },
|
||||
{ createCategoryFolderInFilePlan() },
|
||||
// unfiled records root
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS) },
|
||||
{ getFilePlanComponent(UNFILED_RECORDS_CONTAINER_ALIAS) },
|
||||
// an arbitrary unfiled records folder
|
||||
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric()) }
|
||||
};
|
||||
@@ -148,23 +126,13 @@ public class BaseRestTest extends RestTest
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param userModel FIXME!!!
|
||||
* @param httpStatus FIXME!!!
|
||||
*/
|
||||
protected void authenticateUser(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel);
|
||||
}
|
||||
|
||||
protected void assertStatusCodeIs(HttpStatus httpStatus)
|
||||
protected void assertStatusCode(HttpStatus httpStatus)
|
||||
{
|
||||
getRmRestWrapper().assertStatusCodeIs(httpStatus);
|
||||
}
|
||||
|
||||
protected void disconnect()
|
||||
{
|
||||
getRmRestWrapper().disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create the RM Site via the POST request
|
||||
* if the site doesn't exist
|
||||
@@ -172,86 +140,115 @@ public class BaseRestTest extends RestTest
|
||||
public void createRMSiteIfNotExists() throws Exception
|
||||
{
|
||||
// Check RM site doesn't exist
|
||||
if (!rmSite.existsRMSite())
|
||||
if (!getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the RM site
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
rmSite.createRMSite(rmSiteModel);
|
||||
getRMSiteAPI().createRMSite(createStandardRMSiteModel());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create child category
|
||||
*
|
||||
* @param user user under whose privileges this structure is going to be created
|
||||
* @param parentCategoryId The id of the parent category
|
||||
* @param categoryName The name of the category
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponentModel createCategory(UserModel user, String parentCategoryId, String categoryName) throws Exception
|
||||
{
|
||||
return createComponent(user, parentCategoryId, categoryName, RECORD_CATEGORY_TYPE, CATEGORY_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param parentCategoryId FIXME!!!
|
||||
* @param categoryName FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createCategory(String parentCategoryId, String categoryName) throws Exception
|
||||
{
|
||||
return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE, CATEGORY_TITLE);
|
||||
return createCategory(dataUser.getAdminUser(), parentCategoryId, categoryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create child folder
|
||||
*
|
||||
* @param user user under whose privileges this structure is going to be created
|
||||
* @param parentCategoryId The id of the parent category
|
||||
* @param folderName The name of the category
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponentModel createFolder(UserModel user, String parentCategoryId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(user, parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param parentCategoryId FIXME!!!
|
||||
* @param folderName FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createFolder(String parentCategoryId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
return createFolder(dataUser.getAdminUser(), parentCategoryId, folderName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create child unfiled record folder
|
||||
*
|
||||
* @param user user under whose privileges this structure is going to be created
|
||||
* @param parentId The id of the parent folder
|
||||
* @param folderName The name of the folder
|
||||
* @return The created folder
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponentModel createUnfiledRecordsFolder(UserModel user, String parentId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(user, parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param parentId FIXME!!!
|
||||
* @param folderName FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createUnfiledRecordsFolder(String parentId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
return createUnfiledRecordsFolder(dataUser.getAdminUser(), parentId, folderName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create generic child component
|
||||
*
|
||||
* @param user user under whose privileges this structure is going to be created
|
||||
* @param parentComponentId The id of the parent file plan component
|
||||
* @param componentName The name of the file plan component
|
||||
* @param componentType The name of the file plan component
|
||||
* @param componentTitle
|
||||
* @param componentType The type of the file plan component
|
||||
* @param componentTitle The title of the file plan component
|
||||
* @return The created file plan component
|
||||
* @throws Exception
|
||||
*/
|
||||
private FilePlanComponentModel createComponent(String parentComponentId, String componentName, String componentType, String componentTitle) throws Exception
|
||||
private FilePlanComponentModel createComponent(UserModel user, String parentComponentId, String componentName, String componentType, String componentTitle) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel filePlanComponentModel = createFilePlanComponentModel(componentName, componentType, componentTitle);
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI(user).createFilePlanComponent(filePlanComponentModel, parentComponentId);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(componentTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponentModel fpc = getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, parentComponentId);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
return fpc;
|
||||
return filePlanComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,39 +259,48 @@ public class BaseRestTest extends RestTest
|
||||
*/
|
||||
public FilePlanComponentModel closeFolder(String folderId) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// build fileplan component + properties for update request
|
||||
// build file plan component + properties for update request
|
||||
FilePlanComponentProperties properties = new FilePlanComponentProperties();
|
||||
properties.setIsClosed(true);
|
||||
FilePlanComponentModel filePlanComponent = new FilePlanComponentModel();
|
||||
filePlanComponent.setProperties(properties);
|
||||
|
||||
FilePlanComponentModel updatedComponent = getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, folderId);
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
return updatedComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a randomly-named <category>/<folder> structure in fileplan
|
||||
* Helper method to create a randomly-named <category>/<folder> structure in file plan
|
||||
*
|
||||
* @param user user under whose privileges this structure is going to be created
|
||||
* @param parentId parent container id
|
||||
* @return record folder
|
||||
* @throws Exception on failed creation
|
||||
*/
|
||||
public FilePlanComponentModel createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
||||
public FilePlanComponentModel createCategoryFolderInFilePlan(UserModel user) throws Exception
|
||||
{
|
||||
authenticateUser(user);
|
||||
|
||||
// create root category
|
||||
FilePlanComponentModel recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric());
|
||||
FilePlanComponentModel recordCategory = createCategory(user, FILE_PLAN_ALIAS, "Category " + getRandomAlphanumeric());
|
||||
|
||||
// and return a folder underneath
|
||||
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
||||
return createFolder(user, recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to retieve a fileplan component with user's privilege
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param parentId FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createCategoryFolderInFilePlan() throws Exception
|
||||
{
|
||||
return createCategoryFolderInFilePlan(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to retrieve a file plan component with user's privilege
|
||||
* @param user user under whose privileges a component is to be read
|
||||
* @param componentId id of the component to read
|
||||
* @return {@link FilePlanComponent} for given componentId
|
||||
@@ -302,50 +308,18 @@ public class BaseRestTest extends RestTest
|
||||
*/
|
||||
public FilePlanComponentModel getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception
|
||||
{
|
||||
authenticateUser(user);
|
||||
return getFilePlanComponentsAPI().getFilePlanComponent(componentId);
|
||||
return getFilePlanComponentsAPI(user).getFilePlanComponent(componentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add permission on a component to user
|
||||
* @param component {@link FilePlanComponent} on which permission should be given
|
||||
* @param user {@link UserModel} for a user to be granted permission
|
||||
* @param permission {@link UserPermissions} to be granted
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param componentId FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
// FIXME: As of December 2016 there is no v1-style API for managing RM permissions.
|
||||
// Until such APIs have become available, this method is just a proxy to an "old-style"
|
||||
// API call.
|
||||
public void addUserPermission(FilePlanComponentModel component, UserModel user, String permission)
|
||||
public FilePlanComponentModel getFilePlanComponent(String componentId) throws Exception
|
||||
{
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
|
||||
JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
.addObject()
|
||||
.add("authority", user.getUsername())
|
||||
.add("role", permission)
|
||||
.end()
|
||||
.getJson();
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
// execute an "old-style" API call
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.auth().basic(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", component.getId())
|
||||
.log().all()
|
||||
.when()
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
rmRestWrapper.setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
return getFilePlanComponentAsUser(dataUser.getAdminUser(), componentId);
|
||||
}
|
||||
}
|
@@ -102,7 +102,7 @@ public interface TestData
|
||||
/**
|
||||
* The default CATEGORY name used when creating categories
|
||||
*/
|
||||
public static String CATEGORY_NAME = "CATEGORY NAME"+ getRandomAlphanumeric();
|
||||
public static String CATEGORY_NAME = "CATEGORY NAME" + getRandomAlphanumeric();
|
||||
|
||||
/**
|
||||
* The default CATEGORY title used when creating categories
|
||||
|
@@ -26,11 +26,9 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||
|
||||
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.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
@@ -90,15 +88,9 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void adminCanDeleteElectronicRecord(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId());
|
||||
|
||||
// create an electronic record
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
deleteAndVerify(newRecord);
|
||||
}
|
||||
@@ -123,17 +115,10 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void adminCanDeleteNonElectronicRecord(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create a non-electronic record
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
container.getId());
|
||||
assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), container.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
deleteAndVerify(newRecord);
|
||||
}
|
||||
@@ -157,18 +142,10 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void userWithoutWritePermissionsCantDeleteRecord() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create a non-electronic record in unfiled records
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// create test user and add it with collab. privileges
|
||||
UserModel deleteUser = dataUser.createRandomTestUser("delnoperm");
|
||||
@@ -180,12 +157,9 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
// log in as deleteUser
|
||||
authenticateUser(deleteUser);
|
||||
|
||||
// try to delete newRecord
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
getFilePlanComponentsAPI(deleteUser).deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,8 +181,6 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void userWithoutDeleteRecordsCapabilityCantDeleteRecord() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create test user and add it with collab. privileges
|
||||
UserModel deleteUser = dataUser.createRandomTestUser("delnoperm");
|
||||
deleteUser.setUserRole(UserRole.SiteCollaborator);
|
||||
@@ -220,35 +192,26 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
// create random folder
|
||||
FilePlanComponentModel randomFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
FilePlanComponentModel randomFolder = createCategoryFolderInFilePlan();
|
||||
logger.info("random folder:" + randomFolder.getName());
|
||||
|
||||
// grant deleteUser Filing privileges on randomFolder category, this will be
|
||||
// inherited to randomFolder
|
||||
addUserPermission(getFilePlanComponentsAPI().getFilePlanComponent(randomFolder.getParentId()),
|
||||
rmUserAPI.addUserPermission(getFilePlanComponentsAPI().getFilePlanComponent(randomFolder.getParentId()),
|
||||
deleteUser, UserPermissions.PERMISSION_FILING);
|
||||
assertStatusCodeIs(OK);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
// create a non-electronic record in randomFolder
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
randomFolder.getId());
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// log in as deleteUser
|
||||
authenticateUser(deleteUser);
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId());
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// verify the user can see the newRecord
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(OK);
|
||||
getFilePlanComponentsAPI(deleteUser).getFilePlanComponent(newRecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
// try to delete newRecord
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
getFilePlanComponentsAPI(deleteUser).deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,14 +221,12 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
*/
|
||||
private void deleteAndVerify(FilePlanComponentModel record) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// delete it and verify status
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(record.getId());
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
// try to get deleted file plan component
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(record.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
@@ -41,8 +41,6 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -57,25 +55,23 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class ElectronicRecordTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
/** image resource file to be used for records body */
|
||||
private static final String IMAGE_FILE = "money.JPG";
|
||||
|
||||
/** Valid root containers where electronic records can be created */
|
||||
@DataProvider(name = "invalidParentContainers")
|
||||
public Object[][] invalidContainers() throws Exception {
|
||||
return new Object[][] {
|
||||
public Object[][] invalidContainers() throws Exception
|
||||
{
|
||||
return new Object[][]
|
||||
{
|
||||
// record category
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(),
|
||||
createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS).getParentId()) },
|
||||
{ getFilePlanComponent(createCategoryFolderInFilePlan().getParentId()) },
|
||||
// file plan root
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS) },
|
||||
{ getFilePlanComponent(FILE_PLAN_ALIAS) },
|
||||
// transfers
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS) },
|
||||
{ getFilePlanComponent(TRANSFERS_ALIAS) },
|
||||
// holds
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS) },
|
||||
{ getFilePlanComponent(HOLDS_ALIAS) },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,17 +92,11 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build object the filePlan
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId());
|
||||
|
||||
// verify the create request status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,8 +112,7 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Electronic record can't be created in closed record folder")
|
||||
public void cantCreateElectronicRecordInClosedFolder() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan();
|
||||
|
||||
// the folder should be open
|
||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||
@@ -132,14 +121,10 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
closeFolder(recordFolder.getId());
|
||||
|
||||
// try to create it, this should fail
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, recordFolder.getId());
|
||||
getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, recordFolder.getId());
|
||||
|
||||
// verify the status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,9 +154,8 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
// only record folders can be open or closed
|
||||
@@ -187,7 +171,7 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(record, container.getId());
|
||||
|
||||
// verify the status code is BAD_REQUEST
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,18 +198,13 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void canCreateElectronicRecordsInValidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
FilePlanComponentModel record = createElectronicRecordModel();
|
||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// get newly created electonic record and verify its properties
|
||||
// get newly created electronic record and verify its properties
|
||||
FilePlanComponentModel electronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
||||
// created record will have record identifier inserted in its name but will be prefixed with
|
||||
// the name it was created as
|
||||
@@ -245,8 +224,6 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void recordNameDerivedFromFileName(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// record object without name set
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.nodeType(CONTENT_TYPE)
|
||||
@@ -255,7 +232,7 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// get newly created electonic record and verify its properties
|
||||
FilePlanComponentModel electronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
||||
|
@@ -85,18 +85,13 @@ public class FilePlanTests extends BaseRestTest
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan component
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
//check the response code is NOT_FOUND
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given that a file plan exists
|
||||
* When I ask the API for the details of the file plan
|
||||
@@ -113,14 +108,11 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan special container
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the response code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Check the response contains the right node type
|
||||
assertEquals(filePlanComponent.getNodeType(), filePlanComponentType);
|
||||
@@ -142,9 +134,6 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan special containers with the optional parameter allowableOperations
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().getFilePlanComponent(specialContainerAlias, "include=" + ALLOWABLE_OPERATIONS);
|
||||
|
||||
@@ -181,9 +170,6 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build object for updating the filePlan
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
@@ -196,7 +182,7 @@ public class FilePlanTests extends BaseRestTest
|
||||
FilePlanComponentModel renamedFilePlanComponent = getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the response status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned description field for the file plan component
|
||||
assertEquals(renamedFilePlanComponent.getProperties().getDescription(), FILE_PLAN_DESCRIPTION);
|
||||
@@ -221,14 +207,11 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Delete the file plan component
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the DELETE response status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,22 +230,14 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Disconnect the current user from the API session
|
||||
disconnect();
|
||||
// Authenticate admin user to Alfresco REST API
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create a random user
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate using the random user
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Delete the file plan component
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentAlias);
|
||||
getFilePlanComponentsAPI(nonRMuser).deleteFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the DELETE response status code
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,9 +257,6 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the RM site ID
|
||||
String rmSiteId = getRMSiteAPI().getSite().getGuid();
|
||||
String name = filePlanComponentAlias + getRandomAlphanumeric();
|
||||
@@ -297,20 +269,17 @@ public class FilePlanTests extends BaseRestTest
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the special containers into RM site - parent folder
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
|
||||
// Create the special containers into RM site - parent folder
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
|
||||
// Create the special containers into the root of special containers containers
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, filePlanComponentAlias);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,22 +298,13 @@ public class FilePlanTests extends BaseRestTest
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Disconnect user from REST API session
|
||||
disconnect();
|
||||
|
||||
// Authenticate admin user to Alfresco REST API
|
||||
restClient.authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create a random user
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate using the random user
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Get the special file plan components
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
getFilePlanComponentsAPI(nonRMuser).getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the response status code is FORBIDDEN
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
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.util.PojoUtility.toJson;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
@@ -78,14 +80,6 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Non-electronic record can't be created as a child of invalid parent Id")
|
||||
public void cantCreateForInvalidParentIds() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// non-electronic record object to be used for create tests
|
||||
FilePlanComponentModel nonElectronicRecord = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
|
||||
// create record category, non-electronic records can't be its children
|
||||
FilePlanComponentModel recordCategoryModel = FilePlanComponentModel.builder()
|
||||
.name("Category " + getRandomAlphanumeric())
|
||||
@@ -101,14 +95,14 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
{
|
||||
try
|
||||
{
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(nonElectronicRecord, id);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), id);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
}
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,9 +130,8 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void canCreateInValidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
// only record folders can be open or closed
|
||||
@@ -179,7 +172,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// get newly created non-electonic record and verify its properties
|
||||
FilePlanComponentModel nonElectronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(nonElectronicId);
|
||||
@@ -207,8 +200,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Non-electronic record can't be created in closed record folder")
|
||||
public void cantCreateInClosedFolder() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan();
|
||||
|
||||
// the folder should be open
|
||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||
@@ -217,16 +209,10 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
closeFolder(recordFolder.getId());
|
||||
|
||||
// try to create it, this should fail and throw an exception
|
||||
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build(),
|
||||
recordFolder.getId())
|
||||
.getId();
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), recordFolder.getId());
|
||||
|
||||
// verify the status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,8 +241,6 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void allMandatoryPropertiesRequired(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
@@ -295,7 +279,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
}
|
||||
|
||||
// verify the status code is BAD_REQUEST
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -315,10 +299,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
)
|
||||
public void cantCreateIfNoRmPrivileges(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
String username = "zzzuser";
|
||||
UserModel user = createUserWithRole(username, UserRole.SiteManager);
|
||||
|
||||
authenticateUser(user);
|
||||
UserModel user = createUserWithRole("zzzuser", SiteManager);
|
||||
|
||||
// try to create a fileplan component
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
@@ -334,14 +315,14 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
// this should fail and throw an exception
|
||||
try
|
||||
{
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(record, container.getId());
|
||||
getFilePlanComponentsAPI(user).createFilePlanComponent(record, container.getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// user who isn't an RM site member can't access the container path
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +351,6 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
*/
|
||||
private UserModel createUserWithRole(String userName, UserRole userRole) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String siteId = getRMSiteAPI().getSite().getId();
|
||||
|
||||
// check if user exists
|
||||
|
@@ -81,9 +81,6 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
)
|
||||
public void createCategoryTest() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
@@ -101,7 +98,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertTrue(filePlanComponent.getIsCategory());
|
||||
@@ -132,9 +129,6 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
)
|
||||
public void renameCategory() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create record category first
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
@@ -161,7 +155,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
FilePlanComponentModel renamedFilePlanComponent = getFilePlanComponentsAPI().updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(renamedFilePlanComponent.getName(), newCategoryName);
|
||||
@@ -185,9 +179,6 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
)
|
||||
public void deleteCategory() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create record category first
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
@@ -209,11 +200,11 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponent.getId());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
// Deleted component should no longer be retrievable
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,14 +268,11 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// List children from API
|
||||
FilePlanComponentsCollection apiChildren = getFilePlanComponentsAPI().listChildComponents(rootCategory.getId());
|
||||
|
||||
// Check status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
logger.info("parent: " + rootCategory.getId());
|
||||
|
||||
// Check listed children against created list
|
||||
@@ -355,9 +343,6 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
{
|
||||
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Create the category
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, COMPONENT_NAME);
|
||||
|
||||
@@ -373,7 +358,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
|
||||
//create the invalid node type
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, category.getId());
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
|
||||
@@ -401,9 +386,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
*/
|
||||
private FilePlanComponentModel createComponent(String parentComponentId, String componentName, String componentType) throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Build node properties
|
||||
// Build node properties
|
||||
FilePlanComponentModel component = FilePlanComponentModel.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType)
|
||||
@@ -412,9 +395,9 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponentModel fpc = getFilePlanComponentsAPI().createFilePlanComponent(component, parentComponentId);
|
||||
assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(component, parentComponentId);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
return fpc;
|
||||
return filePlanComponent;
|
||||
}
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
@Autowired
|
||||
public DataUser dataUser;
|
||||
|
||||
private static final int NUMBER_OF_FOLDERS= 5;
|
||||
private static final int NUMBER_OF_FOLDERS = 5;
|
||||
/**
|
||||
* Given that a record category exists
|
||||
* When I use the API to create a new record folder
|
||||
@@ -86,8 +86,8 @@ public class RecordFolderTests extends BaseRestTest
|
||||
public void createFolderTest() throws Exception
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel filePlanComponent = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
@@ -101,7 +101,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
// Create the record folder
|
||||
FilePlanComponentModel folder = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, filePlanComponent.getId());
|
||||
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Check folder has been created within the category created
|
||||
assertEquals(filePlanComponent.getId(),folder.getParentId());
|
||||
@@ -133,9 +133,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
@Bug(id="RM-4327")
|
||||
public void createFolderIntoSpecialContainers(String filePlanComponent) throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String componentID = getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent).getId();
|
||||
|
||||
// Build the record category properties
|
||||
@@ -151,7 +148,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, componentID);
|
||||
|
||||
// Check the API Response code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,8 +163,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
public void checkTheRecordFolderProperties() throws Exception
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
FilePlanComponentModel folder = createFolder(category.getId(),FOLDER_NAME);
|
||||
|
||||
@@ -202,9 +198,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Create a record category
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
@@ -233,7 +226,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
FilePlanComponentModel folderUpdated = getFilePlanComponentsAPI().updateFilePlanComponent(recordFolder, folder.getId());
|
||||
|
||||
// Check the Response Status Code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertEquals(folderName, folderUpdated.getName());
|
||||
@@ -259,9 +252,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
@@ -271,12 +261,12 @@ public class RecordFolderTests extends BaseRestTest
|
||||
// Delete the Record folder
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(folder.getId());
|
||||
// Check the Response Status Code
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
// Check the File Plan Component is not found
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(folder.getId());
|
||||
// Check the Response Status Code
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,7 +286,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
// Add child olders
|
||||
@@ -310,14 +299,11 @@ public class RecordFolderTests extends BaseRestTest
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// List children from API
|
||||
FilePlanComponentsCollection apiChildren = getFilePlanComponentsAPI().listChildComponents(category.getId());
|
||||
|
||||
// Check status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Check listed children against created list
|
||||
apiChildren.getEntries().forEach(c ->
|
||||
@@ -373,21 +359,19 @@ public class RecordFolderTests extends BaseRestTest
|
||||
public void createFolderWithRelativePath() throws Exception
|
||||
{
|
||||
//RelativePath specify the container structure to create relative to the record folder to be created
|
||||
String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth();
|
||||
String relativePath = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" + LocalDateTime.now().getDayOfMonth();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
//The record folder to be created
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.relativePath(relativePath)
|
||||
.build();
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponentModel folder = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||
//Check the API response code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder.getIsCategory());
|
||||
@@ -395,24 +379,24 @@ public class RecordFolderTests extends BaseRestTest
|
||||
assertTrue(folder.getIsRecordFolder());
|
||||
|
||||
//Check the path return contains the RELATIVE_PATH
|
||||
assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
|
||||
assertTrue(folder.getPath().getName().contains(relativePath));
|
||||
//check the parent is a category
|
||||
assertTrue(getFilePlanComponentsAPI().getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||
|
||||
//check the created folder from the server
|
||||
folder = getFilePlanComponentsAPI().getFilePlanComponent(folder.getId(), "include=" + PATH);
|
||||
//Check the API response code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder.getIsCategory());
|
||||
assertFalse(folder.getIsFile());
|
||||
assertTrue(folder.getIsRecordFolder());
|
||||
|
||||
//Check the path return contains the RELATIVE_PATH
|
||||
assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
|
||||
assertTrue(folder.getPath().getName().contains(relativePath));
|
||||
|
||||
//New Relative Path only a part of containers need to be created before the record folder
|
||||
String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1);
|
||||
String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" + (LocalDateTime.now().getDayOfMonth() + 1);
|
||||
//The record folder to be created
|
||||
FilePlanComponentModel recordFolder2 = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
@@ -423,7 +407,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
// Create the record folder
|
||||
FilePlanComponentModel folder2 = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||
//Check the API response code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder2.getIsCategory());
|
||||
@@ -438,7 +422,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
// Check the folder created on the server
|
||||
folder2 = getFilePlanComponentsAPI().getFilePlanComponent(folder2.getId(), "include=" + PATH);
|
||||
//Check the API response code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder2.getIsCategory());
|
||||
@@ -451,7 +435,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
@AfterClass (alwaysRun = true)
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
getFilePlanComponentsAPI().listChildComponents(FILE_PLAN_ALIAS).getEntries().forEach(filePlanComponentEntry ->
|
||||
{
|
||||
try
|
||||
|
@@ -93,9 +93,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Create root unfiled records folder")
|
||||
public void createRootUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String folderName = "Folder " + getRandomAlphanumeric();
|
||||
String folderTitle = folderName + " Title";
|
||||
String folderDescription = folderName + " Description";
|
||||
@@ -113,7 +110,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
@@ -141,8 +138,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
)
|
||||
public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(String filePlanComponentType)
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String folderName = "Folder " + getRandomAlphanumeric();
|
||||
String folderTitle = folderName + " Title";
|
||||
String folderDescription = folderName + " Description";
|
||||
@@ -168,7 +163,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
}
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,8 +176,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Child unfiled records folder can be created in a parent unfiled records folder")
|
||||
public void childUnfiledRecordsFolderCanBeCreated() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String parentFolderName = "Parent Folder " + getRandomAlphanumeric();
|
||||
String childFolderName = "Child Folder " + getRandomAlphanumeric();
|
||||
String childFolderTitle = childFolderName + " Title";
|
||||
@@ -206,7 +199,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
FilePlanComponentModel childFolder = getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, parentFolder.getId());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(childFolder.getIsCategory());
|
||||
@@ -228,7 +221,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
// Does child's parent point to it?
|
||||
// Perform another call as our parentFolder had been executed before childFolder existed
|
||||
FilePlanComponentsCollection parentsChildren = getFilePlanComponentsAPI().listChildComponents(parentFolder.getId());
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
List<String> childIds = parentsChildren.getEntries()
|
||||
.stream()
|
||||
.map(c -> c.getFilePlanComponentModel().getId())
|
||||
@@ -251,7 +244,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Unfiled record folder")
|
||||
public void editUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String modified = "Modified ";
|
||||
String folderName = "Folder To Modify" + getRandomAlphanumeric();
|
||||
|
||||
@@ -271,7 +263,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
// Update the unfiled records folder
|
||||
getFilePlanComponentsAPI().updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
||||
FilePlanComponentModel renamedFolder = getFilePlanComponentsAPI().getFilePlanComponent(folderToModify.getId());
|
||||
@@ -292,7 +284,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Delete unfiled record folder")
|
||||
public void deleteUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String folderName = "Folder To Delete" + getRandomAlphanumeric();
|
||||
|
||||
// Create folderToDelete
|
||||
@@ -303,10 +294,10 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(folderToDelete.getId());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
// Deleted component should no longer be retrievable
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(folderToDelete.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -27,10 +27,15 @@
|
||||
package org.alfresco.rest.rm.community.site;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ANOTHER_ADMIN;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_EMAIL;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
|
||||
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
|
||||
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_DESCRIPTION;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_ID;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_TITLE;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel;
|
||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
@@ -42,10 +47,9 @@ import static org.springframework.social.alfresco.api.entities.Site.Visibility.P
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.alfresco.dataprep.UserService;
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.rest.rm.community.requests.RMUserAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
@@ -63,10 +67,10 @@ import org.testng.annotations.Test;
|
||||
public class RMSiteTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
/**
|
||||
* Given that RM module is installed
|
||||
@@ -79,9 +83,6 @@ public class RMSiteTests extends BaseRestTest
|
||||
)
|
||||
public void createRMSiteAsAdminUser() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if the RM site exists
|
||||
if (getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
@@ -90,14 +91,10 @@ public class RMSiteTests extends BaseRestTest
|
||||
}
|
||||
|
||||
// Create the RM site
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
|
||||
RMSiteModel rmSiteResponse = getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
RMSiteModel rmSiteResponse = getRMSiteAPI().createRMSite(createStandardRMSiteModel());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSiteResponse.getId(), RM_ID);
|
||||
@@ -105,7 +102,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
assertEquals(rmSiteResponse.getDescription(), RM_DESCRIPTION);
|
||||
assertEquals(rmSiteResponse.getCompliance(), STANDARD);
|
||||
assertEquals(rmSiteResponse.getVisibility(), PUBLIC);
|
||||
assertEquals(rmSiteResponse.getRole(), UserRole.SiteManager.toString());
|
||||
assertEquals(rmSiteResponse.getRole(), SiteManager.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,9 +119,6 @@ public class RMSiteTests extends BaseRestTest
|
||||
// Create the RM site if it does not exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Construct new properties
|
||||
String newTitle = RM_TITLE + "createRMSiteWhenSiteExists";
|
||||
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
||||
@@ -137,7 +131,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CONFLICT);
|
||||
assertStatusCode(CONFLICT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,14 +145,11 @@ public class RMSiteTests extends BaseRestTest
|
||||
)
|
||||
public void deleteRMSite() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Delete the RM site
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,14 +163,11 @@ public class RMSiteTests extends BaseRestTest
|
||||
)
|
||||
public void getRMSite() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if RM site exists
|
||||
if (!getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
// Verify the status code when RM site doesn't exist
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCode(NOT_FOUND);
|
||||
createRMSiteIfNotExists();
|
||||
}
|
||||
else
|
||||
@@ -188,7 +176,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
RMSiteModel rmSiteModel = getRMSiteAPI().getSite();
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
|
||||
assertEquals(rmSiteModel.getCompliance(), STANDARD);
|
||||
@@ -208,9 +196,6 @@ public class RMSiteTests extends BaseRestTest
|
||||
@Bug (id="RM-4289")
|
||||
public void createRMSiteAsAnotherAdminUser() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if the RM site exists
|
||||
if (getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
@@ -218,32 +203,14 @@ public class RMSiteTests extends BaseRestTest
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
}
|
||||
|
||||
// Disconnect the current user from the API session
|
||||
disconnect();
|
||||
|
||||
// Create user
|
||||
userService.create(dataUser.getAdminUser().getUsername(),
|
||||
dataUser.getAdminUser().getPassword(),
|
||||
ANOTHER_ADMIN,
|
||||
DEFAULT_PASSWORD,
|
||||
DEFAULT_EMAIL,
|
||||
ANOTHER_ADMIN,
|
||||
ANOTHER_ADMIN);
|
||||
|
||||
// Build the user model
|
||||
UserModel userModel = new UserModel(ANOTHER_ADMIN,DEFAULT_PASSWORD);
|
||||
|
||||
// Authenticate as that new user
|
||||
authenticateUser(userModel);
|
||||
rmUserAPI.createUser(ANOTHER_ADMIN);
|
||||
|
||||
// Create the RM site
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(DOD5015).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
rmSiteModel = getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
RMSiteModel rmSiteModel = getRMSiteAPI(new UserModel(ANOTHER_ADMIN, DEFAULT_PASSWORD)).createRMSite(createDOD5015RMSiteModel());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(CREATED);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
@@ -251,7 +218,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
|
||||
assertEquals(rmSiteModel.getCompliance(), DOD5015);
|
||||
assertEquals(rmSiteModel.getVisibility(), PUBLIC);
|
||||
assertEquals(rmSiteModel.getRole(), UserRole.SiteManager.toString());
|
||||
assertEquals(rmSiteModel.getRole(), SiteManager.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,14 +229,11 @@ public class RMSiteTests extends BaseRestTest
|
||||
* Then RM site details are updated
|
||||
*/
|
||||
@Test
|
||||
public void updateRMSiteDetails()throws Exception
|
||||
public void updateRMSiteDetails() throws Exception
|
||||
{
|
||||
String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric();
|
||||
String NEW_DESCRIPTION = RM_DESCRIPTION + RandomData.getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the site if it does not exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
@@ -278,32 +242,17 @@ public class RMSiteTests extends BaseRestTest
|
||||
rmSiteToUpdate.setTitle(NEW_TITLE);
|
||||
rmSiteToUpdate.setDescription(NEW_DESCRIPTION);
|
||||
|
||||
// Disconnect the user from the API session
|
||||
disconnect();
|
||||
|
||||
// Create a random user
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate as that random user
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Create the RM site
|
||||
getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
getRMSiteAPI(dataUser.createRandomTestUser("testUser")).updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
|
||||
// Disconnect the user from the API session
|
||||
disconnect();
|
||||
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
assertStatusCode(FORBIDDEN);
|
||||
|
||||
// Update the RM Site
|
||||
RMSiteModel rmSiteModel = getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the response status code
|
||||
assertStatusCodeIs(OK);
|
||||
assertStatusCode(OK);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
@@ -321,19 +270,16 @@ public class RMSiteTests extends BaseRestTest
|
||||
@Test
|
||||
public void updateRMSiteComplianceAsAdmin() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the RM site if it does not exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Build the RM site properties
|
||||
RMSiteModel rmSiteToUpdate = RMSiteModel.builder().compliance(DOD5015).build();
|
||||
RMSiteModel rmSiteToUpdate = RMSiteModel.builder().compliance(DOD5015).build();
|
||||
|
||||
// Update the RM site
|
||||
getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the response status code
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.rest.rm.community.utils;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponentsUtil
|
||||
{
|
||||
private FilePlanComponentsUtil()
|
||||
{
|
||||
// Intentionally blank
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param nodeType FIXME!!!
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
private static FilePlanComponentModel createRecordModel(String nodeType)
|
||||
{
|
||||
return FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(nodeType)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public static FilePlanComponentModel createElectronicRecordModel()
|
||||
{
|
||||
return createRecordModel(CONTENT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public static FilePlanComponentModel createNonElectronicRecordModel()
|
||||
{
|
||||
return createRecordModel(NON_ELECTRONIC_RECORD_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param name FIXME!!!
|
||||
* @param type FIXME!!!
|
||||
* @param title FIXME!!!
|
||||
* @return
|
||||
*/
|
||||
public static FilePlanComponentModel createFilePlanComponentModel(String name, String type, String title)
|
||||
{
|
||||
return FilePlanComponentModel.builder()
|
||||
.name(name)
|
||||
.nodeType(type)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(title)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.rest.rm.community.utils;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
|
||||
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteCompliance;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RMSiteUtil
|
||||
{
|
||||
private RMSiteUtil()
|
||||
{
|
||||
// Intentionally blank
|
||||
}
|
||||
|
||||
/** Constants */
|
||||
public static final String RM_ID = "rm";
|
||||
public static final String RM_TITLE = "Records Management";
|
||||
public static final String RM_DESCRIPTION = "Records Management Site";
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param compliance FIXME!!!
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
private static RMSiteModel createRMSiteModel(RMSiteCompliance compliance)
|
||||
{
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(compliance).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
return rmSiteModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public static RMSiteModel createStandardRMSiteModel()
|
||||
{
|
||||
return createRMSiteModel(STANDARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public static RMSiteModel createDOD5015RMSiteModel()
|
||||
{
|
||||
return createRMSiteModel(DOD5015);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user