Package org.alfresco.rest.core.v0
Class BaseAPI
java.lang.Object
org.alfresco.rest.core.v0.BaseAPI
- Direct Known Subclasses:
CopyToAPI,CustomDefinitionsAPI,DispositionScheduleService,ExportAPI,HoldsAPI,LinksAPI,NodeAPI,NodePropertiesAPI,RecordCategoriesAPI,RecordFoldersAPI,RecordsAPI,RMAuditAPI,RMRolesAndActionsAPI,RulesAPI,SearchAPI,UserTrashcanAPI
The base API class containing common methods for making v0 API requests
- Since:
- 2.5
- Author:
- Kristijan Conkas
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enumUsed to execute rm actions on a nodestatic enumUsed to set RM items properties including records, categories and folders -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected org.alfresco.dataprep.ContentServiceprotected static final org.slf4j.Loggerstatic final Stringstatic final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <K extends Enum<?>>
org.json.JSONObjectaddPropertyToRequest(org.json.JSONObject requestParams, String propertyRequestValue, Map<K, String> itemProperties, Enum<?> property) Retrieves the property value and decides if that gets to be added to the requestprotected voiddeleteItem(String username, String password, String itemPath) Deletes the category, folder or record given as parameterprotected org.json.JSONObjectdoDeleteRequest(String adminUser, String adminPassword, String urlTemplate, String... urlTemplateParams) Helper method for Delete requestsprotected org.json.JSONObjectdoGetRequest(String adminUser, String adminPassword, String urlTemplate, String... urlTemplateParams) Helper method for GET requestsprotected org.apache.http.HttpResponsedoPostJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requestsprotected org.json.JSONObjectdoPostRequest(String adminUser, String adminPassword, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requestsprotected org.apache.http.HttpResponsedoPutJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for PUT requestsprotected org.json.JSONObjectdoPutRequest(String adminUser, String adminPassword, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for PUT requestsprotected org.apache.http.HttpResponsedoSlingshotPostJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requests to slingshot.protected org.json.JSONObjectfacetedRequest(String username, String password, List<org.apache.http.NameValuePair> parameters, String requestURI) Generic faceted request.static StringRetrieve the File Plan pathgetItemNodeRef(String username, String password, String path) Retrieves the nodeRef of an item (category, folder or record) with the given pathstatic StringRetrieve the node ref spaces store valueprotected org.apache.chemistry.opencmis.client.api.CmisObjectgetObjectByPath(String username, String password, String path) Retrieve a Cmis object by its pathgetPropertyValue(Map<K, String> properties, Enum<?> property) Util to return the property value from a mapprotected StringgetPropertyValue(org.json.JSONObject result, String nodeRef, String propertyName) Helper method to extract the property value for the given nodeRef and property namegetPropertyValues(org.json.JSONObject result, String propertyName) Helper method to extract list of properties values from result.getPropertyValuesByUniquePropertyValue(org.json.JSONObject requestResult, String uniqueProperty, List<String> otherProperties) Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.
-
Field Details
-
LOGGER
protected static final org.slf4j.Logger LOGGER -
NODE_PREFIX
- See Also:
-
UPDATE_METADATA_API
- See Also:
-
ACTIONS_API
- See Also:
-
RM_ACTIONS_API
- See Also:
-
RM_SITE_ID
- See Also:
-
SHARE_ACTION_API
- See Also:
-
contentService
@Autowired protected org.alfresco.dataprep.ContentService contentService -
NODE_REF_WORKSPACE_SPACES_STORE
- See Also:
-
-
Constructor Details
-
BaseAPI
public BaseAPI()
-
-
Method Details
-
getPropertyValues
Helper method to extract list of properties values from result.- Parameters:
result- the response- Returns:
- list of specified property values in result
- Throws:
RuntimeException- for malformed response
-
getPropertyValue
Helper method to extract the property value for the given nodeRef and property name- Parameters:
result-nodeRef-propertyName-- Returns:
-
getPropertyValuesByUniquePropertyValue
protected Map<String,List<String>> getPropertyValuesByUniquePropertyValue(org.json.JSONObject requestResult, String uniqueProperty, List<String> otherProperties) Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.- Parameters:
requestResult- the request response- Returns:
- a map containing information about multiple properties values that correspond to a unique one
- Throws:
RuntimeException- for malformed response
-
getItemNodeRef
Retrieves the nodeRef of an item (category, folder or record) with the given path- Parameters:
username- the usernamepassword- the passwordpath- 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 ""- Returns:
- the container nodeRef
-
getObjectByPath
protected org.apache.chemistry.opencmis.client.api.CmisObject getObjectByPath(String username, String password, String path) Retrieve a Cmis object by its path- Parameters:
username- the user's usernamepassword- its passwordpath- the object path- Returns:
- the object in case it exists, null if its does not exist
-
facetedRequest
protected org.json.JSONObject facetedRequest(String username, String password, List<org.apache.http.NameValuePair> parameters, String requestURI) Generic faceted request.- Parameters:
username- the usernamepassword- the passwordparameters- if the request has parameters- Returns:
- result object (see API reference for more details), null for any errors
-
doGetRequest
protected org.json.JSONObject doGetRequest(String adminUser, String adminPassword, String urlTemplate, String... urlTemplateParams) Helper method for GET requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doDeleteRequest
protected org.json.JSONObject doDeleteRequest(String adminUser, String adminPassword, String urlTemplate, String... urlTemplateParams) Helper method for Delete requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doPutRequest
protected org.json.JSONObject doPutRequest(String adminUser, String adminPassword, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for PUT requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserrequestParams- zero or more endpoint specific request parametersurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doPutJsonRequest
protected org.apache.http.HttpResponse doPutJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for PUT requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserexpectedStatusCode- The expected return status code.requestParams- zero or more endpoint specific request parametersurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doPostRequest
protected org.json.JSONObject doPostRequest(String adminUser, String adminPassword, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserrequestParams- zero or more endpoint specific request parametersurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doPostJsonRequest
protected org.apache.http.HttpResponse doPostJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requests- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserexpectedStatusCode- The expected return status code.requestParams- zero or more endpoint specific request parametersurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
doSlingshotPostJsonRequest
protected org.apache.http.HttpResponse doSlingshotPostJsonRequest(String adminUser, String adminPassword, int expectedStatusCode, org.json.JSONObject requestParams, String urlTemplate, String... urlTemplateParams) Helper method for POST requests to slingshot.- Parameters:
adminUser- user with administrative privilegesadminPassword- password for adminUserexpectedStatusCode- The expected return status code.requestParams- zero or more endpoint specific request parametersurlTemplate- request URL templateurlTemplateParams- zero or more parameters used with urlTemplate
-
getPropertyValue
Util to return the property value from a map- Parameters:
properties- the map containing propertiesproperty- to get value for- Returns:
- the property value
-
addPropertyToRequest
protected <K extends Enum<?>> org.json.JSONObject addPropertyToRequest(org.json.JSONObject requestParams, String propertyRequestValue, Map<K, String> itemProperties, Enum<?> property) throws org.json.JSONExceptionRetrieves the property value and decides if that gets to be added to the request- Parameters:
requestParams- the request parameterspropertyRequestValue- the property name in the request, eg. "prop_cm_name"itemProperties- map of item's properties valuesproperty- the property in the property map to check value for- Returns:
- the json object used in request with the property with its value added if that is not null or empty
- Throws:
org.json.JSONException
-
deleteItem
Deletes the category, folder or record given as parameter- Parameters:
username- the username with whom the delete is performedpassword- the user's passworditemPath- 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.
-
getNodeRefSpacesStore
Retrieve the node ref spaces store value- Returns:
- node ref spaces store
-
getFilePlanPath
Retrieve the File Plan path- Returns:
- the File Plan path
-