format java code

This commit is contained in:
Marcello Teodori
2021-10-19 18:14:57 +02:00
parent fa4613d452
commit 6f0466a909
6726 changed files with 988330 additions and 943957 deletions

View File

@@ -26,12 +26,12 @@
*/
package org.alfresco.rest.core;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import lombok.Getter;
/**
* Extends {@link RestProperties} to be able to change/add properties
*
@@ -43,20 +43,19 @@ import lombok.Getter;
@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"})
@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true)
@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true)
public class RMRestProperties extends RestProperties
{
@Value ("${alfresco.scheme}")
public class RMRestProperties extends RestProperties {
@Value("${alfresco.scheme}")
private String scheme;
@Value ("${alfresco.server}")
@Value("${alfresco.server}")
private String server;
@Value ("${alfresco.port}")
@Value("${alfresco.port}")
private String port;
@Value ("${rest.rmPath}")
@Value("${rest.rmPath}")
private String restRmPath;
@Value ("${docker.host}")
@Value("${docker.host}")
private String dockerHost;
}

View File

@@ -28,6 +28,8 @@ package org.alfresco.rest.core;
import io.restassured.builder.RequestSpecBuilder;
import lombok.Getter;
import org.alfresco.rest.exception.EmptyJsonResponseException;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestHtmlResponse;
@@ -43,8 +45,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import lombok.Getter;
/**
* Extends {@link RestWrapper} in order to call GS APIs with our own properties
*
@@ -53,118 +53,105 @@ import lombok.Getter;
*/
@Service
@Scope(value = "prototype")
public class RMRestWrapper
{
public class RMRestWrapper {
/** The class that wraps the ReST APIs from core. */
@Autowired
private RestWrapper restWrapper;
@Autowired private RestWrapper restWrapper;
@Autowired
@Getter
private RMRestProperties rmRestProperties;
@Autowired @Getter private RMRestProperties rmRestProperties;
public GSCoreAPI withGSCoreAPI()
{
public GSCoreAPI withGSCoreAPI() {
return new GSCoreAPI(this, getRmRestProperties());
}
/** Get the core class that wraps the ReST APIs. */
public RestWrapper getRestWrapper()
{
public RestWrapper getRestWrapper() {
return restWrapper;
}
/** Authenticate specific user to Alfresco REST API */
public void authenticateUser(UserModel userModel)
{
public void authenticateUser(UserModel userModel) {
restWrapper.authenticateUser(userModel);
}
/** Get the last error thrown (if any). */
public RestErrorModel assertLastError()
{
public RestErrorModel assertLastError() {
return restWrapper.assertLastError();
}
/** Process responses for a collection of models as {@link RestSiteModelsCollection}. */
public <T> T processModels(Class<T> classz, RestRequest simpleRequest)
{
public <T> T processModels(Class<T> classz, RestRequest simpleRequest) {
return restWrapper.processModels(classz, simpleRequest);
}
/** Process responses for a single model as {@link RestSiteModel}. */
public <T> T processModel(Class<T> classz, RestRequest restRequest)
{
public <T> T processModel(Class<T> classz, RestRequest restRequest) {
return restWrapper.processModel(classz, restRequest);
}
/** Process a response that has no body - basically will need only the status code from it. */
public void processEmptyModel(RestRequest simpleRequest)
{
public void processEmptyModel(RestRequest simpleRequest) {
restWrapper.processEmptyModel(simpleRequest);
}
/** Get the most recently returned status object. */
public StatusModel getLastStatus()
{
public StatusModel getLastStatus() {
return restWrapper.getLastStatus();
}
/** Get the most recently returned status code. */
public String getStatusCode()
{
public String getStatusCode() {
return restWrapper.getStatusCode();
}
/** Set the status code. This should only be needed when calling APIs without using the TAS framework. */
public void setStatusCode(String statusCode)
{
/**
* Set the status code. This should only be needed when calling APIs without using the TAS
* framework.
*/
public void setStatusCode(String statusCode) {
restWrapper.setStatusCode(statusCode);
}
/** Assert that a specific status code is returned. */
public void assertStatusCodeIs(HttpStatus statusCode)
{
public void assertStatusCodeIs(HttpStatus statusCode) {
restWrapper.assertStatusCodeIs(statusCode);
}
/** @return A parameters string that you could pass on the request ?param=value */
public String getParameters()
{
public String getParameters() {
return restWrapper.getParameters();
}
/** Create a {@link UserModel} for a new test user. */
public UserModel getTestUser()
{
public UserModel getTestUser() {
return restWrapper.getTestUser();
}
/** Get the Alfresco Core API. */
public RestCoreAPI withCoreAPI()
{
public RestCoreAPI withCoreAPI() {
return restWrapper.withCoreAPI();
}
/** Get the Alfresco Search API. */
public SearchAPI withSearchAPI()
{
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 data you can use: <pre>
* You can handle the request sent to server by calling this method. If for example you want to
* sent multipart form data you can use:
*
* <pre>
* restClient.configureRequestSpec()
* .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
* .addFormParam("renditions", "doclib")
* .addFormParam("autoRename", true);
*
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
* </pre> This will create the node using the multipart data defined.
* </pre>
*
* This will create the node using the multipart data defined.
*/
public RequestSpecBuilder configureRequestSpec()
{
public RequestSpecBuilder configureRequestSpec() {
return restWrapper.configureRequestSpec();
}
@@ -173,8 +160,7 @@ public class RMRestWrapper
*
* @throws EmptyJsonResponseException If there is no response from the server.
*/
public RestHtmlResponse processHtmlResponse(RestRequest simpleRequest)
{
public RestHtmlResponse processHtmlResponse(RestRequest simpleRequest) {
return restWrapper.processHtmlResponse(simpleRequest);
}
}

View File

@@ -28,10 +28,9 @@ package org.alfresco.rest.core;
import static lombok.AccessLevel.PROTECTED;
import javax.annotation.Resource;
import lombok.Getter;
import lombok.Setter;
import org.alfresco.rest.requests.Node;
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
import org.alfresco.rest.requests.search.SearchAPI;
@@ -55,6 +54,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* REST API Factory which provides access to the APIs
*
@@ -63,10 +64,9 @@ import org.springframework.stereotype.Service;
*/
@Service
@Scope(value = "prototype")
public class RestAPIFactory
{
public class RestAPIFactory {
@Autowired
@Getter (value = PROTECTED)
@Getter(value = PROTECTED)
private DataUserAIS dataUser;
@Resource(name = "RMRestWrapper")
@@ -74,173 +74,138 @@ public class RestAPIFactory
@Setter
private RMRestWrapper rmRestWrapper;
private GSCoreAPI getGSCoreAPI(UserModel userModel)
{
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
private GSCoreAPI getGSCoreAPI(UserModel userModel) {
getRmRestWrapper()
.authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
return getRmRestWrapper().withGSCoreAPI();
}
private RestCoreAPI getCoreAPI(UserModel userModel)
{
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
private RestCoreAPI getCoreAPI(UserModel userModel) {
getRmRestWrapper()
.authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
return getRmRestWrapper().withCoreAPI();
}
public SearchAPI getSearchAPI(UserModel userModel)
{
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
public SearchAPI getSearchAPI(UserModel userModel) {
getRmRestWrapper()
.authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
return getRmRestWrapper().withSearchAPI();
}
/**
* When no user is given the default is set to admin
*/
public SearchAPI getSearchAPI()
{
/** When no user is given the default is set to admin */
public SearchAPI getSearchAPI() {
return getSearchAPI(null);
}
public Node getNodeAPI(RepoTestModel model) throws RuntimeException
{
try
{
public Node getNodeAPI(RepoTestModel model) throws RuntimeException {
try {
return getCoreAPI(null).usingNode(model);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException("Failed to load nodeAPI.", e);
}
}
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws RuntimeException
{
try
{
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws RuntimeException {
try {
return getCoreAPI(userModel).usingNode(model);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException("Failed to load nodeAPI.", e);
}
}
public RMSiteAPI getRMSiteAPI()
{
public RMSiteAPI getRMSiteAPI() {
return getGSCoreAPI(null).usingRMSite();
}
public RMSiteAPI getRMSiteAPI(UserModel userModel)
{
public RMSiteAPI getRMSiteAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingRMSite();
}
public FilePlanAPI getFilePlansAPI()
{
public FilePlanAPI getFilePlansAPI() {
return getGSCoreAPI(null).usingFilePlans();
}
public FilePlanAPI getFilePlansAPI(UserModel userModel)
{
public FilePlanAPI getFilePlansAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingFilePlans();
}
public RecordCategoryAPI getRecordCategoryAPI()
{
public RecordCategoryAPI getRecordCategoryAPI() {
return getGSCoreAPI(null).usingRecordCategory();
}
public RecordCategoryAPI getRecordCategoryAPI(UserModel userModel)
{
public RecordCategoryAPI getRecordCategoryAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingRecordCategory();
}
public RecordFolderAPI getRecordFolderAPI()
{
public RecordFolderAPI getRecordFolderAPI() {
return getGSCoreAPI(null).usingRecordFolder();
}
public RecordFolderAPI getRecordFolderAPI(UserModel userModel)
{
public RecordFolderAPI getRecordFolderAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingRecordFolder();
}
public RecordsAPI getRecordsAPI()
{
public RecordsAPI getRecordsAPI() {
return getGSCoreAPI(null).usingRecords();
}
public RecordsAPI getRecordsAPI(UserModel userModel)
{
public RecordsAPI getRecordsAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingRecords();
}
public FilesAPI getFilesAPI()
{
public FilesAPI getFilesAPI() {
return getGSCoreAPI(null).usingFiles();
}
public FilesAPI getFilesAPI(UserModel userModel)
{
public FilesAPI getFilesAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingFiles();
}
public TransferContainerAPI getTransferContainerAPI()
{
public TransferContainerAPI getTransferContainerAPI() {
return getGSCoreAPI(null).usingTransferContainer();
}
public TransferContainerAPI getTransferContainerAPI(UserModel userModel)
{
public TransferContainerAPI getTransferContainerAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingTransferContainer();
}
public TransferAPI getTransferAPI()
{
public TransferAPI getTransferAPI() {
return getGSCoreAPI(null).usingTransfer();
}
public TransferAPI getTransferAPI(UserModel userModel)
{
public TransferAPI getTransferAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingTransfer();
}
public RMUserAPI getRMUserAPI()
{
public RMUserAPI getRMUserAPI() {
return getGSCoreAPI(null).usingRMUser();
}
public RMUserAPI getRMUserAPI(UserModel userModel)
{
public RMUserAPI getRMUserAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingRMUser();
}
public UnfiledContainerAPI getUnfiledContainersAPI()
{
public UnfiledContainerAPI getUnfiledContainersAPI() {
return getGSCoreAPI(null).usingUnfiledContainers();
}
public UnfiledContainerAPI getUnfiledContainersAPI(UserModel userModel)
{
public UnfiledContainerAPI getUnfiledContainersAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingUnfiledContainers();
}
public UnfiledRecordFolderAPI getUnfiledRecordFoldersAPI()
{
public UnfiledRecordFolderAPI getUnfiledRecordFoldersAPI() {
return getGSCoreAPI(null).usingUnfiledRecordFolder();
}
public UnfiledRecordFolderAPI getUnfiledRecordFoldersAPI(UserModel userModel)
{
public UnfiledRecordFolderAPI getUnfiledRecordFoldersAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingUnfiledRecordFolder();
}
public ActionsExecutionAPI getActionsAPI(UserModel userModel)
{
public ActionsExecutionAPI getActionsAPI(UserModel userModel) {
return getGSCoreAPI(userModel).usingActionsExecutionsAPI();
}
public ActionsExecutionAPI getActionsAPI()
{
public ActionsExecutionAPI getActionsAPI() {
return getGSCoreAPI(null).usingActionsExecutionsAPI();
}
}

View File

@@ -26,32 +26,25 @@
*/
package org.alfresco.rest.core.search;
import java.util.List;
import org.alfresco.rest.search.Pagination;
import org.alfresco.rest.search.RestRequestQueryModel;
import org.alfresco.rest.search.SearchRequest;
/**
* Builder class for creating a search api request
*/
public class SearchRequestBuilder extends SearchRequest
{
/**
* Constructor for Search API Request
*/
public SearchRequestBuilder()
{
import java.util.List;
/** Builder class for creating a search api request */
public class SearchRequestBuilder extends SearchRequest {
/** Constructor for Search API Request */
public SearchRequestBuilder() {
new SearchRequest();
}
/**
* Set the sql statement for the SearchRequest
*
* @param query sql statement
* @return search request
* @return search request
*/
public SearchRequestBuilder setQueryBuilder(RestRequestQueryModel query)
{
public SearchRequestBuilder setQueryBuilder(RestRequestQueryModel query) {
super.setQuery(query);
return this;
}
@@ -62,17 +55,13 @@ public class SearchRequestBuilder extends SearchRequest
* @param paging pagination requested
* @return search request
*/
public SearchRequestBuilder setPagingBuilder(Pagination paging)
{
public SearchRequestBuilder setPagingBuilder(Pagination paging) {
super.setPaging(paging);
return this;
}
/**
* Set the pagination properties
*/
public Pagination setPagination(Integer maxItems, Integer skipCount)
{
/** Set the pagination properties */
public Pagination setPagination(Integer maxItems, Integer skipCount) {
Pagination pagination = new Pagination();
pagination.setMaxItems(maxItems);
pagination.setSkipCount(skipCount);
@@ -85,10 +74,8 @@ public class SearchRequestBuilder extends SearchRequest
* @param fields requested fields
* @return search request
*/
public SearchRequestBuilder setFieldsBuilder(List<String> fields)
{
public SearchRequestBuilder setFieldsBuilder(List<String> fields) {
super.setFields(fields);
return this;
}
}

View File

@@ -26,13 +26,6 @@
*/
package org.alfresco.rest.core.v0;
import javax.json.Json;
import javax.json.JsonReader;
import java.io.IOException;
import java.io.InputStream;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -42,25 +35,33 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import javax.json.Json;
import javax.json.JsonReader;
/**
* Helper methods for use with REST APIs.
*
* @author Tom Page
* @since 2.6
*/
public class APIUtils
{
public class APIUtils {
/** Logger for this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(APIUtils.class);
/** The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:305Z'
* similar with {@link DateTimeFormatter#ISO_INSTANT}, but with only 3 nanoseconds*/
/**
* The ISO instant formatter that formats or parses an instant in UTC, such as
* '2011-12-03T10:15:305Z' similar with {@link DateTimeFormatter#ISO_INSTANT}, but with only 3
* nanoseconds
*/
public static final DateTimeFormatter ISO_INSTANT_FORMATTER =
new DateTimeFormatterBuilder().appendInstant(3).toFormatter();
/** Private constructor for helper class. */
private APIUtils()
{
}
private APIUtils() {}
/**
* Extract the body of a HTTP response as a JSON object.
@@ -68,15 +69,11 @@ public class APIUtils
* @param httpResponse The HTTP response.
* @return A JSON representation of the object.
*/
public static JSONObject convertHTTPResponseToJSON(HttpResponse httpResponse)
{
public static JSONObject convertHTTPResponseToJSON(HttpResponse httpResponse) {
String source = null;
try
{
try {
source = IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8");
}
catch (IOException e)
{
} catch (IOException e) {
throw new IllegalArgumentException("Could not extract JSON from HTTP response.", e);
}
LOGGER.info("Response body:\n{}", source);
@@ -89,30 +86,21 @@ public class APIUtils
* @param httpResponse http response
* @return error message from the http response
*/
public static String extractErrorMessageFromHttpResponse(HttpResponse httpResponse)
{
public static String extractErrorMessageFromHttpResponse(HttpResponse httpResponse) {
final HttpEntity entity = httpResponse.getEntity();
JsonReader reader = null;
try
{
try {
final InputStream responseStream = entity.getContent();
reader = Json.createReader(responseStream);
return reader.readObject().getString("message");
}
catch (JSONException error)
{
} catch (JSONException error) {
LOGGER.error("Converting message body to JSON failed. Body: {}", httpResponse, error);
}
catch (ParseException | IOException error)
{
} catch (ParseException | IOException error) {
LOGGER.error("Parsing message body failed.", error);
}
finally
{
if (reader != null)
{
} finally {
if (reader != null) {
reader.close();
}
}

View File

@@ -29,16 +29,6 @@ package org.alfresco.rest.core.v0;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.dataprep.ContentService;
@@ -64,33 +54,42 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The base API class containing common methods for making v0 API requests
*
* @author Kristijan Conkas
* @since 2.5
*/
public abstract class BaseAPI
{
public abstract class BaseAPI {
// logger
protected static final Logger LOGGER = LoggerFactory.getLogger(BaseAPI.class);
/** exception key in JSON response body */
private static final String EXCEPTION_KEY = "exception";
private static final String MESSAGE_KEY = "message";
public static final String NODE_PREFIX = "workspace/SpacesStore/";
protected static final String UPDATE_METADATA_API = "{0}node/{1}/formprocessor";
protected static final String ACTIONS_API = "{0}actionQueue";
protected static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
public static final String RM_SITE_ID = "rm";
protected static final String SHARE_ACTION_API = "{0}internal/shared/share/workspace/SpacesStore/{1}";
protected static final String SHARE_ACTION_API =
"{0}internal/shared/share/workspace/SpacesStore/{1}";
private static final String SLINGSHOT_PREFIX = "alfresco/s/slingshot/";
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired
protected ContentService contentService;
@Autowired protected ContentService contentService;
public static final String NODE_REF_WORKSPACE_SPACES_STORE = "workspace://SpacesStore/";
private static final String FILE_PLAN_PATH = "/Sites/rm/documentLibrary";
@@ -102,20 +101,15 @@ public abstract class BaseAPI
* @return list of specified property values in result
* @throws RuntimeException for malformed response
*/
protected List<String> getPropertyValues(JSONObject result, String propertyName)
{
protected List<String> getPropertyValues(JSONObject result, String propertyName) {
ArrayList<String> results = new ArrayList<>();
try
{
try {
JSONArray items = result.getJSONArray("items");
for (int i = 0; i < items.length(); i++)
{
for (int i = 0; i < items.length(); i++) {
results.add(items.getJSONObject(i).getString(propertyName));
}
}
catch (JSONException error)
{
} catch (JSONException error) {
throw new RuntimeException("Unable to parse result", error);
}
@@ -124,62 +118,55 @@ public abstract class BaseAPI
/**
* Helper method to extract the property value for the given nodeRef and property name
*
*
* @param result
* @param nodeRef
* @param propertyName
* @return
*/
protected String getPropertyValue(JSONObject result, String nodeRef, String propertyName)
{
protected String getPropertyValue(JSONObject result, String nodeRef, String propertyName) {
String propertyValue = "";
try
{
try {
JSONArray items = result.getJSONArray("items");
for (int i = 0; i < items.length(); i++)
{
for (int i = 0; i < items.length(); i++) {
JSONObject item = items.getJSONObject(i);
if(nodeRef.equals(item.getString("nodeRef")))
{
if (nodeRef.equals(item.getString("nodeRef"))) {
propertyValue = item.getJSONObject("properties").getString(propertyName);
}
}
}
catch (JSONException error)
{
} catch (JSONException error) {
throw new RuntimeException("Unable to parse result", error);
}
return propertyValue;
}
/**
* Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.
* Helper method to extract property values from request result and put them in map as a list
* that corresponds to a unique property value.
*
* @param requestResult the request response
* @return a map containing information about multiple properties values that correspond to a unique one
* @return a map containing information about multiple properties values that correspond to a
* unique one
* @throws RuntimeException for malformed response
*/
protected Map<String, List<String>> getPropertyValuesByUniquePropertyValue(JSONObject requestResult, String uniqueProperty, List<String> otherProperties)
{
protected Map<String, List<String>> getPropertyValuesByUniquePropertyValue(
JSONObject requestResult, String uniqueProperty, List<String> otherProperties) {
Map<String, List<String>> valuesByUniqueProperty = new HashMap<>();
try
{
try {
JSONArray items = requestResult.getJSONArray("items");
for (int i = 0; i < items.length(); i++)
{
for (int i = 0; i < items.length(); i++) {
List<String> otherPropertiesValues = new ArrayList<>();
for (int j = 0; j < otherProperties.size(); j++)
{
otherPropertiesValues.add(items.getJSONObject(i).get(otherProperties.get(j)).toString());
for (int j = 0; j < otherProperties.size(); j++) {
otherPropertiesValues.add(
items.getJSONObject(i).get(otherProperties.get(j)).toString());
}
valuesByUniqueProperty.put(items.getJSONObject(i).getString(uniqueProperty), otherPropertiesValues);
valuesByUniqueProperty.put(
items.getJSONObject(i).getString(uniqueProperty), otherPropertiesValues);
}
}
catch (JSONException error)
{
} catch (JSONException error) {
throw new RuntimeException("Unable to parse result", error);
}
@@ -191,13 +178,12 @@ public abstract class BaseAPI
*
* @param username the username
* @param password the password
* @param path the path to the container eg. in case of a category it would be the category name,
* in case of a folder it would be /categoryName/folderName
* when trying to get File Plan, the path would be ""
* @param path the path to the container eg. in case of a category it would be the category
* name, in case of a folder it would be /categoryName/folderName when trying to get File
* Plan, the path would be ""
* @return the container nodeRef
*/
public String getItemNodeRef(String username, String password, String path)
{
public String getItemNodeRef(String username, String password, String path) {
return contentService.getNodeRefByPath(username, password, FILE_PLAN_PATH + path);
}
@@ -206,17 +192,14 @@ public abstract class BaseAPI
*
* @param username the user's username
* @param password its password
* @param path the object path
* @param path the object path
* @return the object in case it exists, null if its does not exist
*/
protected CmisObject getObjectByPath(String username, String password, String path)
{
protected CmisObject getObjectByPath(String username, String password, String path) {
CmisObject object;
try
{
try {
object = contentService.getCMISSession(username, password).getObjectByPath(path);
} catch (CmisObjectNotFoundException notFoundError)
{
} catch (CmisObjectNotFoundException notFoundError) {
return null;
}
return object;
@@ -230,23 +213,19 @@ public abstract class BaseAPI
* @param parameters if the request has parameters
* @return result object (see API reference for more details), null for any errors
*/
protected JSONObject facetedRequest(String username, String password, List<NameValuePair> parameters, String requestURI)
{
protected JSONObject facetedRequest(
String username, String password, List<NameValuePair> parameters, String requestURI) {
String requestURL;
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
if (parameters == null || parameters.isEmpty())
{
requestURL = MessageFormat.format(
requestURI,
client.getAlfrescoUrl());
}
else
{
requestURL = MessageFormat.format(
requestURI,
client.getAlfrescoUrl(),
URLEncodedUtils.format(parameters, "UTF-8"));
if (parameters == null || parameters.isEmpty()) {
requestURL = MessageFormat.format(requestURI, client.getAlfrescoUrl());
} else {
requestURL =
MessageFormat.format(
requestURI,
client.getAlfrescoUrl(),
URLEncodedUtils.format(parameters, "UTF-8"));
}
LOGGER.info("On GET {}, received following response: ", requestURL);
client.close();
@@ -255,89 +234,77 @@ public abstract class BaseAPI
/**
* Helper method for GET requests
*
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected JSONObject doGetRequest(String adminUser,
String adminPassword,
String urlTemplate,
String ... urlTemplateParams)
{
protected JSONObject doGetRequest(
String adminUser,
String adminPassword,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String requestUrl = MessageFormat.format(
urlTemplate,
client.getApiUrl(),
urlTemplateParams);
String requestUrl =
MessageFormat.format(urlTemplate, client.getApiUrl(), urlTemplateParams);
client.close();
try
{
try {
return doRequest(HttpGet.class, requestUrl, adminUser, adminPassword, null);
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doGetRequest failed", error);
}
}
/**
* Helper method for Delete requests
*
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected JSONObject doDeleteRequest(String adminUser,
String adminPassword,
String urlTemplate,
String ... urlTemplateParams)
{
protected JSONObject doDeleteRequest(
String adminUser,
String adminPassword,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String requestUrl = MessageFormat.format(
urlTemplate,
client.getApiUrl(),
urlTemplateParams);
String requestUrl =
MessageFormat.format(urlTemplate, client.getApiUrl(), urlTemplateParams);
client.close();
try
{
try {
return doRequest(HttpDelete.class, requestUrl, adminUser, adminPassword, null);
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doDeleteRequest failed", error);
}
}
/**
* Helper method for PUT requests
*
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param requestParams zero or more endpoint specific request parameters
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected JSONObject doPutRequest(String adminUser,
String adminPassword,
JSONObject requestParams,
String urlTemplate,
String ... urlTemplateParams)
{
protected JSONObject doPutRequest(
String adminUser,
String adminPassword,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String requestUrl = MessageFormat.format(
urlTemplate,
client.getApiUrl(),
urlTemplateParams);
String requestUrl =
MessageFormat.format(urlTemplate, client.getApiUrl(), urlTemplateParams);
client.close();
try
{
try {
return doRequest(HttpPut.class, requestUrl, adminUser, adminPassword, requestParams);
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doPutRequest failed", error);
}
}
@@ -352,15 +319,22 @@ public abstract class BaseAPI
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected HttpResponse doPutJsonRequest(String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams)
{
protected HttpResponse doPutJsonRequest(
String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
return doPutJsonRequest(adminUser, adminPassword, expectedStatusCode, client.getApiUrl(), requestParams, urlTemplate, urlTemplateParams);
return doPutJsonRequest(
adminUser,
adminPassword,
expectedStatusCode,
client.getApiUrl(),
requestParams,
urlTemplate,
urlTemplateParams);
}
/**
@@ -375,23 +349,25 @@ public abstract class BaseAPI
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
* @throws AssertionError if the returned status code is not as expected.
*/
private HttpResponse doPutJsonRequest(String adminUser,
String adminPassword,
int expectedStatusCode,
String urlStart,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams)
{
private HttpResponse doPutJsonRequest(
String adminUser,
String adminPassword,
int expectedStatusCode,
String urlStart,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
String requestUrl = formatRequestUrl(urlStart, urlTemplate, urlTemplateParams);
try
{
HttpResponse httpResponse = doRequestJson(HttpPut.class, requestUrl, adminUser, adminPassword, requestParams);
assertEquals("PUT request to " + requestUrl + " was not successful.", expectedStatusCode, httpResponse.getStatusLine().getStatusCode());
try {
HttpResponse httpResponse =
doRequestJson(
HttpPut.class, requestUrl, adminUser, adminPassword, requestParams);
assertEquals(
"PUT request to " + requestUrl + " was not successful.",
expectedStatusCode,
httpResponse.getStatusLine().getStatusCode());
return httpResponse;
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doPutRequest failed", error);
}
}
@@ -404,10 +380,9 @@ public abstract class BaseAPI
* @param urlTemplateParams Any parameters that need to be filled into the URL template.
* @return The resultant URL.
*/
private String formatRequestUrl(String urlStart, String urlTemplate, String[] urlTemplateParams)
{
if (urlTemplateParams.length == 1)
{
private String formatRequestUrl(
String urlStart, String urlTemplate, String[] urlTemplateParams) {
if (urlTemplateParams.length == 1) {
// The format method needs some help to know not to use the whole array object.
return MessageFormat.format(urlTemplate, urlStart, urlTemplateParams[0]);
}
@@ -416,31 +391,27 @@ public abstract class BaseAPI
/**
* Helper method for POST requests
*
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param requestParams zero or more endpoint specific request parameters
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected JSONObject doPostRequest(String adminUser,
String adminPassword,
JSONObject requestParams,
String urlTemplate,
String ... urlTemplateParams)
{
protected JSONObject doPostRequest(
String adminUser,
String adminPassword,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String requestUrl = MessageFormat.format(
urlTemplate,
client.getApiUrl(),
urlTemplateParams);
String requestUrl =
MessageFormat.format(urlTemplate, client.getApiUrl(), urlTemplateParams);
client.close();
try
{
try {
return doRequest(HttpPost.class, requestUrl, adminUser, adminPassword, requestParams);
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doPostRequest failed", error);
}
}
@@ -455,15 +426,22 @@ public abstract class BaseAPI
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected HttpResponse doPostJsonRequest(String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams)
{
protected HttpResponse doPostJsonRequest(
String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
return doPostJsonRequest(adminUser, adminPassword, expectedStatusCode, client.getApiUrl(), requestParams, urlTemplate, urlTemplateParams);
return doPostJsonRequest(
adminUser,
adminPassword,
expectedStatusCode,
client.getApiUrl(),
requestParams,
urlTemplate,
urlTemplateParams);
}
/**
@@ -476,15 +454,22 @@ public abstract class BaseAPI
* @param urlTemplate request URL template
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
*/
protected HttpResponse doSlingshotPostJsonRequest(String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams)
{
protected HttpResponse doSlingshotPostJsonRequest(
String adminUser,
String adminPassword,
int expectedStatusCode,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
return doPostJsonRequest(adminUser, adminPassword, expectedStatusCode, client.getAlfrescoUrl() + SLINGSHOT_PREFIX, requestParams, urlTemplate, urlTemplateParams);
return doPostJsonRequest(
adminUser,
adminPassword,
expectedStatusCode,
client.getAlfrescoUrl() + SLINGSHOT_PREFIX,
requestParams,
urlTemplate,
urlTemplateParams);
}
/**
@@ -499,30 +484,33 @@ public abstract class BaseAPI
* @param urlTemplateParams zero or more parameters used with <i>urlTemplate</i>
* @throws AssertionError if the returned status code is not as expected.
*/
private HttpResponse doPostJsonRequest(String adminUser,
String adminPassword,
int expectedStatusCode,
String urlStart,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams)
{
private HttpResponse doPostJsonRequest(
String adminUser,
String adminPassword,
int expectedStatusCode,
String urlStart,
JSONObject requestParams,
String urlTemplate,
String... urlTemplateParams) {
String requestUrl;
requestUrl = formatRequestUrl(urlStart, urlTemplate, urlTemplateParams);
try
{
HttpResponse httpResponse = doRequestJson(HttpPost.class, requestUrl, adminUser, adminPassword, requestParams);
assertEquals("POST request to " + requestUrl + " was not successful.", expectedStatusCode, httpResponse.getStatusLine().getStatusCode());
try {
HttpResponse httpResponse =
doRequestJson(
HttpPost.class, requestUrl, adminUser, adminPassword, requestParams);
assertEquals(
"POST request to " + requestUrl + " was not successful.",
expectedStatusCode,
httpResponse.getStatusLine().getStatusCode());
return httpResponse;
}
catch (InstantiationException | IllegalAccessException error)
{
} catch (InstantiationException | IllegalAccessException error) {
throw new IllegalArgumentException("doPostRequest failed", error);
}
}
/**
* Helper method for handling generic HTTP requests
*
* @param requestType request type (a subclass of {@link HttpRequestBase})
* @param requestUrl URL the request is to be sent to
* @param adminUser user with administrative privileges
@@ -533,88 +521,76 @@ public abstract class BaseAPI
* @throws InstantiationException for invalid <i>requestType</i>
*/
private <T extends HttpRequestBase> JSONObject doRequest(
Class<T> requestType,
String requestUrl,
String adminUser,
String adminPassword,
JSONObject requestParams) throws InstantiationException, IllegalAccessException
{
Class<T> requestType,
String requestUrl,
String adminUser,
String adminPassword,
JSONObject requestParams)
throws InstantiationException, IllegalAccessException {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
T request = requestType.newInstance();
JSONObject responseBody = null;
JSONObject returnValues = null;
try
{
try {
request.setURI(new URI(requestUrl));
if (requestParams != null && request instanceof HttpEntityEnclosingRequestBase)
{
((HttpEntityEnclosingRequestBase) request).setEntity(new StringEntity(requestParams.toString()));
if (requestParams != null && request instanceof HttpEntityEnclosingRequestBase) {
((HttpEntityEnclosingRequestBase) request)
.setEntity(new StringEntity(requestParams.toString()));
}
LOGGER.info("Sending {} request to {}", requestType.getSimpleName(), requestUrl);
LOGGER.info("Request body: {}", requestParams);
HttpResponse response = client.execute(adminUser, adminPassword, request);
LOGGER.info("Response: {}", response.getStatusLine());
try
{
try {
responseBody = new JSONObject(EntityUtils.toString(response.getEntity()));
}
catch (JSONException error)
{
LOGGER.error("Converting message body to JSON failed. Body: {}", responseBody, error);
}
catch (ParseException | IOException error)
{
} catch (JSONException error) {
LOGGER.error(
"Converting message body to JSON failed. Body: {}", responseBody, error);
} catch (ParseException | IOException error) {
LOGGER.error("Parsing message body failed.", error);
}
switch (response.getStatusLine().getStatusCode())
{
switch (response.getStatusLine().getStatusCode()) {
case HttpStatus.SC_OK:
case HttpStatus.SC_CREATED:
// request successful
if (responseBody != null)
{
if (responseBody != null) {
returnValues = responseBody;
}
break;
case HttpStatus.SC_INTERNAL_SERVER_ERROR:
if (responseBody != null && responseBody.has(EXCEPTION_KEY))
{
LOGGER.error("Request failed with error message: {}", responseBody.getString(MESSAGE_KEY));
if (responseBody != null && responseBody.has(EXCEPTION_KEY)) {
LOGGER.error(
"Request failed with error message: {}",
responseBody.getString(MESSAGE_KEY));
returnValues = responseBody;
}
break;
case HttpStatus.SC_BAD_REQUEST:
case HttpStatus.SC_UNPROCESSABLE_ENTITY:
if (responseBody != null && responseBody.has(EXCEPTION_KEY))
{
if (responseBody != null && responseBody.has(EXCEPTION_KEY)) {
LOGGER.error("Request failed: {}", responseBody.getString(EXCEPTION_KEY));
returnValues = responseBody;
}
break;
default:
LOGGER.error("Request returned unexpected HTTP status {}", response.getStatusLine().getStatusCode());
LOGGER.error(
"Request returned unexpected HTTP status {}",
response.getStatusLine().getStatusCode());
break;
}
}
catch (JSONException error)
{
} catch (JSONException error) {
LOGGER.error("Unable to extract response parameter", error);
}
catch (UnsupportedEncodingException | URISyntaxException error1)
{
} catch (UnsupportedEncodingException | URISyntaxException error1) {
LOGGER.error("Unable to construct request", error1);
}
finally
{
if (request != null)
{
} finally {
if (request != null) {
request.releaseConnection();
}
client.close();
@@ -628,19 +604,18 @@ public abstract class BaseAPI
String requestUrl,
String adminUser,
String adminPassword,
JSONObject requestParams) throws InstantiationException, IllegalAccessException
{
JSONObject requestParams)
throws InstantiationException, IllegalAccessException {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
T request = requestType.newInstance();
try
{
try {
request.setURI(new URI(requestUrl));
request.setHeader("Content-Type", "application/json");
if (requestParams != null && request instanceof HttpEntityEnclosingRequestBase)
{
((HttpEntityEnclosingRequestBase) request).setEntity(new StringEntity(requestParams.toString()));
if (requestParams != null && request instanceof HttpEntityEnclosingRequestBase) {
((HttpEntityEnclosingRequestBase) request)
.setEntity(new StringEntity(requestParams.toString()));
}
LOGGER.info("Sending {} request to {}", requestType.getSimpleName(), requestUrl);
@@ -648,15 +623,10 @@ public abstract class BaseAPI
HttpResponse httpResponse = client.execute(adminUser, adminPassword, request);
LOGGER.info("Response: {}", httpResponse.getStatusLine());
return httpResponse;
}
catch (UnsupportedEncodingException | URISyntaxException error1)
{
} catch (UnsupportedEncodingException | URISyntaxException error1) {
LOGGER.error("Unable to construct request", error1);
}
finally
{
if (request != null)
{
} finally {
if (request != null) {
request.releaseConnection();
}
client.close();
@@ -665,12 +635,8 @@ public abstract class BaseAPI
return null;
}
/**
* Used to set RM items properties
* including records, categories and folders
*/
public enum RMProperty
{
/** Used to set RM items properties including records, categories and folders */
public enum RMProperty {
NAME,
TITLE,
CONTENT,
@@ -687,8 +653,7 @@ public abstract class BaseAPI
PUBLICATION_DATE
}
public enum RETENTION_SCHEDULE
{
public enum RETENTION_SCHEDULE {
NAME,
DESCRIPTION,
RETENTION_AUTHORITY,
@@ -702,11 +667,8 @@ public abstract class BaseAPI
COMBINE_DISPOSITION_STEP_CONDITIONS
}
/**
* Used to execute rm actions on a node
*/
public enum RM_ACTIONS
{
/** Used to execute rm actions on a node */
public enum RM_ACTIONS {
EDIT_DISPOSITION_DATE("editDispositionActionAsOfDate"),
END_RETENTION("retain"),
CUT_OFF("cutoff"),
@@ -717,19 +679,16 @@ public abstract class BaseAPI
DESTROY("destroy");
String action;
private RM_ACTIONS(String action)
{
private RM_ACTIONS(String action) {
this.action = action;
}
public String getAction()
{
public String getAction() {
return action;
}
}
public enum PermissionType
{
public enum PermissionType {
SET_READ,
REMOVE_READ,
SET_READ_AND_FILE,
@@ -740,14 +699,13 @@ public abstract class BaseAPI
* Util to return the property value from a map
*
* @param properties the map containing properties
* @param property to get value for
* @param property to get value for
* @return the property value
*/
public <K extends Enum<?>> String getPropertyValue(Map<K, String> properties, Enum<?> property)
{
public <K extends Enum<?>> String getPropertyValue(
Map<K, String> properties, Enum<?> property) {
String value = properties.get(property);
if (value == null)
{
if (value == null) {
return "";
}
return value;
@@ -756,18 +714,22 @@ public abstract class BaseAPI
/**
* Retrieves the property value and decides if that gets to be added to the request
*
* @param requestParams the request parameters
* @param requestParams the request parameters
* @param propertyRequestValue the property name in the request, eg. "prop_cm_name"
* @param itemProperties map of item's properties values
* @param property the property in the property map to check value for
* @return the json object used in request with the property with its value added if that is not null or empty
* @param itemProperties map of item's properties values
* @param property the property in the property map to check value for
* @return the json object used in request with the property with its value added if that is not
* null or empty
*/
protected <K extends Enum<?>> JSONObject addPropertyToRequest(JSONObject requestParams, String propertyRequestValue, Map<K, String> itemProperties, Enum<?> property) throws JSONException
{
protected <K extends Enum<?>> JSONObject addPropertyToRequest(
JSONObject requestParams,
String propertyRequestValue,
Map<K, String> itemProperties,
Enum<?> property)
throws JSONException {
String propertyValue = getPropertyValue(itemProperties, property);
if (!propertyValue.equals(""))
{
if (!propertyValue.equals("")) {
requestParams.put(propertyRequestValue, propertyValue);
}
return requestParams;
@@ -778,16 +740,14 @@ public abstract class BaseAPI
*
* @param username the username with whom the delete is performed
* @param password the user's password
* @param itemPath the path to the item eg. in case of a category it would be the "/" + category name,
* in case of a folder or subCategory it would be /categoryName/folderName or /categoryName/subCategoryName/
* in case of a record /categoryName/folderName/recordName
* @param itemPath the path to the item eg. in case of a category it would be the "/" + category
* name, in case of a folder or subCategory it would be /categoryName/folderName or
* /categoryName/subCategoryName/ in case of a record /categoryName/folderName/recordName
* @throws AssertionError if the delete was not successful.
*/
protected void deleteItem(String username, String password, String itemPath)
{
protected void deleteItem(String username, String password, String itemPath) {
CmisObject container = getObjectByPath(username, password, FILE_PLAN_PATH + itemPath);
if (container != null)
{
if (container != null) {
container.delete();
}
assertNull("Could not delete " + itemPath, getObjectByPath(username, password, itemPath));
@@ -798,8 +758,7 @@ public abstract class BaseAPI
*
* @return node ref spaces store
*/
public static String getNodeRefSpacesStore()
{
public static String getNodeRefSpacesStore() {
return NODE_REF_WORKSPACE_SPACES_STORE;
}
@@ -808,8 +767,7 @@ public abstract class BaseAPI
*
* @return the File Plan path
*/
public static String getFilePlanPath()
{
public static String getFilePlanPath() {
return FILE_PLAN_PATH;
}
}

View File

@@ -26,8 +26,7 @@
*/
package org.alfresco.rest.core.v0;
public enum RMEvents
{
public enum RMEvents {
ABOLISHED("abolished"),
ALL_ALLOWANCES_GRANTED_ARE_TERMINATED("all_allowances_granted_are_terminated"),
CASE_CLOSED("case_closed"),
@@ -37,13 +36,11 @@ public enum RMEvents
STUDY_COMPLETE("study_complete");
private String eventName;
RMEvents(String eventName)
{
RMEvents(String eventName) {
this.eventName = eventName;
}
public String getEventName()
{
public String getEventName() {
return eventName;
}
}

View File

@@ -26,8 +26,6 @@
*/
package org.alfresco.rest.rm.community.model.audit;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -35,8 +33,11 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for audit entry
*
@@ -47,43 +48,40 @@ import org.alfresco.utility.model.TestModel;
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class AuditEntry extends TestModel
{
@JsonProperty (required = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuditEntry extends TestModel {
@JsonProperty(required = true)
private String nodeName;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<Object> changedValues;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String identifier;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String path;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeRef;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String fullName;
@JsonProperty
private String createPerson;
@JsonProperty private String createPerson;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String userName;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String userRole;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String event;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String timestamp;
}

View File

@@ -29,12 +29,10 @@ package org.alfresco.rest.rm.community.model.audit;
/**
* Enumerates the list of events audited
*
* @author Rodica Sutu
* @author Rodica Sutu
* @since 2.7
*
*/
public enum AuditEvents
{
public enum AuditEvents {
CREATE_PERSON("Create Person", "Create User"),
DELETE_PERSON("Delete Person", "Delete User"),
CREATE_USER_GROUP("Create User Group", "Create User Group"),
@@ -54,8 +52,7 @@ public enum AuditEvents
/** display name for the event audited */
public final String eventDisplayName;
AuditEvents(String event, String displayName)
{
AuditEvents(String event, String displayName) {
this.event = event;
this.eventDisplayName = displayName;
}

View File

@@ -26,8 +26,6 @@
*/
package org.alfresco.rest.rm.community.model.common;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -35,6 +33,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* POJO for id/name pair
*
@@ -45,17 +45,16 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IdNamePair
{
@JsonProperty (required = true)
public class IdNamePair {
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
}

View File

@@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alfresco.utility.model.TestModel;
/**
@@ -42,10 +43,7 @@ import org.alfresco.utility.model.TestModel;
@Builder
@Data
@EqualsAndHashCode(callSuper = true)
//@NoArgsConstructor
//@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class Owner extends TestModel
{
}
// @NoArgsConstructor
// @AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class Owner extends TestModel {}

View File

@@ -26,18 +26,18 @@
*/
package org.alfresco.rest.rm.community.model.common;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for path parameter
*
@@ -49,14 +49,13 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Path extends TestModel
{
@JsonProperty (required = true)
public class Path extends TestModel {
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private Boolean isComplete;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<IdNamePair> elements;
}

View File

@@ -43,11 +43,10 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReviewPeriod
{
@JsonProperty (required = true)
public class ReviewPeriod {
@JsonProperty(required = true)
private String periodType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String expression;
}

View File

@@ -32,22 +32,16 @@ package org.alfresco.rest.rm.community.model.custom;
* @author Rodica Sutu
* @since 2.6
*/
public enum CustomDefinitions
{
public enum CustomDefinitions {
ATTACHMENT("Attachment"),
MESSAGE("Message"),
NEXT_VERSION("Next Version"),
RENDITION("Rendition");
/**
* The name of custom reference.
*/
/** The name of custom reference. */
private String definition;
/**
* Private constructor.
*/
CustomDefinitions(String definition)
{
/** Private constructor. */
CustomDefinitions(String definition) {
this.definition = definition;
}
@@ -56,8 +50,7 @@ public enum CustomDefinitions
*
* @return The value of custom reference.
*/
public String getDefinition()
{
public String getDefinition() {
return definition;
}
}

View File

@@ -26,20 +26,20 @@
*/
package org.alfresco.rest.rm.community.model.fileplan;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for file plan
*
@@ -52,48 +52,45 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FilePlan extends TestModel
{
public class FilePlan extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private FilePlanProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
}

View File

@@ -35,14 +35,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
* POJO for file plan properties
*
@@ -54,29 +54,28 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanProperties extends TestModel
{
public class FilePlanProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_COMPONENT_ID)
@JsonProperty(required = true, value = PROPERTIES_COMPONENT_ID)
private String componentd;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
/************************/
/** Optional parameters */
/************************/
@JsonProperty (PROPERTIES_COUNT)
@JsonProperty(PROPERTIES_COUNT)
private Integer count;
@JsonProperty (PROPERTIES_TITLE)
@JsonProperty(PROPERTIES_TITLE)
private String title;
@JsonProperty (PROPERTIES_DESCRIPTION)
@JsonProperty(PROPERTIES_DESCRIPTION)
private String description;
}

View File

@@ -32,8 +32,7 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponentAlias
{
public class FilePlanComponentAlias {
public static final String FILE_PLAN_ALIAS = "-filePlan-";
public static final String TRANSFERS_ALIAS = "-transfers-";
public static final String UNFILED_RECORDS_CONTAINER_ALIAS = "-unfiled-";

View File

@@ -32,20 +32,17 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentAspects
{
public class FilePlanComponentAspects {
/** Private constructor to prevent instantiation. */
private FilePlanComponentAspects()
{
}
private FilePlanComponentAspects() {}
// aspect present on completed records
public static final String ASPECTS_COMPLETED_RECORD = "rma:declaredRecord";
// aspect present on record folders/categories with vital records
public static final String ASPECTS_VITAL_RECORD_DEFINITION= "rma:vitalRecordDefinition";
// aspect present on record folders/categories with vital records
public static final String ASPECTS_VITAL_RECORD_DEFINITION = "rma:vitalRecordDefinition";
// aspect present on vital records
// aspect present on vital records
public static final String ASPECTS_VITAL_RECORD = "rma:vitalRecord";
// Frozen aspect

View File

@@ -32,61 +32,79 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponentFields
{
public class FilePlanComponentFields {
/** Common properties for file plans, record categories, record folders and records */
public static final String PROPERTIES_ROOT_NODE_REF = "rma:rootNodeRef";
public static final String PROPERTIES_IDENTIFIER = "rma:identifier";
/** Common properties for record categories, record folders and records */
// Non-electronic record properties
public static final String PROPERTIES_TITLE = "cm:title";
public static final String PROPERTIES_DESCRIPTION = "cm:description";
/** Common properties for record categories and record folders **/
/** Common properties for record categories and record folders * */
public static final String PROPERTIES_VITAL_RECORD_INDICATOR = "rma:vitalRecordIndicator";
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
public static final String PROPERTIES_OWNER = "cm:owner";
public static final String PROPERTIES_AUTHOR="cm:author";
public static final String PROPERTIES_AUTHOR = "cm:author";
/** Common properties for record folders and records */
public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE = "rma:recordSearchHasDispositionSchedule";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION = "rma:recordSearchDispositionPeriodExpression";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY = "rma:recordSearchDispositionAuthority";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF = "rma:recordSearchDispositionActionAsOf";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD = "rma:recordSearchDispositionPeriod";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME = "rma:recordSearchDispositionActionName";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE = "rma:recordSearchDispositionEventsEligible";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS = "rma:recordSearchDispositionInstructions";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS = "rma:recordSearchDispositionEvents";
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_BY = "rma:declassificationReviewCompletedBy";
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_AT = "rma:declassificationReviewCompletedAt";
public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE =
"rma:recordSearchHasDispositionSchedule";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION =
"rma:recordSearchDispositionPeriodExpression";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY =
"rma:recordSearchDispositionAuthority";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF =
"rma:recordSearchDispositionActionAsOf";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD =
"rma:recordSearchDispositionPeriod";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME =
"rma:recordSearchDispositionActionName";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE =
"rma:recordSearchDispositionEventsEligible";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS =
"rma:recordSearchDispositionInstructions";
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS =
"rma:recordSearchDispositionEvents";
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_BY =
"rma:declassificationReviewCompletedBy";
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_AT =
"rma:declassificationReviewCompletedAt";
/** File plan properties */
public static final String PROPERTIES_COMPONENT_ID = "st:componentId";
public static final String PROPERTIES_COUNT = "rma:count";
/** Record category properties */
// All fields are shared with record folders
/** Record folder properties */
public static final String PROPERTIES_IS_CLOSED = "rma:isClosed"; // not to be confused with IS_CLOSED!
public static final String PROPERTIES_IS_CLOSED =
"rma:isClosed"; // not to be confused with IS_CLOSED!
public static final String PROPERTIES_HELD_CHILDREN_COUNT = "rma:heldChildrenCount";
public static final String PROPERTIES_LOCATION = "rma:location";
public static final String PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD = "rma:recordSearchVitalRecordReviewPeriod";
public static final String PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = "rma:recordSearchVitalRecordReviewPeriodExpression";
public static final String PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD =
"rma:recordSearchVitalRecordReviewPeriod";
public static final String PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION =
"rma:recordSearchVitalRecordReviewPeriodExpression";
/**
* Record properties
*/
/** Record properties */
public static final String PROPERTIES_CLASSIFICATION = "sc:classification";
public static final String PROPERTIES_DATE_FILED = "rma:dateFiled";
public static final String PROPERTIES_ORIGINAL_NAME = "rma:origionalName";
public static final String PROPERTIES_REVIEW_AS_OF = "rma:reviewAsOf";
/** Electronic record properties */
public static final String PROPERTIES_VERSION_TYPE = "cm:versionType";
public static final String PROPERTIES_VERSION_LABEL = "cm:versionLabel";
public static final String PROPERTIES_VERSIONED_NODEREF = "rmv:versionedNodeRef";
public static final String PROPERTIES_RMV_VERSIONED = "rmv:versionLabel";
@@ -105,12 +123,16 @@ public class FilePlanComponentFields
public static final String PROPERTIES_SOFTWARE = "exif:software";
public static final String PROPERTIES_X_RESOLUTION = "exif:xResolution";
public static final String PROPERTIES_Y_RESOLUTION = "exif:yResolution";
public static final String PROPERTIES_RECORD_ORIGINATING_LOCATION = "rma:recordOriginatingLocation";
public static final String PROPERTIES_RECORD_ORIGINATING_USER_ID = "rma:recordOriginatingUserId";
public static final String PROPERTIES_RECORD_ORIGINATING_CREATION_DATE = "rma:recordOriginatingCreationDate";
public static final String PROPERTIES_RECORD_ORIGINATING_LOCATION =
"rma:recordOriginatingLocation";
public static final String PROPERTIES_RECORD_ORIGINATING_USER_ID =
"rma:recordOriginatingUserId";
public static final String PROPERTIES_RECORD_ORIGINATING_CREATION_DATE =
"rma:recordOriginatingCreationDate";
/** Non-electronic record properties */
public static final String PROPERTIES_SHELF = "rma:shelf";
public static final String PROPERTIES_STORAGE_LOCATION = "rma:storageLocation";
public static final String PROPERTIES_FILE = "rma:file";
public static final String PROPERTIES_BOX = "rma:box";
@@ -119,15 +141,18 @@ public class FilePlanComponentFields
/** Transfer properties */
public static final String PROPERTIES_PDF_INDICATOR = "rma:transferPDFIndicator";
public static final String PROPERTIES_TRANSFER_LOCATION = "rma:transferLocation";
public static final String PROPERTIES_ACCESSION_INDICATOR = "rma:transferAccessionIndicator";
/** Parameters */
public static final String RELATIVE_PATH = "relativePath";
public static final String INCLUDE = "include";
/** Include options */
public static final String ALLOWABLE_OPERATIONS = "allowableOperations";
public static final String IS_CLOSED = "isClosed";
public static final String IS_COMPLETED = "isCompleted";
public static final String CONTENT = "content";

View File

@@ -32,8 +32,7 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponentType
{
public class FilePlanComponentType {
public static final String FILE_PLAN_TYPE = "rma:filePlan";
public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
public static final String RECORD_FOLDER_TYPE = "rma:recordFolder";

View File

@@ -33,6 +33,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
@@ -45,12 +46,11 @@ import org.alfresco.utility.model.TestModel;
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class HoldEntry extends TestModel
{
@JsonProperty (required = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class HoldEntry extends TestModel {
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeRef;
}

View File

@@ -26,10 +26,14 @@
*/
package org.alfresco.rest.rm.community.model.record;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.core.IRestModel;
import org.alfresco.rest.core.assertion.ModelAssertion;
import org.alfresco.rest.model.RestByUserModel;
@@ -37,11 +41,7 @@ import org.alfresco.rest.model.RestNodeModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* POJO for record
@@ -54,76 +54,66 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Record extends TestModel implements IRestModel<RestNodeModel>
{
public final static String CONTENT_NODE_TYPE = "cm:content";
public class Record extends TestModel implements IRestModel<RestNodeModel> {
public static final String CONTENT_NODE_TYPE = "cm:content";
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private RecordContent content;
@JsonProperty private RecordContent content;
@JsonProperty
private Boolean isCompleted;
@JsonProperty private Boolean isCompleted;
@JsonProperty
private RecordProperties properties;
@JsonProperty private RecordProperties properties;
@JsonProperty
private List<String> aspectNames;
@JsonProperty private List<String> aspectNames;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
@Override
public ModelAssertion<RestNodeModel> assertThat()
{
public ModelAssertion<RestNodeModel> assertThat() {
return new ModelAssertion<>(this);
}
@Override
public ModelAssertion<RestNodeModel> and()
{
public ModelAssertion<RestNodeModel> and() {
return assertThat();
}
@JsonProperty (value = "entry")
@JsonProperty(value = "entry")
RestNodeModel model;
@Override
public RestNodeModel onModel()
{
public RestNodeModel onModel() {
return model;
}
}

View File

@@ -28,14 +28,14 @@ package org.alfresco.rest.rm.community.model.record;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
* POJO for File records
*
@@ -47,8 +47,6 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordBodyFile extends TestModel
{
@JsonProperty
private String targetParentId;
public class RecordBodyFile extends TestModel {
@JsonProperty private String targetParentId;
}

View File

@@ -28,14 +28,14 @@ package org.alfresco.rest.rm.community.model.record;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
* POJO for record content field
*
@@ -48,17 +48,16 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordContent extends TestModel
{
@JsonProperty (required = true)
public class RecordContent extends TestModel {
@JsonProperty(required = true)
private String mimeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String mimeTypeName;
@JsonProperty (required = true)
@JsonProperty(required = true)
private Integer sizeInBytes;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String encoding;
}

View File

@@ -64,7 +64,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RESOLUTION_UNIT;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_AS_OF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RMV_VERSIONED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
@@ -80,9 +79,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -91,9 +87,13 @@ import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
import java.util.Date;
import java.util.List;
/**
* POJO for record properties
*
@@ -106,165 +106,164 @@ import org.alfresco.utility.model.TestModel;
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecordProperties extends TestModel
{
public class RecordProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (required = true, value = PROPERTIES_DATE_FILED)
@JsonProperty(required = true, value = PROPERTIES_DATE_FILED)
private String dateField;
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
@JsonProperty(required = true, value = PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
@JsonProperty (required = true, value = PROPERTIES_ORIGINAL_NAME)
@JsonProperty(required = true, value = PROPERTIES_ORIGINAL_NAME)
private String originalName;
@JsonProperty (PROPERTIES_CLASSIFICATION)
@JsonProperty(PROPERTIES_CLASSIFICATION)
private List<String> classification;
/*********************************/
/** Electronic record parameters */
/*********************************/
@JsonProperty (PROPERTIES_VERSION_TYPE)
@JsonProperty(PROPERTIES_VERSION_TYPE)
private String versionType;
@JsonProperty (PROPERTIES_VERSION_LABEL)
@JsonProperty(PROPERTIES_VERSION_LABEL)
private String versionLabel;
@JsonProperty(PROPERTIES_VERSIONED_NODEREF)
private String versionedNodeRef;
@JsonProperty (PROPERTIES_RMV_VERSIONED)
@JsonProperty(PROPERTIES_RMV_VERSIONED)
private String recordVersionLabel;
@JsonProperty (PROPERTIES_DATE_TIME_ORIGINAL)
@JsonProperty(PROPERTIES_DATE_TIME_ORIGINAL)
private String dateTimeOriginal;
@JsonProperty (PROPERTIES_EXPOSURE_TIME)
@JsonProperty(PROPERTIES_EXPOSURE_TIME)
private Double exposureTime;
@JsonProperty (PROPERTIES_FLASH)
@JsonProperty(PROPERTIES_FLASH)
private Boolean flash;
@JsonProperty (PROPERTIES_F_NUMBER)
@JsonProperty(PROPERTIES_F_NUMBER)
private Double fNumber;
@JsonProperty (PROPERTIES_FOCAL_LENGTH)
@JsonProperty(PROPERTIES_FOCAL_LENGTH)
private Double focalLength;
@JsonProperty (PROPERTIES_ISO_SPEED_RATINGS)
@JsonProperty(PROPERTIES_ISO_SPEED_RATINGS)
private Integer isoSpeedRatings;
@JsonProperty (PROPERTIES_MANUFACTURER)
@JsonProperty(PROPERTIES_MANUFACTURER)
private String manufacturer;
@JsonProperty (PROPERTIES_MODEL)
@JsonProperty(PROPERTIES_MODEL)
private String model;
@JsonProperty (PROPERTIES_ORIENTATION)
@JsonProperty(PROPERTIES_ORIENTATION)
private Integer orientation;
@JsonProperty (PROPERTIES_PIXEL_X_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_X_DIMENSION)
private Integer pixelXDimension;
@JsonProperty (PROPERTIES_PIXEL_Y_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_Y_DIMENSION)
private Integer pixelYDimension;
@JsonProperty (PROPERTIES_RESOLUTION_UNIT)
@JsonProperty(PROPERTIES_RESOLUTION_UNIT)
private String resolutionUnit;
@JsonProperty (PROPERTIES_SOFTWARE)
@JsonProperty(PROPERTIES_SOFTWARE)
private String software;
@JsonProperty (PROPERTIES_X_RESOLUTION)
@JsonProperty(PROPERTIES_X_RESOLUTION)
private Double xResolution;
@JsonProperty (PROPERTIES_Y_RESOLUTION)
@JsonProperty(PROPERTIES_Y_RESOLUTION)
private Double yResolution;
@JsonProperty (PROPERTIES_RECORD_ORIGINATING_LOCATION)
@JsonProperty(PROPERTIES_RECORD_ORIGINATING_LOCATION)
private String originatingLocation;
@JsonProperty (PROPERTIES_RECORD_ORIGINATING_USER_ID)
@JsonProperty(PROPERTIES_RECORD_ORIGINATING_USER_ID)
private String originatingUserId;
@JsonProperty (PROPERTIES_RECORD_ORIGINATING_CREATION_DATE)
@JsonProperty(PROPERTIES_RECORD_ORIGINATING_CREATION_DATE)
private String originatingCreationDate;
/*************************************/
/** Non-electronic record parameters */
/*************************************/
@JsonProperty (PROPERTIES_TITLE)
@JsonProperty(PROPERTIES_TITLE)
private String title;
@JsonProperty (PROPERTIES_SHELF)
@JsonProperty(PROPERTIES_SHELF)
private String shelf;
@JsonProperty (PROPERTIES_STORAGE_LOCATION)
@JsonProperty(PROPERTIES_STORAGE_LOCATION)
private String storageLocation;
@JsonProperty (PROPERTIES_FILE)
@JsonProperty(PROPERTIES_FILE)
private String file;
@JsonProperty (PROPERTIES_BOX)
@JsonProperty(PROPERTIES_BOX)
private String box;
@JsonProperty (PROPERTIES_DESCRIPTION)
@JsonProperty(PROPERTIES_DESCRIPTION)
private String description;
@JsonProperty (PROPERTIES_NUMBER_OF_COPIES)
@JsonProperty(PROPERTIES_NUMBER_OF_COPIES)
private Integer numberOfCopies;
@JsonProperty (PROPERTIES_PHYSICAL_SIZE)
@JsonProperty(PROPERTIES_PHYSICAL_SIZE)
private Integer physicalSize;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
@JsonProperty(PROPERTIES_AUTHOR)
private String author;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
private String recordSearchDispositionPeriodExpression;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
private String recordSearchDispositionAuthority;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF)
private Date recordSearchDispositionActionAsOf;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD)
private String recordSearchDispositionPeriod;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME)
private String recordSearchDispositionActionName;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
private Boolean recordSearchDispositionEventsEligible;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
private List<String> recordSearchDispositionEvents;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
private String recordSearchDispositionInstructions;
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
@JsonProperty(PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
private String recordSearchVitalRecordReviewPeriod;
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)
@JsonProperty(PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)
private String recordSearchVitalRecordReviewPeriodExpression;
@JsonProperty(PROPERTIES_REVIEW_AS_OF)
private Date reviewAsOf;
@JsonProperty (PROPERTIES_STORE)
@JsonProperty(PROPERTIES_STORE)
private String store;
@JsonProperty(PROPERTIES_WORM_UNLOCK_DATE)

View File

@@ -26,20 +26,20 @@
*/
package org.alfresco.rest.rm.community.model.recordcategory;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record category
*
@@ -51,53 +51,49 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordCategory extends TestModel
{
public class RecordCategory extends TestModel {
public static final String DEFAULT_FILE_PLAN_ALIAS = "-filePlan-";
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RecordCategoryProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private Boolean hasRetentionSchedule;
@JsonProperty private Boolean hasRetentionSchedule;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
}

View File

@@ -26,20 +26,20 @@
*/
package org.alfresco.rest.rm.community.model.recordcategory;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record category child
*
@@ -51,64 +51,54 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordCategoryChild extends TestModel
{
public class RecordCategoryChild extends TestModel {
public static final String RECORD_FOLDER_NODE_TYPE = "rma:recordFolder";
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private Boolean isRecordCategory;
@JsonProperty private Boolean isRecordCategory;
@JsonProperty
private Boolean isRecordFolder;
@JsonProperty private Boolean isRecordFolder;
@JsonProperty
private RecordCategoryChildProperties properties;
@JsonProperty private RecordCategoryChildProperties properties;
@JsonProperty
private List<String> aspectNames;
@JsonProperty private List<String> aspectNames;
@JsonProperty
private Boolean hasRetentionSchedule;
@JsonProperty private Boolean hasRetentionSchedule;
@JsonProperty
private Boolean isClosed;
@JsonProperty private Boolean isClosed;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
@JsonProperty
private String relativePath;
@JsonProperty private String relativePath;
}

View File

@@ -35,7 +35,5 @@ import org.alfresco.rest.core.RestModels;
* @author Tuna Aksoy
* @since 2.6
*/
public class RecordCategoryChildCollection extends RestModels<RecordCategoryChildEntry, RecordCategoryChildCollection>
{
}
public class RecordCategoryChildCollection
extends RestModels<RecordCategoryChildEntry, RecordCategoryChildCollection> {}

View File

@@ -28,11 +28,11 @@ package org.alfresco.rest.rm.community.model.recordcategory;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alfresco.rest.core.RestModels;
/**
* POJO for record category child entry
*
@@ -41,8 +41,6 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RecordCategoryChildEntry extends RestModels<RecordCategory, RecordCategoryChildEntry>
{
@JsonProperty
private RecordCategoryChild entry;
public class RecordCategoryChildEntry extends RestModels<RecordCategory, RecordCategoryChildEntry> {
@JsonProperty private RecordCategoryChild entry;
}

View File

@@ -32,37 +32,37 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import java.util.Date;
import java.util.List;
/**
* POJO for record category child properties
*
@@ -74,70 +74,68 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordCategoryChildProperties extends TestModel
{
public class RecordCategoryChildProperties extends TestModel {
/**************************************************************************/
/** Mandatory parameters - Shared by record categories and record folders */
/**************************************************************************/
@JsonProperty (required = true, value = PROPERTIES_TITLE)
@JsonProperty(required = true, value = PROPERTIES_TITLE)
private String title;
@JsonProperty (required = true, value = PROPERTIES_VITAL_RECORD_INDICATOR)
@JsonProperty(required = true, value = PROPERTIES_VITAL_RECORD_INDICATOR)
private Boolean vitalRecordIndicator;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_REVIEW_PERIOD)
@JsonSerialize (using = ReviewPeriodSerializer.class)
@JsonProperty(required = true, value = PROPERTIES_REVIEW_PERIOD)
@JsonSerialize(using = ReviewPeriodSerializer.class)
private ReviewPeriod reviewPeriod;
@JsonProperty (required = true, value = PROPERTIES_DESCRIPTION)
@JsonProperty(required = true, value = PROPERTIES_DESCRIPTION)
private String description;
/*********************************************************/
/** Optional parameters - Applies only to record folders */
/*********************************************************/
@JsonProperty (PROPERTIES_HELD_CHILDREN_COUNT)
@JsonProperty(PROPERTIES_HELD_CHILDREN_COUNT)
private Integer heldChildrenCount;
@JsonProperty (PROPERTIES_LOCATION)
@JsonProperty(PROPERTIES_LOCATION)
private String location;
@JsonProperty (PROPERTIES_IS_CLOSED)
@JsonProperty(PROPERTIES_IS_CLOSED)
private Boolean isClosed;
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
@JsonProperty(PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
private String recordSearchDispositionPeriodExpression;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
private String recordSearchDispositionAuthority;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF)
private Date recordSearchDispositionActionAsOf;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD)
private String recordSearchDispositionPeriod;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME)
private String recordSearchDispositionActionName;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
private Boolean recordSearchDispositionEventsEligible;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
private String recordSearchDispositionInstructions;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
private List<String> recordSearchDispositionEvents;
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
}

View File

@@ -35,7 +35,5 @@ import org.alfresco.rest.core.RestModels;
* @author Tuna Aksoy
* @since 2.6
*/
public class RecordCategoryCollection extends RestModels<RecordCategoryEntry, RecordCategoryCollection>
{
}
public class RecordCategoryCollection
extends RestModels<RecordCategoryEntry, RecordCategoryCollection> {}

View File

@@ -28,12 +28,12 @@ package org.alfresco.rest.rm.community.model.recordcategory;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
/**
* POJO for file plan entry
*
@@ -43,8 +43,6 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RecordCategoryEntry extends RestModels<FilePlan, RecordCategoryEntry>
{
@JsonProperty
private RecordCategory entry;
public class RecordCategoryEntry extends RestModels<FilePlan, RecordCategoryEntry> {
@JsonProperty private RecordCategory entry;
}

View File

@@ -35,24 +35,23 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record category properties
*
@@ -64,37 +63,36 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class RecordCategoryProperties extends TestModel
{
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecordCategoryProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_REVIEW_PERIOD)
@JsonSerialize (using = ReviewPeriodSerializer.class)
@JsonProperty(required = true, value = PROPERTIES_REVIEW_PERIOD)
@JsonSerialize(using = ReviewPeriodSerializer.class)
private ReviewPeriod reviewPeriod;
@JsonProperty (required = true, value = PROPERTIES_VITAL_RECORD_INDICATOR)
@JsonProperty(required = true, value = PROPERTIES_VITAL_RECORD_INDICATOR)
private Boolean vitalRecordIndicator;
/************************/
/** Optional parameters */
/************************/
@JsonProperty (PROPERTIES_TITLE)
@JsonProperty(PROPERTIES_TITLE)
private String title;
@JsonProperty (PROPERTIES_ROOT_NODE_REF)
@JsonProperty(PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (PROPERTIES_DESCRIPTION)
@JsonProperty(PROPERTIES_DESCRIPTION)
private String description;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
@JsonProperty (PROPERTIES_CLASSIFICATION)
@JsonProperty(PROPERTIES_CLASSIFICATION)
private List<String> classification;
}

View File

@@ -26,11 +26,8 @@
*/
package org.alfresco.rest.rm.community.model.recordcategory;
/**
* The property of the dispositioned item that is used to calculate the "as of" period.
*/
public enum RetentionPeriodProperty
{
/** The property of the dispositioned item that is used to calculate the "as of" period. */
public enum RetentionPeriodProperty {
/** Item created date. */
CREATED_DATE("cm:created"),
/** Record filed date. */
@@ -40,13 +37,11 @@ public enum RetentionPeriodProperty
String periodProperty;
RetentionPeriodProperty(String periodProperty)
{
RetentionPeriodProperty(String periodProperty) {
this.periodProperty = periodProperty;
}
public String getPeriodProperty()
{
public String getPeriodProperty() {
return periodProperty;
}
}

View File

@@ -26,20 +26,20 @@
*/
package org.alfresco.rest.rm.community.model.recordfolder;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record folder
*
@@ -51,50 +51,46 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordFolder extends TestModel
{
public class RecordFolder extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RecordFolderProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private Boolean isClosed;
@JsonProperty private Boolean isClosed;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
}

View File

@@ -35,7 +35,4 @@ import org.alfresco.rest.core.RestModels;
* @author Tuna Aksoy
* @since 2.6
*/
public class RecordFolderCollection extends RestModels<RecordFolderEntry, RecordFolderCollection>
{
}
public class RecordFolderCollection extends RestModels<RecordFolderEntry, RecordFolderCollection> {}

View File

@@ -28,15 +28,15 @@ package org.alfresco.rest.rm.community.model.recordfolder;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.record.Record;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.record.Record;
/**
* POJO for record folder entry
*
@@ -48,8 +48,6 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RecordFolderEntry extends RestModels<RecordFolder, RecordFolderEntry>
{
@JsonProperty
private Record entry;
public class RecordFolderEntry extends RestModels<RecordFolder, RecordFolderEntry> {
@JsonProperty private Record entry;
}

View File

@@ -33,10 +33,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields
.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields
.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION;
@@ -45,23 +43,23 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record folder properties
*
@@ -73,62 +71,60 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class RecordFolderProperties extends TestModel
{
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecordFolderProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IS_CLOSED)
@JsonProperty(required = true, value = PROPERTIES_IS_CLOSED)
private Boolean isClosed;
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_HELD_CHILDREN_COUNT)
@JsonProperty(required = true, value = PROPERTIES_HELD_CHILDREN_COUNT)
private Integer heldChildrenCount;
/************************/
/** Optional parameters */
/************************/
@JsonProperty (PROPERTIES_TITLE)
@JsonProperty(PROPERTIES_TITLE)
private String title;
@JsonProperty (PROPERTIES_VITAL_RECORD_INDICATOR)
@JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR)
private Boolean vitalRecordIndicator;
@JsonProperty (PROPERTIES_ROOT_NODE_REF)
@JsonProperty(PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (PROPERTIES_LOCATION)
@JsonProperty(PROPERTIES_LOCATION)
private String location;
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
@JsonProperty(PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
@JsonProperty (PROPERTIES_REVIEW_PERIOD)
@JsonSerialize (using = ReviewPeriodSerializer.class)
@JsonProperty(PROPERTIES_REVIEW_PERIOD)
@JsonSerialize(using = ReviewPeriodSerializer.class)
private ReviewPeriod reviewPeriod;
@JsonProperty (PROPERTIES_CLASSIFICATION)
@JsonProperty(PROPERTIES_CLASSIFICATION)
private List<String> classification;
@JsonProperty (PROPERTIES_DESCRIPTION)
@JsonProperty(PROPERTIES_DESCRIPTION)
private String description;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
@JsonProperty(PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
private String recordSearchVitalRecordReviewPeriod;
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)
@JsonProperty(PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)
private String recordSearchVitalRecordReviewPeriodExpression;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
private String recordSearchDispositionAuthority;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
@JsonProperty(PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
private String recordSearchDispositionInstructions;
}

View File

@@ -26,11 +26,8 @@
*/
package org.alfresco.rest.rm.community.model.rules;
/**
* Action values.
*/
public enum ActionsOnRule
{
/** Action values. */
public enum ActionsOnRule {
COMPLETE_RECORD("declareRecord"),
REOPEN_RECORD("undeclareRecord"),
OPEN_RECORD_FOLDER("openRecordFolder"),
@@ -54,13 +51,11 @@ public enum ActionsOnRule
private String actionValue;
ActionsOnRule(String value)
{
ActionsOnRule(String value) {
this.actionValue = value;
}
public String getActionValue()
{
public String getActionValue() {
return actionValue;
}
}

View File

@@ -26,23 +26,18 @@
*/
package org.alfresco.rest.rm.community.model.rules;
/**
* enum used to find the when condition names options by their value
*/
public enum ConditionsOnRule
{
/** enum used to find the when condition names options by their value */
public enum ConditionsOnRule {
UPDATE("update"),
ADDED("inbound"),
REMOVED("outbound");
private String whenConditionValue;
ConditionsOnRule(String value)
{
this.whenConditionValue = value;
ConditionsOnRule(String value) {
this.whenConditionValue = value;
}
public String getWhenConditionValue()
{
return whenConditionValue;
public String getWhenConditionValue() {
return whenConditionValue;
}
}

View File

@@ -28,11 +28,8 @@ package org.alfresco.rest.rm.community.model.rules;
import java.util.List;
/**
* A class describing the rule
*/
public class RuleDefinition
{
/** A class describing the rule */
public class RuleDefinition {
private String id = "";
private String title;
private String description = "";
@@ -52,152 +49,124 @@ public class RuleDefinition
*
* @return the object
*/
public static RuleDefinition createNewRule()
{
public static RuleDefinition createNewRule() {
return new RuleDefinition();
}
public String getId()
{
public String getId() {
return id;
}
public RuleDefinition id(String id)
{
public RuleDefinition id(String id) {
this.id = id;
return this;
}
public String getTitle()
{
public String getTitle() {
return title;
}
public RuleDefinition title(String title)
{
public RuleDefinition title(String title) {
this.title = title;
return this;
}
public String getDescription()
{
public String getDescription() {
return description;
}
public RuleDefinition description(String description)
{
public RuleDefinition description(String description) {
this.description = description;
return this;
}
public boolean isDisabled()
{
public boolean isDisabled() {
return disabled;
}
public RuleDefinition disabled(boolean disabled)
{
public RuleDefinition disabled(boolean disabled) {
this.disabled = disabled;
return this;
}
public boolean isApplyToChildren()
{
public boolean isApplyToChildren() {
return applyToChildren;
}
public RuleDefinition applyToChildren(boolean applyToChildren)
{
public RuleDefinition applyToChildren(boolean applyToChildren) {
this.applyToChildren = applyToChildren;
return this;
}
public boolean getRunInBackground()
{
public boolean getRunInBackground() {
return runInBackground;
}
public RuleDefinition runInBackground(boolean runInBackground)
{
public RuleDefinition runInBackground(boolean runInBackground) {
this.runInBackground = runInBackground;
return this;
}
public String getRuleType()
{
public String getRuleType() {
return ruleType;
}
public RuleDefinition ruleType(String ruleType)
{
public RuleDefinition ruleType(String ruleType) {
this.ruleType = ruleType;
return this;
}
public String getPath()
{
public String getPath() {
return path;
}
public RuleDefinition path(String path)
{
public RuleDefinition path(String path) {
this.path = path;
return this;
}
public Boolean getCreateRecordPath()
{
public Boolean getCreateRecordPath() {
return createRecordPath;
}
public RuleDefinition createRecordPath(boolean createRecordPath)
{
public RuleDefinition createRecordPath(boolean createRecordPath) {
this.createRecordPath = createRecordPath;
return this;
}
public String getContentTitle()
{
public String getContentTitle() {
return contentTitle;
}
public RuleDefinition contentTitle(String contentTitle)
{
public RuleDefinition contentTitle(String contentTitle) {
this.contentTitle = contentTitle;
return this;
}
public String getContentDescription()
{
public String getContentDescription() {
return contentDescription;
}
public RuleDefinition contentDescription(String contentDescription)
{
public RuleDefinition contentDescription(String contentDescription) {
this.contentDescription = contentDescription;
return this;
}
public String getRejectReason()
{
public String getRejectReason() {
return rejectReason;
}
public RuleDefinition rejectReason(String rejectReason)
{
public RuleDefinition rejectReason(String rejectReason) {
this.rejectReason = rejectReason;
return this;
}
public List<String> getActions()
{
public List<String> getActions() {
return actions;
}
public RuleDefinition actions(List<String> actions)
{
public RuleDefinition actions(List<String> actions) {
this.actions = actions;
return this;
}
}

View File

@@ -28,14 +28,14 @@ package org.alfresco.rest.rm.community.model.site;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestSiteModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestSiteModel;
/**
* POJO for RM Site component
*
@@ -46,15 +46,13 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RMSite extends RestSiteModel
{
@JsonProperty (required = true)
public class RMSite extends RestSiteModel {
@JsonProperty(required = true)
private RMSiteCompliance compliance;
/** Private constructor allowing Lombok to include superclass fields in the builder. */
@Builder
private RMSite(String title, String description, RMSiteCompliance compliance)
{
private RMSite(String title, String description, RMSiteCompliance compliance) {
this.setTitle(title);
this.setDescription(description);
this.compliance = compliance;

View File

@@ -32,8 +32,7 @@ package org.alfresco.rest.rm.community.model.site;
* @author Tuna Aksoy
* @since 2.6
*/
public enum RMSiteCompliance
{
public enum RMSiteCompliance {
STANDARD,
DOD5015
}

View File

@@ -27,26 +27,20 @@
package org.alfresco.rest.rm.community.model.site;
/**
*RM Site properties from the RM Model Schema
*"entry": {
* "id": "string",
* "guid": "string",
* "title": "string",
* "description": "string",
* "visibility": "{@link org.springframework.social.alfresco.api.entities.Site.Visibility}",
* "compliance": "{@link RMSiteCompliance}",
* "role": "{@link org.alfresco.utility.constants.UserRole}"
*}
* RM Site properties from the RM Model Schema "entry": { "id": "string", "guid": "string", "title":
* "string", "description": "string", "visibility": "{@link
* org.springframework.social.alfresco.api.entities.Site.Visibility}", "compliance": "{@link
* RMSiteCompliance}", "role": "{@link org.alfresco.utility.constants.UserRole}" }
*
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 2.6
*/
public class RMSiteFields
{
public class RMSiteFields {
public static final String ID = "id";
public static final String COMPLIANCE = "compliance";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public static final String VISIBILITY ="visibility";
public static final String VISIBILITY = "visibility";
public static final String ROLE = "role";
}

View File

@@ -27,19 +27,19 @@
package org.alfresco.rest.rm.community.model.transfer;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for Transfer
*
@@ -51,38 +51,36 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Transfer extends TestModel
{
public class Transfer extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private TransferProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
}

View File

@@ -27,20 +27,20 @@
package org.alfresco.rest.rm.community.model.transfer;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for transfer child
*
@@ -52,59 +52,50 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferChild extends TestModel
{
public class TransferChild extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private TransferChildProperties properties;
@JsonProperty private TransferChildProperties properties;
@JsonProperty
private Boolean isRecord;
@JsonProperty private Boolean isRecord;
@JsonProperty
private Boolean isRecordFolder;
@JsonProperty private Boolean isRecordFolder;
@JsonProperty
private List<String> aspectNames;
@JsonProperty private List<String> aspectNames;
@JsonProperty
private Boolean isCompleted;
@JsonProperty private Boolean isCompleted;
@JsonProperty
private Boolean isClosed;
@JsonProperty private Boolean isClosed;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
}

View File

@@ -31,10 +31,9 @@ import org.alfresco.rest.core.RestModels;
/**
* Handle collection of {@link TransferChildEntry}
*
* @author Silviu Dinuta
* @since 2.6
*/
public class TransferChildCollection extends RestModels<TransferChildEntry, TransferChildCollection>
{
}
public class TransferChildCollection
extends RestModels<TransferChildEntry, TransferChildCollection> {}

View File

@@ -27,8 +27,6 @@
package org.alfresco.rest.rm.community.model.transfer;
import org.alfresco.rest.core.RestModels;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -37,6 +35,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.core.RestModels;
/**
* POJO for transfer child entry
*
@@ -48,8 +48,6 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferChildEntry extends RestModels<Transfer, TransferChildEntry>
{
@JsonProperty
private TransferChild entry;
public class TransferChildEntry extends RestModels<Transfer, TransferChildEntry> {
@JsonProperty private TransferChild entry;
}

View File

@@ -64,11 +64,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -78,6 +73,11 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
/**
* POJO for transfer child properties
*
@@ -89,131 +89,129 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferChildProperties extends TestModel
{
public class TransferChildProperties extends TestModel {
/**************************************************************************/
/** Mandatory parameters - Shared by record folders and records*/
/** Mandatory parameters - Shared by record folders and records */
/**************************************************************************/
@JsonProperty (PROPERTIES_TITLE)
@JsonProperty(PROPERTIES_TITLE)
private String title;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (PROPERTIES_DESCRIPTION)
@JsonProperty(PROPERTIES_DESCRIPTION)
private String description;
/*********************************************************/
/** Optional parameters - Applies only to record folders */
/*********************************************************/
@JsonProperty (PROPERTIES_VITAL_RECORD_INDICATOR)
@JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR)
private Boolean vitalRecordIndicator;
@JsonProperty (PROPERTIES_REVIEW_PERIOD)
@JsonSerialize (using = ReviewPeriodSerializer.class)
@JsonProperty(PROPERTIES_REVIEW_PERIOD)
@JsonSerialize(using = ReviewPeriodSerializer.class)
private ReviewPeriod reviewPeriod;
@JsonProperty (PROPERTIES_HELD_CHILDREN_COUNT)
@JsonProperty(PROPERTIES_HELD_CHILDREN_COUNT)
private Integer heldChildrenCount;
@JsonProperty (PROPERTIES_LOCATION)
@JsonProperty(PROPERTIES_LOCATION)
private String location;
@JsonProperty (PROPERTIES_IS_CLOSED)
@JsonProperty(PROPERTIES_IS_CLOSED)
private Boolean isClosed;
/*********************************************************/
/** Optional parameters - Applies only to records */
/*********************************************************/
@JsonProperty (PROPERTIES_DATE_FILED)
@JsonProperty(PROPERTIES_DATE_FILED)
private String dateField;
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
@JsonProperty(PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
@JsonProperty (PROPERTIES_ORIGINAL_NAME)
@JsonProperty(PROPERTIES_ORIGINAL_NAME)
private String originalName;
/*********************************/
/** Electronic record parameters */
/*********************************/
@JsonProperty (PROPERTIES_VERSION_TYPE)
@JsonProperty(PROPERTIES_VERSION_TYPE)
private String versionType;
@JsonProperty (PROPERTIES_VERSION_LABEL)
@JsonProperty(PROPERTIES_VERSION_LABEL)
private String versionLabel;
@JsonProperty (PROPERTIES_DATE_TIME_ORIGINAL)
@JsonProperty(PROPERTIES_DATE_TIME_ORIGINAL)
private String dateTimeOriginal;
@JsonProperty (PROPERTIES_EXPOSURE_TIME)
@JsonProperty(PROPERTIES_EXPOSURE_TIME)
private Double exposureTime;
@JsonProperty (PROPERTIES_FLASH)
@JsonProperty(PROPERTIES_FLASH)
private Boolean flash;
@JsonProperty (PROPERTIES_F_NUMBER)
@JsonProperty(PROPERTIES_F_NUMBER)
private Double fNumber;
@JsonProperty (PROPERTIES_FOCAL_LENGTH)
@JsonProperty(PROPERTIES_FOCAL_LENGTH)
private Double focalLength;
@JsonProperty (PROPERTIES_ISO_SPEED_RATINGS)
@JsonProperty(PROPERTIES_ISO_SPEED_RATINGS)
private Integer isoSpeedRatings;
@JsonProperty (PROPERTIES_MANUFACTURER)
@JsonProperty(PROPERTIES_MANUFACTURER)
private String manufacturer;
@JsonProperty (PROPERTIES_MODEL)
@JsonProperty(PROPERTIES_MODEL)
private String model;
@JsonProperty (PROPERTIES_ORIENTATION)
@JsonProperty(PROPERTIES_ORIENTATION)
private Integer orientation;
@JsonProperty (PROPERTIES_PIXEL_X_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_X_DIMENSION)
private Integer pixelXDimension;
@JsonProperty (PROPERTIES_PIXEL_Y_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_Y_DIMENSION)
private Integer pixelYDimension;
@JsonProperty (PROPERTIES_RESOLUTION_UNIT)
@JsonProperty(PROPERTIES_RESOLUTION_UNIT)
private String resolutionUnit;
@JsonProperty (PROPERTIES_SOFTWARE)
@JsonProperty(PROPERTIES_SOFTWARE)
private String software;
@JsonProperty (PROPERTIES_X_RESOLUTION)
@JsonProperty(PROPERTIES_X_RESOLUTION)
private Double xResolution;
@JsonProperty (PROPERTIES_Y_RESOLUTION)
@JsonProperty(PROPERTIES_Y_RESOLUTION)
private Double yResolution;
/*************************************/
/** Non-electronic record parameters */
/*************************************/
@JsonProperty (PROPERTIES_SHELF)
@JsonProperty(PROPERTIES_SHELF)
private String shelf;
@JsonProperty (PROPERTIES_STORAGE_LOCATION)
@JsonProperty(PROPERTIES_STORAGE_LOCATION)
private String storageLocation;
@JsonProperty (PROPERTIES_FILE)
@JsonProperty(PROPERTIES_FILE)
private String file;
@JsonProperty (PROPERTIES_BOX)
@JsonProperty(PROPERTIES_BOX)
private String box;
@JsonProperty (PROPERTIES_NUMBER_OF_COPIES)
@JsonProperty(PROPERTIES_NUMBER_OF_COPIES)
private Integer numberOfCopies;
@JsonProperty (PROPERTIES_PHYSICAL_SIZE)
@JsonProperty(PROPERTIES_PHYSICAL_SIZE)
private Integer physicalSize;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
}

View File

@@ -31,10 +31,8 @@ import org.alfresco.rest.core.RestModels;
/**
* Handle collection of {@link TransferEntry}
*
* @author Silviu Dinuta
* @since 2.6
*/
public class TransferCollection extends RestModels<TransferEntry, TransferCollection>
{
}
public class TransferCollection extends RestModels<TransferEntry, TransferCollection> {}

View File

@@ -27,9 +27,6 @@
package org.alfresco.rest.rm.community.model.transfer;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -38,6 +35,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer;
/**
* POJO for transfer entry
*
@@ -49,8 +49,6 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferEntry extends RestModels<TransferContainer, TransferEntry>
{
@JsonProperty
private Transfer entry;
public class TransferEntry extends RestModels<TransferContainer, TransferEntry> {
@JsonProperty private Transfer entry;
}

View File

@@ -27,15 +27,12 @@
package org.alfresco.rest.rm.community.model.transfer;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ACCESSION_INDICATOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PDF_INDICATOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TRANSFER_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ACCESSION_INDICATOR;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -45,6 +42,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
/**
* POJO for Transfer properties
*
@@ -56,29 +56,28 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferProperties extends TestModel
{
public class TransferProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
/************************/
/** Optional parameters */
/************************/
@JsonProperty (PROPERTIES_ROOT_NODE_REF)
@JsonProperty(PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
@JsonProperty (PROPERTIES_PDF_INDICATOR)
@JsonProperty(PROPERTIES_PDF_INDICATOR)
private Boolean pdfIndicator;
@JsonProperty (PROPERTIES_TRANSFER_LOCATION)
@JsonProperty(PROPERTIES_TRANSFER_LOCATION)
private String transferLocation;
@JsonProperty (PROPERTIES_ACCESSION_INDICATOR)
@JsonProperty(PROPERTIES_ACCESSION_INDICATOR)
private Boolean accessionIndicator;
}

View File

@@ -27,19 +27,19 @@
package org.alfresco.rest.rm.community.model.transfercontainer;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for Transfer Container
*
@@ -51,44 +51,42 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferContainer extends TestModel
{
public class TransferContainer extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private TransferContainerProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
}

View File

@@ -31,8 +31,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -41,6 +39,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
* POJO for Transfer Container properties
*
@@ -52,21 +52,19 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class TransferContainerProperties extends TestModel
{
public class TransferContainerProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
/************************/
/** Optional parameters */
/************************/
@JsonProperty (PROPERTIES_ROOT_NODE_REF)
@JsonProperty(PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (PROPERTIES_COUNT)
@JsonProperty(PROPERTIES_COUNT)
private Integer count;
}

View File

@@ -26,12 +26,6 @@
*/
package org.alfresco.rest.rm.community.model.unfiledcontainer;
import java.util.List;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -40,6 +34,12 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for unfiled container
*
@@ -51,47 +51,44 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class UnfiledContainer extends TestModel
{
public class UnfiledContainer extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
@JsonProperty (required = true)
@JsonProperty(required = true)
private List<String> aspectNames;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private UnfiledContainerProperties properties;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
}

View File

@@ -26,13 +26,6 @@
*/
package org.alfresco.rest.rm.community.model.unfiledcontainer;
import java.util.List;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -42,6 +35,13 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for record category child
*
@@ -53,66 +53,57 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class UnfiledContainerChild extends TestModel
{
@JsonIgnoreProperties(ignoreUnknown = true)
public class UnfiledContainerChild extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private Boolean isUnfiledRecordFolder;
@JsonProperty (required = true)
@JsonProperty(required = true)
private Boolean isRecord;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private UnfiledContainerChildProperties properties;
@JsonProperty private UnfiledContainerChildProperties properties;
@JsonProperty
private List<String> aspectNames;
@JsonProperty private List<String> aspectNames;
@JsonProperty
private Boolean isClosed;
@JsonProperty private Boolean isClosed;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
@JsonProperty
private String relativePath;
@JsonProperty private String relativePath;
@JsonProperty
private RecordContent content;
@JsonProperty private RecordContent content;
@JsonProperty
private Boolean isCompleted;
@JsonProperty private Boolean isCompleted;
}

View File

@@ -35,7 +35,5 @@ import org.alfresco.rest.core.RestModels;
* @author Tuna Aksoy
* @since 2.6
*/
public class UnfiledContainerChildCollection extends RestModels<UnfiledContainerChildEntry, UnfiledContainerChildCollection>
{
}
public class UnfiledContainerChildCollection
extends RestModels<UnfiledContainerChildEntry, UnfiledContainerChildCollection> {}

View File

@@ -28,11 +28,11 @@ package org.alfresco.rest.rm.community.model.unfiledcontainer;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alfresco.rest.core.RestModels;
/**
* POJO for record category child entry
*
@@ -41,8 +41,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class UnfiledContainerChildEntry extends RestModels<UnfiledContainer, UnfiledContainerChildEntry>
{
@JsonProperty
private UnfiledContainerChild entry;
public class UnfiledContainerChildEntry
extends RestModels<UnfiledContainer, UnfiledContainerChildEntry> {
@JsonProperty private UnfiledContainerChild entry;
}

View File

@@ -62,15 +62,15 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
/**
* POJO for record category child properties
*
@@ -83,112 +83,111 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class UnfiledContainerChildProperties extends TestModel
{
@JsonIgnoreProperties(ignoreUnknown = true)
public class UnfiledContainerChildProperties extends TestModel {
/**************************************************************************/
/** Mandatory parameters - Shared by unfiled record folder and records */
/**************************************************************************/
@JsonProperty (required = true, value = PROPERTIES_TITLE)
@JsonProperty(required = true, value = PROPERTIES_TITLE)
private String title;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_DESCRIPTION)
@JsonProperty(required = true, value = PROPERTIES_DESCRIPTION)
private String description;
@JsonProperty (value = PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
@JsonProperty(value = PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
/*********************************/
/** Electronic record parameters */
/*********************************/
@JsonProperty (PROPERTIES_VERSION_TYPE)
@JsonProperty(PROPERTIES_VERSION_TYPE)
private String versionType;
@JsonProperty (PROPERTIES_VERSION_LABEL)
@JsonProperty(PROPERTIES_VERSION_LABEL)
private String versionLabel;
@JsonProperty(PROPERTIES_VERSIONED_NODEREF)
private String versionedNodeRef;
@JsonProperty (PROPERTIES_RMV_VERSIONED)
@JsonProperty(PROPERTIES_RMV_VERSIONED)
private String recordVersionLabel;
@JsonProperty (PROPERTIES_DATE_TIME_ORIGINAL)
@JsonProperty(PROPERTIES_DATE_TIME_ORIGINAL)
private String dateTimeOriginal;
@JsonProperty (PROPERTIES_EXPOSURE_TIME)
@JsonProperty(PROPERTIES_EXPOSURE_TIME)
private Double exposureTime;
@JsonProperty (PROPERTIES_FLASH)
@JsonProperty(PROPERTIES_FLASH)
private Boolean flash;
@JsonProperty (PROPERTIES_F_NUMBER)
@JsonProperty(PROPERTIES_F_NUMBER)
private Double fNumber;
@JsonProperty (PROPERTIES_FOCAL_LENGTH)
@JsonProperty(PROPERTIES_FOCAL_LENGTH)
private Double focalLength;
@JsonProperty (PROPERTIES_ISO_SPEED_RATINGS)
@JsonProperty(PROPERTIES_ISO_SPEED_RATINGS)
private Integer isoSpeedRatings;
@JsonProperty (PROPERTIES_MANUFACTURER)
@JsonProperty(PROPERTIES_MANUFACTURER)
private String manufacturer;
@JsonProperty (PROPERTIES_MODEL)
@JsonProperty(PROPERTIES_MODEL)
private String model;
@JsonProperty (PROPERTIES_ORIENTATION)
@JsonProperty(PROPERTIES_ORIENTATION)
private Integer orientation;
@JsonProperty (PROPERTIES_PIXEL_X_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_X_DIMENSION)
private Integer pixelXDimension;
@JsonProperty (PROPERTIES_PIXEL_Y_DIMENSION)
@JsonProperty(PROPERTIES_PIXEL_Y_DIMENSION)
private Integer pixelYDimension;
@JsonProperty (PROPERTIES_RESOLUTION_UNIT)
@JsonProperty(PROPERTIES_RESOLUTION_UNIT)
private String resolutionUnit;
@JsonProperty (PROPERTIES_SOFTWARE)
@JsonProperty(PROPERTIES_SOFTWARE)
private String software;
@JsonProperty (PROPERTIES_X_RESOLUTION)
@JsonProperty(PROPERTIES_X_RESOLUTION)
private Double xResolution;
@JsonProperty (PROPERTIES_Y_RESOLUTION)
@JsonProperty(PROPERTIES_Y_RESOLUTION)
private Double yResolution;
@JsonProperty (PROPERTIES_ORIGINAL_NAME)
@JsonProperty(PROPERTIES_ORIGINAL_NAME)
private String originalName;
/*************************************/
/** Non-electronic record parameters */
/*************************************/
@JsonProperty (PROPERTIES_SHELF)
@JsonProperty(PROPERTIES_SHELF)
private String shelf;
@JsonProperty (PROPERTIES_STORAGE_LOCATION)
@JsonProperty(PROPERTIES_STORAGE_LOCATION)
private String storageLocation;
@JsonProperty (PROPERTIES_FILE)
@JsonProperty(PROPERTIES_FILE)
private String file;
@JsonProperty (PROPERTIES_BOX)
@JsonProperty(PROPERTIES_BOX)
private String box;
@JsonProperty (PROPERTIES_NUMBER_OF_COPIES)
@JsonProperty(PROPERTIES_NUMBER_OF_COPIES)
private Integer numberOfCopies;
@JsonProperty (PROPERTIES_PHYSICAL_SIZE)
@JsonProperty(PROPERTIES_PHYSICAL_SIZE)
private Integer physicalSize;
@JsonProperty (PROPERTIES_OWNER)
@JsonProperty(PROPERTIES_OWNER)
private Owner owner;
}

View File

@@ -32,14 +32,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel;
/**
* POJO for file plan properties
*
@@ -51,15 +51,14 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true)
public class UnfiledContainerProperties extends TestModel
{
@JsonIgnoreProperties(ignoreUnknown = true)
public class UnfiledContainerProperties extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
@JsonProperty(required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
@JsonProperty(required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
}

View File

@@ -26,13 +26,6 @@
*/
package org.alfresco.rest.rm.community.model.unfiledcontainer;
import java.util.List;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -41,6 +34,13 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.utility.model.TestModel;
import java.util.List;
/**
* POJO for unfiled container
*
@@ -52,62 +52,52 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class UnfiledRecordFolder extends TestModel
{
public class UnfiledRecordFolder extends TestModel {
/*************************/
/** Mandatory parameters */
/*************************/
@JsonProperty (required = true)
@JsonProperty(required = true)
private String createdAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel createdByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String modifiedAt;
@JsonProperty (required = true)
@JsonProperty(required = true)
private RestByUserModel modifiedByUser;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String name;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String id;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String nodeType;
@JsonProperty (required = true)
@JsonProperty(required = true)
private String parentId;
/************************/
/** Optional parameters */
/************************/
@JsonProperty
private UnfiledContainerChildProperties properties;
@JsonProperty private UnfiledContainerChildProperties properties;
@JsonProperty
private List<String> aspectNames;
@JsonProperty private List<String> aspectNames;
@JsonProperty
private Boolean hasRetentionSchedule;
@JsonProperty private Boolean hasRetentionSchedule;
@JsonProperty
private Boolean isClosed;
@JsonProperty private Boolean isClosed;
@JsonProperty
private List<String> allowableOperations;
@JsonProperty private List<String> allowableOperations;
@JsonProperty
private Path path;
@JsonProperty private Path path;
@JsonProperty
private String relativePath;
@JsonProperty private String relativePath;
@JsonProperty
private RecordContent content;
@JsonProperty private RecordContent content;
@JsonProperty
private Boolean isCompleted;
@JsonProperty private Boolean isCompleted;
}

View File

@@ -32,8 +32,7 @@ package org.alfresco.rest.rm.community.model.user;
* @author Rodica Sutu
* @since 2.7
*/
public class UserCapabilities
{
public class UserCapabilities {
/** The id of the view records capability. */
public static final String VIEW_RECORDS_CAP = "ViewRecords";

View File

@@ -28,20 +28,18 @@ package org.alfresco.rest.rm.community.model.user;
/**
* Constants for RM user capabilities
*
*
* @author Kristijan Conkas
* @since 2.6
*/
public enum UserPermissions
{
public enum UserPermissions {
PERMISSION_FILING("Filing"),
PERMISSION_READ_RECORDS("ReadRecords"),
PERMISSION_FILE_RECORDS("FileRecords");
public final String permissionId;
UserPermissions(String permissionId)
{
UserPermissions(String permissionId) {
this.permissionId = permissionId;
}
}

View File

@@ -33,8 +33,7 @@ package org.alfresco.rest.rm.community.model.user;
* @author Kristijan Conkas
* @since 2.6
*/
public enum UserRoles
{
public enum UserRoles {
IN_PLACE_WRITERS("ExtendedWriters", "In-Place Writers"),
ROLE_RM_ADMIN("Administrator", "Records Management Administrator"),
ROLE_RM_MANAGER("RecordsManager", "Records Management Manager"),
@@ -45,11 +44,8 @@ public enum UserRoles
public final String roleId;
public final String displayName;
UserRoles(String roleId, String displayName)
{
UserRoles(String roleId, String displayName) {
this.roleId = roleId;
this.displayName = displayName;
}
}

View File

@@ -29,29 +29,25 @@ package org.alfresco.rest.rm.community.requests;
import static lombok.AccessLevel.PRIVATE;
import static lombok.AccessLevel.PROTECTED;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.requests.ModelRequest;
import lombok.Getter;
import lombok.Setter;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.requests.ModelRequest;
/**
* Extends {@link ModelRequest} to set {@link RMRestWrapper}
*
* @author Tuna Aksoy
* @since 2.6
*/
public abstract class RMModelRequest<Request> extends ModelRequest<Request>
{
@Getter (value = PROTECTED)
@Setter (value = PRIVATE)
public abstract class RMModelRequest<Request> extends ModelRequest<Request> {
@Getter(value = PROTECTED)
@Setter(value = PRIVATE)
private RMRestWrapper rmRestWrapper;
/**
* @param rmRestWrapper
*/
public RMModelRequest(RMRestWrapper rmRestWrapper)
{
/** @param rmRestWrapper */
public RMModelRequest(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper.getRestWrapper());
setRmRestWrapper(rmRestWrapper);
}

View File

@@ -33,8 +33,8 @@ import io.restassured.RestAssured;
import org.alfresco.rest.core.RMRestProperties;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.requests.gscore.api.ActionsExecutionAPI;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.requests.gscore.api.ActionsExecutionAPI;
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.RMSiteAPI;
@@ -48,24 +48,22 @@ import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
/**
* Defines the entire GS Core API
* {@link http://host:port/gs-api-explorer} select "GS Core API"
* Defines the entire GS Core API {@link http://host:port/gs-api-explorer} select "GS Core API"
*
* @author Tuna Aksoy
* @since 2.6
*/
public class GSCoreAPI extends RMModelRequest
{
public class GSCoreAPI extends RMModelRequest {
/**
* Constructor
*
* @param rmRestWrapper RM REST Wrapper
* @param rmRestProperties RM REST Properties
*/
public GSCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties)
{
public GSCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties) {
super(rmRestWrapper);
RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
RestAssured.baseURI =
format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
RestAssured.port = parseInt(rmRestProperties.getPort());
RestAssured.basePath = rmRestProperties.getRestRmPath();
restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath);
@@ -76,9 +74,8 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link RMSiteAPI}
*/
public RMSiteAPI usingRMSite()
{
return new RMSiteAPI(getRmRestWrapper());
public RMSiteAPI usingRMSite() {
return new RMSiteAPI(getRmRestWrapper());
}
/**
@@ -86,8 +83,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link FilePlanAPI}
*/
public FilePlanAPI usingFilePlans()
{
public FilePlanAPI usingFilePlans() {
return new FilePlanAPI(getRmRestWrapper());
}
@@ -96,8 +92,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link RecordCategoryAPI}
*/
public RecordCategoryAPI usingRecordCategory()
{
public RecordCategoryAPI usingRecordCategory() {
return new RecordCategoryAPI(getRmRestWrapper());
}
@@ -106,8 +101,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link RecordFolderAPI}
*/
public RecordFolderAPI usingRecordFolder()
{
public RecordFolderAPI usingRecordFolder() {
return new RecordFolderAPI(getRmRestWrapper());
}
@@ -116,8 +110,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link RecordsAPI}
*/
public RecordsAPI usingRecords()
{
public RecordsAPI usingRecords() {
return new RecordsAPI(getRmRestWrapper());
}
@@ -126,8 +119,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link FilesAPI}
*/
public FilesAPI usingFiles()
{
public FilesAPI usingFiles() {
return new FilesAPI(getRmRestWrapper());
}
@@ -136,8 +128,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link TransferContainerAPI}
*/
public TransferContainerAPI usingTransferContainer()
{
public TransferContainerAPI usingTransferContainer() {
return new TransferContainerAPI(getRmRestWrapper());
}
@@ -146,8 +137,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link TransferAPI}
*/
public TransferAPI usingTransfer()
{
public TransferAPI usingTransfer() {
return new TransferAPI(getRmRestWrapper());
}
@@ -156,8 +146,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link UnfiledContainerAPI}
*/
public UnfiledContainerAPI usingUnfiledContainers()
{
public UnfiledContainerAPI usingUnfiledContainers() {
return new UnfiledContainerAPI(getRmRestWrapper());
}
@@ -166,8 +155,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link UnfiledRecordFolderAPI}
*/
public UnfiledRecordFolderAPI usingUnfiledRecordFolder()
{
public UnfiledRecordFolderAPI usingUnfiledRecordFolder() {
return new UnfiledRecordFolderAPI(getRmRestWrapper());
}
@@ -176,8 +164,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link RMUserAPI}
*/
public RMUserAPI usingRMUser()
{
public RMUserAPI usingRMUser() {
return new RMUserAPI(getRmRestWrapper());
}
@@ -186,8 +173,7 @@ public class GSCoreAPI extends RMModelRequest
*
* @return {@link ActionsExecutionAPI}
*/
public ActionsExecutionAPI usingActionsExecutionsAPI()
{
public ActionsExecutionAPI usingActionsExecutionsAPI() {
return new ActionsExecutionAPI(getRmRestWrapper());
}
}

View File

@@ -29,6 +29,7 @@ package org.alfresco.rest.rm.community.requests.gscore.api;
import com.google.common.collect.ImmutableMap;
import lombok.SneakyThrows;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
@@ -41,28 +42,28 @@ import org.json.JSONObject;
* @author Claudia Agache
* @since 3.1
*/
public class ActionsExecutionAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public ActionsExecutionAPI(RMRestWrapper rmRestWrapper)
{
public class ActionsExecutionAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public ActionsExecutionAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* Declares and files a document as record to a record folder using v1 actions api
*
* @param targetNode the node on which the action is executed
* @param targetNode the node on which the action is executed
* @param destinationPath the path to the record folder
* @throws Exception
*/
public JSONObject declareAndFile(RepoTestModel targetNode, String destinationPath) throws Exception
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.DECLARE_AS_RECORD.getActionValue(), targetNode,
ImmutableMap.of("path", destinationPath));
public JSONObject declareAndFile(RepoTestModel targetNode, String destinationPath)
throws Exception {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(
ActionsOnRule.DECLARE_AS_RECORD.getActionValue(),
targetNode,
ImmutableMap.of("path", destinationPath));
}
/**
@@ -71,25 +72,29 @@ public class ActionsExecutionAPI extends RMModelRequest
* @param targetNode the node on which the action is executed
* @throws Exception
*/
public JSONObject declareAsRecord(RepoTestModel targetNode) throws Exception
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.DECLARE_AS_RECORD.getActionValue(), targetNode);
public JSONObject declareAsRecord(RepoTestModel targetNode) throws Exception {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(ActionsOnRule.DECLARE_AS_RECORD.getActionValue(), targetNode);
}
/**
* Declares and file a document version as record to a record folder using v1 actions api
*
* @param targetNode the node on which the action is executed
* @param targetNode the node on which the action is executed
* @param destinationPath the path to the record folder
* @throws Exception
*/
public JSONObject declareAndFileVersionAsRecord(RepoTestModel targetNode, String destinationPath) throws Exception
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(), targetNode,
ImmutableMap.of("path", destinationPath));
public JSONObject declareAndFileVersionAsRecord(
RepoTestModel targetNode, String destinationPath) throws Exception {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(
ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(),
targetNode,
ImmutableMap.of("path", destinationPath));
}
/**
@@ -98,10 +103,12 @@ public class ActionsExecutionAPI extends RMModelRequest
* @param targetNode the node on which the action is executed
* @throws Exception
*/
public JSONObject declareVersionAsRecord(RepoTestModel targetNode) throws Exception
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(), targetNode);
public JSONObject declareVersionAsRecord(RepoTestModel targetNode) throws Exception {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(
ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(), targetNode);
}
/**
@@ -111,24 +118,28 @@ public class ActionsExecutionAPI extends RMModelRequest
* @throws Exception
*/
@SneakyThrows
public JSONObject addWORMLock(RepoTestModel targetNode)
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.WORM_LOCK.getActionValue(), targetNode);
public JSONObject addWORMLock(RepoTestModel targetNode) {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(ActionsOnRule.WORM_LOCK.getActionValue(), targetNode);
}
/**
* WORM lock a node for a period of days
*
* @param targetNode the node on which the action is executed
* @param targetNode the node on which the action is executed
* @param retentionPeriod the retention period in days for the WORM lock
* @throws Exception
*/
@SneakyThrows
public JSONObject addWORMLock(RepoTestModel targetNode, int retentionPeriod)
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.WORM_LOCK.getActionValue(), targetNode,
ImmutableMap.of("retentionPeriod", String.valueOf(retentionPeriod)));
public JSONObject addWORMLock(RepoTestModel targetNode, int retentionPeriod) {
return getRmRestWrapper()
.withCoreAPI()
.usingActions()
.executeAction(
ActionsOnRule.WORM_LOCK.getActionValue(),
targetNode,
ImmutableMap.of("retentionPeriod", String.valueOf(retentionPeriod)));
}
}

View File

@@ -49,23 +49,18 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanAPI extends RMModelRequest
{
public class FilePlanAPI extends RMModelRequest {
/**
* Constructor.
*
* @param rmRestWrapper RM REST Wrapper
*/
public FilePlanAPI(RMRestWrapper rmRestWrapper)
{
public FilePlanAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* see {@link #getFilePlan(String, String)}
*/
public FilePlan getFilePlan(String filePlanId)
{
/** see {@link #getFilePlan(String, String)} */
public FilePlan getFilePlan(String filePlanId) {
mandatoryString("filePlanId", filePlanId);
return getFilePlan(filePlanId, EMPTY);
@@ -78,30 +73,28 @@ public class FilePlanAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link FilePlan} for the given {@code filePlanId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code filePlanId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code filePlanId}</li>
* <li>{@code filePlanId} does not exist</li>
* </ul>
* <ul>
* <li>{@code filePlanId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code filePlanId}
* <li>{@code filePlanId} does not exist
* </ul>
*/
public FilePlan getFilePlan(String filePlanId, String parameters)
{
public FilePlan getFilePlan(String filePlanId, String parameters) {
mandatoryString("filePlanId", filePlanId);
return getRmRestWrapper().processModel(FilePlan.class, simpleRequest(
GET,
"/file-plans/{filePlanId}?{parameters}",
filePlanId,
parameters
));
return getRmRestWrapper()
.processModel(
FilePlan.class,
simpleRequest(
GET,
"/file-plans/{filePlanId}?{parameters}",
filePlanId,
parameters));
}
/**
* see {@link #getRootRecordCategories(String, String)}
*/
public RecordCategoryCollection getRootRecordCategories(String filePlanId)
{
/** see {@link #getRootRecordCategories(String, String)} */
public RecordCategoryCollection getRootRecordCategories(String filePlanId) {
mandatoryString("filePlanId", filePlanId);
return getRootRecordCategories(filePlanId, EMPTY);
@@ -114,29 +107,28 @@ public class FilePlanAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link RecordCategoryCollection} for the given {@code filePlanId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code filePlanId}</li>
* <li>{@code filePlanId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code filePlanId}
* <li>{@code filePlanId} does not exist
* </ul>
*/
public RecordCategoryCollection getRootRecordCategories(String filePlanId, String parameters)
{
public RecordCategoryCollection getRootRecordCategories(String filePlanId, String parameters) {
mandatoryString("filePlanId", filePlanId);
return getRmRestWrapper().processModels(RecordCategoryCollection.class, simpleRequest(
GET,
"file-plans/{filePlanId}/categories?{parameters}",
filePlanId,
parameters
));
return getRmRestWrapper()
.processModels(
RecordCategoryCollection.class,
simpleRequest(
GET,
"file-plans/{filePlanId}/categories?{parameters}",
filePlanId,
parameters));
}
/**
* see {@link #createRootRecordCategory(RecordCategory, String, String)}
*/
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId)
{
/** see {@link #createRootRecordCategory(RecordCategory, String, String)} */
public RecordCategory createRootRecordCategory(
RecordCategory recordCategoryModel, String filePlanId) {
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("filePlanId", filePlanId);
@@ -151,34 +143,35 @@ public class FilePlanAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The created {@link RecordCategory}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code filePlanId} is not a valid format or {@code filePlanId} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to add children to {@code filePlanId}</li>
* <li>{@code filePlanIds} does not exist</li>
* <li>new name clashes with an existing node in the current parent container</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
* <ul>
* <li>{@code filePlanId} is not a valid format or {@code filePlanId} is invalid
* <li>authentication fails
* <li>current user does not have permission to add children to {@code filePlanId}
* <li>{@code filePlanIds} does not exist
* <li>new name clashes with an existing node in the current parent container
* <li>model integrity exception, including node name with invalid characters
* </ul>
*/
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId, String parameters)
{
public RecordCategory createRootRecordCategory(
RecordCategory recordCategoryModel, String filePlanId, String parameters) {
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("filePlanId", filePlanId);
return getRmRestWrapper().processModel(RecordCategory.class, requestWithBody(
POST,
toJson(recordCategoryModel),
"file-plans/{filePlanId}/categories?{parameters}",
filePlanId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordCategory.class,
requestWithBody(
POST,
toJson(recordCategoryModel),
"file-plans/{filePlanId}/categories?{parameters}",
filePlanId,
parameters));
}
/**
* see {@link #updateFilePlan(FilePlan, String, String)
*/
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId)
{
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId) {
mandatoryObject("filePlanModel", filePlanModel);
mandatoryString("filePlanId", filePlanId);
@@ -188,29 +181,31 @@ public class FilePlanAPI extends RMModelRequest
/**
* Updates a file plan.
*
* @param filePlanModel The file plan model which holds the information
* @param filePlanId The identifier of the file plan
* @param parameters The URL parameters to add
* @param filePlanModel The file plan model which holds the information
* @param filePlanId The identifier of the file plan
* @param parameters The URL parameters to add
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code filePlanId} is not a valid format or {@code filePlanModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code filePlanId}</li>
* <li>{@code filePlanId} does not exist</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code filePlanId} is not a valid format or {@code
* filePlanModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code filePlanId}
* <li>{@code filePlanId} does not exist
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId, String parameters)
{
public FilePlan updateFilePlan(FilePlan filePlanModel, String filePlanId, String parameters) {
mandatoryObject("filePlanModel", filePlanModel);
mandatoryString("filePlanId", filePlanId);
return getRmRestWrapper().processModel(FilePlan.class, requestWithBody(
PUT,
toJson(filePlanModel),
"file-plans/{filePlanId}?{parameters}",
filePlanId,
parameters));
return getRmRestWrapper()
.processModel(
FilePlan.class,
requestWithBody(
PUT,
toJson(filePlanModel),
"file-plans/{filePlanId}?{parameters}",
filePlanId,
parameters));
}
}

View File

@@ -40,15 +40,11 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Kristijan Conkas
* @since 2.6
*/
public class FilesAPI extends RMModelRequest<FilesAPI>
{
public class FilesAPI extends RMModelRequest<FilesAPI> {
public static final String PARENT_ID_PARAM = "parentId";
/**
* @param rmRestWrapper RM REST Wrapper
*/
public FilesAPI(RMRestWrapper rmRestWrapper)
{
/** @param rmRestWrapper RM REST Wrapper */
public FilesAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
@@ -59,16 +55,16 @@ public class FilesAPI extends RMModelRequest<FilesAPI>
* @return The {@link Record} for created record
* @throws RuntimeException for malformed JSON responses
*/
public Record declareAsRecord(String fileId)
{
public Record declareAsRecord(String fileId) {
mandatoryString("fileId", fileId);
return getRmRestWrapper().processModel(Record.class, simpleRequest(
POST,
"/files/{fileId}/declare?{parameters}",
fileId,
getRmRestWrapper().getParameters()
));
return getRmRestWrapper()
.processModel(
Record.class,
simpleRequest(
POST,
"/files/{fileId}/declare?{parameters}",
fileId,
getRmRestWrapper().getParameters()));
}
}

View File

@@ -46,15 +46,13 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Tuna Aksoy
* @since 2.6
*/
public class RMSiteAPI extends RMModelRequest
{
public class RMSiteAPI extends RMModelRequest {
/**
* Constructor
*
* @param rmRestWrapper RM REST Wrapper
*/
public RMSiteAPI(RMRestWrapper rmRestWrapper)
{
public RMSiteAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
@@ -63,19 +61,16 @@ public class RMSiteAPI extends RMModelRequest
*
* @return The {@link RMSite} for the given file plan component id
* @throws RuntimeException for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</li>
* <li>Api Response code 409 If RM Site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM
* site
* <li>Api Response code 401 If authentication failed
* <li>Api Response code 409 If RM Site does not exist
* <li>Api Response code default Unexpected error
* </ul>
*/
public RMSite getSite()
{
return getRmRestWrapper().processModel(RMSite.class, simpleRequest(
GET,
"gs-sites/rm"
));
public RMSite getSite() {
return getRmRestWrapper().processModel(RMSite.class, simpleRequest(GET, "gs-sites/rm"));
}
/**
@@ -84,41 +79,37 @@ public class RMSiteAPI extends RMModelRequest
* @param rmSiteModel The properties of the rm site to be created
* @return The {@link RMSite} with the given properties
* @throws RuntimeException for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: title, or description exceed the maximum length; or siteBodyCreate invalid</li>
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 409 RM Site already exists</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
* <ul>
* <li>Api Response code 400 Invalid parameter: title, or description exceed the maximum
* length; or siteBodyCreate invalid
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 409 RM Site already exists
* <li>Api Response code default Unexpected error
* </ul>
*/
public RMSite createRMSite(RMSite rmSiteModel)
{
public RMSite createRMSite(RMSite rmSiteModel) {
mandatoryObject("rmSiteModel", rmSiteModel);
return getRmRestWrapper().processModel(RMSite.class, requestWithBody(
POST,
toJson(rmSiteModel),
"gs-sites"
));
return getRmRestWrapper()
.processModel(RMSite.class, requestWithBody(POST, toJson(rmSiteModel), "gs-sites"));
}
/**
* Delete RM site
*
* @throws RuntimeException for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: DELETE request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 403 Current user does not have permission to delete the site that is visible to them.</li>
* <li>Api Response code 404 RM site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
* <ul>
* <li>Api Response code 400 Invalid parameter: DELETE request is supported only for the
* RM site
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 403 Current user does not have permission to delete the site that
* is visible to them.
* <li>Api Response code 404 RM site does not exist
* <li>Api Response code default Unexpected error
* </ul>
*/
public void deleteRMSite()
{
getRmRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"gs-sites/rm"
));
public void deleteRMSite() {
getRmRestWrapper().processEmptyModel(simpleRequest(DELETE, "gs-sites/rm"));
}
/**
@@ -127,23 +118,20 @@ public class RMSiteAPI extends RMModelRequest
* @param rmSiteModel The properties to be updated
* @return The updated {@link RMSite}
* @throws RuntimeException for the following cases:
* <ul>
* <li>Api Response code 400 the update request is invalid {@code rmSiteModel} is invalid</li>
* <li>Api Response code 401 If authentication fails</li>
* <li>Api Response code 403 does not have permission to update {@code RMSite}</li>
* <li>Api Response code 404 {@code RMSiteModel} does not exist</li>
* <li>Api Response code default Unexpected error,model integrity exception</li>
* </ul>
* <ul>
* <li>Api Response code 400 the update request is invalid {@code rmSiteModel} is invalid
* <li>Api Response code 401 If authentication fails
* <li>Api Response code 403 does not have permission to update {@code RMSite}
* <li>Api Response code 404 {@code RMSiteModel} does not exist
* <li>Api Response code default Unexpected error,model integrity exception
* </ul>
*/
public RMSite updateRMSite(RMSite rmSiteModel)
{
public RMSite updateRMSite(RMSite rmSiteModel) {
mandatoryObject("rmSiteProperties", rmSiteModel);
return getRmRestWrapper().processModel(RMSite.class, requestWithBody(
PUT,
toJson(rmSiteModel),
"gs-sites/rm"
));
return getRmRestWrapper()
.processModel(
RMSite.class, requestWithBody(PUT, toJson(rmSiteModel), "gs-sites/rm"));
}
/**
@@ -151,15 +139,15 @@ public class RMSiteAPI extends RMModelRequest
*
* @return <code>true</code> if the RM site exists, <code>false</code> otherwise
* @throws RuntimeException for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</li>
* <li>Api Response code 409 If RM Site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM
* site
* <li>Api Response code 401 If authentication failed
* <li>Api Response code 409 If RM Site does not exist
* <li>Api Response code default Unexpected error
* </ul>
*/
public boolean existsRMSite()
{
public boolean existsRMSite() {
getSite();
return getRmRestWrapper().getStatusCode().equals(String.valueOf(OK.value()));
}

View File

@@ -26,6 +26,9 @@
*/
package org.alfresco.rest.rm.community.requests.gscore.api;
import static io.restassured.RestAssured.basic;
import static io.restassured.RestAssured.given;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.OK;
@@ -35,8 +38,6 @@ import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import static io.restassured.RestAssured.basic;
import static io.restassured.RestAssured.given;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
@@ -54,24 +55,21 @@ import org.alfresco.utility.model.UserModel;
* @since 2.6
*/
// FIXME: As of December 2016 there is no v1-style API for managing RM users and users'
// roles/permissions. 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.
public class RMUserAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public RMUserAPI(RMRestWrapper rmRestWrapper)
{
public class RMUserAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public RMUserAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* Helper method to obtain {@link AlfrescoHttpClient}
*
* @return Initialized {@link AlfrescoHttpClient} instance
*/
private AlfrescoHttpClient getAlfrescoHttpClient()
{
private AlfrescoHttpClient getAlfrescoHttpClient() {
RMRestProperties properties = getRmRestWrapper().getRmRestProperties();
AlfrescoHttpClientFactory factory = new AlfrescoHttpClientFactory();
@@ -89,117 +87,120 @@ public class RMUserAPI extends RMModelRequest
* @param userRole User's RM role, one of {@link UserRoles} roles
* @throws RuntimeException for failed requests
*/
public void assignRoleToUser(String userName, String userRole)
{
public void assignRoleToUser(String userName, String userRole) {
UserModel adminUser = getRmRestWrapper().getTestUser();
// get an "old-style" REST API client
AlfrescoHttpClient client = getAlfrescoHttpClient();
// override v1 baseURI and basePath
RequestSpecification spec = new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.build();
RequestSpecification spec =
new RequestSpecBuilder().setBaseUri(client.getApiUrl()).setBasePath("/").build();
Response response = given()
.spec(spec)
.log().all()
.pathParam("role", userRole)
.pathParam("authority", userName)
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
adminUser.getPassword()))
.when()
.post("/rm/roles/{role}/authorities/{authority}")
.prettyPeek()
.andReturn();
Response response =
given().spec(spec)
.log()
.all()
.pathParam("role", userRole)
.pathParam("authority", userName)
.param(
"alf_ticket",
client.getAlfTicket(
adminUser.getUsername(), adminUser.getPassword()))
.when()
.post("/rm/roles/{role}/authorities/{authority}")
.prettyPeek()
.andReturn();
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
}
/**
* Helper method to add permission on a component to user
* @param filePlanComponentId The id of the file plan component on which permission should be given
*
* @param filePlanComponentId The id of the file plan component 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(String filePlanComponentId, UserModel user, UserPermissions permission)
{
public void addUserPermission(
String filePlanComponentId, UserModel user, UserPermissions permission) {
UserModel adminUser = getRmRestWrapper().getTestUser();
// get an "old-style" REST API client
AlfrescoHttpClient client = getAlfrescoHttpClient();
JsonObject bodyJson = buildObject()
.addArray("permissions")
.addObject()
.add("authority", user.getUsername())
.add("role", permission.permissionId)
.end()
.getJson();
JsonObject bodyJson =
buildObject()
.addArray("permissions")
.addObject()
.add("authority", user.getUsername())
.add("role", permission.permissionId)
.end()
.getJson();
// override v1 baseURI and basePath
RequestSpecification spec = new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.build();
RequestSpecification spec =
new RequestSpecBuilder().setBaseUri(client.getApiUrl()).setBasePath("/").build();
// execute an "old-style" API call
Response response = given()
.spec(spec)
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
.contentType(ContentType.JSON)
.body(bodyJson.toString())
.pathParam("nodeId", filePlanComponentId)
.log().all()
.when()
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
.prettyPeek()
.andReturn();
Response response =
given().spec(spec)
.auth()
.basic(adminUser.getUsername(), adminUser.getPassword())
.contentType(ContentType.JSON)
.body(bodyJson.toString())
.pathParam("nodeId", filePlanComponentId)
.log()
.all()
.when()
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
.prettyPeek()
.andReturn();
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
}
/**
* Helper method to set permission inheritance on a file plan component
*
* @param filePlanComponentId The id of the file plan component on which inherited permission should be set
* @param isInherited true if the permission is inherited
* false if the permission inheritance is disabled
* @param filePlanComponentId The id of the file plan component on which inherited permission
* should be set
* @param isInherited true if the permission is inherited false if the permission inheritance is
* disabled
*/
public void setUserPermissionInheritance(String filePlanComponentId, Boolean isInherited)
{
public void setUserPermissionInheritance(String filePlanComponentId, Boolean isInherited) {
final UserModel adminUser = getRmRestWrapper().getTestUser();
// get an "old-style" REST API client
final AlfrescoHttpClient client = getAlfrescoHttpClient();
final JsonObject bodyJson = buildObject()
.addArray("permissions")
.end()
.add("isInherited", isInherited)
.getJson();
final JsonObject bodyJson =
buildObject()
.addArray("permissions")
.end()
.add("isInherited", isInherited)
.getJson();
// override v1 baseURI and basePath
RequestSpecification spec = new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.build();
RequestSpecification spec =
new RequestSpecBuilder().setBaseUri(client.getApiUrl()).setBasePath("/").build();
// execute an "old-style" API call
final Response response = given()
.spec(spec)
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
.contentType(ContentType.JSON)
.body(bodyJson.toString())
.pathParam("nodeId", filePlanComponentId)
.log().all()
.when()
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
.prettyPeek()
.andReturn();
final Response response =
given().spec(spec)
.auth()
.basic(adminUser.getUsername(), adminUser.getPassword())
.contentType(ContentType.JSON)
.body(bodyJson.toString())
.pathParam("nodeId", filePlanComponentId)
.log()
.all()
.when()
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
.prettyPeek()
.andReturn();
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
}
/**
* Creates a user with the given name using the old APIs
*
@@ -208,35 +209,31 @@ public class RMUserAPI extends RMModelRequest
* @param userEmail The user's e-mail address
* @return <code>true</code> if the user was created successfully, <code>false</code> otherwise.
*/
public boolean createUser(String userName, String userPassword, String userEmail)
{
public boolean createUser(String userName, String userPassword, String userEmail) {
UserModel adminUser = getRmRestWrapper().getTestUser();
final AlfrescoHttpClient client = getAlfrescoHttpClient();
JsonObject body = buildObject()
.add("userName", userName)
.add("firstName", userName)
.add("lastName", userName)
.add("password", userPassword)
.add("email", userEmail)
.getJson();
JsonObject body =
buildObject()
.add("userName", userName)
.add("firstName", userName)
.add("lastName", userName)
.add("password", userPassword)
.add("email", userEmail)
.getJson();
final RequestSpecification spec = new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.setAuth(basic(adminUser.getUsername(), adminUser.getPassword()))
.setContentType(ContentType.JSON)
.setBody(body.toString())
.build();
final RequestSpecification spec =
new RequestSpecBuilder()
.setBaseUri(client.getApiUrl())
.setBasePath("/")
.setAuth(basic(adminUser.getUsername(), adminUser.getPassword()))
.setContentType(ContentType.JSON)
.setBody(body.toString())
.build();
// create POST request to "people" endpoint
Response response = given()
.spec(spec)
.log().all()
.when()
.post("people")
.prettyPeek()
.andReturn();
Response response =
given().spec(spec).log().all().when().post("people").prettyPeek().andReturn();
return (response.getStatusCode() == OK.value());
}

View File

@@ -49,15 +49,13 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Tuna Aksoy
* @since 2.6
*/
public class RecordCategoryAPI extends RMModelRequest
{
public class RecordCategoryAPI extends RMModelRequest {
/**
* Constructor.
*
* @param rmRestWrapper RM REST Wrapper
*/
public RecordCategoryAPI(RMRestWrapper rmRestWrapper)
{
public RecordCategoryAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
@@ -66,30 +64,25 @@ public class RecordCategoryAPI extends RMModelRequest
*
* @param recordCategoryId The identifier of a record category
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordCategoryId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to delete {@code recordCategoryId}</li>
* <li>{@code recordCategoryId} does not exist</li>
* <li>{@code recordCategoryId} is locked and cannot be deleted</li>
* </ul>
* <ul>
* <li>{@code recordCategoryId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to delete {@code recordCategoryId}
* <li>{@code recordCategoryId} does not exist
* <li>{@code recordCategoryId} is locked and cannot be deleted
* </ul>
*/
public void deleteRecordCategory(String recordCategoryId)
{
public void deleteRecordCategory(String recordCategoryId) {
mandatoryString("recordCategoryId", recordCategoryId);
getRmRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"record-categories/{recordCategoryId}",
recordCategoryId
));
getRmRestWrapper()
.processEmptyModel(
simpleRequest(
DELETE, "record-categories/{recordCategoryId}", recordCategoryId));
}
/**
* see {@link #getRecordCategory(String, String)}
*/
public RecordCategory getRecordCategory(String recordCategoryId)
{
/** see {@link #getRecordCategory(String, String)} */
public RecordCategory getRecordCategory(String recordCategoryId) {
mandatoryString("recordCategoryId", recordCategoryId);
return getRecordCategory(recordCategoryId, EMPTY);
@@ -102,30 +95,31 @@ public class RecordCategoryAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link RecordCategory} for the given {@code recordCategoryId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordCategoryId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code recordCategoryId}</li>
* <li>{@code recordCategoryId} does not exist</li>
* </ul>
* <ul>
* <li>{@code recordCategoryId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code recordCategoryId}
* <li>{@code recordCategoryId} does not exist
* </ul>
*/
public RecordCategory getRecordCategory(String recordCategoryId, String parameters)
{
public RecordCategory getRecordCategory(String recordCategoryId, String parameters) {
mandatoryString("recordCategoryId", recordCategoryId);
return getRmRestWrapper().processModel(RecordCategory.class, simpleRequest(
GET,
"record-categories/{recordCategoryId}?{parameters}",
recordCategoryId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordCategory.class,
simpleRequest(
GET,
"record-categories/{recordCategoryId}?{parameters}",
recordCategoryId,
parameters));
}
/**
* see {@link #updateRecordCategory(RecordCategory, String, String)
*/
public RecordCategory updateRecordCategory(RecordCategory recordCategoryModel, String recordCategoryId)
{
public RecordCategory updateRecordCategory(
RecordCategory recordCategoryModel, String recordCategoryId) {
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("recordCategoryId", recordCategoryId);
@@ -140,34 +134,35 @@ public class RecordCategoryAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @param returns The updated {@link RecordCategory}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code recordCategoryId} is not a valid format or {@code recordCategoryModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code recordCategoryId}</li>
* <li>{@code recordCategoryId} does not exist</li>
* <li>the updated name clashes with an existing record category in the current parent category</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code recordCategoryId} is not a valid format or
* {@code recordCategoryModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code recordCategoryId}
* <li>{@code recordCategoryId} does not exist
* <li>the updated name clashes with an existing record category in the current parent
* category
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public RecordCategory updateRecordCategory(RecordCategory recordCategoryModel, String recordCategoryId, String parameters)
{
public RecordCategory updateRecordCategory(
RecordCategory recordCategoryModel, String recordCategoryId, String parameters) {
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("recordCategoryId", recordCategoryId);
return getRmRestWrapper().processModel(RecordCategory.class, requestWithBody(
PUT,
toJson(recordCategoryModel),
"record-categories/{recordCategoryId}?{parameters}",
recordCategoryId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordCategory.class,
requestWithBody(
PUT,
toJson(recordCategoryModel),
"record-categories/{recordCategoryId}?{parameters}",
recordCategoryId,
parameters));
}
/**
* see {@link #getRecordCategoryChildren(String, String)}
*/
public RecordCategoryChildCollection getRecordCategoryChildren(String recordCategoryId)
{
/** see {@link #getRecordCategoryChildren(String, String)} */
public RecordCategoryChildCollection getRecordCategoryChildren(String recordCategoryId) {
mandatoryString("recordCategoryId", recordCategoryId);
return getRecordCategoryChildren(recordCategoryId, EMPTY);
@@ -180,29 +175,29 @@ public class RecordCategoryAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link RecordCategoryChildCollection} for the given {@code recordCategoryId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code recordCategoryId}</li>
* <li>{@code recordCategoryId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code recordCategoryId}
* <li>{@code recordCategoryId} does not exist
* </ul>
*/
public RecordCategoryChildCollection getRecordCategoryChildren(String recordCategoryId, String parameters)
{
public RecordCategoryChildCollection getRecordCategoryChildren(
String recordCategoryId, String parameters) {
mandatoryString("recordCategoryId", recordCategoryId);
return getRmRestWrapper().processModels(RecordCategoryChildCollection.class, simpleRequest(
GET,
"record-categories/{recordCategoryId}/children?{parameters}",
recordCategoryId,
parameters
));
return getRmRestWrapper()
.processModels(
RecordCategoryChildCollection.class,
simpleRequest(
GET,
"record-categories/{recordCategoryId}/children?{parameters}",
recordCategoryId,
parameters));
}
/**
* see {@link #createRecordCategoryChild(RecordCategoryChild, String, String)}
*/
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId)
{
/** see {@link #createRecordCategoryChild(RecordCategoryChild, String, String)} */
public RecordCategoryChild createRecordCategoryChild(
RecordCategoryChild recordCategoryChildModel, String recordCategoryId) {
mandatoryObject("recordCategoryChildModel", recordCategoryChildModel);
mandatoryString("recordCategoryId", recordCategoryId);
@@ -217,26 +212,31 @@ public class RecordCategoryAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The created {@link RecordCategoryChild}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordCategoryId} is not a valid format or {@code recordCategoryChildModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to add children to {@code recordCategoryId}</li>
* <li>{@code recordCategoryId} does not exist</li>
* <li>new name clashes with an existing node in the current parent container</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
* <ul>
* <li>{@code recordCategoryId} is not a valid format or {@code recordCategoryChildModel}
* is invalid
* <li>authentication fails
* <li>current user does not have permission to add children to {@code recordCategoryId}
* <li>{@code recordCategoryId} does not exist
* <li>new name clashes with an existing node in the current parent container
* <li>model integrity exception, including node name with invalid characters
* </ul>
*/
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId, String parameters)
{
public RecordCategoryChild createRecordCategoryChild(
RecordCategoryChild recordCategoryChildModel,
String recordCategoryId,
String parameters) {
mandatoryObject("filePlanComponentProperties", recordCategoryChildModel);
mandatoryString("recordCategoryId", recordCategoryId);
return getRmRestWrapper().processModel(RecordCategoryChild.class, requestWithBody(
POST,
toJson(recordCategoryChildModel),
"record-categories/{recordCategoryId}/children?{parameters}",
recordCategoryId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordCategoryChild.class,
requestWithBody(
POST,
toJson(recordCategoryChildModel),
"record-categories/{recordCategoryId}/children?{parameters}",
recordCategoryId,
parameters));
}
}

View File

@@ -39,12 +39,9 @@ import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
@@ -55,21 +52,23 @@ import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
/**
* Record folder REST API Wrapper
*
* @author Tuna Aksoy
* @since 2.6
*/
public class RecordFolderAPI extends RMModelRequest
{
public class RecordFolderAPI extends RMModelRequest {
/**
* Constructor.
*
* @param rmRestWrapper RM REST Wrapper
*/
public RecordFolderAPI(RMRestWrapper rmRestWrapper)
{
public RecordFolderAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
@@ -78,30 +77,24 @@ public class RecordFolderAPI extends RMModelRequest
*
* @param recordFolderId The identifier of a record folder
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordFolderId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to delete {@code recordFolderId}</li>
* <li>{@code recordFolderId} does not exist</li>
* <li>{@code recordFolderId} is locked and cannot be deleted</li>
* </ul>
* <ul>
* <li>{@code recordFolderId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to delete {@code recordFolderId}
* <li>{@code recordFolderId} does not exist
* <li>{@code recordFolderId} is locked and cannot be deleted
* </ul>
*/
public void deleteRecordFolder(String recordFolderId)
{
public void deleteRecordFolder(String recordFolderId) {
mandatoryString("recordFolderId", recordFolderId);
getRmRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"record-folders/{recordFolderId}",
recordFolderId
));
getRmRestWrapper()
.processEmptyModel(
simpleRequest(DELETE, "record-folders/{recordFolderId}", recordFolderId));
}
/**
* see {@link #getRecordFolder(String, String)}
*/
public RecordFolder getRecordFolder(String recordFolderId)
{
/** see {@link #getRecordFolder(String, String)} */
public RecordFolder getRecordFolder(String recordFolderId) {
mandatoryString("recordFolderId", recordFolderId);
return getRecordFolder(recordFolderId, EMPTY);
@@ -114,30 +107,30 @@ public class RecordFolderAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link RecordFolder} for the given {@code recordFolderId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordFolderId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code recordFolderId}</li>
* <li>{@code recordFolderId} does not exist</li>
* </ul>
* <ul>
* <li>{@code recordFolderId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code recordFolderId}
* <li>{@code recordFolderId} does not exist
* </ul>
*/
public RecordFolder getRecordFolder(String recordFolderId, String parameters)
{
public RecordFolder getRecordFolder(String recordFolderId, String parameters) {
mandatoryString("recordFolderId", recordFolderId);
return getRmRestWrapper().processModel(RecordFolder.class, simpleRequest(
GET,
"record-folders/{recordFolderId}?{parameters}",
recordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordFolder.class,
simpleRequest(
GET,
"record-folders/{recordFolderId}?{parameters}",
recordFolderId,
parameters));
}
/**
* see {@link #updateRecordFolder(RecordFolder, String, String)
*/
public RecordFolder updateRecordFolder(RecordFolder recordFolderModel, String recordFolderId)
{
public RecordFolder updateRecordFolder(RecordFolder recordFolderModel, String recordFolderId) {
mandatoryObject("recordFolderModel", recordFolderModel);
mandatoryString("recordFolderId", recordFolderId);
@@ -152,34 +145,35 @@ public class RecordFolderAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @param returns The updated {@link RecordFolder}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code recordFolderId} is not a valid format or {@code recordFolderModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code recordFolderId}</li>
* <li>{@code recordFolderId} does not exist</li>
* <li>the updated name clashes with an existing record folder in the current parent category</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code recordFolderId} is not a valid format or
* {@code recordFolderModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code recordFolderId}
* <li>{@code recordFolderId} does not exist
* <li>the updated name clashes with an existing record folder in the current parent
* category
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public RecordFolder updateRecordFolder(RecordFolder recordFolderModel, String recordFolderId, String parameters)
{
public RecordFolder updateRecordFolder(
RecordFolder recordFolderModel, String recordFolderId, String parameters) {
mandatoryObject("recordFolderModel", recordFolderModel);
mandatoryString("recordFolderId", recordFolderId);
return getRmRestWrapper().processModel(RecordFolder.class, requestWithBody(
PUT,
toJson(recordFolderModel),
"record-folders/{recordFolderId}?{parameters}",
recordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
RecordFolder.class,
requestWithBody(
PUT,
toJson(recordFolderModel),
"record-folders/{recordFolderId}?{parameters}",
recordFolderId,
parameters));
}
/**
* see {@link #getRecordFolderChildren(String, String)}
*/
public RecordFolderCollection getRecordFolderChildren(String recordFolderId)
{
/** see {@link #getRecordFolderChildren(String, String)} */
public RecordFolderCollection getRecordFolderChildren(String recordFolderId) {
mandatoryString("recordFolderId", recordFolderId);
return getRecordFolderChildren(recordFolderId, EMPTY);
@@ -192,29 +186,28 @@ public class RecordFolderAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link RecordFolderCollection} for the given {@code recordFolderId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code recordFolderId}</li>
* <li>{@code recordFolderId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code recordFolderId}
* <li>{@code recordFolderId} does not exist
* </ul>
*/
public RecordFolderCollection getRecordFolderChildren(String recordFolderId, String parameters)
{
public RecordFolderCollection getRecordFolderChildren(
String recordFolderId, String parameters) {
mandatoryString("recordFolderId", recordFolderId);
return getRmRestWrapper().processModels(RecordFolderCollection.class, simpleRequest(
GET,
"record-folders/{recordFolderId}/records?{parameters}",
recordFolderId,
parameters
));
return getRmRestWrapper()
.processModels(
RecordFolderCollection.class,
simpleRequest(
GET,
"record-folders/{recordFolderId}/records?{parameters}",
recordFolderId,
parameters));
}
/**
* see {@link #createRecord(Record, String, String)}
*/
public Record createRecord(Record recordModel, String recordFolderId)
{
/** see {@link #createRecord(Record, String, String)} */
public Record createRecord(Record recordModel, String recordFolderId) {
mandatoryObject("recordModel", recordModel);
mandatoryString("recordFolderId", recordFolderId);
@@ -225,19 +218,19 @@ public class RecordFolderAPI extends RMModelRequest
* Create a record from file resource
*
* @param recordModel {@link Record} for electronic record to be created
* @param recordContent {@link File} pointing to the content of the electronic record to be created
* @param recordContent {@link File} pointing to the content of the electronic record to be
* created
* @param recordFolderId The identifier of a record folder
* @return newly created {@link Record}
* @throws RuntimeException for invalid recordModel JSON strings
*/
public Record createRecord(Record recordModel, String recordFolderId, File recordContent) throws RuntimeException
{
public Record createRecord(Record recordModel, String recordFolderId, File recordContent)
throws RuntimeException {
mandatoryString("recordFolderId", recordFolderId);
mandatoryObject("recordContent", recordContent);
mandatoryObject("recordModel", recordModel);
if (!recordModel.getNodeType().equals(CONTENT_TYPE))
{
if (!recordModel.getNodeType().equals(CONTENT_TYPE)) {
fail("Only electronic records are supported");
}
@@ -247,18 +240,20 @@ public class RecordFolderAPI extends RMModelRequest
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root;
try
{
root = new ObjectMapper().readTree(toJson(recordModel, Record.class, FilePlanComponentMixIn.class));
}
catch (IOException e)
{
try {
root =
new ObjectMapper()
.readTree(
toJson(
recordModel,
Record.class,
FilePlanComponentMixIn.class));
} catch (IOException e) {
throw new RuntimeException("Failed to convert model to JSON.", e);
}
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())
{
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name());
}
@@ -284,17 +279,18 @@ public class RecordFolderAPI extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public Record createRecord(Record recordModel, String recordFolderId, String parameters)
{
public Record createRecord(Record recordModel, String recordFolderId, String parameters) {
mandatoryObject("recordModel", recordModel);
mandatoryString("recordFolderId", recordFolderId);
return getRmRestWrapper().processModel(Record.class, requestWithBody(
POST,
toJson(recordModel),
"record-folders/{recordFolderId}/records?{parameters}",
recordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
Record.class,
requestWithBody(
POST,
toJson(recordModel),
"record-folders/{recordFolderId}/records?{parameters}",
recordFolderId,
parameters));
}
}

View File

@@ -37,27 +37,22 @@ import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import io.restassured.response.ResponseBody;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.record.RecordBodyFile;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import io.restassured.response.ResponseBody;
/**
* Records REST API Wrapper
*
* @author Rodica Sutu
* @since 2.6
*/
public class RecordsAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public RecordsAPI(RMRestWrapper rmRestWrapper)
{
public class RecordsAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public RecordsAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
@@ -67,42 +62,40 @@ public class RecordsAPI extends RMModelRequest
* @param recordId The id of the electronic record
* @return {@link ResponseBody} representing content for the given record id
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordId} has no content</li>
* <li> {@code recordId} is not a valid format, or is not a record</li>
* <li>authentication fails</li>
* <li>{@code recordId} does not exist</li>
* </ul>
* <ul>
* <li>{@code recordId} has no content
* <li>{@code recordId} is not a valid format, or is not a record
* <li>authentication fails
* <li>{@code recordId} does not exist
* </ul>
*/
public ResponseBody<?> getRecordContent(String recordId)
{
public ResponseBody<?> getRecordContent(String recordId) {
mandatoryString("recordId", recordId);
return getRmRestWrapper()
.processHtmlResponse(simpleRequest(GET,"records/{recordId}/content", recordId))
.getBody();
.processHtmlResponse(simpleRequest(GET, "records/{recordId}/content", recordId))
.getBody();
}
/**
* File the record recordId into file plan structure based on the location sent via the request body
* File the record recordId into file plan structure based on the location sent via the request
* body
*
* @param recordBodyFile The properties where to file the record
* @param recordId The id of the record to file
* @param recordId The id of the record to file
* @return The {@link Record} with the given properties
* @throws RuntimeException for the following cases:
* <ul>
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is not a record</li>
* <li>authentication fails</li>
* <li>current user does not have permission to file to {@code fileplanComponentId}</li>
* <li>{@code recordId} does not exist</li>
* <li>targetParentId from recordBodyFile does not exist</li>
* <li>model integrity exception: the action breaks system's integrity restrictions</li>
* </ul>
*
* <ul>
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is
* not a record
* <li>authentication fails
* <li>current user does not have permission to file to {@code fileplanComponentId}
* <li>{@code recordId} does not exist
* <li>targetParentId from recordBodyFile does not exist
* <li>model integrity exception: the action breaks system's integrity restrictions
* </ul>
*/
public Record fileRecord(RecordBodyFile recordBodyFile, String recordId)
{
public Record fileRecord(RecordBodyFile recordBodyFile, String recordId) {
mandatoryObject("recordBodyFile", recordBodyFile);
mandatoryString("recordId", recordId);
@@ -110,41 +103,42 @@ public class RecordsAPI extends RMModelRequest
}
/**
* File the record recordId into file plan structure based on the location sent via the request body
* File the record recordId into file plan structure based on the location sent via the request
* body
*
* @param recordBodyFile The properties where to file the record
* @param recordId The id of the record to file
* @param recordId The id of the record to file
* @return The {@link Record} with the given properties
* @throws RuntimeException for the following cases:
* <ul>
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is not a record</li>
* <li>authentication fails</li>
* <li>current user does not have permission to file to {@code fileplanComponentId}</li>
* <li>{@code recordId} does not exist</li>
* <li>targetParentId from recordBodyFile does not exist</li>
* <li>model integrity exception: the action breaks system's integrity restrictions</li>
* </ul>
*
* <ul>
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is
* not a record
* <li>authentication fails
* <li>current user does not have permission to file to {@code fileplanComponentId}
* <li>{@code recordId} does not exist
* <li>targetParentId from recordBodyFile does not exist
* <li>model integrity exception: the action breaks system's integrity restrictions
* </ul>
*/
public Record fileRecord(RecordBodyFile recordBodyFile, String recordId, String parameters)
{
public Record fileRecord(RecordBodyFile recordBodyFile, String recordId, String parameters) {
mandatoryObject("requestBodyFile", recordBodyFile);
mandatoryString("recordId", recordId);
return getRmRestWrapper().processModel(Record.class, requestWithBody(
POST,
toJson(recordBodyFile),
"/records/{recordId}/file?{parameters}",
recordId,
parameters
));
return getRmRestWrapper()
.processModel(
Record.class,
requestWithBody(
POST,
toJson(recordBodyFile),
"/records/{recordId}/file?{parameters}",
recordId,
parameters));
}
/**
* see {@link #completeRecord(String, String)
*/
public Record completeRecord(String recordId)
{
public Record completeRecord(String recordId) {
mandatoryString("recordId", recordId);
return completeRecord(recordId, EMPTY);
@@ -156,55 +150,48 @@ public class RecordsAPI extends RMModelRequest
* @param recordId The id of the record to complete
* @return The completed {@link Record} with the given properties
* @throws RuntimeException for the following cases:
* <ul>
* <li>Invalid parameter: {@code recordId} is not a record</li>
* <li>authentication fails</li>
* <li>current user does not have permission to complete {@code recordId}</li>
* <li>{@code recordId} does not exist or is frozen</li>
* <li>model integrity exception: the record is already completed</li>
* <li>model integrity exception: the record has missing meta-data</li>
* </ul>
* <ul>
* <li>Invalid parameter: {@code recordId} is not a record
* <li>authentication fails
* <li>current user does not have permission to complete {@code recordId}
* <li>{@code recordId} does not exist or is frozen
* <li>model integrity exception: the record is already completed
* <li>model integrity exception: the record has missing meta-data
* </ul>
*/
public Record completeRecord(String recordId, String parameters)
{
public Record completeRecord(String recordId, String parameters) {
mandatoryString("recordId", recordId);
return getRmRestWrapper().processModel(Record.class, simpleRequest(
POST,
"/records/{recordId}/complete?{parameters}",
recordId,
parameters
));
return getRmRestWrapper()
.processModel(
Record.class,
simpleRequest(
POST,
"/records/{recordId}/complete?{parameters}",
recordId,
parameters));
}
/**
* Deletes a record.
*
* @param recordId The identifier of a record
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to delete {@code recordId}</li>
* <li>{@code recordId} does not exist</li>
* <li>{@code recordId} is locked and cannot be deleted</li>
* </ul>
* <ul>
* <li>{@code recordId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to delete {@code recordId}
* <li>{@code recordId} does not exist
* <li>{@code recordId} is locked and cannot be deleted
* </ul>
*/
public void deleteRecord(String recordId)
{
public void deleteRecord(String recordId) {
mandatoryString("recordId", recordId);
getRmRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"records/{recordId}",
recordId
));
getRmRestWrapper().processEmptyModel(simpleRequest(DELETE, "records/{recordId}", recordId));
}
/**
* see {@link #getRecord(String, String)}
*/
public Record getRecord(String recordId)
{
/** see {@link #getRecord(String, String)} */
public Record getRecord(String recordId) {
mandatoryString("recordId", recordId);
return getRecord(recordId, EMPTY);
@@ -217,30 +204,27 @@ public class RecordsAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link Record} for the given {@code recordId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code recordId}</li>
* <li>{@code recordId} does not exist</li>
* </ul>
* <ul>
* <li>{@code recordId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code recordId}
* <li>{@code recordId} does not exist
* </ul>
*/
public Record getRecord(String recordId, String parameters)
{
public Record getRecord(String recordId, String parameters) {
mandatoryString("recordId", recordId);
return getRmRestWrapper().processModel(Record.class, simpleRequest(
GET,
"records/{recordId}?{parameters}",
recordId,
parameters
));
return getRmRestWrapper()
.processModel(
Record.class,
simpleRequest(
GET, "records/{recordId}?{parameters}", recordId, parameters));
}
/**
* see {@link #updateRecord(Record, String, String)
*/
public Record updateRecord(Record recordModel, String recordId)
{
public Record updateRecord(Record recordModel, String recordId) {
mandatoryObject("recordModel", recordModel);
mandatoryString("recordId", recordId);
@@ -255,26 +239,28 @@ public class RecordsAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The updated {@link Record}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code recordId} is not a valid format or {@code recordModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code recordId}</li>
* <li>{@code recordId} does not exist</li>
* <li>the updated name clashes with an existing record in the current parent folder</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code recordId} is not a valid format or {@code
* recordModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code recordId}
* <li>{@code recordId} does not exist
* <li>the updated name clashes with an existing record in the current parent folder
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public Record updateRecord(Record recordModel, String recordId, String parameters)
{
public Record updateRecord(Record recordModel, String recordId, String parameters) {
mandatoryObject("recordModel", recordModel);
mandatoryString("recordId", recordId);
return getRmRestWrapper().processModel(Record.class, requestWithBody(
PUT,
toJson(recordModel),
"records/{recordId}?{parameters}",
recordId,
parameters
));
return getRmRestWrapper()
.processModel(
Record.class,
requestWithBody(
PUT,
toJson(recordModel),
"records/{recordId}?{parameters}",
recordId,
parameters));
}
}

View File

@@ -43,21 +43,14 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Silviu Dinuta
* @since 2.6
*/
public class TransferAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public TransferAPI(RMRestWrapper rmRestWrapper)
{
public class TransferAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public TransferAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* see {@link #getTransfer(String, String)}
*/
public Transfer getTransfer(String transferId)
{
/** see {@link #getTransfer(String, String)} */
public Transfer getTransfer(String transferId) {
mandatoryString("transferId", transferId);
return getTransfer(transferId, EMPTY);
@@ -70,29 +63,27 @@ public class TransferAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link Transfer} for the given {@code transferId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code transferId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code transferId}</li>
* <li>{@code transferId} does not exist</li>
* </ul>
* <ul>
* <li>{@code transferId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code transferId}
* <li>{@code transferId} does not exist
* </ul>
*/
public Transfer getTransfer(String transferId, String parameters)
{
public Transfer getTransfer(String transferId, String parameters) {
mandatoryString("transferId", transferId);
return getRmRestWrapper().processModel(Transfer.class, simpleRequest(
GET,
"/transfers/{transferId}?{parameters}",
transferId,
parameters
));
return getRmRestWrapper()
.processModel(
Transfer.class,
simpleRequest(
GET,
"/transfers/{transferId}?{parameters}",
transferId,
parameters));
}
/**
* see {@link #getTransfersChildren(String, String)}
*/
public TransferChildCollection getTransfersChildren(String transferId)
{
/** see {@link #getTransfersChildren(String, String)} */
public TransferChildCollection getTransfersChildren(String transferId) {
mandatoryString("transferId", transferId);
return getTransfersChildren(transferId, EMPTY);
@@ -105,21 +96,22 @@ public class TransferAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link TransferChildCollection} for the given {@code transferId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code transferId}</li>
* <li>{@code filePlanId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code transferId}
* <li>{@code filePlanId} does not exist
* </ul>
*/
public TransferChildCollection getTransfersChildren(String transferId, String parameters)
{
public TransferChildCollection getTransfersChildren(String transferId, String parameters) {
mandatoryString("transferId", transferId);
return getRmRestWrapper().processModels(TransferChildCollection.class, simpleRequest(
GET,
"transfers/{filePlanId}/children?{parameters}",
transferId,
parameters
));
return getRmRestWrapper()
.processModels(
TransferChildCollection.class,
simpleRequest(
GET,
"transfers/{filePlanId}/children?{parameters}",
transferId,
parameters));
}
}

View File

@@ -47,21 +47,14 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
* @author Silviu Dinuta
* @since 2.6
*/
public class TransferContainerAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public TransferContainerAPI(RMRestWrapper rmRestWrapper)
{
public class TransferContainerAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public TransferContainerAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* see {@link #getTransferContainer(String, String)}
*/
public TransferContainer getTransferContainer(String transferContainerId)
{
/** see {@link #getTransferContainer(String, String)} */
public TransferContainer getTransferContainer(String transferContainerId) {
mandatoryString("transferContainerId", transferContainerId);
return getTransferContainer(transferContainerId, EMPTY);
@@ -74,30 +67,31 @@ public class TransferContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link TransferContainer} for the given {@code transferContainerId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code transferContainerId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code transferContainerId}</li>
* <li>{@code transferContainerId} does not exist</li>
* </ul>
* <ul>
* <li>{@code transferContainerId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code transferContainerId}
* <li>{@code transferContainerId} does not exist
* </ul>
*/
public TransferContainer getTransferContainer(String transferContainerId, String parameters)
{
public TransferContainer getTransferContainer(String transferContainerId, String parameters) {
mandatoryString("transferContainerId", transferContainerId);
return getRmRestWrapper().processModel(TransferContainer.class, simpleRequest(
GET,
"/transfer-containers/{transferContainerId}?{parameters}",
transferContainerId,
parameters
));
return getRmRestWrapper()
.processModel(
TransferContainer.class,
simpleRequest(
GET,
"/transfer-containers/{transferContainerId}?{parameters}",
transferContainerId,
parameters));
}
/**
* see {@link #updateTransferContainer(TransferContainer, String, String)
*/
public TransferContainer updateTransferContainer(TransferContainer transferContainerModel, String transferContainerId)
{
public TransferContainer updateTransferContainer(
TransferContainer transferContainerModel, String transferContainerId) {
mandatoryObject("transferContainerModel", transferContainerModel);
mandatoryString("transferContainerId", transferContainerId);
@@ -112,34 +106,38 @@ public class TransferContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @param returns The updated {@link TransferContainer}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code transferContainerId} is not a valid format or {@code transferContainerModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code transferContainerId}</li>
* <li>{@code transferContainerId} does not exist</li>
* <li>the updated name clashes with an existing transfer container in the current file plan</li>
* <li>model integrity exception, including transfer container name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code transferContainerId} is not a valid format
* or {@code transferContainerModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code transferContainerId}
* <li>{@code transferContainerId} does not exist
* <li>the updated name clashes with an existing transfer container in the current file
* plan
* <li>model integrity exception, including transfer container name with invalid
* characters
* </ul>
*/
public TransferContainer updateTransferContainer(TransferContainer transferContainerModel, String transferContainerId, String parameters)
{
public TransferContainer updateTransferContainer(
TransferContainer transferContainerModel,
String transferContainerId,
String parameters) {
mandatoryObject("transferContainerModel", transferContainerModel);
mandatoryString("transferContainerId", transferContainerId);
return getRmRestWrapper().processModel(TransferContainer.class, requestWithBody(
PUT,
toJson(transferContainerModel),
"transfer-containers/{transferContainerId}?{parameters}",
transferContainerId,
parameters
));
return getRmRestWrapper()
.processModel(
TransferContainer.class,
requestWithBody(
PUT,
toJson(transferContainerModel),
"transfer-containers/{transferContainerId}?{parameters}",
transferContainerId,
parameters));
}
/**
* see {@link #getTransfers(String, String)}
*/
public TransferCollection getTransfers(String transferContainerId)
{
/** see {@link #getTransfers(String, String)} */
public TransferCollection getTransfers(String transferContainerId) {
mandatoryString("transferContainerId", transferContainerId);
return getTransfers(transferContainerId, EMPTY);
@@ -152,21 +150,22 @@ public class TransferContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link TransferCollection} for the given {@code transferContainerId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code transferContainerId}</li>
* <li>{@code filePlanId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code transferContainerId}
* <li>{@code filePlanId} does not exist
* </ul>
*/
public TransferCollection getTransfers(String transferContainerId, String parameters)
{
public TransferCollection getTransfers(String transferContainerId, String parameters) {
mandatoryString("transferContainerId", transferContainerId);
return getRmRestWrapper().processModels(TransferCollection.class, simpleRequest(
GET,
"transfer-containers/{filePlanId}/transfers?{parameters}",
transferContainerId,
parameters
));
return getRmRestWrapper()
.processModels(
TransferCollection.class,
simpleRequest(
GET,
"transfer-containers/{filePlanId}/transfers?{parameters}",
transferContainerId,
parameters));
}
}

View File

@@ -38,10 +38,6 @@ import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -55,6 +51,10 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
/**
* Unfiled Container REST API Wrapper
*
@@ -62,21 +62,14 @@ import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
* @author Ana Bozianu
* @since 2.6
*/
public class UnfiledContainerAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public UnfiledContainerAPI(RMRestWrapper rmRestWrapper)
{
public class UnfiledContainerAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public UnfiledContainerAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* see {@link #getUnfiledContainer(String, String)}
*/
public UnfiledContainer getUnfiledContainer(String unfiledContainerId)
{
/** see {@link #getUnfiledContainer(String, String)} */
public UnfiledContainer getUnfiledContainer(String unfiledContainerId) {
mandatoryString("unfiledContainerId", unfiledContainerId);
return getUnfiledContainer(unfiledContainerId, EMPTY);
@@ -89,30 +82,28 @@ public class UnfiledContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link UnfiledContainer} for the given {@code unfiledContainerId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code unfiledContainerId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code unfiledContainerId}</li>
* <li>{@code unfiledContainerId} does not exist</li>
* </ul>
* <ul>
* <li>{@code unfiledContainerId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code unfiledContainerId}
* <li>{@code unfiledContainerId} does not exist
* </ul>
*/
public UnfiledContainer getUnfiledContainer(String unfiledContainerId, String parameters)
{
public UnfiledContainer getUnfiledContainer(String unfiledContainerId, String parameters) {
mandatoryString("unfiledContainerId", unfiledContainerId);
return getRmRestWrapper().processModel(UnfiledContainer.class, simpleRequest(
GET,
"unfiled-containers/{unfiledContainerId}?{parameters}",
unfiledContainerId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledContainer.class,
simpleRequest(
GET,
"unfiled-containers/{unfiledContainerId}?{parameters}",
unfiledContainerId,
parameters));
}
/**
* see {@link #getUnfiledContainerChildren(String)} (String, String)}
*/
public UnfiledContainerChildCollection getUnfiledContainerChildren(String unfiledContainerId)
{
/** see {@link #getUnfiledContainerChildren(String)} (String, String)} */
public UnfiledContainerChildCollection getUnfiledContainerChildren(String unfiledContainerId) {
mandatoryString("unfiledContainerId", unfiledContainerId);
return getUnfiledContainerChildren(unfiledContainerId, EMPTY);
@@ -125,29 +116,29 @@ public class UnfiledContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link UnfiledContainerChildCollection} for the given {@code unfiledContainerId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code unfiledContainerId}</li>
* <li>{@code unfiledContainerId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code unfiledContainerId}
* <li>{@code unfiledContainerId} does not exist
* </ul>
*/
public UnfiledContainerChildCollection getUnfiledContainerChildren(String unfiledContainerId, String parameters)
{
public UnfiledContainerChildCollection getUnfiledContainerChildren(
String unfiledContainerId, String parameters) {
mandatoryString("unfiledContainerId", unfiledContainerId);
return getRmRestWrapper().processModels(UnfiledContainerChildCollection.class, simpleRequest(
GET,
"unfiled-containers/{unfiledContainerId}/children?{parameters}",
unfiledContainerId,
parameters
));
return getRmRestWrapper()
.processModels(
UnfiledContainerChildCollection.class,
simpleRequest(
GET,
"unfiled-containers/{unfiledContainerId}/children?{parameters}",
unfiledContainerId,
parameters));
}
/**
* see {@link #createUnfiledContainerChild(UnfiledContainerChild, String, String)}
*/
public UnfiledContainerChild createUnfiledContainerChild(UnfiledContainerChild unfiledContainerChildModel, String unfiledContainerId)
{
/** see {@link #createUnfiledContainerChild(UnfiledContainerChild, String, String)} */
public UnfiledContainerChild createUnfiledContainerChild(
UnfiledContainerChild unfiledContainerChildModel, String unfiledContainerId) {
mandatoryObject("unfiledContainerChildModel", unfiledContainerChildModel);
mandatoryString("unfiledContainerId", unfiledContainerId);
@@ -157,51 +148,60 @@ public class UnfiledContainerAPI extends RMModelRequest
/**
* Creates an unfiled container child. Can be a record or an unfiled record folder.
*
* @param unfiledContainerChildModel The unfiled container child model which holds the information
* @param unfiledContainerChildModel The unfiled container child model which holds the
* information
* @param unfiledContainerId The identifier of an unfiled container
* @param parameters The URL parameters to add
* @return The created {@link UnfiledContainerChild}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code unfiledContainerId} is not a valid format or {@code unfiledContainerChildModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to add children to {@code unfiledContainerId}</li>
* <li>{@code unfiledContainerId} does not exist</li>
* <li>new name clashes with an existing node in the current parent container</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
* <ul>
* <li>{@code unfiledContainerId} is not a valid format or {@code
* unfiledContainerChildModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to add children to {@code unfiledContainerId}
* <li>{@code unfiledContainerId} does not exist
* <li>new name clashes with an existing node in the current parent container
* <li>model integrity exception, including node name with invalid characters
* </ul>
*/
public UnfiledContainerChild createUnfiledContainerChild(UnfiledContainerChild unfiledContainerChildModel, String unfiledContainerId, String parameters)
{
public UnfiledContainerChild createUnfiledContainerChild(
UnfiledContainerChild unfiledContainerChildModel,
String unfiledContainerId,
String parameters) {
mandatoryObject("unfiledContainerChildModel", unfiledContainerChildModel);
mandatoryString("unfiledContainerId", unfiledContainerId);
return getRmRestWrapper().processModel(UnfiledContainerChild.class, requestWithBody(
POST,
toJson(unfiledContainerChildModel),
"unfiled-containers/{unfiledContainerId}/children?{parameters}",
unfiledContainerId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledContainerChild.class,
requestWithBody(
POST,
toJson(unfiledContainerChildModel),
"unfiled-containers/{unfiledContainerId}/children?{parameters}",
unfiledContainerId,
parameters));
}
/**
* Create a record from file resource
*
* @param unfiledContainerChildModel {@link UnfiledContainerChild} for electronic record to be created
* @param unfiledContainerChildContent {@link File} pointing to the content of the electronic record to be created
* @param unfiledContainerChildModel {@link UnfiledContainerChild} for electronic record to be
* created
* @param unfiledContainerChildContent {@link File} pointing to the content of the electronic
* record to be created
* @param unfiledContainerId The identifier of a unfiled container
* @return newly created {@link UnfiledContainerChild}
* @throws RuntimeException for invalid recordModel JSON strings
*/
public UnfiledContainerChild uploadRecord(UnfiledContainerChild unfiledContainerChildModel, String unfiledContainerId, File unfiledContainerChildContent)
{
public UnfiledContainerChild uploadRecord(
UnfiledContainerChild unfiledContainerChildModel,
String unfiledContainerId,
File unfiledContainerChildContent) {
mandatoryObject("unfiledContainerChildModel", unfiledContainerChildModel);
mandatoryObject("unfiledContainerChildContent", unfiledContainerChildContent);
mandatoryString("unfiledContainerId", unfiledContainerId);
if (!unfiledContainerChildModel.getNodeType().equals(CONTENT_TYPE))
{
if (!unfiledContainerChildModel.getNodeType().equals(CONTENT_TYPE)) {
fail("Only electronic records are supported");
}
@@ -211,18 +211,20 @@ public class UnfiledContainerAPI extends RMModelRequest
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root;
try
{
root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
}
catch (IOException e)
{
try {
root =
new ObjectMapper()
.readTree(
toJson(
unfiledContainerChildModel,
UnfiledContainerChild.class,
UnfiledContainerChildMixin.class));
} catch (IOException e) {
throw new RuntimeException("Failed to convert model to JSON.", e);
}
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())
{
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name());
}
@@ -235,8 +237,8 @@ public class UnfiledContainerAPI extends RMModelRequest
/**
* see {@link #updateUnfiledContainer(UnfiledContainer, String, String)
*/
public UnfiledContainer updateUnfiledContainer(UnfiledContainer unfiledContainerModel, String unfiledContainerId)
{
public UnfiledContainer updateUnfiledContainer(
UnfiledContainer unfiledContainerModel, String unfiledContainerId) {
mandatoryObject("unfiledContainerModel", unfiledContainerModel);
mandatoryString("unfiledContainerId", unfiledContainerId);
@@ -251,27 +253,30 @@ public class UnfiledContainerAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @param returns The updated {@link UnfiledContainer}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code unfiledContainerId} is not a valid format or {@code unfiledContainerModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code unfiledContainerId}</li>
* <li>{@code unfiledContainerId} does not exist</li>
* <li>the updated name clashes with an existing root category of special container in the current fileplan</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code unfiledContainerId} is not a valid format
* or {@code unfiledContainerModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code unfiledContainerId}
* <li>{@code unfiledContainerId} does not exist
* <li>the updated name clashes with an existing root category of special container in the
* current fileplan
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public UnfiledContainer updateUnfiledContainer(UnfiledContainer unfiledContainerModel, String unfiledContainerId, String parameters)
{
public UnfiledContainer updateUnfiledContainer(
UnfiledContainer unfiledContainerModel, String unfiledContainerId, String parameters) {
mandatoryObject("unfiledContainerModel", unfiledContainerModel);
mandatoryString("unfiledContainerId", unfiledContainerId);
return getRmRestWrapper().processModel(UnfiledContainer.class, requestWithBody(
PUT,
toJson(unfiledContainerModel),
"unfiled-containers/{unfiledContainerId}?{parameters}",
unfiledContainerId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledContainer.class,
requestWithBody(
PUT,
toJson(unfiledContainerModel),
"unfiled-containers/{unfiledContainerId}?{parameters}",
unfiledContainerId,
parameters));
}
}

View File

@@ -39,12 +39,9 @@ import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
@@ -55,27 +52,24 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
/**
* Unfiled Record Folders REST API Wrapper
*
* @author Ramona Popa
* @since 2.6
*/
public class UnfiledRecordFolderAPI extends RMModelRequest
{
/**
* @param rmRestWrapper RM REST Wrapper
*/
public UnfiledRecordFolderAPI(RMRestWrapper rmRestWrapper)
{
public class UnfiledRecordFolderAPI extends RMModelRequest {
/** @param rmRestWrapper RM REST Wrapper */
public UnfiledRecordFolderAPI(RMRestWrapper rmRestWrapper) {
super(rmRestWrapper);
}
/**
* see {@link #getUnfiledRecordFolder(String, String)}
*/
public UnfiledRecordFolder getUnfiledRecordFolder(String unfiledRecordFolderId)
{
/** see {@link #getUnfiledRecordFolder(String, String)} */
public UnfiledRecordFolder getUnfiledRecordFolder(String unfiledRecordFolderId) {
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getUnfiledRecordFolder(unfiledRecordFolderId, EMPTY);
@@ -88,30 +82,30 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @return The {@link UnfiledRecordFolder} for the given {@code unfiledRecordFolderId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code unfiledRecordFolderId}</li>
* <li>{@code unfiledRecordFolderId} does not exist</li>
* </ul>
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to read {@code unfiledRecordFolderId}
* <li>{@code unfiledRecordFolderId} does not exist
* </ul>
*/
public UnfiledRecordFolder getUnfiledRecordFolder(String unfiledRecordFolderId, String parameters)
{
public UnfiledRecordFolder getUnfiledRecordFolder(
String unfiledRecordFolderId, String parameters) {
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getRmRestWrapper().processModel(UnfiledRecordFolder.class, simpleRequest(
GET,
"unfiled-record-folders/{unfiledRecordFolderId}?{parameters}",
unfiledRecordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledRecordFolder.class,
simpleRequest(
GET,
"unfiled-record-folders/{unfiledRecordFolderId}?{parameters}",
unfiledRecordFolderId,
parameters));
}
/**
* see {@link #getUnfiledRecordFolderChildren(String, String)}
*/
public UnfiledContainerChildCollection getUnfiledRecordFolderChildren(String unfiledRecordFolderId)
{
/** see {@link #getUnfiledRecordFolderChildren(String, String)} */
public UnfiledContainerChildCollection getUnfiledRecordFolderChildren(
String unfiledRecordFolderId) {
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getUnfiledRecordFolderChildren(unfiledRecordFolderId, EMPTY);
@@ -122,85 +116,97 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
*
* @param unfiledRecordFolderId The identifier of an unfiled records folder
* @param parameters The URL parameters to add
* @return The {@link UnfiledRecordFolderChildCollection} for the given {@code unfiledRecordFolderId}
* @return The {@link UnfiledRecordFolderChildCollection} for the given {@code
* unfiledRecordFolderId}
* @throws RuntimeException for the following cases:
* <ul>
* <li>authentication fails</li>
* <li>current user does not have permission to read {@code unfiledRecordFolderId}</li>
* <li>{@code unfiledRecordFolderId} does not exist</li>
*</ul>
* <ul>
* <li>authentication fails
* <li>current user does not have permission to read {@code unfiledRecordFolderId}
* <li>{@code unfiledRecordFolderId} does not exist
* </ul>
*/
public UnfiledContainerChildCollection getUnfiledRecordFolderChildren(String unfiledRecordFolderId, String parameters)
{
public UnfiledContainerChildCollection getUnfiledRecordFolderChildren(
String unfiledRecordFolderId, String parameters) {
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getRmRestWrapper().processModels(UnfiledContainerChildCollection.class, simpleRequest(
GET,
"unfiled-record-folders/{unfiledRecordFolderId}/children?{parameters}",
unfiledRecordFolderId,
parameters
));
return getRmRestWrapper()
.processModels(
UnfiledContainerChildCollection.class,
simpleRequest(
GET,
"unfiled-record-folders/{unfiledRecordFolderId}/children?{parameters}",
unfiledRecordFolderId,
parameters));
}
/**
* see {@link #createUnfiledRecordFolderChild(UnfiledContainerChild, String, String)}
*/
public UnfiledContainerChild createUnfiledRecordFolderChild(UnfiledContainerChild unfiledRecordFolderChildModel, String unfiledRecordFolderId)
{
/** see {@link #createUnfiledRecordFolderChild(UnfiledContainerChild, String, String)} */
public UnfiledContainerChild createUnfiledRecordFolderChild(
UnfiledContainerChild unfiledRecordFolderChildModel, String unfiledRecordFolderId) {
mandatoryObject("unfiledRecordFolderChildModel", unfiledRecordFolderChildModel);
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return createUnfiledRecordFolderChild(unfiledRecordFolderChildModel, unfiledRecordFolderId, EMPTY);
return createUnfiledRecordFolderChild(
unfiledRecordFolderChildModel, unfiledRecordFolderId, EMPTY);
}
/**
* Creates an unfiled record folder child. Can be a record or an unfiled record folder.
*
* @param unfiledRecordFolderChildModel The unfiled folder child model which holds the information
* @param unfiledRecordFolderChildModel The unfiled folder child model which holds the
* information
* @param unfiledRecordFolderId The identifier of an unfiled folder
* @param parameters The URL parameters to add
* @return The created {@link UnfiledRecordFolderChild}
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format or {@code unfiledRecordFolderChildModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to add children to {@code unfiledRecordFolderId}</li>
* <li>{@code unfiledRecordFolderId} does not exist</li>
* <li>new name clashes with an existing node in the current parent container</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format or {@code
* unfiledRecordFolderChildModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to add children to {@code
* unfiledRecordFolderId}
* <li>{@code unfiledRecordFolderId} does not exist
* <li>new name clashes with an existing node in the current parent container
* <li>model integrity exception, including node name with invalid characters
* </ul>
*/
public UnfiledContainerChild createUnfiledRecordFolderChild(UnfiledContainerChild unfiledRecordFolderChildModel, String unfiledRecordFolderId, String parameters)
{
public UnfiledContainerChild createUnfiledRecordFolderChild(
UnfiledContainerChild unfiledRecordFolderChildModel,
String unfiledRecordFolderId,
String parameters) {
mandatoryObject("unfiledRecordFolderChildModel", unfiledRecordFolderChildModel);
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getRmRestWrapper().processModel(UnfiledContainerChild.class, requestWithBody(
POST,
toJson(unfiledRecordFolderChildModel),
"unfiled-record-folders/{unfiledRecordFolderId}/children?{parameters}",
unfiledRecordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledContainerChild.class,
requestWithBody(
POST,
toJson(unfiledRecordFolderChildModel),
"unfiled-record-folders/{unfiledRecordFolderId}/children?{parameters}",
unfiledRecordFolderId,
parameters));
}
/**
* Create a record from file resource
*
* @param unfiledRecordFolderChildModel {@link UnfiledContainerChild} for electronic record to be created
* @param unfiledRecordFolderChildContent {@link File} pointing to the content of the electronic record to be created
* @param unfiledRecordFolderChildModel {@link UnfiledContainerChild} for electronic record to
* be created
* @param unfiledRecordFolderChildContent {@link File} pointing to the content of the electronic
* record to be created
* @param unfiledRecordFolderId The identifier of a unfiled record folder
* @return newly created {@link UnfiledContainerChild}
* @throws RuntimeException for invalid recordModel JSON strings
*/
public UnfiledContainerChild uploadRecord(UnfiledContainerChild unfiledRecordFolderChildModel, String unfiledRecordFolderId, File unfiledRecordFolderChildContent)
{
public UnfiledContainerChild uploadRecord(
UnfiledContainerChild unfiledRecordFolderChildModel,
String unfiledRecordFolderId,
File unfiledRecordFolderChildContent) {
mandatoryObject("unfiledRecordFolderChildModel", unfiledRecordFolderChildModel);
mandatoryObject("unfiledRecordFolderChildContent", unfiledRecordFolderChildContent);
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
if (!unfiledRecordFolderChildModel.getNodeType().equals(CONTENT_TYPE))
{
if (!unfiledRecordFolderChildModel.getNodeType().equals(CONTENT_TYPE)) {
fail("Only electronic records are supported");
}
@@ -210,22 +216,25 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root;
try
{
root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
}
catch (IOException e)
{
try {
root =
new ObjectMapper()
.readTree(
toJson(
unfiledRecordFolderChildModel,
UnfiledContainerChild.class,
UnfiledContainerChildMixin.class));
} catch (IOException e) {
throw new RuntimeException("Failed to convert model to JSON.", e);
}
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())
{
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name());
}
builder.addMultiPart("filedata", unfiledRecordFolderChildContent, ContentType.BINARY.name());
builder.addMultiPart(
"filedata", unfiledRecordFolderChildContent, ContentType.BINARY.name());
// create node with given content
return createUnfiledRecordFolderChild(unfiledRecordFolderChildModel, unfiledRecordFolderId);
@@ -234,8 +243,8 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
/**
* see {@link #updateUnfiledRecordFolder(UnfiledRecordFolder, String, String)
*/
public UnfiledRecordFolder updateUnfiledRecordFolder(UnfiledRecordFolder unfiledRecordFolderModel, String unfiledRecordFolderId)
{
public UnfiledRecordFolder updateUnfiledRecordFolder(
UnfiledRecordFolder unfiledRecordFolderModel, String unfiledRecordFolderId) {
mandatoryObject("unfiledRecordFolderModel", unfiledRecordFolderModel);
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
@@ -250,27 +259,33 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
* @param parameters The URL parameters to add
* @param returns The updated {@link UnfiledRecordFolder}
* @throws RuntimeException for the following cases:
* <ul>
* <li>the update request is invalid or {@code unfiledRecordFolderId} is not a valid format or {@code unfiledRecordFolderModel} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code unfiledRecordFolderId}</li>
* <li>{@code unfiledRecordFolderId} does not exist</li>
* <li>the updated name clashes with an existing root category of special container in the current fileplan</li>
* <li>model integrity exception, including file name with invalid characters</li>
* </ul>
* <ul>
* <li>the update request is invalid or {@code unfiledRecordFolderId} is not a valid
* format or {@code unfiledRecordFolderModel} is invalid
* <li>authentication fails
* <li>current user does not have permission to update {@code unfiledRecordFolderId}
* <li>{@code unfiledRecordFolderId} does not exist
* <li>the updated name clashes with an existing root category of special container in the
* current fileplan
* <li>model integrity exception, including file name with invalid characters
* </ul>
*/
public UnfiledRecordFolder updateUnfiledRecordFolder(UnfiledRecordFolder unfiledRecordFolderModel, String unfiledRecordFolderId, String parameters)
{
public UnfiledRecordFolder updateUnfiledRecordFolder(
UnfiledRecordFolder unfiledRecordFolderModel,
String unfiledRecordFolderId,
String parameters) {
mandatoryObject("unfiledRecordFolderModel", unfiledRecordFolderModel);
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
return getRmRestWrapper().processModel(UnfiledRecordFolder.class, requestWithBody(
PUT,
toJson(unfiledRecordFolderModel),
"unfiled-record-folders/{unfiledRecordFolderId}?{parameters}",
unfiledRecordFolderId,
parameters
));
return getRmRestWrapper()
.processModel(
UnfiledRecordFolder.class,
requestWithBody(
PUT,
toJson(unfiledRecordFolderModel),
"unfiled-record-folders/{unfiledRecordFolderId}?{parameters}",
unfiledRecordFolderId,
parameters));
}
/**
@@ -278,23 +293,22 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
*
* @param unfiledRecordFolderId The identifier of a unfiled record folder
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to delete {@code unfiledRecordFolderId}</li>
* <li>{@code unfiledRecordFolderId} does not exist</li>
* <li>{@code unfiledRecordFolderId} is locked and cannot be deleted</li>
* </ul>
* <ul>
* <li>{@code unfiledRecordFolderId} is not a valid format
* <li>authentication fails
* <li>current user does not have permission to delete {@code unfiledRecordFolderId}
* <li>{@code unfiledRecordFolderId} does not exist
* <li>{@code unfiledRecordFolderId} is locked and cannot be deleted
* </ul>
*/
public void deleteUnfiledRecordFolder(String unfiledRecordFolderId)
{
public void deleteUnfiledRecordFolder(String unfiledRecordFolderId) {
mandatoryString("unfiledRecordFolderId", unfiledRecordFolderId);
getRmRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"unfiled-record-folders/{recordFolderId}",
unfiledRecordFolderId
));
getRmRestWrapper()
.processEmptyModel(
simpleRequest(
DELETE,
"unfiled-record-folders/{recordFolderId}",
unfiledRecordFolderId));
}
}

View File

@@ -35,24 +35,20 @@ import java.util.UUID;
* @author Tom Page
* @since 2.6
*/
public class CommonTestUtils
{
/**
* The default pattern used for the user full name when users are created with tas utility
*/
public class CommonTestUtils {
/** The default pattern used for the user full name when users are created with tas utility */
public static final String USER_FULLNAME_PATTERN = "FN-%1$s LN-%1$s";
/** Private constructor to prevent instantiation. */
private CommonTestUtils()
{
}
private CommonTestUtils() {}
/**
* Generate a prefix to namespace the objects in a test class. Note that four random hex digits should be good enough to avoid
* collisions when running locally and should also be short enough to maintain readability.
* Generate a prefix to namespace the objects in a test class. Note that four random hex digits
* should be good enough to avoid collisions when running locally and should also be short
* enough to maintain readability.
*/
public static String generateTestPrefix(Class<?> clazz)
{
return clazz.getSimpleName().substring(0, 7) + UUID.randomUUID().toString().substring(0, 4).toUpperCase();
public static String generateTestPrefix(Class<?> clazz) {
return clazz.getSimpleName().substring(0, 7)
+ UUID.randomUUID().toString().substring(0, 4).toUpperCase();
}
}

View File

@@ -29,11 +29,6 @@ package org.alfresco.rest.rm.community.util;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.LogContainerCmd;
import com.github.dockerjava.api.model.Container;
@@ -44,6 +39,7 @@ import com.github.dockerjava.netty.NettyDockerCmdExecFactory;
import lombok.Getter;
import lombok.Setter;
import org.alfresco.utility.Utility;
import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger;
@@ -52,6 +48,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Helper class for interaction with docker containers
*
@@ -59,30 +60,23 @@ import org.springframework.stereotype.Service;
* @since 3.1
*/
@Service
public class DockerHelper
{
public class DockerHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(DockerHelper.class);
private static final String REPO_IMAGE_NAME = "repository";
@Getter
@Setter
private DockerClient dockerClient;
@Getter @Setter private DockerClient dockerClient;
@Autowired
public DockerHelper(@Value ("${docker.host}") String dockerHost)
{
if (SystemUtils.IS_OS_WINDOWS)
{
this.dockerClient = DockerClientBuilder
.getInstance(dockerHost)
.withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
.build();
}
else
{
this.dockerClient = DockerClientBuilder
.getInstance()
.withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
.build();
public DockerHelper(@Value("${docker.host}") String dockerHost) {
if (SystemUtils.IS_OS_WINDOWS) {
this.dockerClient =
DockerClientBuilder.getInstance(dockerHost)
.withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
.build();
} else {
this.dockerClient =
DockerClientBuilder.getInstance()
.withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
.build();
}
}
@@ -93,30 +87,30 @@ public class DockerHelper
* @param timeStamp - get the logs since a specific timestamp
* @return list of strings, where every string is log line
*/
private List<String> getDockerLogs(String containerId, int timeStamp)
{
private List<String> getDockerLogs(String containerId, int timeStamp) {
final List<String> logs = new ArrayList<>();
final LogContainerCmd logContainerCmd = getDockerClient().logContainerCmd(containerId);
logContainerCmd.withStdOut(true)
.withStdErr(true)
.withSince(timeStamp) // UNIX timestamp to filter logs. Output log-entries since that timestamp.
.withTimestamps(true); //print timestamps for every log line
logContainerCmd
.withStdOut(true)
.withStdErr(true)
.withSince(
timeStamp) // UNIX timestamp to filter logs. Output log-entries since that
// timestamp.
.withTimestamps(true); // print timestamps for every log line
try
{
logContainerCmd.exec(new LogContainerResultCallback()
{
@Override
public void onNext(Frame item)
{
logs.add(item.toString());
}
}).awaitCompletion();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt(); // set interrupt flag
try {
logContainerCmd
.exec(
new LogContainerResultCallback() {
@Override
public void onNext(Frame item) {
logs.add(item.toString());
}
})
.awaitCompletion();
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // set interrupt flag
LOGGER.error("Failed to retrieve logs of container " + containerId, e);
}
@@ -128,19 +122,18 @@ public class DockerHelper
*
* @return list of strings, where every string is log line
*/
public List<String> getAlfrescoLogs()
{
public List<String> getAlfrescoLogs() {
final List<Container> alfrescoContainers = findContainersByImageName(REPO_IMAGE_NAME);
if (alfrescoContainers.isEmpty())
{
if (alfrescoContainers.isEmpty()) {
return Collections.emptyList();
}
else
{
} else {
List<String> alfrescoLogs = new ArrayList<>();
// get the logs since current time - 10 seconds
final int timeStamp = (int) (System.currentTimeMillis() / 1000) - 10;
alfrescoContainers.forEach(alfrescoContainer -> alfrescoLogs.addAll(getDockerLogs(alfrescoContainer.getId(), timeStamp)));
alfrescoContainers.forEach(
alfrescoContainer ->
alfrescoLogs.addAll(
getDockerLogs(alfrescoContainer.getId(), timeStamp)));
return alfrescoLogs;
}
}
@@ -151,14 +144,17 @@ public class DockerHelper
* @param expectedException the expected exception to be thrown
* @throws Exception
*/
public void checkExceptionIsInAlfrescoLogs(String expectedException) throws Exception
{
//Retry the operation because sometimes it takes few seconds to throw the exception
Utility.sleep(6000, 30000, () ->
{
List<String> alfrescoLogs = getAlfrescoLogs();
assertTrue(alfrescoLogs.stream().anyMatch(logLine -> logLine.contains(expectedException)));
});
public void checkExceptionIsInAlfrescoLogs(String expectedException) throws Exception {
// Retry the operation because sometimes it takes few seconds to throw the exception
Utility.sleep(
6000,
30000,
() -> {
List<String> alfrescoLogs = getAlfrescoLogs();
assertTrue(
alfrescoLogs.stream()
.anyMatch(logLine -> logLine.contains(expectedException)));
});
}
/**
@@ -167,12 +163,12 @@ public class DockerHelper
* @param imageName - the name of the image used by container
* @return the containers
*/
private List<Container> findContainersByImageName(String imageName)
{
final List<Container> containers = getDockerClient().listContainersCmd().withShowAll(true).exec();
private List<Container> findContainersByImageName(String imageName) {
final List<Container> containers =
getDockerClient().listContainersCmd().withShowAll(true).exec();
return containers.stream()
.filter(container -> container.getImage().contains(imageName))
.collect(Collectors.toList());
.filter(container -> container.getImage().contains(imageName))
.collect(Collectors.toList());
}
}

View File

@@ -31,18 +31,16 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.alfresco.rest.rm.community.model.record.RecordProperties;
/**
* Mix class for Record POJO class
* Mix-in annotations are: a way to associate annotations with classes
* without modifying (target) classes themselves.
* Mix class for Record POJO class Mix-in annotations are: a way to associate annotations with
* classes without modifying (target) classes themselves.
*
* @author Rodica Sutu
* @since 2.6
*/
public abstract class FilePlanComponentMixIn
{
public abstract class FilePlanComponentMixIn {
/**
* Annotation used to indicate that a property should be serialized "unwrapped"
* Its properties are instead included as properties of its containing Object
* Annotation used to indicate that a property should be serialized "unwrapped" Its properties
* are instead included as properties of its containing Object
*/
@JsonUnwrapped
abstract RecordProperties getProperties();

View File

@@ -34,10 +34,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
* @author Tuna Aksoy
* @since 2.6
*/
public class ParameterCheck
{
private ParameterCheck()
{
public class ParameterCheck {
private ParameterCheck() {
// Intentionally blank
}
@@ -48,11 +46,10 @@ public class ParameterCheck
* @param paramValue The value of the parameter to check
* @throws IllegalArgumentException Throws an exception if the given value is blank
*/
public static void mandatoryString(final String paramName, final String paramValue) throws IllegalArgumentException
{
if (isBlank(paramValue))
{
throw new IllegalArgumentException("'" + paramName + "' is a mandatory parameter.");
public static void mandatoryString(final String paramName, final String paramValue)
throws IllegalArgumentException {
if (isBlank(paramValue)) {
throw new IllegalArgumentException("'" + paramName + "' is a mandatory parameter.");
}
}
@@ -63,11 +60,10 @@ public class ParameterCheck
* @param object The value of the parameter to check
* @throws IllegalArgumentException Throws an exception if the given value is null
*/
public static void mandatoryObject(final String paramName, final Object object) throws IllegalArgumentException
{
if (object == null)
{
throw new IllegalArgumentException("'" + paramName + "' is a mandatory parameter.");
public static void mandatoryObject(final String paramName, final Object object)
throws IllegalArgumentException {
if (object == null) {
throw new IllegalArgumentException("'" + paramName + "' is a mandatory parameter.");
}
}
}

View File

@@ -28,9 +28,6 @@ package org.alfresco.rest.rm.community.util;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -41,28 +38,24 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
/**
* Utility class for creating the json object
*
* @author Rodica Sutu
* @since 2.6
*/
public class PojoUtility
{
/**
* Logger for the class.
*/
public class PojoUtility {
/** Logger for the class. */
private static final Logger LOGGER = LoggerFactory.getLogger(PojoUtility.class);
/** Private constructor to prevent instantiation. */
private PojoUtility()
{}
private PojoUtility() {}
/**
* see {@link #toJson(Object, Class, Class)}
*/
public static String toJson(Object model)
{
/** see {@link #toJson(Object, Class, Class)} */
public static String toJson(Object model) {
mandatoryObject("model", model);
return toJson(model, null, null);
@@ -73,59 +66,53 @@ public class PojoUtility
*
* @param model The java object model to convert
* @param target Class (or interface) whose annotations to effectively override
* @param mixinSource Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary
* @param mixinSource Class (or interface) whose annotations are to be "added" to target's
* annotations, overriding as necessary
* @return The converted java object as JSON string
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the
* POJO class model
*/
public static String toJson(Object model, Class<?> target, Class<?> mixinSource)
{
public static String toJson(Object model, Class<?> target, Class<?> mixinSource) {
mandatoryObject("model", model);
ObjectMapper mapper = new ObjectMapper();
if (target != null && mixinSource != null)
{
//inject the "mix-in" annotations from FilePlanComponentMix to
if (target != null && mixinSource != null) {
// inject the "mix-in" annotations from FilePlanComponentMix to
// FilePlanComponent POJO class when converting to json
mapper.addMixIn(target, mixinSource);
}
//include only non null values
// include only non null values
mapper.setSerializationInclusion(Include.NON_NULL);
//return the json object
try
{
// return the json object
try {
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
}
catch (JsonProcessingException error)
{
} catch (JsonProcessingException error) {
return error.toString();
}
}
/**
* Converting json to java object
* Converting json to java object
*
* @param json The json object to convert
* @param classz Class for the java object
* @param json The json object to convert
* @param classz Class for the java object
* @return The converted java object
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the
* POJO class model
*/
public static <T> T jsonToObject(JSONObject json, Class<T> classz)
{
public static <T> T jsonToObject(JSONObject json, Class<T> classz) {
mandatoryObject("model", classz);
mandatoryObject("jsonObject", json);
ObjectMapper mapper = new ObjectMapper();
T obj = null;
try
{
try {
obj = mapper.readValue(json.toString(), classz);
}
catch (IOException e)
{
} catch (IOException e) {
LOGGER.error("Unable to convert the json into a java object.", e);
}
@@ -135,32 +122,28 @@ public class PojoUtility
/**
* Converting json array into a list of java objects
*
* @param json The json array to convert
* @param classz Class for the java object
* @param json The json array to convert
* @param classz Class for the java object
* @return The list of converted java objects
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the
* POJO class model
*/
public static <T> List<T> jsonToObject(JSONArray json, Class<T> classz)
{
public static <T> List<T> jsonToObject(JSONArray json, Class<T> classz) {
mandatoryObject("model", classz);
mandatoryObject("jsonObject", json);
ObjectMapper mapper = new ObjectMapper();
CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(List.class, classz);
CollectionType collectionType =
mapper.getTypeFactory().constructCollectionType(List.class, classz);
List<T> asList = null;
try
{
try {
asList = mapper.readValue(json.toString(), collectionType);
}
catch (IOException e)
{
} catch (IOException e) {
LOGGER.error("Unable to convert the json array into a java collection.", e);
}
return asList;
}
}

View File

@@ -26,8 +26,6 @@
*/
package org.alfresco.rest.rm.community.util;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
@@ -35,25 +33,32 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import java.io.IOException;
/**
* Utility class for serializing @{FilePlanComponentReviewPeriod}
*
* @author Rodica Sutu
* @since 2.6
*/
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
{
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod> {
/**
* @param value The Review Period value that is being serialized.
* @param gen Jackson utility is responsible for writing JSON
* @param serializers Provider for getting access to other serializers and configurations registered with the ObjectMapper.
* @param serializers Provider for getting access to other serializers and configurations
* registered with the ObjectMapper.
* @throws IOException
* @throws JsonProcessingException
*/
@Override
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
{
//create the custom string value for the Review Period type
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers)
throws IOException, JsonProcessingException {
// create the custom string value for the Review Period type
gen.writeString(
new StringBuilder()
.append(value.getPeriodType())
.append("|")
.append(value.getExpression())
.toString());
}
}

View File

@@ -31,18 +31,16 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
/**
* Mix class for Record POJO class
* Mix-in annotations are: a way to associate annotations with classes
* without modifying (target) classes themselves.
* Mix class for Record POJO class Mix-in annotations are: a way to associate annotations with
* classes without modifying (target) classes themselves.
*
* @author Tuna Aksoy
* @since 2.6
*/
public abstract class UnfiledContainerChildMixin
{
public abstract class UnfiledContainerChildMixin {
/**
* Annotation used to indicate that a property should be serialized "unwrapped"
* Its properties are instead included as properties of its containing Object
* Annotation used to indicate that a property should be serialized "unwrapped" Its properties
* are instead included as properties of its containing Object
*/
@JsonUnwrapped
abstract UnfiledContainerChildProperties getProperties();

View File

@@ -26,9 +26,6 @@
*/
package org.alfresco.rest.v0;
import java.text.MessageFormat;
import java.util.List;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.http.HttpResponse;
import org.json.JSONArray;
@@ -37,6 +34,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.util.List;
/**
* The v0 REST API for copy-to (which supports multi-item copy).
*
@@ -44,8 +44,7 @@ import org.springframework.stereotype.Component;
* @since 2.6
*/
@Component
public class CopyToAPI extends BaseAPI
{
public class CopyToAPI extends BaseAPI {
/** Logger for the class. */
private static final Logger LOGGER = LoggerFactory.getLogger(CopyToAPI.class);
/** The URI for the copy-to API. */
@@ -57,14 +56,14 @@ public class CopyToAPI extends BaseAPI
* @param user The username of the user to use.
* @param password The password of the user.
* @param targetContainerPath The destination to copy the nodes to. This should be in the format
* "{site}/{container}/{path}", "{site}/{container}", "{store_type}/{store_id}/{id}/{path}",
* "{store_type}/{store_id}/{id}" or "{store_type}/{store_id}".
* "{site}/{container}/{path}", "{site}/{container}", "{store_type}/{store_id}/{id}/{path}",
* "{store_type}/{store_id}/{id}" or "{store_type}/{store_id}".
* @param nodeRefs The list of nodes to copy.
* @return The HTTP Response.
* @throws AssertionError If the API call didn't return a 200 response.
*/
public HttpResponse copyTo(String user, String password, String targetContainerPath, List<String> nodeRefs)
{
public HttpResponse copyTo(
String user, String password, String targetContainerPath, List<String> nodeRefs) {
return copyTo(user, password, 200, targetContainerPath, nodeRefs);
}
@@ -75,18 +74,26 @@ public class CopyToAPI extends BaseAPI
* @param password The password of the user.
* @param expectedStatusCode The expected return status code.
* @param targetContainerPath The destination to copy the nodes to. This should be in the format
* "{site}/{container}/{path}", "{site}/{container}", "{store_type}/{store_id}/{id}/{path}",
* "{store_type}/{store_id}/{id}" or "{store_type}/{store_id}".
* "{site}/{container}/{path}", "{site}/{container}", "{store_type}/{store_id}/{id}/{path}",
* "{store_type}/{store_id}/{id}" or "{store_type}/{store_id}".
* @param nodeRefs The list of nodes to copy.
* @return The HTTP Response.
* @throws AssertionError If the API didn't return the expected status code.
*/
public HttpResponse copyTo(String user, String password, int expectedStatusCode, String targetContainerPath, List<String> nodeRefs)
{
public HttpResponse copyTo(
String user,
String password,
int expectedStatusCode,
String targetContainerPath,
List<String> nodeRefs) {
JSONObject requestParams = new JSONObject();
requestParams.put("nodeRefs", new JSONArray(nodeRefs));
return doSlingshotPostJsonRequest(user, password, expectedStatusCode, requestParams,
MessageFormat.format(COPY_TO_API, "{0}", targetContainerPath));
return doSlingshotPostJsonRequest(
user,
password,
expectedStatusCode,
requestParams,
MessageFormat.format(COPY_TO_API, "{0}", targetContainerPath));
}
}

View File

@@ -28,8 +28,6 @@ package org.alfresco.rest.v0;
import static org.testng.AssertJUnit.assertTrue;
import java.text.MessageFormat;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.rm.community.model.custom.CustomDefinitions;
import org.json.JSONArray;
@@ -39,73 +37,67 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
/**
* Methods to make API requests using v0 API on Records Management Custom Model Reference Definitions
* Methods to make API requests using v0 API on Records Management Custom Model Reference
* Definitions
*
* @author Rodica Sutu
* @since 2.6
*/
@Component
public class CustomDefinitionsAPI extends BaseAPI
{
/**
* custom references endpoint
*/
private static final String CUSTOM_REFERENCE_API_ENDPOINT = "{0}rma/admin/customreferencedefinitions";
public class CustomDefinitionsAPI extends BaseAPI {
/** custom references endpoint */
private static final String CUSTOM_REFERENCE_API_ENDPOINT =
"{0}rma/admin/customreferencedefinitions";
/**
* create reference endpoint
*/
/** create reference endpoint */
private static final String CREATE_RELATIONSHIP_API_ENDPOINT = "{0}node/{1}/customreferences";
/**
* logger
*/
/** logger */
private static final Logger LOGGER = LoggerFactory.getLogger(CustomDefinitionsAPI.class);
/**
* Helper method to get the reference id for a custom reference
*
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param customDefinition custom reference definition name
* @return <code>reference id</code> if the customDefinition is found
* <code> null </code> otherwise
*
* @return <code>reference id</code> if the customDefinition is found <code> null </code>
* otherwise
*/
public String getCustomReferenceId(String adminUser, String adminPassword, String customDefinition)
{
public String getCustomReferenceId(
String adminUser, String adminPassword, String customDefinition) {
JSONObject getResponse = doGetRequest(adminUser, adminPassword, CUSTOM_REFERENCE_API_ENDPOINT);
if (getResponse != null)
{
try
{
JSONArray customDefinitions = getResponse.getJSONObject("data").getJSONArray("customReferences");
for (int i = 0; i < customDefinitions.length(); i++)
{
JSONObject getResponse =
doGetRequest(adminUser, adminPassword, CUSTOM_REFERENCE_API_ENDPOINT);
if (getResponse != null) {
try {
JSONArray customDefinitions =
getResponse.getJSONObject("data").getJSONArray("customReferences");
for (int i = 0; i < customDefinitions.length(); i++) {
JSONObject item = customDefinitions.getJSONObject(i);
boolean hasSource = customDefinition.equalsIgnoreCase(
item.has("source") ? item.getString("source") : null
);
boolean hasSource =
customDefinition.equalsIgnoreCase(
item.has("source") ? item.getString("source") : null);
boolean hasTarget = customDefinition.equalsIgnoreCase(
item.has("target") ? item.getString("target") : null
);
boolean hasTarget =
customDefinition.equalsIgnoreCase(
item.has("target") ? item.getString("target") : null);
boolean hasLabel = customDefinition.equalsIgnoreCase(
item.has("label") ? item.getString("label") : null
);
if ( hasSource || hasTarget || hasLabel)
{
boolean hasLabel =
customDefinition.equalsIgnoreCase(
item.has("label") ? item.getString("label") : null);
if (hasSource || hasTarget || hasLabel) {
return item.getString("refId");
}
}
}
catch (JSONException error)
{
LOGGER.error("Unable to get the refId for the custom reference definition {}", customDefinition);
} catch (JSONException error) {
LOGGER.error(
"Unable to get the refId for the custom reference definition {}",
customDefinition);
}
}
return null;
@@ -114,11 +106,11 @@ public class CustomDefinitionsAPI extends BaseAPI
/**
* Helper method to add custom reference instance to the specified record node
*
* @param adminUser user with administrative privileges
* @param adminUser user with administrative privileges
* @param adminPassword password for adminUser
* @param recordNodeIdFrom node ref to set a custom reference
* @param recordNodeIdTo node ref of the to record
* @param relationshipType relation type to be created
* @param recordNodeIdTo node ref of the to record
* @param relationshipType relation type to be created
* @throws AssertionError if the creation fails.
*/
public void createRelationship(
@@ -126,19 +118,32 @@ public class CustomDefinitionsAPI extends BaseAPI
String adminPassword,
String recordNodeIdFrom,
String recordNodeIdTo,
CustomDefinitions relationshipType)
{
//create the request body
CustomDefinitions relationshipType) {
// create the request body
JSONObject requestParams = new JSONObject();
requestParams.put("toNode", NODE_REF_WORKSPACE_SPACES_STORE + recordNodeIdTo);
requestParams.put("refId", getCustomReferenceId(adminUser, adminPassword, relationshipType
.getDefinition()));
//send the API request to create the relationship
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
//check the response
boolean success = (setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
requestParams.put(
"refId",
getCustomReferenceId(adminUser, adminPassword, relationshipType.getDefinition()));
// send the API request to create the relationship
JSONObject setRelationshipStatus =
doPostRequest(
adminUser,
adminPassword,
requestParams,
MessageFormat.format(
CREATE_RELATIONSHIP_API_ENDPOINT,
"{0}",
NODE_PREFIX + recordNodeIdFrom));
// check the response
boolean success =
(setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
assertTrue(
"Creating relationship from "
+ recordNodeIdFrom
+ " to "
+ recordNodeIdTo
+ " failed.",
success);
}
}

View File

@@ -26,74 +26,77 @@
*/
package org.alfresco.rest.v0;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.http.HttpResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Methods to make API requests using v0 API for Exporting Items
*
* @author Shubham Jain
* @since 7.1.0
*/
@Component
public class ExportAPI extends BaseAPI
{
/**
* The URI to export an item
*/
public class ExportAPI extends BaseAPI {
/** The URI to export an item */
private static final String EXPORT_API = "{0}rma/admin/export";
/**
* Export a single Record/Record Folder/Record Category using V0 Export API
*
* @param user User performing the export
* @param password User's Password
* @param user User performing the export
* @param password User's Password
* @param expectedStatusCode Expected Response Code
* @param nodeID ID of the Node(Record/RecordFolder) to be exported
* @param nodeID ID of the Node(Record/RecordFolder) to be exported
* @return HTTP Response
*/
public HttpResponse exportRMNode(String user, String password, int expectedStatusCode, String nodeID)
{
return export(user, password, expectedStatusCode, Collections.singletonList(getNodeRefSpacesStore() + nodeID));
public HttpResponse exportRMNode(
String user, String password, int expectedStatusCode, String nodeID) {
return export(
user,
password,
expectedStatusCode,
Collections.singletonList(getNodeRefSpacesStore() + nodeID));
}
/**
* Export a list of nodes using V0 Export API
*
* @param user User performing the export
* @param password User's Password
* @param user User performing the export
* @param password User's Password
* @param expectedStatusCode Expected Response Code
* @param nodeIDList List of the nodes to be exported
* @param nodeIDList List of the nodes to be exported
* @return HTTP Response
*/
public HttpResponse exportRMNodes(String user, String password, int expectedStatusCode, List<String> nodeIDList)
{
public HttpResponse exportRMNodes(
String user, String password, int expectedStatusCode, List<String> nodeIDList) {
List<String> nodeRefs =
nodeIDList.stream().map(nodeID -> getNodeRefSpacesStore() + nodeID).collect(Collectors.toList());
nodeIDList.stream()
.map(nodeID -> getNodeRefSpacesStore() + nodeID)
.collect(Collectors.toList());
return export(user, password, expectedStatusCode, nodeRefs);
}
/**
* Export API function to perform Export Operation on items with given noderefs using V0 Export Rest API
* Export API function to perform Export Operation on items with given noderefs using V0 Export
* Rest API
*
* @param user User performing the export
* @param password User's Password
* @param user User performing the export
* @param password User's Password
* @param expectedStatusCode Expected Response Code
* @param nodeRefs list of the noderefs for the items to be exported
* @param nodeRefs list of the noderefs for the items to be exported
* @return Rest API Post Request
*/
public HttpResponse export(String user, String password, int expectedStatusCode, List<String> nodeRefs)
{
public HttpResponse export(
String user, String password, int expectedStatusCode, List<String> nodeRefs) {
final JSONObject requestParams = new JSONObject();
requestParams.put("nodeRefs", new JSONArray(nodeRefs));

View File

@@ -29,11 +29,6 @@ package org.alfresco.rest.v0;
import static org.alfresco.rest.core.v0.APIUtils.convertHTTPResponseToJSON;
import static org.apache.http.HttpStatus.SC_OK;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.alfresco.rest.core.v0.APIUtils;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.rm.community.model.hold.HoldEntry;
@@ -46,6 +41,11 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Methods to make API requests using v0 API for generalized holds
*
@@ -53,53 +53,51 @@ import org.springframework.stereotype.Component;
* @since 3.2
*/
@Component
public class HoldsAPI extends BaseAPI
{
public class HoldsAPI extends BaseAPI {
public static final String HOLDS_CONTAINER = "Holds";
/**
* The URI to create a hold
*/
/** The URI to create a hold */
private static final String CREATE_HOLDS_API = "{0}type/rma:hold/formprocessor";
/**
* The URI to add items to hold or to remove items from hold
*/
/** The URI to add items to hold or to remove items from hold */
private static final String RM_HOLDS_API = "{0}rma/holds";
/**
* The URI to get holds.
*/
/** The URI to get holds. */
private static final String GET_RM_HOLDS = RM_HOLDS_API + "?{1}";
/**
* Util method to create a hold
*
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name
* @param reason hold reason
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name
* @param reason hold reason
* @param description hold description
* @return The HTTP response.
*/
public HttpResponse createHold(String user, String password, String holdName, String reason, String description)
{
public HttpResponse createHold(
String user, String password, String holdName, String reason, String description) {
return createHold(user, password, holdName, reason, description, SC_OK);
}
/**
* Util method to create a hold
*
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name
* @param reason hold reason
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name
* @param reason hold reason
* @param description hold description
* @param expectedStatusCode The expected return status code.
* @return The HTTP response or throws AssertionError if the returned status code is not as expected.
* @return The HTTP response or throws AssertionError if the returned status code is not as
* expected.
*/
public HttpResponse createHold(String user, String password, String holdName, String reason, String description,
int expectedStatusCode)
{
public HttpResponse createHold(
String user,
String password,
String holdName,
String reason,
String description,
int expectedStatusCode) {
// retrieve the Holds container nodeRef
final String parentNodeRef = getItemNodeRef(user, password, "/" + HOLDS_CONTAINER);
@@ -109,35 +107,31 @@ public class HoldsAPI extends BaseAPI
requestParams.put("prop_cm_description", description);
requestParams.put("prop_rma_holdReason", reason);
return doPostJsonRequest(user, password, expectedStatusCode, requestParams, CREATE_HOLDS_API);
return doPostJsonRequest(
user, password, expectedStatusCode, requestParams, CREATE_HOLDS_API);
}
/**
* Create a hold and get the node ref of the hold from the response body
*
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name to be created
* @param reason reason of the hold to be created
* @param user the user creating the hold
* @param password the user's password
* @param holdName the hold name to be created
* @param reason reason of the hold to be created
* @param description hold description
* @return node ref of the hold created
*/
public String createHoldAndGetNodeRef(String user, String password,
String holdName, String reason, String description)
{
public String createHoldAndGetNodeRef(
String user, String password, String holdName, String reason, String description) {
final HttpResponse httpResponse = createHold(user, password, holdName, reason, description);
try
{
return convertHTTPResponseToJSON(httpResponse).getString("persistedObject")
.replace(NODE_REF_WORKSPACE_SPACES_STORE, "");
}
catch(JSONException error)
{
try {
return convertHTTPResponseToJSON(httpResponse)
.getString("persistedObject")
.replace(NODE_REF_WORKSPACE_SPACES_STORE, "");
} catch (JSONException error) {
LOGGER.error("Converting message body to JSON failed. Body: {}", httpResponse, error);
}
catch(ParseException error)
{
} catch (ParseException error) {
LOGGER.error("Parsing message body failed.", error);
}
@@ -151,8 +145,7 @@ public class HoldsAPI extends BaseAPI
* @param holdNodeRef the hold node ref
* @return The HTTP Response or throws AssertionError if the request is not successful.
*/
public HttpResponse deleteHold(UserModel user, String holdNodeRef)
{
public HttpResponse deleteHold(UserModel user, String holdNodeRef) {
return deleteHold(user.getUsername(), user.getPassword(), holdNodeRef, SC_OK);
}
@@ -162,15 +155,17 @@ public class HoldsAPI extends BaseAPI
* @param username user's username
* @param password its password
* @param holdNodeRef the hold node ref
* @return The HTTP Response or throws AssertionError if the returned status code is not as expected.
* @return The HTTP Response or throws AssertionError if the returned status code is not as
* expected.
*/
public HttpResponse deleteHold(String username, String password, String holdNodeRef, int expectedStatusCode)
{
public HttpResponse deleteHold(
String username, String password, String holdNodeRef, int expectedStatusCode) {
JSONObject requestParams = new JSONObject();
requestParams.put("name", "deleteHold");
requestParams.put("nodeRef", getNodeRefSpacesStore() + holdNodeRef);
return doPostJsonRequest(username, password, expectedStatusCode, requestParams, RM_ACTIONS_API);
return doPostJsonRequest(
username, password, expectedStatusCode, requestParams, RM_ACTIONS_API);
}
/**
@@ -181,84 +176,106 @@ public class HoldsAPI extends BaseAPI
* @param holdName the hold name
* @throws AssertionError if the deletion was unsuccessful.
*/
public void deleteHold( String username, String password, String holdName)
{
public void deleteHold(String username, String password, String holdName) {
deleteItem(username, password, String.format("/%s/%s", HOLDS_CONTAINER, holdName));
}
/**
* Adds item(content/record/record folder) to the hold
*
* @param user the user who adds the item to the hold
* @param password the user's password
* @param user the user who adds the item to the hold
* @param password the user's password
* @param itemNodeRef the nodeRef of the item to be added to hold
* @param holdName the hold name
* @param holdName the hold name
* @return The HTTP response
*/
public HttpResponse addItemToHold(String user, String password, String itemNodeRef, String holdName)
{
return addItemsToHolds(user, password, Collections.singletonList(itemNodeRef), Collections.singletonList(holdName));
public HttpResponse addItemToHold(
String user, String password, String itemNodeRef, String holdName) {
return addItemsToHolds(
user,
password,
Collections.singletonList(itemNodeRef),
Collections.singletonList(holdName));
}
/**
* Adds a list of items (content/record/record folder) to a list of holds
*
* @param user the user who adds the items to the holds
* @param password the user's password
* @param user the user who adds the items to the holds
* @param password the user's password
* @param itemNodeRefs the list of items nodeRefs to be added to holds
* @param holdNames the list of holds
* @param holdNames the list of holds
* @return The HTTP response
*/
public HttpResponse addItemsToHolds(String user, String password, List<String> itemNodeRefs, List<String> holdNames)
{
final List<String> holdNodeRefs = holdNames.stream()
.map(hold -> getItemNodeRef(user, password, String.format("/%s/%s", HOLDS_CONTAINER, hold)))
.collect(Collectors.toList());
public HttpResponse addItemsToHolds(
String user, String password, List<String> itemNodeRefs, List<String> holdNames) {
final List<String> holdNodeRefs =
holdNames.stream()
.map(
hold ->
getItemNodeRef(
user,
password,
String.format("/%s/%s", HOLDS_CONTAINER, hold)))
.collect(Collectors.toList());
return addItemsToHolds(user, password, SC_OK, itemNodeRefs, holdNodeRefs);
}
/**
* Adds a list of items (content/record/record folder) to a list of holds
*
* @param user the user who adds the items to the holds
* @param password the user's password
* @param user the user who adds the items to the holds
* @param password the user's password
* @param itemNodeRefs the list of items nodeRefs to be added to holds
* @param holdNodeRefs the list of holds
* @return The HTTP response
*/
public HttpResponse addItemsToHolds(String user, String password, int expectedStatus, List<String> itemNodeRefs,
List<String> holdNodeRefs)
{
final JSONObject requestParams = addOrRemoveToFromHoldJsonObject(itemNodeRefs, holdNodeRefs);
public HttpResponse addItemsToHolds(
String user,
String password,
int expectedStatus,
List<String> itemNodeRefs,
List<String> holdNodeRefs) {
final JSONObject requestParams =
addOrRemoveToFromHoldJsonObject(itemNodeRefs, holdNodeRefs);
return doPostJsonRequest(user, password, expectedStatus, requestParams, RM_HOLDS_API);
}
/**
* Util method to add item(content/record/record folder) to the hold and get the error message
*
* @param user the user who adds the item to the hold
* @param password the user's password
* @param user the user who adds the item to the hold
* @param password the user's password
* @param itemNodeRef the nodeRef of the item to be added to hold
* @param holdNodeRef the hold node ref
* @return The error message
*/
public String addToHoldAndGetMessage(String user, String password, int expectedStatus, String itemNodeRef, String
holdNodeRef)
{
final HttpResponse httpResponse = addItemsToHolds(user, password, expectedStatus, Collections.singletonList(itemNodeRef),
Collections.singletonList(holdNodeRef));
public String addToHoldAndGetMessage(
String user,
String password,
int expectedStatus,
String itemNodeRef,
String holdNodeRef) {
final HttpResponse httpResponse =
addItemsToHolds(
user,
password,
expectedStatus,
Collections.singletonList(itemNodeRef),
Collections.singletonList(holdNodeRef));
return APIUtils.extractErrorMessageFromHttpResponse(httpResponse);
}
/**
* Util method to create the request body used when adding items to holds or when removing items from holds
* Util method to create the request body used when adding items to holds or when removing items
* from holds
*
* @param items list of items node refs to be added to holds
* @param items list of items node refs to be added to holds
* @param holdNodeRefs list of hold node refs for add/remove items
* @return JSONObject fo
*/
private JSONObject addOrRemoveToFromHoldJsonObject(List<String> items, List<String> holdNodeRefs)
{
private JSONObject addOrRemoveToFromHoldJsonObject(
List<String> items, List<String> holdNodeRefs) {
final JSONArray nodeRefs = new JSONArray();
items.forEach(itemNodeRef -> nodeRefs.put(getNodeRefSpacesStore() + itemNodeRef));
final JSONArray holds = new JSONArray();
@@ -272,88 +289,119 @@ public class HoldsAPI extends BaseAPI
/**
* Remove item(content/record/record folder) from hold
*
* @param user the user who removes the item from the hold
* @param password the user's password
* @param user the user who removes the item from the hold
* @param password the user's password
* @param itemNodeRef the nodeRef of the item to be removed from hold
* @param holdName the hold name
* @param holdName the hold name
* @return The HTTP response
*/
public HttpResponse removeItemFromHold(String user, String password, String itemNodeRef, String holdName)
{
return removeItemsFromHolds(user, password, Collections.singletonList(itemNodeRef), Collections.singletonList(holdName));
public HttpResponse removeItemFromHold(
String user, String password, String itemNodeRef, String holdName) {
return removeItemsFromHolds(
user,
password,
Collections.singletonList(itemNodeRef),
Collections.singletonList(holdName));
}
/**
* Remove a list of items (content/record/record folder) from a list of holds
*
* @param user the user who removes the item from the hold
* @param password the user's password
* @param itemNodeRefs the list of items nodeRefs to be removed from hold
* @param holdNames the list of hold names
* @param user the user who removes the item from the hold
* @param password the user's password
* @param itemNodeRefs the list of items nodeRefs to be removed from hold
* @param holdNames the list of hold names
* @return The HTTP response
*/
public HttpResponse removeItemsFromHolds(String user, String password, List<String> itemNodeRefs, List<String> holdNames)
{
final List<String> holdNodeRefs = holdNames.stream()
.map(hold -> getItemNodeRef(user, password, String.format("/%s/%s", HOLDS_CONTAINER, hold)))
.collect(Collectors.toList());
public HttpResponse removeItemsFromHolds(
String user, String password, List<String> itemNodeRefs, List<String> holdNames) {
final List<String> holdNodeRefs =
holdNames.stream()
.map(
hold ->
getItemNodeRef(
user,
password,
String.format("/%s/%s", HOLDS_CONTAINER, hold)))
.collect(Collectors.toList());
return removeItemsFromHolds(user, password, SC_OK, itemNodeRefs, holdNodeRefs);
}
/**
* Remove a list of items (content/record/record folder) from a list of holds
*
* @param user the user who removes the item from the hold
* @param password the user's password
* @param user the user who removes the item from the hold
* @param password the user's password
* @param expectedStatus https status code expected
* @param itemNodeRefs the list of items nodeRefs to be removed from hold
* @param holdNodeRefs the list of hold node refs
* @param itemNodeRefs the list of items nodeRefs to be removed from hold
* @param holdNodeRefs the list of hold node refs
* @return The HTTP response
*/
public HttpResponse removeItemsFromHolds(String user, String password, int expectedStatus, List<String> itemNodeRefs,
List<String> holdNodeRefs)
{
final JSONObject requestParams = addOrRemoveToFromHoldJsonObject(itemNodeRefs, holdNodeRefs);
public HttpResponse removeItemsFromHolds(
String user,
String password,
int expectedStatus,
List<String> itemNodeRefs,
List<String> holdNodeRefs) {
final JSONObject requestParams =
addOrRemoveToFromHoldJsonObject(itemNodeRefs, holdNodeRefs);
return doPutJsonRequest(user, password, expectedStatus, requestParams, RM_HOLDS_API);
}
/**
* Util method to remove item(content/record/record folder) from hold and get the error message
*
* @param user the user who removes the item from hold
* @param password the user's password
* @param user the user who removes the item from hold
* @param password the user's password
* @param itemNodeRef the nodeRef of the item to be removed from hold
* @param holdNodeRef the hold node ref
* @return The error message
*/
public String removeFromHoldAndGetMessage(String user, String password, int expectedStatus, String itemNodeRef, String
holdNodeRef)
{
final HttpResponse httpResponse = removeItemsFromHolds(user, password, expectedStatus, Collections.singletonList(itemNodeRef),
Collections.singletonList(holdNodeRef));
public String removeFromHoldAndGetMessage(
String user,
String password,
int expectedStatus,
String itemNodeRef,
String holdNodeRef) {
final HttpResponse httpResponse =
removeItemsFromHolds(
user,
password,
expectedStatus,
Collections.singletonList(itemNodeRef),
Collections.singletonList(holdNodeRef));
return APIUtils.extractErrorMessageFromHttpResponse(httpResponse);
}
/**
* Get the list of the available holds which have the item node reference if includedInHold parameter is true,
* otherwise a list of hold node references will be retrieved which do not include the given node reference.
* Get the list of the available holds which have the item node reference if includedInHold
* parameter is true, otherwise a list of hold node references will be retrieved which do not
* include the given node reference.
*
* @param user The username of the user to use.
* @param user The username of the user to use.
* @param password The password of the user.
* @param itemNodeRef The item node reference
* @param includedInHold True to retrieve the holds which have the item node reference
* @param fileOnly True if only files should be return
* @return return a list of hold entries
*/
public List<HoldEntry> getHolds(String user, String password, final String itemNodeRef,
final Boolean includedInHold, final Boolean fileOnly)
{
final String parameters = (itemNodeRef != null ? "itemNodeRef=" + NODE_REF_WORKSPACE_SPACES_STORE + itemNodeRef : "")
+ (includedInHold != null ? "&includedInHold=" + includedInHold : "")
+ (fileOnly != null ? "&fileOnly=" + fileOnly : "");
public List<HoldEntry> getHolds(
String user,
String password,
final String itemNodeRef,
final Boolean includedInHold,
final Boolean fileOnly) {
final String parameters =
(itemNodeRef != null
? "itemNodeRef=" + NODE_REF_WORKSPACE_SPACES_STORE + itemNodeRef
: "")
+ (includedInHold != null ? "&includedInHold=" + includedInHold : "")
+ (fileOnly != null ? "&fileOnly=" + fileOnly : "");
final JSONArray holdEntries = doGetRequest(user, password,
MessageFormat.format(GET_RM_HOLDS, "{0}", parameters)).getJSONObject("data").getJSONArray("holds");
final JSONArray holdEntries =
doGetRequest(user, password, MessageFormat.format(GET_RM_HOLDS, "{0}", parameters))
.getJSONObject("data")
.getJSONArray("holds");
return PojoUtility.jsonToObject(holdEntries, HoldEntry.class);
}

View File

@@ -25,7 +25,6 @@
* #L%
*/
package org.alfresco.rest.v0;
import java.text.MessageFormat;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
@@ -36,39 +35,38 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
/**
* The v0 REST API for nodes
*
*
* @author jcule
* @since 2.7EA1
*/
@Component
public class NodeAPI extends BaseAPI
{
public class NodeAPI extends BaseAPI {
/** Logger for the class. */
private static final Logger LOGGER = LoggerFactory.getLogger(NodeAPI.class);
/** The URI for the get node API. */
private static final String GET_NODE_API = "{0}alfresco/s/slingshot/doclib2/node/{1}";
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
/**
* Get the node metadata using the using the node data webscript: Document List v2 Component
*
* Get the node metadata using the using the node data webscript: Document List v2 Component
*
* @param username
* @param password
* @param nodeId
* @return
*/
public JSONObject getNode(String username, String password, String nodeId)
{
public JSONObject getNode(String username, String password, String nodeId) {
String requestURL;
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
requestURL = MessageFormat.format(GET_NODE_API, client.getAlfrescoUrl(), NODE_PREFIX + nodeId);
requestURL =
MessageFormat.format(GET_NODE_API, client.getAlfrescoUrl(), NODE_PREFIX + nodeId);
client.close();
return doGetRequest(username, password, requestURL);
}
}

View File

@@ -27,9 +27,6 @@
package org.alfresco.rest.v0;
import java.io.IOException;
import java.text.MessageFormat;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.rest.core.v0.BaseAPI;
@@ -44,21 +41,20 @@ import org.json.simple.JSONValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.text.MessageFormat;
/**
* The v0 API to get the node properties
*
* @since AGS 3.4
*/
@Component
public class NodePropertiesAPI extends BaseAPI
{
/**
* The URI for the get node API.
*/
public class NodePropertiesAPI extends BaseAPI {
/** The URI for the get node API. */
private static final String GET_NODE_API = "{0}alfresco/s/slingshot/node/{1}";
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
/**
* Get the node properties
@@ -66,26 +62,24 @@ public class NodePropertiesAPI extends BaseAPI
* @param username
* @param password
* @param nodeId
* @return JSONArray object
* @return JSONArray object
*/
protected JSONArray getNodeProperties(String username, String password, String nodeId)
{
protected JSONArray getNodeProperties(String username, String password, String nodeId) {
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String requestURL = MessageFormat.format(GET_NODE_API, client.getAlfrescoUrl(), NODE_PREFIX + nodeId);
String requestURL =
MessageFormat.format(GET_NODE_API, client.getAlfrescoUrl(), NODE_PREFIX + nodeId);
// doRequest from BaseAPI cannot be used as parsing the response body to org.json.JSONObject is throwing an
// doRequest from BaseAPI cannot be used as parsing the response body to
// org.json.JSONObject is throwing an
// JSONException
// construct a get request
HttpGet get = new HttpGet(requestURL);
HttpResponse response = client.execute(username, password, get);
HttpEntity entity = response.getEntity();
String responseString;
try
{
try {
responseString = EntityUtils.toString(entity, "UTF-8");
}
catch (IOException e)
{
} catch (IOException e) {
throw new IllegalArgumentException("Failed to read the response", e);
}
client.close();
@@ -101,11 +95,9 @@ public class NodePropertiesAPI extends BaseAPI
* @param nodeId
* @return Return the content url string
*/
public String getContentUrl(UserModel userModel, String nodeId)
{
public String getContentUrl(UserModel userModel, String nodeId) {
String contentProperty = getContentProperty(userModel, nodeId);
if (contentProperty != null)
{
if (contentProperty != null) {
// get the first element before the first |
// e.g. "contentUrl=s3://-system-/fc077fe8-1742-4c45-a153-8309c857996b
// .bin|mimetype=text/plain|size=19|encoding=ISO-8859-2|locale=en_US_|id=508"
@@ -122,16 +114,14 @@ public class NodePropertiesAPI extends BaseAPI
* @param nodeId
* @return Return the content property string
*/
public String getContentProperty(UserModel userModel, String nodeId)
{
JSONArray properties = getNodeProperties(userModel.getUsername(), userModel.getPassword(), nodeId);
public String getContentProperty(UserModel userModel, String nodeId) {
JSONArray properties =
getNodeProperties(userModel.getUsername(), userModel.getPassword(), nodeId);
for (int i = 0; i < properties.size(); i++)
{
for (int i = 0; i < properties.size(); i++) {
JSONObject object = (JSONObject) properties.get(i);
JSONArray valuesArray = (JSONArray) object.get("values");
if (valuesArray.toString().contains("contentUrl"))
{
if (valuesArray.toString().contains("contentUrl")) {
return ((JSONObject) valuesArray.get(0)).get("value").toString();
}
}

View File

@@ -28,11 +28,6 @@ package org.alfresco.rest.v0;
import static org.testng.Assert.assertTrue;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.List;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
import org.alfresco.rest.rm.community.util.PojoUtility;
@@ -42,6 +37,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.List;
/**
* The v0 REST API for rm audit logs
*
@@ -49,37 +49,42 @@ import org.springframework.stereotype.Component;
* @since 2.7
*/
@Component
public class RMAuditAPI extends BaseAPI
{
public class RMAuditAPI extends BaseAPI {
/** Logger for the class. */
private static final Logger LOGGER = LoggerFactory.getLogger(RMAuditAPI.class);
/** The URI for the audit API. */
private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog";
private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}";
/**
* Returns a list of rm audit entries .
*
* @param user The username of the user to use.
* @param user The username of the user to use.
* @param password The password of the user.
* @param size Maximum number of log entries to return
* @param event The name of audit event to be retrieved
* @param size Maximum number of log entries to return
* @param event The name of audit event to be retrieved
* @return return Only return log entries matching this event
*/
public List<AuditEntry> getRMAuditLog(String user, String password, final int size, final String event)
{
public List<AuditEntry> getRMAuditLog(
String user, String password, final int size, final String event) {
String parameters = null;
try
{
parameters = "size=" + size + (event != null ? "&event=" + URLEncoder.encode(event, "UTF-8"):"");
}
catch (UnsupportedEncodingException e)
{
try {
parameters =
"size="
+ size
+ (event != null ? "&event=" + URLEncoder.encode(event, "UTF-8") : "");
} catch (UnsupportedEncodingException e) {
LOGGER.error("Unable to encode the event name {}", e.getMessage());
}
JSONArray auditEntries = doGetRequest(user, password,
MessageFormat.format(RM_AUDIT_LOG_API,"{0}", parameters)).getJSONObject("data").getJSONArray("entries");
JSONArray auditEntries =
doGetRequest(
user,
password,
MessageFormat.format(RM_AUDIT_LOG_API, "{0}", parameters))
.getJSONObject("data")
.getJSONArray("entries");
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
}
@@ -91,14 +96,12 @@ public class RMAuditAPI extends BaseAPI
* @param password The password of the user.
* @throws AssertionError If the API call didn't clear the audit log.
*/
public void clearAuditLog(String username, String password)
{
public void clearAuditLog(String username, String password) {
JSONObject deleteStatus = doDeleteRequest(username, password, RM_AUDIT_API);
assertTrue(deleteStatus != null
//audit clear and login events are returned
&& getRMAuditLog(username, password, 100, null).size() == 2);
assertTrue(
deleteStatus != null
// audit clear and login events are returned
&& getRMAuditLog(username, password, 100, null).size() == 2);
}
}

View File

@@ -34,14 +34,6 @@ import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
import java.io.IOException;
import java.text.MessageFormat;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.dataprep.UserService;
@@ -64,47 +56,54 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.text.MessageFormat;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
/**
* Methods to make API requests using v0 API on RM items (move, update and other actions) including adding users to RM roles
* Methods to make API requests using v0 API on RM items (move, update and other actions) including
* adding users to RM roles
*
* @author Oana Nechiforescu
* @since 2.5
*/
@Component
public class RMRolesAndActionsAPI extends BaseAPI
{
public class RMRolesAndActionsAPI extends BaseAPI {
/** The URI to view the configured roles and capabilities. */
private static final String RM_ROLES = "{0}rma/admin/rmroles";
/** The URI for REST requests about a particular configured role. */
private static final String RM_ROLES_ROLE = RM_ROLES + "/{1}";
private static final String RM_ROLES_AUTHORITIES = "{0}rm/roles/{1}/authorities/{2}?alf_ticket={3}";
private static final String RM_ROLES_AUTHORITIES =
"{0}rm/roles/{1}/authorities/{2}?alf_ticket={3}";
// logger
private static final Logger LOGGER = LoggerFactory.getLogger(RMRolesAndActionsAPI.class);
private static final String MOVE_ACTIONS_API = "action/rm-move-to/site/rm/documentLibrary/{0}";
/** http client factory */
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
/** user service */
@Autowired
private UserService userService;
@Autowired private UserService userService;
@Autowired
private DataUserAIS dataUser;
@Autowired private DataUserAIS dataUser;
/**
* Get all the configured RM roles.
*
* @param adminUser The RM admin user.
* @param adminPassword The password of the user.
* @return The RM roles in the system (Note that this will be the internal names, not the display labels).
* @return The RM roles in the system (Note that this will be the internal names, not the
* display labels).
*/
public Set<String> getConfiguredRoles(String adminUser, String adminPassword)
{
public Set<String> getConfiguredRoles(String adminUser, String adminPassword) {
// Using "is=true" includes the in-place readers and writers.
final JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject(
"data");
final JSONObject jsonObject =
doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject("data");
return jsonObject.toMap().keySet();
}
@@ -116,24 +115,25 @@ public class RMRolesAndActionsAPI extends BaseAPI
* @param role The role to get capabilities for.
* @return The set of system names for the capabilities.
*/
public Set<String> getCapabilitiesForRole(String adminUser, String adminPassword, String role)
{
final JSONObject jsonObject = doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject(
"data");
assertTrue("Could not find role '" + role + "' in " + jsonObject.keySet(), jsonObject.has(role));
public Set<String> getCapabilitiesForRole(String adminUser, String adminPassword, String role) {
final JSONObject jsonObject =
doGetRequest(adminUser, adminPassword, RM_ROLES + "?is=true").getJSONObject("data");
assertTrue(
"Could not find role '" + role + "' in " + jsonObject.keySet(),
jsonObject.has(role));
return jsonObject.getJSONObject(role).getJSONObject("capabilities").keySet();
}
/**
* Creates the body for PUT/POST Roles API requests
*
* @param roleName the role name
* @param roleName the role name
* @param roleDisplayLabel a human-readable label for the role
* @param capabilities a list of capabilities for the role
* @param capabilities a list of capabilities for the role
* @return
*/
private JSONObject roleRequestBody(String roleName, String roleDisplayLabel, Set<String> capabilities)
{
private JSONObject roleRequestBody(
String roleName, String roleDisplayLabel, Set<String> capabilities) {
final JSONObject requestBody = new JSONObject();
requestBody.put("name", roleName);
requestBody.put("displayLabel", roleDisplayLabel);
@@ -152,9 +152,17 @@ public class RMRolesAndActionsAPI extends BaseAPI
* @param roleDisplayLabel A human-readable label for the role.
* @param capabilities A list of capabilities for the role.
*/
public void createRole(String adminUser, String adminPassword, String roleName, String roleDisplayLabel, Set<String> capabilities)
{
doPostJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, roleRequestBody(roleName, roleDisplayLabel, capabilities),
public void createRole(
String adminUser,
String adminPassword,
String roleName,
String roleDisplayLabel,
Set<String> capabilities) {
doPostJsonRequest(
adminUser,
adminPassword,
HttpStatus.SC_OK,
roleRequestBody(roleName, roleDisplayLabel, capabilities),
RM_ROLES);
}
@@ -167,10 +175,19 @@ public class RMRolesAndActionsAPI extends BaseAPI
* @param roleDisplayLabel A human-readable label for the role.
* @param capabilities A list of capabilities for the role.
*/
public void updateRole(String adminUser, String adminPassword, String roleName, String roleDisplayLabel, Set<String> capabilities)
{
doPutJsonRequest(adminUser, adminPassword, HttpStatus.SC_OK, roleRequestBody(roleName, roleDisplayLabel, capabilities),
RM_ROLES_ROLE, roleName);
public void updateRole(
String adminUser,
String adminPassword,
String roleName,
String roleDisplayLabel,
Set<String> capabilities) {
doPutJsonRequest(
adminUser,
adminPassword,
HttpStatus.SC_OK,
roleRequestBody(roleName, roleDisplayLabel, capabilities),
RM_ROLES_ROLE,
roleName);
}
/**
@@ -180,27 +197,19 @@ public class RMRolesAndActionsAPI extends BaseAPI
* @param adminPassword The password for the admin user.
* @param roleName The name of the role to be deleted.
*/
public void deleteRole(String adminUser, String adminPassword, String roleName)
{
doDeleteRequest(adminUser, adminPassword, MessageFormat.format(RM_ROLES_ROLE, "{0}", roleName));
assertFalse("Failed to delete role " + roleName + " with " + adminUser,
public void deleteRole(String adminUser, String adminPassword, String roleName) {
doDeleteRequest(
adminUser, adminPassword, MessageFormat.format(RM_ROLES_ROLE, "{0}", roleName));
assertFalse(
"Failed to delete role " + roleName + " with " + adminUser,
getConfiguredRoles(adminUser, adminPassword).contains(roleName));
}
/**
* create user and assign to records management role
*/
/** create user and assign to records management role */
public void createUserAndAssignToRole(
String adminUser,
String adminPassword,
String userName,
String password,
String role)
{
if (!userService.userExists(adminUser, adminPassword, userName))
{
String adminUser, String adminPassword, String userName, String password, String role) {
if (!userService.userExists(adminUser, adminPassword, userName)) {
dataUser.createUser(userName, password);
}
assignRoleToUser(adminUser, adminPassword, userName, role);
}
@@ -210,54 +219,55 @@ public class RMRolesAndActionsAPI extends BaseAPI
*
* @throws AssertionError if the assignation is unsuccessful.
*/
public void assignRoleToUser(String adminUser, String adminPassword, String userName, String role)
{
public void assignRoleToUser(
String adminUser, String adminPassword, String userName, String role) {
final AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
final String reqURL = MessageFormat.format(
RM_ROLES_AUTHORITIES,
client.getApiUrl(),
role,
userName,
client.getAlfTicket(adminUser, adminPassword));
final String reqURL =
MessageFormat.format(
RM_ROLES_AUTHORITIES,
client.getApiUrl(),
role,
userName,
client.getAlfTicket(adminUser, adminPassword));
HttpPost request = null;
HttpResponse response;
try
{
try {
request = new HttpPost(reqURL);
response = client.execute(adminUser, adminPassword, request);
}
finally
{
if (request != null)
{
} finally {
if (request != null) {
request.releaseConnection();
}
client.close();
}
assertEquals("Assigning role " + role + " to user " + userName + " failed.", SC_OK,
response.getStatusLine().getStatusCode());
assertEquals(
"Assigning role " + role + " to user " + userName + " failed.",
SC_OK,
response.getStatusLine().getStatusCode());
}
/**
* Move action
*
* @param user the user to move the contentPath
* @param password the user's password
* @param contentPath path to the content to be moved
* @param user the user to move the contentPath
* @param password the user's password
* @param contentPath path to the content to be moved
* @param destinationPath destination path
* @throws AssertionError if the move was unsuccessful.
*/
public void moveTo(String user, String password, String contentPath, String destinationPath)
{
String contentNodeRef = getNodeRefSpacesStore() + getItemNodeRef(user, password, contentPath);
public void moveTo(String user, String password, String contentPath, String destinationPath) {
String contentNodeRef =
getNodeRefSpacesStore() + getItemNodeRef(user, password, contentPath);
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
String url = MessageFormat.format(client.getAlfrescoUrl() + "alfresco/s/slingshot/doclib/" + MOVE_ACTIONS_API, destinationPath);
String url =
MessageFormat.format(
client.getAlfrescoUrl() + "alfresco/s/slingshot/doclib/" + MOVE_ACTIONS_API,
destinationPath);
HttpPost request = new HttpPost(url);
boolean success = false;
try
{
try {
JSONObject body = new JSONObject();
body.put("nodeRefs", new JSONArray(Arrays.asList(contentNodeRef)));
StringEntity se = new StringEntity(body.toString(), AlfrescoHttpClient.UTF_8_ENCODING);
@@ -265,8 +275,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
request.setEntity(se);
HttpResponse response = client.execute(user, password, request);
switch (response.getStatusLine().getStatusCode())
{
switch (response.getStatusLine().getStatusCode()) {
case HttpStatus.SC_OK:
JSONObject json = new JSONObject(EntityUtils.toString(response.getEntity()));
success = (Boolean) json.get("overallSuccess");
@@ -278,15 +287,10 @@ public class RMRolesAndActionsAPI extends BaseAPI
LOGGER.error("Unable to move: " + response.toString());
break;
}
}
catch (JSONException | IOException e)
{
} catch (JSONException | IOException e) {
LOGGER.error(e.toString());
}
finally
{
if (request != null)
{
} finally {
if (request != null) {
request.releaseConnection();
}
client.close();
@@ -298,20 +302,17 @@ public class RMRolesAndActionsAPI extends BaseAPI
/**
* Move action
*
* @param user the user to move the contentPath
* @param password the user's password
* @param contentPath path to the content to be moved
* @param user the user to move the contentPath
* @param password the user's password
* @param contentPath path to the content to be moved
* @param destinationPath destination path
* @throws AssertionError if the move was unexpectedly successful.
*/
public void moveToAndExpectFailure(String user, String password, String contentPath, String destinationPath)
{
try
{
public void moveToAndExpectFailure(
String user, String password, String contentPath, String destinationPath) {
try {
moveTo(user, password, contentPath, destinationPath);
}
catch(AssertionError e)
{
} catch (AssertionError e) {
// We are expecting the move to fail.
return;
}
@@ -321,62 +322,68 @@ public class RMRolesAndActionsAPI extends BaseAPI
/**
* Perform an action on the given content
*
* @param user the user executing the action
* @param password the user's password
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @return The HTTP response.
*/
public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS action)
{
public HttpResponse executeAction(
String user, String password, String contentName, RM_ACTIONS action) {
return executeAction(user, password, contentName, action, null, SC_OK);
}
/**
* Perform an action on the given content
*
* @param user the user executing the action
* @param password the user's password
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @return The HTTP response.
*/
public HttpResponse executeActionAndExpectResponseCode(String user, String password, String contentName, RM_ACTIONS action,
int status)
{
public HttpResponse executeActionAndExpectResponseCode(
String user, String password, String contentName, RM_ACTIONS action, int status) {
return executeAction(user, password, contentName, action, null, status);
}
/**
* Perform an action on the given content
*
* @param user the user executing the action
* @param password the user's password
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @return The HTTP response.
*/
public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS action,
ZonedDateTime date)
{
public HttpResponse executeAction(
String user,
String password,
String contentName,
RM_ACTIONS action,
ZonedDateTime date) {
return executeAction(user, password, contentName, action, date, SC_OK);
}
/**
* Creates the body for Actions API requests
*
* @param user the user executing the action
* @param password the user's password
* @param contentName the content on which the action is executed
* @param action the action executed
* @param user the user executing the action
* @param password the user's password
* @param contentName the content on which the action is executed
* @param action the action executed
* @param actionsParams the request parameters
* @return the JSONObject created
*/
private JSONObject actionsRequestBody(String user, String password, String contentName, RM_ACTIONS action,
JSONObject actionsParams)
{
final String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, contentName);
private JSONObject actionsRequestBody(
String user,
String password,
String contentName,
RM_ACTIONS action,
JSONObject actionsParams) {
final String recNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, RM_SITE_ID, contentName);
final JSONObject requestParams = new JSONObject();
requestParams.put("name", action.getAction());
requestParams.put("nodeRef", recNodeRef);
if (actionsParams != null)
{
if (actionsParams != null) {
requestParams.put("params", actionsParams);
}
return requestParams;
@@ -385,102 +392,143 @@ public class RMRolesAndActionsAPI extends BaseAPI
/**
* Perform an action on the record folder
*
* @param user the user executing the action
* @param password the user's password
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @param date the date to be updated
* @param date the date to be updated
* @return The HTTP response.
*/
public HttpResponse executeAction(String user, String password, String contentName, RM_ACTIONS action,
ZonedDateTime date, int status)
{
public HttpResponse executeAction(
String user,
String password,
String contentName,
RM_ACTIONS action,
ZonedDateTime date,
int status) {
final JSONObject actionParams = new JSONObject();
if (date != null)
{
actionParams.put("asOfDate", new JSONObject().put("iso8601", ISO_INSTANT_FORMATTER.format(date)));
if (date != null) {
actionParams.put(
"asOfDate",
new JSONObject().put("iso8601", ISO_INSTANT_FORMATTER.format(date)));
}
final JSONObject requestParams = actionsRequestBody(user, password, contentName, action, actionParams);
final JSONObject requestParams =
actionsRequestBody(user, password, contentName, action, actionParams);
return doPostJsonRequest(user, password, status, requestParams, RM_ACTIONS_API);
}
/**
* Complete an event on the record/record folder
*
* @param user the user executing the action
* @param password the user's password
* @param nodeName the node name
* @param event the event to be completed
* @param date the date to be updated
* @param user the user executing the action
* @param password the user's password
* @param nodeName the node name
* @param event the event to be completed
* @param date the date to be updated
* @return The HTTP response.
*/
public HttpResponse completeEvent(String user, String password, String nodeName, RMEvents event, Instant date)
{
public HttpResponse completeEvent(
String user, String password, String nodeName, RMEvents event, Instant date) {
date = (date != null) ? date : Instant.now();
final JSONObject actionParams = new JSONObject().put("eventName", event.getEventName())
.put("eventCompletedBy", user)
.put("eventCompletedAt", new JSONObject()
.put("iso8601", ISO_INSTANT_FORMATTER.format(date))
);
final JSONObject requestParams = actionsRequestBody(user, password, nodeName, RM_ACTIONS.COMPLETE_EVENT,
actionParams);
final JSONObject actionParams =
new JSONObject()
.put("eventName", event.getEventName())
.put("eventCompletedBy", user)
.put(
"eventCompletedAt",
new JSONObject()
.put("iso8601", ISO_INSTANT_FORMATTER.format(date)));
final JSONObject requestParams =
actionsRequestBody(
user, password, nodeName, RM_ACTIONS.COMPLETE_EVENT, actionParams);
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
/**
* Undo an event on the record/record folder
*
* @param user the user executing the action
* @param password the user's password
* @param user the user executing the action
* @param password the user's password
* @param contentName the content name
* @param event the event to be undone
* @param event the event to be undone
* @return The HTTP response.
*/
public HttpResponse undoEvent(String user, String password, String contentName, RMEvents event)
{
final JSONObject requestParams = actionsRequestBody(user, password, contentName, RM_ACTIONS.UNDO_EVENT,
new JSONObject().put("eventName", event.getEventName()));
public HttpResponse undoEvent(
String user, String password, String contentName, RMEvents event) {
final JSONObject requestParams =
actionsRequestBody(
user,
password,
contentName,
RM_ACTIONS.UNDO_EVENT,
new JSONObject().put("eventName", event.getEventName()));
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
/**
* Deletes every item in the given container
*
* @param username the user's username
* @param password its password
* @param siteId the site id in which the container is located
* @param username the user's username
* @param password its password
* @param siteId the site id in which the container is located
* @param containerName the container to look for items into
* @throws AssertionError if not all items could be deleted.
*/
public void deleteAllItemsInContainer(String username, String password, String siteId, String containerName)
{
for (CmisObject item : contentService.getFolderObject(contentService.getCMISSession(username, password), siteId, containerName).getChildren())
{
public void deleteAllItemsInContainer(
String username, String password, String siteId, String containerName) {
for (CmisObject item :
contentService
.getFolderObject(
contentService.getCMISSession(username, password),
siteId,
containerName)
.getChildren()) {
item.delete();
}
assertFalse("Not all items were deleted from " + containerName,
contentService.getFolderObject(contentService.getCMISSession(username, password), siteId, containerName).getChildren().getHasMoreItems());
assertFalse(
"Not all items were deleted from " + containerName,
contentService
.getFolderObject(
contentService.getCMISSession(username, password),
siteId,
containerName)
.getChildren()
.getHasMoreItems());
}
/**
* Updates metadata, can be used on records, folders and categories
*
* @param username the user updating the item
* @param password the user's password
* @param username the user updating the item
* @param password the user's password
* @param itemNodeRef the item noderef
* @return The HTTP response.
*/
public HttpResponse updateMetadata(String username, String password, String itemNodeRef, Map<RMProperty, String> properties)
{
public HttpResponse updateMetadata(
String username,
String password,
String itemNodeRef,
Map<RMProperty, String> properties) {
JSONObject requestParams = new JSONObject();
addPropertyToRequest(requestParams, "prop_cm_name", properties, RMProperty.NAME);
addPropertyToRequest(requestParams, "prop_cm_title", properties, RMProperty.TITLE);
addPropertyToRequest(requestParams, "prop_cm_description", properties, RMProperty.DESCRIPTION);
addPropertyToRequest(
requestParams, "prop_cm_description", properties, RMProperty.DESCRIPTION);
addPropertyToRequest(requestParams, "prop_cm_author", properties, RMProperty.AUTHOR);
addPropertyToRequest(requestParams, "prop_dod_originator", properties, RMProperty.ORIGINATOR);
addPropertyToRequest(requestParams, "prop_dod_originatingOrganization", properties, RMProperty
.ORIGINATING_ORGANIZATION);
addPropertyToRequest(requestParams, "prop_dod_publicationDate", properties, RMProperty.PUBLICATION_DATE);
addPropertyToRequest(
requestParams, "prop_dod_originator", properties, RMProperty.ORIGINATOR);
addPropertyToRequest(
requestParams,
"prop_dod_originatingOrganization",
properties,
RMProperty.ORIGINATING_ORGANIZATION);
addPropertyToRequest(
requestParams, "prop_dod_publicationDate", properties, RMProperty.PUBLICATION_DATE);
return doPostJsonRequest(username, password, SC_OK, requestParams, MessageFormat.format(UPDATE_METADATA_API, "{0}", itemNodeRef));
return doPostJsonRequest(
username,
password,
SC_OK,
requestParams,
MessageFormat.format(UPDATE_METADATA_API, "{0}", itemNodeRef));
}
}

View File

@@ -28,10 +28,6 @@ package org.alfresco.rest.v0;
import static org.apache.http.HttpStatus.SC_OK;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.http.HttpResponse;
import org.json.JSONObject;
@@ -39,6 +35,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
/**
* Methods to make API requests using v0 API on record categories
*
@@ -46,25 +46,24 @@ import org.springframework.stereotype.Component;
* @since 2.5
*/
@Component
public class RecordCategoriesAPI extends BaseAPI
{
public class RecordCategoriesAPI extends BaseAPI {
private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class);
private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions";
private static final String DISPOSITION_ACTIONS_API =
"{0}node/{1}/dispositionschedule/dispositionactiondefinitions";
private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule";
/**
* Creates a retention schedule for the category given as parameter
*
* @param user the user creating the disposition schedule
* @param password the user's password
* @param user the user creating the disposition schedule
* @param password the user's password
* @param categoryName the category name to create the retention schedule for
* @return The HTTP Response.
*/
public HttpResponse createRetentionSchedule(String user, String password, String categoryName)
{
String catNodeRef = getNodeRefSpacesStore() + getItemNodeRef(user, password, "/" + categoryName);
public HttpResponse createRetentionSchedule(String user, String password, String categoryName) {
String catNodeRef =
getNodeRefSpacesStore() + getItemNodeRef(user, password, "/" + categoryName);
JSONObject requestParams = new JSONObject();
requestParams.put("name", "createDispositionSchedule");
@@ -81,111 +80,153 @@ public class RecordCategoriesAPI extends BaseAPI
* @param categoryName
* @return the disposition schedule nodeRef
*/
public String getDispositionScheduleNodeRef(String user, String password, String categoryName)
{
public String getDispositionScheduleNodeRef(String user, String password, String categoryName) {
String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName);
JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef));
return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), "");
JSONObject dispositionSchedule =
doGetRequest(
user,
password,
MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef));
return dispositionSchedule
.getJSONObject("data")
.getString("nodeRef")
.replace(getNodeRefSpacesStore(), "");
}
/**
* Sets retention schedule authority and instructions, also if it is applied to records or folders
* Sets retention schedule authority and instructions, also if it is applied to records or
* folders
*
* @param user the user creating the disposition schedule
* @param password the user's password
* @param user the user creating the disposition schedule
* @param password the user's password
* @param retentionNodeRef the retention nodeRef
* @return The HTTP Response.
*/
public HttpResponse setRetentionScheduleGeneralFields(String user, String password, String retentionNodeRef, Map<RETENTION_SCHEDULE, String> retentionProperties, Boolean appliedToRecords)
{
public HttpResponse setRetentionScheduleGeneralFields(
String user,
String password,
String retentionNodeRef,
Map<RETENTION_SCHEDULE, String> retentionProperties,
Boolean appliedToRecords) {
String dispRetentionNodeRef = NODE_PREFIX + retentionNodeRef;
JSONObject requestParams = new JSONObject();
requestParams.put("prop_rma_dispositionAuthority", getPropertyValue(retentionProperties, RETENTION_SCHEDULE.RETENTION_AUTHORITY));
requestParams.put("prop_rma_dispositionInstructions", getPropertyValue(retentionProperties, RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS));
requestParams.put(
"prop_rma_dispositionAuthority",
getPropertyValue(retentionProperties, RETENTION_SCHEDULE.RETENTION_AUTHORITY));
requestParams.put(
"prop_rma_dispositionInstructions",
getPropertyValue(retentionProperties, RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS));
requestParams.put("prop_rma_recordLevelDisposition", appliedToRecords.toString());
return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(UPDATE_METADATA_API, "{0}", dispRetentionNodeRef));
return doPostJsonRequest(
user,
password,
SC_OK,
requestParams,
MessageFormat.format(UPDATE_METADATA_API, "{0}", dispRetentionNodeRef));
}
/**
* Creates a retention schedule steps for the category given as parameter
*
* @param user the user creating the disposition schedule
* @param password the user's password
* @param user the user creating the disposition schedule
* @param password the user's password
* @param categoryName the category name to create the retention schedule for
* @return The HTTP Response.
*/
public HttpResponse addDispositionScheduleSteps(String user, String password, String categoryName, Map<RETENTION_SCHEDULE, String> properties)
{
public HttpResponse addDispositionScheduleSteps(
String user,
String password,
String categoryName,
Map<RETENTION_SCHEDULE, String> properties) {
String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName);
JSONObject requestParams = new JSONObject();
addPropertyToRequest(requestParams, "name", properties, RETENTION_SCHEDULE.NAME);
addPropertyToRequest(requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION);
addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD);
addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST);
addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY);
addPropertyToRequest(requestParams, "location", properties, RETENTION_SCHEDULE.RETENTION_LOCATION);
addPropertyToRequest(
requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION);
addPropertyToRequest(
requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD);
addPropertyToRequest(
requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST);
addPropertyToRequest(
requestParams,
"periodProperty",
properties,
RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY);
addPropertyToRequest(
requestParams, "location", properties, RETENTION_SCHEDULE.RETENTION_LOCATION);
String events = getPropertyValue(properties, RETENTION_SCHEDULE.RETENTION_EVENTS);
if(!events.equals(""))
{
if (!events.equals("")) {
requestParams.append("events", events);
}
addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS);
addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT);
addPropertyToRequest(
requestParams,
"combineDispositionStepConditions",
properties,
RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS);
addPropertyToRequest(
requestParams,
"eligibleOnFirstCompleteEvent",
properties,
RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT);
return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef));
return doPostJsonRequest(
user,
password,
SC_OK,
requestParams,
MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef));
}
/**
* Delete a category
*
* @param username user's username
* @param password its password
* @param username user's username
* @param password its password
* @param categoryName the name of the category
* @throws AssertionError if the delete was unsuccessful.
*/
public void deleteCategory(String username, String password, String categoryName)
{
public void deleteCategory(String username, String password, String categoryName) {
deleteItem(username, password, "/" + categoryName);
}
/**
* Delete a sub-category
*
* @param username user's username
* @param password its password
* @param username user's username
* @param password its password
* @param categoryName the name of the sub-category
* @throws AssertionError if the deletion was unsuccessful.
*/
public void deleteSubCategory(String username, String password, String categoryName, String subCategoryName)
{
public void deleteSubCategory(
String username, String password, String categoryName, String subCategoryName) {
deleteItem(username, password, "/" + categoryName + "/" + subCategoryName);
}
/**
* Delete a folder inside a container in RM site
*
* @param username user's username
* @param password its password
* @param folderName folder name
* @param username user's username
* @param password its password
* @param folderName folder name
* @param containerName the name of the category or container sin which the folder is
* @throws AssertionError if the deletion was unsuccessful.
*/
public void deleteFolderInContainer(String username, String password, String folderName, String containerName)
{
public void deleteFolderInContainer(
String username, String password, String folderName, String containerName) {
deleteItem(username, password, "/" + containerName + "/" + folderName);
}
/**
* Returns a map of retention properties
*
* @param authority retention authority
* @param authority retention authority
* @param instructions retention authority
* @return the map
*/
public Map<RETENTION_SCHEDULE, String> getRetentionProperties(String authority, String instructions)
{
public Map<RETENTION_SCHEDULE, String> getRetentionProperties(
String authority, String instructions) {
Map<RETENTION_SCHEDULE, String> retentionProperties = new HashMap<>();
retentionProperties.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, authority);
retentionProperties.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, instructions);

View File

@@ -43,32 +43,29 @@ import org.springframework.stereotype.Component;
* @since 2.5
*/
@Component
public class RecordFoldersAPI extends BaseAPI
{
public class RecordFoldersAPI extends BaseAPI {
private static final Logger LOGGER = LoggerFactory.getLogger(RecordFoldersAPI.class);
/**
* Close the record folder
*
* @param user the user closing the folder
* @param password the user's password
* @param user the user closing the folder
* @param password the user's password
* @param recordFolder the record folder name
* @return The HTTP Response (or null if the response could not be understood).
*/
public HttpResponse closeRecordFolder(String user, String password, String recordFolder)
{
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
public HttpResponse closeRecordFolder(String user, String password, String recordFolder) {
String recNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
try
{
try {
JSONObject requestParams = new JSONObject();
requestParams.put("name", "closeRecordFolder");
requestParams.put("nodeRef", recNodeRef);
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
catch (JSONException error)
{
} catch (JSONException error) {
LOGGER.error("Unable to extract response parameter", error);
}
return null;

View File

@@ -29,9 +29,6 @@ package org.alfresco.rest.v0;
import static org.apache.http.HttpStatus.SC_OK;
import static org.testng.AssertJUnit.assertTrue;
import java.text.MessageFormat;
import java.util.Map;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.chemistry.opencmis.client.api.CmisObject;
@@ -43,6 +40,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.util.Map;
/**
* Methods to make API requests using v0 API on records
*
@@ -50,25 +50,27 @@ import org.springframework.stereotype.Component;
* @since 2.5
*/
@Component
public class RecordsAPI extends BaseAPI
{
public class RecordsAPI extends BaseAPI {
// logger
private static final Logger LOGGER = LoggerFactory.getLogger(RecordsAPI.class);
private static final String CREATE_NON_ELECTRONIC_RECORD_API = "{0}type/rma:nonElectronicDocument/formprocessor";
private static final String CREATE_NON_ELECTRONIC_RECORD_API =
"{0}type/rma:nonElectronicDocument/formprocessor";
/**
* Declare documents as records
*
* @param user the user declaring the document as record
* @param password the user's password
* @param siteID the site id in which the document exists
* @param user the user declaring the document as record
* @param password the user's password
* @param siteID the site id in which the document exists
* @param documentName the document name
* @return The HTTP Response.
*/
public HttpResponse declareDocumentAsRecord(String user, String password, String siteID, String documentName)
{
String docNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, siteID, documentName);
public HttpResponse declareDocumentAsRecord(
String user, String password, String siteID, String documentName) {
String docNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, siteID, documentName);
JSONObject requestParams = new JSONObject();
requestParams.put("actionedUponNode", docNodeRef);
@@ -80,14 +82,15 @@ public class RecordsAPI extends BaseAPI
/**
* Completes the record given as parameter
*
* @param user the user declaring the document as record
* @param password the user's password
* @param user the user declaring the document as record
* @param password the user's password
* @param recordName the record name
* @return The HTTP Response.
*/
public HttpResponse completeRecord(String user, String password, String recordName)
{
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
public HttpResponse completeRecord(String user, String password, String recordName) {
String recNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
JSONObject requestParams = new JSONObject();
requestParams.put("name", "declareRecord");
@@ -99,15 +102,15 @@ public class RecordsAPI extends BaseAPI
/**
* Reject the record given as parameter
*
* @param user the user declaring the document as record
* @param password the user's password
* @param user the user declaring the document as record
* @param password the user's password
* @param recordName the record name
* @param reason reject reason
* @param reason reject reason
* @return The HTTP Response.
* @throws AssertionError If the POST call is not successful.
*/
public HttpResponse rejectRecord(String user, String password, String recordName, String reason)
{
public HttpResponse rejectRecord(
String user, String password, String recordName, String reason) {
return rejectRecord(user, password, SC_OK, recordName, reason);
}
@@ -122,15 +125,20 @@ public class RecordsAPI extends BaseAPI
* @return The HTTP Response.
* @throws AssertionError If the expectedStatusCode was not returned.
*/
public HttpResponse rejectRecord(String user, String password, int expectedStatusCode, String recordName, String reason)
{
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
public HttpResponse rejectRecord(
String user,
String password,
int expectedStatusCode,
String recordName,
String reason) {
String recNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
JSONObject requestParams = new JSONObject();
requestParams.put("name", "reject");
requestParams.put("nodeRef", recNodeRef);
requestParams.put("params",new JSONObject()
.put("reason",reason));
requestParams.put("params", new JSONObject().put("reason", reason));
return doPostJsonRequest(user, password, expectedStatusCode, requestParams, RM_ACTIONS_API);
}
@@ -138,15 +146,17 @@ public class RecordsAPI extends BaseAPI
/**
* Declare document version as record
*
* @param user the user declaring the document version as record
* @param password the user's password
* @param siteID the site id in which the document exists
* @param user the user declaring the document version as record
* @param password the user's password
* @param siteID the site id in which the document exists
* @param documentName the document name
* @return The HTTP Response.
*/
public HttpResponse declareDocumentVersionAsRecord(String user, String password, String siteID, String documentName)
{
String docNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, siteID, documentName);
public HttpResponse declareDocumentVersionAsRecord(
String user, String password, String siteID, String documentName) {
String docNodeRef =
getNodeRefSpacesStore()
+ contentService.getNodeRef(user, password, siteID, documentName);
JSONObject requestParams = new JSONObject();
requestParams.put("actionedUponNode", docNodeRef);
@@ -157,36 +167,46 @@ public class RecordsAPI extends BaseAPI
/**
* Creates a non-electronic record
*
* <ul>
* <li>eg. of usage for Unfiled records with folder : createNonElectronicRecord(getAdminName(), getAdminPassword(), properties, UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
* <li>eg. of usage for creating record directly in Unfiled Records : createNonElectronicRecord(getAdminName(), getAdminPassword(), properties, UNFILED_RECORDS_BREADCRUMB, "");
* <li>eg. of usage for Unfiled records with folder :
* createNonElectronicRecord(getAdminName(), getAdminPassword(), properties,
* UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
* <li>eg. of usage for creating record directly in Unfiled Records :
* createNonElectronicRecord(getAdminName(), getAdminPassword(), properties,
* UNFILED_RECORDS_BREADCRUMB, "");
* </ul>
*
* @param username the username
* @param password the password
* @param properties a map of record properties and their values
* @param categoryName the category that contains the record, in the case in which the container would be Unfiled records use UNFILED_RECORDS_BREADCRUMB as value
* @param folderName the folder inside which the record exists, in the case in which the folder name is "", the record will be created directly in the specified container
* this case is useful when trying to create a record directly in Unfiled Records
* @param username the username
* @param password the password
* @param properties a map of record properties and their values
* @param categoryName the category that contains the record, in the case in which the container
* would be Unfiled records use UNFILED_RECORDS_BREADCRUMB as value
* @param folderName the folder inside which the record exists, in the case in which the folder
* name is "", the record will be created directly in the specified container this case is
* useful when trying to create a record directly in Unfiled Records
* @return The HTTP Response (or null if the request was not needed).
*/
public <K extends Enum<?>> HttpResponse createNonElectronicRecord(String username, String password, Map<K, String> properties, String categoryName, String folderName)
{
public <K extends Enum<?>> HttpResponse createNonElectronicRecord(
String username,
String password,
Map<K, String> properties,
String categoryName,
String folderName) {
String recordName = properties.get(RMProperty.NAME);
if (getRecord(username, password, folderName, recordName) != null)
{
if (getRecord(username, password, folderName, recordName) != null) {
return null;
}
String recordPath = "/" + categoryName;
if (!folderName.equals(""))
{
if (!folderName.equals("")) {
recordPath = recordPath + "/" + folderName;
}
// if the record already exists don't try to create it again
CmisObject record = getObjectByPath(username, password, getFilePlanPath() + recordPath + "/" + recordName);
CmisObject record =
getObjectByPath(
username, password, getFilePlanPath() + recordPath + "/" + recordName);
if (record != null)
{
if (record != null) {
return null;
}
// non-electronic properties
@@ -214,45 +234,75 @@ public class RecordsAPI extends BaseAPI
requestParams.put("prop_rma_box", box);
requestParams.put("prop_rma_file", file);
return doPostJsonRequest(username, password, SC_OK, requestParams, CREATE_NON_ELECTRONIC_RECORD_API);
return doPostJsonRequest(
username, password, SC_OK, requestParams, CREATE_NON_ELECTRONIC_RECORD_API);
}
/**
* Uploads an electronic record
* <p>
* eg. of usage for creating record directly in Unfiled Records : uploadElectronicRecord(getAdminName(), getAdminPassword(), recordPropertiesStringMap, UNFILED_RECORDS_BREADCRUMB, DocumentType.HTML)
* @param username the username
* @param password the password
*
* <p>eg. of usage for creating record directly in Unfiled Records :
* uploadElectronicRecord(getAdminName(), getAdminPassword(), recordPropertiesStringMap,
* UNFILED_RECORDS_BREADCRUMB, DocumentType.HTML)
*
* @param username the username
* @param password the password
* @param properties a map of record properties and their values
* @param folderName the folder inside which the record will be created, it needs to have a unique name, as this method doesn't check other containers than the folder name
* @param folderName the folder inside which the record will be created, it needs to have a
* unique name, as this method doesn't check other containers than the folder name
* @throws AssertionError if the upload was unsuccessful.
*/
public void uploadElectronicRecord(String username, String password, Map<RMProperty, String> properties, String folderName, DocumentType documentType)
{
public void uploadElectronicRecord(
String username,
String password,
Map<RMProperty, String> properties,
String folderName,
DocumentType documentType) {
String recordName = getPropertyValue(properties, RMProperty.NAME);
String recordContent = getPropertyValue(properties, RMProperty.CONTENT);
boolean success = (getRecord(username, password, folderName, recordName) != null) || (contentService.createDocumentInFolder(username, password, RM_SITE_ID, folderName, documentType, recordName, recordContent) != null);
boolean success =
(getRecord(username, password, folderName, recordName) != null)
|| (contentService.createDocumentInFolder(
username,
password,
RM_SITE_ID,
folderName,
documentType,
recordName,
recordContent)
!= null);
assertTrue("Failed to upload electronic record to " + folderName, success);
}
/**
* Delete a record from the given path
*
* <ul>
* <li>eg. of usage in the case in which the record is inside a folder in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
* <li>eg. of usage in the case in which the record is created directly in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "");
* <li>eg. of usage in the case in which the record is inside a folder in Unfiled Records :
* deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)",
* UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
* <li>eg. of usage in the case in which the record is created directly in Unfiled Records :
* deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)",
* UNFILED_RECORDS_BREADCRUMB, "");
* </ul>
* @param username user's username
* @param password its password
* @param recordName the record name
* @param categoryName the name of the category in which the folder is, in case of unfiled record, this will have UNFILED_RECORDS_BREADCRUMB as container
* @param folderName folder name, in case in which trying to delete a record in Unfiled records directly, this will be ""
*
* @param username user's username
* @param password its password
* @param recordName the record name
* @param categoryName the name of the category in which the folder is, in case of unfiled
* record, this will have UNFILED_RECORDS_BREADCRUMB as container
* @param folderName folder name, in case in which trying to delete a record in Unfiled records
* directly, this will be ""
* @throws AssertionError If the record could not be deleted.
*/
public void deleteRecord(String username, String password, String recordName, String categoryName, String folderName)
{
public void deleteRecord(
String username,
String password,
String recordName,
String categoryName,
String folderName) {
String recordPath = "/" + categoryName;
if (!folderName.equals(""))
{
if (!folderName.equals("")) {
recordPath = recordPath + "/" + folderName;
}
deleteItem(username, password, recordPath + "/" + recordName);
@@ -261,18 +311,22 @@ public class RecordsAPI extends BaseAPI
/**
* Retrieves the record object in case it exists
*
* @param username the user's username
* @param password its password
* @param username the user's username
* @param password its password
* @param folderName the folder in which the record is supposed to exist
* @param recordName the String with which the record name starts
* @return the record object in case it exists, null otherwise
*/
private CmisObject getRecord(String username, String password, String folderName, String recordName)
{
for (CmisObject record : contentService.getFolderObject(contentService.getCMISSession(username, password), RM_SITE_ID, folderName).getChildren())
{
if (record.getName().startsWith(recordName))
{
private CmisObject getRecord(
String username, String password, String folderName, String recordName) {
for (CmisObject record :
contentService
.getFolderObject(
contentService.getCMISSession(username, password),
RM_SITE_ID,
folderName)
.getChildren()) {
if (record.getName().startsWith(recordName)) {
return record;
}
}
@@ -282,44 +336,43 @@ public class RecordsAPI extends BaseAPI
/**
* Retrieves record full name for given partial name
*
* @param username the user's username
* @param password its password
* @param folderName the folder in which the record is supposed to exist
* @param username the user's username
* @param password its password
* @param folderName the folder in which the record is supposed to exist
* @param recordPartialName the String with which the record name starts
* @return the record name in case it exists, empty String otherwise
*/
public String getRecordFullName(String username, String password, String folderName, String recordPartialName)
{
public String getRecordFullName(
String username, String password, String folderName, String recordPartialName) {
CmisObject record = getRecord(username, password, folderName, recordPartialName);
if (record != null)
{
if (record != null) {
return record.getName();
}
return "";
}
/**
* Share a document
*
* @param user the user sharing the file
* @param user the user sharing the file
* @param password the user's password
* @param nodeId the node id of the file
* @return {@link Pair}. on success will be true and the shareId.
* on failure will be false and the response status code.
* @param nodeId the node id of the file
* @return {@link Pair}. on success will be true and the shareId. on failure will be false and
* the response status code.
*/
public Pair<Boolean, String> shareDocument(String user, String password, String nodeId) throws JSONException
{
JSONObject response = doPostRequest(user, password, null,
MessageFormat.format(SHARE_ACTION_API, "{0}", nodeId));
try
{
if (response.has("sharedId"))
{
public Pair<Boolean, String> shareDocument(String user, String password, String nodeId)
throws JSONException {
JSONObject response =
doPostRequest(
user,
password,
null,
MessageFormat.format(SHARE_ACTION_API, "{0}", nodeId));
try {
if (response.has("sharedId")) {
return Pair.of(true, response.getString("sharedId"));
}
} catch (JSONException e)
{
} catch (JSONException e) {
LOGGER.info("Unable to extract response parameter", e);
}
return Pair.of(false, String.valueOf(response.getJSONObject("status").getInt("code")));
@@ -328,13 +381,12 @@ public class RecordsAPI extends BaseAPI
/**
* Hide in place record
*
* @param user the user
* @param password the user's password
* @param nodeId the in place record node id
* @param user the user
* @param password the user's password
* @param nodeId the in place record node id
* @return The HTTP Response.
*/
public HttpResponse hideRecord(String user, String password, String nodeId)
{
public HttpResponse hideRecord(String user, String password, String nodeId) {
String docNodeRef = getNodeRefSpacesStore() + nodeId;
JSONObject requestParams = new JSONObject();
@@ -347,14 +399,15 @@ public class RecordsAPI extends BaseAPI
/**
* Retrieves the record's nodeRef
*
* @param username the user's username
* @param password its password
* @param username the user's username
* @param password its password
* @param recordName the record full name
* @param recordPath the String with which the record name starts
* @return the record nodeRef in case it exists, empty string otherwise
*/
public String getRecordNodeRef(String username, String password, String recordName, String recordPath)
{
return getNodeRefSpacesStore() + getItemNodeRef(username, password, recordPath + "/" + recordName);
public String getRecordNodeRef(
String username, String password, String recordName, String recordPath) {
return getNodeRefSpacesStore()
+ getItemNodeRef(username, password, recordPath + "/" + recordName);
}
}

View File

@@ -27,15 +27,10 @@
package org.alfresco.rest.v0;
import static java.util.Arrays.asList;
import static org.apache.http.HttpStatus.SC_OK;
import static org.testng.AssertJUnit.assertTrue;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static java.util.Arrays.asList;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
@@ -47,12 +42,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* Covers CRUD API operations on rules
*/
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** Covers CRUD API operations on rules */
@Component
public class RulesAPI extends BaseAPI
{
public class RulesAPI extends BaseAPI {
public static final String RULES_API = "{0}node/{1}/ruleset/rules";
public static final String RULE_API = "{0}node/{1}/ruleset/rules/{2}";
@@ -65,17 +62,22 @@ public class RulesAPI extends BaseAPI
* Creates a rule for the specified container with given rule properties
*
* @param containerNodeRef the container to have the rule created on
* @param ruleProperties the rule properties
* @param ruleProperties the rule properties
* @return The HTTP Response (or null if the response could not be understood).
*/
public HttpResponse createRule(String username, String password, String containerNodeRef, RuleDefinition ruleProperties)
{
try
{
return doPostJsonRequest(username, password, SC_OK, getRuleRequest(ruleProperties), MessageFormat.format(RULES_API, "{0}", containerNodeRef));
}
catch (JSONException error)
{
public HttpResponse createRule(
String username,
String password,
String containerNodeRef,
RuleDefinition ruleProperties) {
try {
return doPostJsonRequest(
username,
password,
SC_OK,
getRuleRequest(ruleProperties),
MessageFormat.format(RULES_API, "{0}", containerNodeRef));
} catch (JSONException error) {
LOGGER.error("Unable to extract response parameter.", error);
}
return null;
@@ -85,23 +87,26 @@ public class RulesAPI extends BaseAPI
* Updates a rule for the specified container with given rule properties
*
* @param containerNodeRef the container to have the rule created on
* @param ruleProperties the rule properties
* @param ruleProperties the rule properties
* @return true if the rule has been updated successfully, false otherwise
*/
public JSONObject updateRule(String username, String password, String containerNodeRef, RuleDefinition ruleProperties)
{
public JSONObject updateRule(
String username,
String password,
String containerNodeRef,
RuleDefinition ruleProperties) {
String ruleId = ruleProperties.getId();
if (ruleId == null || ruleId.isEmpty())
{
if (ruleId == null || ruleId.isEmpty()) {
throw new RuntimeException("Can not update a rule without id.");
}
try
{
return doPutRequest(username, password, getRuleRequest(ruleProperties), MessageFormat.format(RULE_API, "{0}", containerNodeRef, ruleId));
}
catch (JSONException error)
{
LOGGER.error("Unable to extract response parameter.", error);
try {
return doPutRequest(
username,
password,
getRuleRequest(ruleProperties),
MessageFormat.format(RULE_API, "{0}", containerNodeRef, ruleId));
} catch (JSONException error) {
LOGGER.error("Unable to extract response parameter.", error);
}
return null;
}
@@ -109,32 +114,37 @@ public class RulesAPI extends BaseAPI
/**
* Deletes a rule on a container and checks it doesn't exist anymore
*
* @param username the user performing the request
* @param password the password
* @param username the user performing the request
* @param password the password
* @param containerNodeRef the container on which the rule has been created
* @param ruleId the rule id
* @param ruleId the rule id
* @throws AssertionError if the rule could not be deleted.
*/
public void deleteRule(String username, String password, String containerNodeRef, String ruleId)
{
doDeleteRequest(username, password, MessageFormat.format(RULE_API, "{0}", containerNodeRef, ruleId));
boolean success = !getRulesIdsSetOnContainer(username, password, containerNodeRef).contains(ruleId);
assertTrue("Rule " + ruleId + " was not deleted successfully from " + containerNodeRef, success);
public void deleteRule(
String username, String password, String containerNodeRef, String ruleId) {
doDeleteRequest(
username,
password,
MessageFormat.format(RULE_API, "{0}", containerNodeRef, ruleId));
boolean success =
!getRulesIdsSetOnContainer(username, password, containerNodeRef).contains(ruleId);
assertTrue(
"Rule " + ruleId + " was not deleted successfully from " + containerNodeRef,
success);
}
/**
* Deletes all the rules on a container and checks they don't exist anymore
*
* @param username the user performing the request
* @param password the password
* @param username the user performing the request
* @param password the password
* @param containerNodeRef the container on which the rules have been created
* @throws AssertionError if at least one of the rules could not be deleted.
*/
public void deleteAllRulesOnContainer(String username, String password, String containerNodeRef)
{
public void deleteAllRulesOnContainer(
String username, String password, String containerNodeRef) {
List<String> ruleIds = getRulesIdsSetOnContainer(username, password, containerNodeRef);
for (String ruleId : ruleIds)
{
for (String ruleId : ruleIds) {
deleteRule(username, password, containerNodeRef, ruleId);
}
}
@@ -145,23 +155,22 @@ public class RulesAPI extends BaseAPI
* @param username the user performing the request
* @param password the password
* @param containerNodeRef the container to get the rules from
*
* @return list of rules on container
*/
public List<RuleDefinition> getRulesSetOnContainer(String username, String password, String containerNodeRef)
{
public List<RuleDefinition> getRulesSetOnContainer(
String username, String password, String containerNodeRef) {
List<RuleDefinition> rulesDefinitions = new ArrayList<>();
// get the rules set on the container
JSONObject rulesJson = doGetRequest(username, password, MessageFormat.format(RULES_API, "{0}", containerNodeRef));
if (rulesJson != null)
{
try
{
JSONObject rulesJson =
doGetRequest(
username,
password,
MessageFormat.format(RULES_API, "{0}", containerNodeRef));
if (rulesJson != null) {
try {
JSONArray rules = rulesJson.getJSONArray("data");
for (int i = 0; i < rules.length(); i++)
{
for (int i = 0; i < rules.length(); i++) {
RuleDefinition ruleDefinition = new RuleDefinition();
JSONObject rule = rules.getJSONObject(i);
ruleDefinition.id(rule.getString("id"));
@@ -171,9 +180,7 @@ public class RulesAPI extends BaseAPI
ruleDefinition.disabled(rule.getBoolean("disabled"));
rulesDefinitions.add(ruleDefinition);
}
}
catch (JSONException error)
{
} catch (JSONException error) {
LOGGER.error("Unable to parse rules.", error);
}
}
@@ -183,14 +190,16 @@ public class RulesAPI extends BaseAPI
/**
* Retrieves all the ids of the rules set on the container
*
* @param username the user performing the request
* @param password the password
* @param username the user performing the request
* @param password the password
* @param containerNodeRef the container's noderef to get set rules for
* @return the list of rules ids that the container has
*/
public List<String> getRulesIdsSetOnContainer(String username, String password, String containerNodeRef)
{
return getRulesSetOnContainer(username, password, containerNodeRef).stream().map(RuleDefinition::getId).collect(Collectors.toList());
public List<String> getRulesIdsSetOnContainer(
String username, String password, String containerNodeRef) {
return getRulesSetOnContainer(username, password, containerNodeRef).stream()
.map(RuleDefinition::getId)
.collect(Collectors.toList());
}
/**
@@ -198,11 +207,9 @@ public class RulesAPI extends BaseAPI
*
* @param ruleProperties the rule properties
* @return a object containing the rule properties for the request
*
* @throws JSONException
*/
private JSONObject getRuleRequest(RuleDefinition ruleProperties) throws JSONException
{
private JSONObject getRuleRequest(RuleDefinition ruleProperties) throws JSONException {
JSONObject requestParams = new JSONObject();
// the id has to be sent as empty string no matter the request
@@ -222,13 +229,10 @@ public class RulesAPI extends BaseAPI
* Adds rules actions to the request
*
* @param ruleProperties the rules properties to extract actions from
*
* @return the object with actions set
*
* @throws JSONException
*/
private JSONObject addRulesActions(RuleDefinition ruleProperties) throws JSONException
{
private JSONObject addRulesActions(RuleDefinition ruleProperties) throws JSONException {
JSONObject action = new JSONObject();
action.put("actionDefinitionName", "composite-action");
JSONObject conditions = new JSONObject();
@@ -243,40 +247,33 @@ public class RulesAPI extends BaseAPI
* Creates the actions list for request
*
* @param ruleProperties given rule properties
*
* @return the list of rule actions objects
*/
private List<JSONObject> getRuleActionsList(RuleDefinition ruleProperties) throws JSONException
{
private List<JSONObject> getRuleActionsList(RuleDefinition ruleProperties)
throws JSONException {
List<JSONObject> ruleActionsList = new ArrayList<>();
for (String ruleAction : ruleProperties.getActions())
{
for (String ruleAction : ruleProperties.getActions()) {
JSONObject ruleActionObj = new JSONObject();
ruleActionObj.put("actionDefinitionName", ruleAction);
JSONObject parameters = new JSONObject();
if (ruleProperties.getPath() != null)
{
if(ruleProperties.getCreateRecordPath() != null)
{
if (ruleProperties.getPath() != null) {
if (ruleProperties.getCreateRecordPath() != null) {
parameters.put("createRecordPath", ruleProperties.getCreateRecordPath());
}
parameters.put("path", ruleProperties.getPath());
}
if (ruleProperties.getContentTitle() != null)
{
if (ruleProperties.getContentTitle() != null) {
parameters.put("property", "cm:title");
parameters.put("value", ruleProperties.getContentTitle());
parameters.put("prop_type", "d:mltext");
}
if (ruleProperties.getContentDescription() != null)
{
if (ruleProperties.getContentDescription() != null) {
parameters.put("property", "cm:description");
parameters.put("value", ruleProperties.getContentDescription());
parameters.put("prop_type", "d:mltext");
}
if (ruleProperties.getRejectReason() != null)
{
if (ruleProperties.getRejectReason() != null) {
parameters.put("reason", ruleProperties.getRejectReason());
}
ruleActionObj.put("parameterValues", parameters);
@@ -291,13 +288,15 @@ public class RulesAPI extends BaseAPI
* @param username the user performing the request
* @param password the password
* @param containerNodeRef container nodeRef
*
* @return the rule id
*/
public String getRuleIdWithTitle(String username, String password, String containerNodeRef, String title)
{
return getRulesSetOnContainer(username, password, containerNodeRef).stream().filter(
rule -> rule.getTitle().equals(title)).findAny().get().getId();
public String getRuleIdWithTitle(
String username, String password, String containerNodeRef, String title) {
return getRulesSetOnContainer(username, password, containerNodeRef).stream()
.filter(rule -> rule.getTitle().equals(title))
.findAny()
.get()
.getId();
}
/**
@@ -306,14 +305,17 @@ public class RulesAPI extends BaseAPI
* @param username the username
* @param password the password
* @param containerNodeRef the container nodeRef
*
* @return The HTTP Response (or null if the current state is disabled).
*/
public HttpResponse disableRulesInheritance(String username, String password, String containerNodeRef)
{
if(containerInheritsRulesFromParent(username, password, containerNodeRef))
{
return doPostJsonRequest(username, password, SC_OK, new JSONObject(), MessageFormat.format(INHERIT_RULES_API, "{0}", containerNodeRef));
public HttpResponse disableRulesInheritance(
String username, String password, String containerNodeRef) {
if (containerInheritsRulesFromParent(username, password, containerNodeRef)) {
return doPostJsonRequest(
username,
password,
SC_OK,
new JSONObject(),
MessageFormat.format(INHERIT_RULES_API, "{0}", containerNodeRef));
}
return null;
}
@@ -321,16 +323,20 @@ public class RulesAPI extends BaseAPI
/**
* Enable inheritance on specific container
*
* @param username the username
* @param password the password
* @param username the username
* @param password the password
* @param containerNodeRef the container nodeRef
* @return The HTTP Response (or null if the current state is disabled).
*/
public HttpResponse enableRulesInheritance(String username, String password, String containerNodeRef)
{
if (!containerInheritsRulesFromParent(username, password, containerNodeRef))
{
return doPostJsonRequest(username, password, SC_OK, new JSONObject(), MessageFormat.format(INHERIT_RULES_API, "{0}", containerNodeRef));
public HttpResponse enableRulesInheritance(
String username, String password, String containerNodeRef) {
if (!containerInheritsRulesFromParent(username, password, containerNodeRef)) {
return doPostJsonRequest(
username,
password,
SC_OK,
new JSONObject(),
MessageFormat.format(INHERIT_RULES_API, "{0}", containerNodeRef));
}
return null;
}
@@ -341,13 +347,16 @@ public class RulesAPI extends BaseAPI
* @param username the username
* @param password the password
* @param containerNodeRef the container nodeRef
*
* @return a boolean specifying if the container inherits rules from parent
* @throws JSONException
*/
public boolean containerInheritsRulesFromParent(String username, String password, String containerNodeRef) throws JSONException
{
JSONObject rulesInheritanceInfo = doGetRequest(username, password, MessageFormat.format(INHERIT_RULES_STATE_API, "{0}", containerNodeRef));
public boolean containerInheritsRulesFromParent(
String username, String password, String containerNodeRef) throws JSONException {
JSONObject rulesInheritanceInfo =
doGetRequest(
username,
password,
MessageFormat.format(INHERIT_RULES_STATE_API, "{0}", containerNodeRef));
return rulesInheritanceInfo.getJSONObject("data").getBoolean("inheritRules");
}
}

View File

@@ -26,11 +26,6 @@
*/
package org.alfresco.rest.v0;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.rest.core.v0.BaseAPI;
import org.apache.http.NameValuePair;
@@ -41,6 +36,11 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Helper methods for performing search using various Alfresco search APIs.
*
@@ -48,44 +48,43 @@ import org.springframework.stereotype.Component;
* @since 2.5
*/
@Component
public class SearchAPI extends BaseAPI
{
public class SearchAPI extends BaseAPI {
/** http client factory */
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
/** 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}";
/** share live search API endpoint */
private static final String SHARE_LIVE_SEARCH_DOCS_ENDPOINT = "{0}alfresco/s/slingshot/live-search-docs?{1}";
private static final String SHARE_LIVE_SEARCH_DOCS_ENDPOINT =
"{0}alfresco/s/slingshot/live-search-docs?{1}";
/** RM search URL template */
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
/** RM all nodes search filters */
private static final String RM_DEFAULT_NODES_FILTERS =
"records/true,undeclared/true,vital/false,folders/{0},categories/{1},frozen/false,cutoff/false";
"records/true,undeclared/true,vital/false,folders/{0},categories/{1},frozen/false,cutoff/false";
/**
* Perform search request on search endpoint as a user.
* <p>
* This method is applicable only to endpoints that support HTTP GET requests and return JSON body as response.
*
* <p>This method is applicable only to endpoints that support HTTP GET requests and return JSON
* body as response.
*
* @param searchEndpoint
* @param searchUser
* @param searchPassword
* @return search results as a {@link JSONObject}, please refer to API documentation for details
*/
private JSONObject doSearch(
String searchEndpoint,
String searchUser,
String searchPassword)
{
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
private JSONObject doSearch(String searchEndpoint, String searchUser, String searchPassword) {
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
}
/**
* Generic rm search.
*
* @param username
* @param password
* @param site
@@ -95,34 +94,32 @@ public class SearchAPI extends BaseAPI
* @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,
String sortby)
{
String username,
String password,
String site,
String query,
String filters,
String sortby) {
List<BasicNameValuePair> searchParameters = new ArrayList<>();
searchParameters.add(new BasicNameValuePair("query", query));
searchParameters.add(new BasicNameValuePair("filters", filters));
if (sortby != null)
{
if (sortby != null) {
searchParameters.add(new BasicNameValuePair("sortby", sortby));
}
String requestURL = MessageFormat.format(
RM_SEARCH_ENDPOINT,
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(),
(site != null) ? site : RM_SITE_ID,
URLEncodedUtils.format(searchParameters, "UTF-8"));
String requestURL =
MessageFormat.format(
RM_SEARCH_ENDPOINT,
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(),
(site != null) ? site : RM_SITE_ID,
URLEncodedUtils.format(searchParameters, "UTF-8"));
return doSearch(requestURL, username, password);
}
/**
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
* by sortby
* <br>
* Search as a user for nodes on site "rm" matching query, using
* SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted by sortby <br>
*
* @param username
* @param password
@@ -130,20 +127,28 @@ public class SearchAPI extends BaseAPI
* @param sortby
* @return list of node names
*/
public List<String> searchForNodeNamesAsUser(
String username,
String password,
String query,
String sortby,
boolean includeCategories,
boolean includeFolders) {
String searchFilterParamaters =
MessageFormat.format(
RM_DEFAULT_NODES_FILTERS,
Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
public List<String> searchForNodeNamesAsUser(String username, String password, String query, String sortby,
boolean includeCategories, boolean includeFolders)
{
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
return getItemNames(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby));
return getItemNames(
rmSearch(username, password, "rm", query, searchFilterParamaters, sortby));
}
/**
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
* by sortby and returns the property value for the given nodeRef and property name
*
* Search as a user for nodes on site "rm" matching query, using
* SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted by sortby and returns the property value for
* the given nodeRef and property name
*
* @param username
* @param password
* @param query
@@ -152,23 +157,36 @@ public class SearchAPI extends BaseAPI
* @param includeFolders
* @return list of node properties
*/
public String searchForNodePropertyAsUser(String username, String password, String nodeRef, String propertyName, String query, String sortby,
boolean includeCategories, boolean includeFolders)
{
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
return getItemProperty(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby), nodeRef, propertyName);
public String searchForNodePropertyAsUser(
String username,
String password,
String nodeRef,
String propertyName,
String query,
String sortby,
boolean includeCategories,
boolean includeFolders) {
String searchFilterParamaters =
MessageFormat.format(
RM_DEFAULT_NODES_FILTERS,
Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
return getItemProperty(
rmSearch(username, password, "rm", query, searchFilterParamaters, sortby),
nodeRef,
propertyName);
}
/**
* Generic faceted search.
*
* @param username
* @param password
* @param parameters
* @return search results (see API reference for more details), null for any errors
*/
public JSONObject facetedSearch(String username, String password, List<NameValuePair> parameters)
{
public JSONObject facetedSearch(
String username, String password, List<NameValuePair> parameters) {
return facetedRequest(username, password, parameters, FACETED_SEARCH_ENDPOINT);
}
@@ -180,48 +198,53 @@ public class SearchAPI extends BaseAPI
* @param searchTerm
* @return search results (see API reference for more details)
*/
public JSONObject liveSearchForDocuments(String searchUser, String searchPassword, String searchTerm)
{
return facetedRequest(searchUser, searchPassword, Arrays.asList(new BasicNameValuePair("t", searchTerm)),
SHARE_LIVE_SEARCH_DOCS_ENDPOINT);
public JSONObject liveSearchForDocuments(
String searchUser, String searchPassword, String searchTerm) {
return facetedRequest(
searchUser,
searchPassword,
Arrays.asList(new BasicNameValuePair("t", searchTerm)),
SHARE_LIVE_SEARCH_DOCS_ENDPOINT);
}
/**
* Execute faceted search for term.
*
* @param searchUser
* @param searchPassword
* @param searchTerm
* @return search results (see API reference for more details)
*/
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)));
searchUser,
searchPassword,
Arrays.asList(new BasicNameValuePair("term", searchTerm)));
}
/**
* Helper method to search for documents as a user using faceted search.
*
* @param username to search as
* @param password for username
* @param term search term
* @return list of document names found
*/
public List<String> searchForDocumentsAsUser(String username, String password, String term)
{
public List<String> searchForDocumentsAsUser(String username, String password, String term) {
return getItemNames(facetedSearchForTerm(username, password, term));
}
/**
* Helper method to search for documents as a user using share live search.
*
* @param username to search as
* @param password for username
* @param term search term
* @return list of document names found
*/
public List<String> liveSearchForDocumentsAsUser(String username, String password, String term) throws JSONException
{
public List<String> liveSearchForDocumentsAsUser(String username, String password, String term)
throws JSONException {
JSONObject searchResult = liveSearchForDocuments(username, password, term);
LOGGER.info(searchResult.toString(3));
return getItemNames(searchResult);
@@ -229,35 +252,33 @@ public class SearchAPI extends BaseAPI
/**
* Helper method to extract list of names from search result.
*
*
* @param searchResult
* @return list of document or record names in search result
* @throws FileNotFoundException
* @throws JsonSyntaxException
* @throws JsonIOException
* @throws FileNotFoundException
* @throws JsonSyntaxException
* @throws JsonIOException
* @throws RuntimeException for malformed search response
*/
/**
* Helper method to extract list of names from search result.
*
*
* @param searchResult
* @return
*/
private List<String> getItemNames(JSONObject searchResult)
{
private List<String> getItemNames(JSONObject searchResult) {
return getPropertyValues(searchResult, "name");
}
/**
* Helper method to extract list of property values from search result for the given nodeRef.
*
*
* @param searchResult
* @param nodeRef
* @param propertyName
* @return
*/
private String getItemProperty(JSONObject searchResult, String nodeRef, String propertyName)
{
private String getItemProperty(JSONObject searchResult, String nodeRef, String propertyName) {
return getPropertyValue(searchResult, nodeRef, propertyName);
}
}

View File

@@ -38,8 +38,7 @@ import org.springframework.stereotype.Component;
* @since 2.6
*/
@Component
public class UserTrashcanAPI extends BaseAPI
{
public class UserTrashcanAPI extends BaseAPI {
private static final String EMPTY_TRASHCAN = "{0}archive/workspace/SpacesStore";
/**
@@ -49,10 +48,9 @@ public class UserTrashcanAPI extends BaseAPI
* @param password the password
* @throws AssertionError if emptying the trashcan fails.
*/
public void emptyTrashcan(String username, String password)
{
assertNotNull("Emptying trashcan failed for user " + username,
doDeleteRequest(username, password, EMPTY_TRASHCAN));
public void emptyTrashcan(String username, String password) {
assertNotNull(
"Emptying trashcan failed for user " + username,
doDeleteRequest(username, password, EMPTY_TRASHCAN));
}
}

View File

@@ -26,11 +26,8 @@
*/
package org.alfresco.rest.v0.service;
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
import java.util.HashMap;
import org.alfresco.rest.core.v0.BaseAPI;
import org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty;
import org.alfresco.rest.v0.RecordCategoriesAPI;
@@ -39,6 +36,8 @@ import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
/**
* Service for different disposition schedule actions
*
@@ -46,137 +45,153 @@ import org.springframework.stereotype.Service;
* @since 2.6.2
*/
@Service
public class DispositionScheduleService extends BaseAPI
{
@Autowired
private RecordCategoriesAPI recordCategoriesAPI;
public class DispositionScheduleService extends BaseAPI {
@Autowired private RecordCategoriesAPI recordCategoriesAPI;
@Autowired
private DataUserAIS dataUser;
@Autowired private DataUserAIS dataUser;
/**
* Helper method for adding a retain after period step
*
* @param categoryName the category in whose schedule the step will be added
* @param period for what period the item will be retained
* @param period for what period the item will be retained
*/
public void addRetainAfterPeriodStep(String categoryName, String period)
{
public void addRetainAfterPeriodStep(String categoryName, String period) {
HashMap<RETENTION_SCHEDULE, String> retainStep = new HashMap<>();
retainStep.put(RETENTION_SCHEDULE.NAME, "retain");
retainStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
retainStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, retainStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
retainStep);
}
/**
* Helper method for adding a cut off immediately after created date step
*
* @param categoryName the category in whose schedule the step will be added
* @param categoryName the category in whose schedule the step will be added
*/
public void addCutOffImmediatelyStep(String categoryName)
{
public void addCutOffImmediatelyStep(String categoryName) {
HashMap<RETENTION_SCHEDULE, String> cutOffStep = new HashMap<>();
cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, "immediately");
cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off immediately step");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, cutOffStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
cutOffStep);
}
/**
* Helper method for adding a cut off after period step
*
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass from periodProperty for cut off to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the "as of" period
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass from periodProperty for cut off to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the
* "as of" period
*/
public void addCutOffAfterPeriodStep(String categoryName, String period, RetentionPeriodProperty periodProperty)
{
public void addCutOffAfterPeriodStep(
String categoryName, String period, RetentionPeriodProperty periodProperty) {
HashMap<RETENTION_SCHEDULE, String> cutOffStep = new HashMap<>();
cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
cutOffStep.put(
RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, cutOffStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
cutOffStep);
}
/**
* Helper method for adding a destroy step with ghosting immediately after CUT OFF date
*
* @param categoryName the category in whose schedule the step will be added
* @param categoryName the category in whose schedule the step will be added
*/
public void addDestroyWithGhostingImmediatelyAfterCutOff(String categoryName)
{
public void addDestroyWithGhostingImmediatelyAfterCutOff(String categoryName) {
addDestroyWithGhostingAfterPeriodStep(categoryName, "immediately", CUT_OFF_DATE);
}
/**
* Helper method for adding a destroy step with ghosting after period
*
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass for destroy to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the "as of" period
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass for destroy to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the
* "as of" period
*/
public void addDestroyWithGhostingAfterPeriodStep(String categoryName, String period, RetentionPeriodProperty periodProperty)
{
public void addDestroyWithGhostingAfterPeriodStep(
String categoryName, String period, RetentionPeriodProperty periodProperty) {
HashMap<RETENTION_SCHEDULE, String> destroyStep = new HashMap<>();
destroyStep.put(RETENTION_SCHEDULE.NAME, "destroy");
destroyStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
destroyStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
destroyStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Destroy after a period step with keep metadata");
destroyStep.put(
RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
destroyStep.put(
RETENTION_SCHEDULE.DESCRIPTION, "Destroy after a period step with keep metadata");
destroyStep.put(RETENTION_SCHEDULE.RETENTION_GHOST, "on");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, destroyStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
destroyStep);
}
/**
* Helper method for adding a destroy step without ghosting after period
*
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass for destroy to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the "as of" period
* @param categoryName the category in whose schedule the step will be added
* @param period the period that needs to pass for destroy to be available
* @param periodProperty the property of the dispositioned item that is used to calculate the
* "as of" period
*/
public void addDestroyWithoutGhostingAfterPeriodStep(String categoryName, String period,
RetentionPeriodProperty periodProperty)
{
public void addDestroyWithoutGhostingAfterPeriodStep(
String categoryName, String period, RetentionPeriodProperty periodProperty) {
HashMap<RETENTION_SCHEDULE, String> destroyStep = new HashMap<>();
destroyStep.put(RETENTION_SCHEDULE.NAME, "destroy");
destroyStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
destroyStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
destroyStep.put(
RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
destroyStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Destroy after a period step");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, destroyStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
destroyStep);
}
/**
* Helper method for adding a cut off after an event occurs step
*
* @param categoryName the category in whose schedule the step will be added
* @param events the events that need to occur for cut off to be available
* @param events the events that need to occur for cut off to be available
*/
public void addCutOffAfterEventStep(String categoryName, String events)
{
public void addCutOffAfterEventStep(String categoryName, String events) {
HashMap<RETENTION_SCHEDULE, String> cutOffStep = new HashMap<>();
cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_EVENTS, events);
cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after event step");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, cutOffStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
cutOffStep);
}
/**
* Helper method for adding a transfer after an event occurs step
*
* @param categoryName the category in whose schedule the step will be added
* @param location the transfer location
* @param events the events that need to occur for transfer to be available
* @param location the transfer location
* @param events the events that need to occur for transfer to be available
*/
public void addTransferAfterEventStep(String categoryName, String location, String events)
{
public void addTransferAfterEventStep(String categoryName, String location, String events) {
HashMap<RETENTION_SCHEDULE, String> transferStep = new HashMap<>();
transferStep.put(RETENTION_SCHEDULE.NAME, "transfer");
transferStep.put(RETENTION_SCHEDULE.RETENTION_LOCATION, location);
@@ -185,8 +200,11 @@ public class DispositionScheduleService extends BaseAPI
transferStep.put(RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS, "false");
transferStep.put(RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT, "true");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, transferStep);
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
transferStep);
}
/**
@@ -198,55 +216,74 @@ public class DispositionScheduleService extends BaseAPI
* @param periodProperty
* @param combineConditions
*/
public void addAccessionStep(String categoryName, Boolean timeOrEvent, String events, String period,
RetentionPeriodProperty periodProperty, Boolean combineConditions)
{
public void addAccessionStep(
String categoryName,
Boolean timeOrEvent,
String events,
String period,
RetentionPeriodProperty periodProperty,
Boolean combineConditions) {
HashMap<RETENTION_SCHEDULE, String> accessionStep = new HashMap<>();
accessionStep.put(RETENTION_SCHEDULE.NAME, "accession");
accessionStep.put(RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS, Boolean.toString(combineConditions));
accessionStep.put(
RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS,
Boolean.toString(combineConditions));
accessionStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
accessionStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
if (!timeOrEvent)
{
accessionStep.put(RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT, Boolean.toString(timeOrEvent));
accessionStep.put(
RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY, periodProperty.getPeriodProperty());
if (!timeOrEvent) {
accessionStep.put(
RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT,
Boolean.toString(timeOrEvent));
}
accessionStep.put(RETENTION_SCHEDULE.RETENTION_EVENTS, events);
accessionStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Accession step with time and event conditions.");
recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), categoryName, accessionStep);
accessionStep.put(
RETENTION_SCHEDULE.DESCRIPTION, "Accession step with time and event conditions.");
recordCategoriesAPI.addDispositionScheduleSteps(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName,
accessionStep);
}
/**
* Helper method to create retention schedule with general fields for the given category as user
* and apply it to the records/ record folders
*
* @param user the user who creates the retention schedule
* @param categoryName the category on which is created the retention schedule
* @param user the user who creates the retention schedule
* @param categoryName the category on which is created the retention schedule
* @param appliedToRecords true if is applied on records, false if is applied on folders
*/
public void createCategoryRetentionSchedule(UserModel user, String categoryName, Boolean appliedToRecords)
{
recordCategoriesAPI.createRetentionSchedule(user.getUsername(), user.getPassword(), categoryName);
String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef(
dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName);
public void createCategoryRetentionSchedule(
UserModel user, String categoryName, Boolean appliedToRecords) {
recordCategoriesAPI.createRetentionSchedule(
user.getUsername(), user.getPassword(), categoryName);
String retentionScheduleNodeRef =
recordCategoriesAPI.getDispositionScheduleNodeRef(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
categoryName);
HashMap<RETENTION_SCHEDULE, String> retentionScheduleGeneralFields = new HashMap<>();
retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority");
retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions");
recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields,
retentionScheduleGeneralFields.put(
RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions");
recordCategoriesAPI.setRetentionScheduleGeneralFields(
dataUser.getAdminUser().getUsername(),
dataUser.getAdminUser().getPassword(),
retentionScheduleNodeRef,
retentionScheduleGeneralFields,
appliedToRecords);
}
/**
* Helper method to create retention schedule with general fields for the given category as admin
* and apply it to the records/record folders
* Helper method to create retention schedule with general fields for the given category as
* admin and apply it to the records/record folders
*
* @param categoryName the category on which is created the retention schedule
* @param categoryName the category on which is created the retention schedule
* @param appliedToRecords true if is applied on records, false if is applied on folders
*/
public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords)
{
public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords) {
createCategoryRetentionSchedule(dataUser.getAdminUser(), categoryName, appliedToRecords);
}
}

Some files were not shown because too many files have changed in this diff Show More