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/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
@@ -35,7 +34,6 @@ import org.alfresco.rest.model.RestHtmlResponse;
|
|||||||
import org.alfresco.rest.model.RestSiteModel;
|
import org.alfresco.rest.model.RestSiteModel;
|
||||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
import org.alfresco.rest.requests.search.SearchAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||||
import org.alfresco.utility.model.StatusModel;
|
import org.alfresco.utility.model.StatusModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -147,24 +145,16 @@ public class RMRestWrapper
|
|||||||
return restWrapper.withCoreAPI();
|
return restWrapper.withCoreAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the Alfresco Search API. */
|
|
||||||
public SearchAPI withSearchAPI()
|
|
||||||
{
|
|
||||||
return restWrapper.withSearchAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can handle the request sent to server by calling this method. If for example you want to sent multipart form
|
* You can handle the request sent to server by calling this method.
|
||||||
* data you can use:
|
* If for example you want to sent multipart form data you can use: <pre>
|
||||||
*
|
* restClient.configureRequestSpec()
|
||||||
* <pre>
|
* .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||||
* restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
* .addFormParam("renditions", "doclib")
|
||||||
* .addFormParam("renditions", "doclib").addFormParam("autoRename", true);
|
* .addFormParam("autoRename", true);
|
||||||
*
|
*
|
||||||
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||||
* </pre>
|
* </pre> This will create the node using the multipart data defined.
|
||||||
*
|
|
||||||
* This will create the node using the multipart data defined.
|
|
||||||
*/
|
*/
|
||||||
public RequestSpecBuilder configureRequestSpec()
|
public RequestSpecBuilder configureRequestSpec()
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
import static lombok.AccessLevel.PROTECTED;
|
||||||
@@ -33,7 +32,6 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
import org.alfresco.rest.requests.Node;
|
import org.alfresco.rest.requests.Node;
|
||||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
import org.alfresco.rest.requests.search.SearchAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
||||||
@@ -87,12 +85,6 @@ public class RestAPIFactory
|
|||||||
return getRmRestWrapper().withCoreAPI();
|
return getRmRestWrapper().withCoreAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchAPI getSearchAPI(UserModel userModel)
|
|
||||||
{
|
|
||||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
|
|
||||||
return getRmRestWrapper().withSearchAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node getNodeAPI(RepoTestModel model) throws Exception
|
public Node getNodeAPI(RepoTestModel model) throws Exception
|
||||||
{
|
{
|
||||||
return getCoreAPI(null).usingNode(model);
|
return getCoreAPI(null).usingNode(model);
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.v0;
|
package org.alfresco.rest.v0;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@@ -51,8 +50,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class SearchAPI extends BaseAPI
|
public class SearchAPI extends BaseAPI
|
||||||
{
|
{
|
||||||
/** http client factory */
|
/** http client factory */
|
||||||
@Autowired
|
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
|
||||||
|
|
||||||
/** faceted search API endpoint */
|
/** faceted search API endpoint */
|
||||||
private static final String FACETED_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/faceted/rmsearch?{1}";
|
private static final String FACETED_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/faceted/rmsearch?{1}";
|
||||||
@@ -61,26 +59,28 @@ public class SearchAPI extends BaseAPI
|
|||||||
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
|
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
|
||||||
|
|
||||||
/** RM document search filters */
|
/** RM document search filters */
|
||||||
private static final String RM_DEFAULT_RECORD_FILTERS = "records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false";
|
private static final String RM_DEFAULT_RECORD_FILTERS =
|
||||||
|
"records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform search request on search endpoint as a user.
|
* Perform search request on search endpoint as a user.
|
||||||
* <p>
|
* <p>
|
||||||
* This method is applicable only to endpoints that support HTTP GET requests and return JSON body as response.
|
* This method is applicable only to endpoints that support HTTP GET requests and return JSON body as response.
|
||||||
*
|
|
||||||
* @param searchEndpoint
|
* @param searchEndpoint
|
||||||
* @param searchUser
|
* @param searchUser
|
||||||
* @param searchPassword
|
* @param searchPassword
|
||||||
* @return search results as a {@link JSONObject}, please refer to API documentation for details
|
* @return search results as a {@link JSONObject}, please refer to API documentation for details
|
||||||
*/
|
*/
|
||||||
private JSONObject doSearch(String searchEndpoint, String searchUser, String searchPassword)
|
private JSONObject doSearch(
|
||||||
|
String searchEndpoint,
|
||||||
|
String searchUser,
|
||||||
|
String searchPassword)
|
||||||
{
|
{
|
||||||
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
|
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic rm search.
|
* Generic rm search.
|
||||||
*
|
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @param site
|
* @param site
|
||||||
@@ -88,36 +88,45 @@ public class SearchAPI extends BaseAPI
|
|||||||
* @param filters
|
* @param filters
|
||||||
* @return search results (see API reference for more details), null for any errors
|
* @return search results (see API reference for more details), null for any errors
|
||||||
*/
|
*/
|
||||||
public JSONObject rmSearch(String username, String password, String site, String query, String filters)
|
public JSONObject rmSearch(
|
||||||
|
String username,
|
||||||
|
String password,
|
||||||
|
String site,
|
||||||
|
String query,
|
||||||
|
String filters)
|
||||||
{
|
{
|
||||||
List<BasicNameValuePair> searchParameters = new ArrayList<BasicNameValuePair>();
|
List<BasicNameValuePair> searchParameters = new ArrayList<BasicNameValuePair>();
|
||||||
searchParameters.add(new BasicNameValuePair("query", query));
|
searchParameters.add(new BasicNameValuePair("query", query));
|
||||||
searchParameters.add(new BasicNameValuePair("filters", filters));
|
searchParameters.add(new BasicNameValuePair("filters", filters));
|
||||||
|
|
||||||
String requestURL = MessageFormat.format(RM_SEARCH_ENDPOINT,
|
String requestURL = MessageFormat.format(
|
||||||
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(), (site != null) ? site : RM_SITE_ID,
|
RM_SEARCH_ENDPOINT,
|
||||||
|
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(),
|
||||||
|
(site != null) ? site : RM_SITE_ID,
|
||||||
URLEncodedUtils.format(searchParameters, "UTF-8"));
|
URLEncodedUtils.format(searchParameters, "UTF-8"));
|
||||||
|
|
||||||
return doSearch(requestURL, username, password);
|
return doSearch(requestURL, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search as a user for records on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS <br>
|
* Search as a user for records on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS
|
||||||
|
* <br>
|
||||||
* If more fine-grained control of search parameters is required, use rmSearch() directly.
|
* If more fine-grained control of search parameters is required, use rmSearch() directly.
|
||||||
*
|
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @param query
|
* @param query
|
||||||
* @return list of record names
|
* @return list of record names
|
||||||
*/
|
*/
|
||||||
public List<String> searchForRecordsAsUser(String username, String password, String query)
|
public List<String> searchForRecordsAsUser(
|
||||||
|
String username,
|
||||||
|
String password,
|
||||||
|
String query)
|
||||||
{
|
{
|
||||||
return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_RECORD_FILTERS));
|
return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_RECORD_FILTERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic faceted search.
|
* Generic faceted search.
|
||||||
*
|
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @param parameters
|
* @param parameters
|
||||||
@@ -130,7 +139,6 @@ public class SearchAPI extends BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute faceted search for term.
|
* Execute faceted search for term.
|
||||||
*
|
|
||||||
* @param searchUser
|
* @param searchUser
|
||||||
* @param searchPassword
|
* @param searchPassword
|
||||||
* @param searchTerm
|
* @param searchTerm
|
||||||
@@ -138,12 +146,14 @@ public class SearchAPI extends BaseAPI
|
|||||||
*/
|
*/
|
||||||
public JSONObject facetedSearchForTerm(String searchUser, String searchPassword, String searchTerm)
|
public JSONObject facetedSearchForTerm(String searchUser, String searchPassword, String searchTerm)
|
||||||
{
|
{
|
||||||
return facetedSearch(searchUser, searchPassword, Arrays.asList(new BasicNameValuePair("term", searchTerm)));
|
return facetedSearch(
|
||||||
|
searchUser,
|
||||||
|
searchPassword,
|
||||||
|
Arrays.asList(new BasicNameValuePair("term", searchTerm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to search for documents as a user using faceted search.
|
* Helper method to search for documents as a user using faceted search.
|
||||||
*
|
|
||||||
* @param username to search as
|
* @param username to search as
|
||||||
* @param password for username
|
* @param password for username
|
||||||
* @param term search term
|
* @param term search term
|
||||||
@@ -156,7 +166,6 @@ public class SearchAPI extends BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract list of names from search result.
|
* Helper method to extract list of names from search result.
|
||||||
*
|
|
||||||
* @param searchResult
|
* @param searchResult
|
||||||
* @return list of document or record names in search result
|
* @return list of document or record names in search result
|
||||||
* @throws RuntimeException for malformed search response
|
* @throws RuntimeException for malformed search response
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.base;
|
package org.alfresco.rest.rm.community.base;
|
||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
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.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.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.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_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_FOLDER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_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_CONTAINER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_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.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.createRecordCategoryChildModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
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 java.util.List;
|
||||||
|
|
||||||
import org.alfresco.dataprep.ContentService;
|
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.rest.RestTest;
|
||||||
import org.alfresco.rest.core.RestAPIFactory;
|
import org.alfresco.rest.core.RestAPIFactory;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
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.model.unfiledcontainer.UnfiledContainerChild;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
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.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.rm.community.requests.gscore.api.RecordsAPI;
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.utility.data.DataUser;
|
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.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -101,14 +92,6 @@ public class BaseRMRestTest extends RestTest
|
|||||||
@Getter (value = PROTECTED)
|
@Getter (value = PROTECTED)
|
||||||
private DataUser dataUser;
|
private DataUser dataUser;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Getter(value = PROTECTED)
|
|
||||||
private ContentService contentService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Getter(value = PROTECTED)
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts the given status code
|
* Asserts the given status code
|
||||||
*
|
*
|
||||||
@@ -133,15 +116,15 @@ public class BaseRMRestTest extends RestTest
|
|||||||
@DataProvider(name = "validRootContainers")
|
@DataProvider(name = "validRootContainers")
|
||||||
public String[][] getValidRootContainers() throws Exception
|
public String[][] getValidRootContainers() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][] {
|
return new String[][]
|
||||||
|
{
|
||||||
// an arbitrary record folder
|
// an arbitrary record folder
|
||||||
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE},
|
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE},
|
||||||
// unfiled records root
|
// unfiled records root
|
||||||
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE},
|
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE},
|
||||||
// an arbitrary unfiled records folder
|
// an arbitrary unfiled records folder
|
||||||
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
|
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(), UNFILED_RECORD_FOLDER_TYPE }
|
||||||
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(),
|
};
|
||||||
UNFILED_RECORD_FOLDER_TYPE } };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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
|
public void createRMSiteIfNotExists() throws Exception
|
||||||
{
|
{
|
||||||
@@ -220,12 +204,10 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created category
|
* @return The created category
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle)
|
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
|
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
|
||||||
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel,
|
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS);
|
||||||
FILE_PLAN_ALIAS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,12 +220,10 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created {@link RecordCategoryChild}
|
* @return The created {@link RecordCategoryChild}
|
||||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||||
*/
|
*/
|
||||||
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name,
|
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name, String type) throws Exception
|
||||||
String type) throws Exception
|
|
||||||
{
|
{
|
||||||
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
|
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
|
||||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel,
|
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel, recordCategoryId);
|
||||||
recordCategoryId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,8 +235,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created {@link RecordCategoryChild}
|
* @return The created {@link RecordCategoryChild}
|
||||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||||
*/
|
*/
|
||||||
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type)
|
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type);
|
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
|
public RecordCategoryChild createFolder(UserModel user, String recordCategoryId, String name) throws Exception
|
||||||
{
|
{
|
||||||
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
|
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
|
||||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel,
|
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel, recordCategoryId);
|
||||||
recordCategoryId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,12 +303,10 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created folder
|
* @return The created folder
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName,
|
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
||||||
String nodeType) throws Exception
|
|
||||||
{
|
{
|
||||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||||
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user)
|
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(childModel, parentId);
|
||||||
.createUnfiledRecordFolderChild(childModel, parentId);
|
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
return child;
|
return child;
|
||||||
@@ -344,8 +320,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created folder
|
* @return The created folder
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType)
|
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
|
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
|
||||||
}
|
}
|
||||||
@@ -360,16 +335,14 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created chid
|
* @return The created chid
|
||||||
* @throws Exception on unsuccessful child creation
|
* @throws Exception on unsuccessful child creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName,
|
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
||||||
String nodeType) throws Exception
|
|
||||||
{
|
{
|
||||||
UnfiledContainerChild child = null;
|
UnfiledContainerChild child = null;
|
||||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||||
|
|
||||||
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
||||||
{
|
{
|
||||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId,
|
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
||||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -389,8 +362,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created chid
|
* @return The created chid
|
||||||
* @throws Exception on unsuccessful child creation
|
* @throws Exception on unsuccessful child creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType)
|
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
|
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
|
||||||
}
|
}
|
||||||
@@ -405,9 +377,11 @@ public class BaseRMRestTest extends RestTest
|
|||||||
protected RecordFolder closeFolder(String folderId) throws Exception
|
protected RecordFolder closeFolder(String folderId) throws Exception
|
||||||
{
|
{
|
||||||
RecordFolder recordFolderModel = RecordFolder.builder()
|
RecordFolder recordFolderModel = RecordFolder.builder()
|
||||||
.properties(RecordFolderProperties.builder().isClosed(true).build()).build();
|
.properties(RecordFolderProperties.builder()
|
||||||
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel,
|
.isClosed(true)
|
||||||
folderId);
|
.build())
|
||||||
|
.build();
|
||||||
|
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel, folderId);
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
return updateRecordFolder;
|
return updateRecordFolder;
|
||||||
@@ -494,68 +468,4 @@ public class BaseRMRestTest extends RestTest
|
|||||||
{
|
{
|
||||||
return getFilePlanAsUser(getAdminUser(), componentId);
|
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