Class RecordsAPI

java.lang.Object
org.alfresco.rest.core.v0.BaseAPI
org.alfresco.rest.v0.RecordsAPI

@Component public class RecordsAPI extends BaseAPI
Methods to make API requests using v0 API on records
Since:
2.5
Author:
Oana Nechiforescu
  • Constructor Details

    • RecordsAPI

      public RecordsAPI()
  • Method Details

    • declareDocumentAsRecord

      public org.apache.http.HttpResponse declareDocumentAsRecord(String user, String password, String siteID, String documentName)
      Declare documents as records
      Parameters:
      user - the user declaring the document as record
      password - the user's password
      siteID - the site id in which the document exists
      documentName - the document name
      Returns:
      The HTTP Response.
    • completeRecord

      public org.apache.http.HttpResponse completeRecord(String user, String password, String recordName)
      Completes the record given as parameter
      Parameters:
      user - the user declaring the document as record
      password - the user's password
      recordName - the record name
      Returns:
      The HTTP Response.
    • rejectRecord

      public org.apache.http.HttpResponse rejectRecord(String user, String password, String recordName, String reason)
      Reject the record given as parameter
      Parameters:
      user - the user declaring the document as record
      password - the user's password
      recordName - the record name
      reason - reject reason
      Returns:
      The HTTP Response.
      Throws:
      AssertionError - If the POST call is not successful.
    • rejectRecord

      public org.apache.http.HttpResponse rejectRecord(String user, String password, int expectedStatusCode, String recordName, String reason)
      Reject the record given as parameter
      Parameters:
      user - the user declaring the document as record
      password - the user's password
      expectedStatusCode - The expected return status code.
      recordName - the record name
      reason - reject reason
      Returns:
      The HTTP Response.
      Throws:
      AssertionError - If the expectedStatusCode was not returned.
    • declareDocumentVersionAsRecord

      public org.apache.http.HttpResponse declareDocumentVersionAsRecord(String user, String password, String siteID, String documentName)
      Declare document version as record
      Parameters:
      user - the user declaring the document version as record
      password - the user's password
      siteID - the site id in which the document exists
      documentName - the document name
      Returns:
      The HTTP Response.
    • createNonElectronicRecord

      public <K extends Enum<?>> org.apache.http.HttpResponse createNonElectronicRecord(String username, String password, Map<K,String> properties, String categoryName, String folderName)
      Creates a non-electronic record
      • eg. of usage for Unfiled records with folder : createNonElectronicRecord(getAdminName(), getAdminPassword(), properties, UNFILED_RECORDS_BREADCRUMB, "unfiled records folder");
      • eg. of usage for creating record directly in Unfiled Records : createNonElectronicRecord(getAdminName(), getAdminPassword(), properties, UNFILED_RECORDS_BREADCRUMB, "");
      Parameters:
      username - the username
      password - the password
      properties - a map of record properties and their values
      categoryName - the category that contains the record, in the case in which the container would be Unfiled records use UNFILED_RECORDS_BREADCRUMB as value
      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
      Returns:
      The HTTP Response (or null if the request was not needed).
    • uploadElectronicRecord

      public void uploadElectronicRecord(String username, String password, Map<BaseAPI.RMProperty,String> properties, String folderName, org.alfresco.dataprep.CMISUtil.DocumentType documentType)
      Uploads an electronic record

      eg. of usage for creating record directly in Unfiled Records : uploadElectronicRecord(getAdminName(), getAdminPassword(), recordPropertiesStringMap, UNFILED_RECORDS_BREADCRUMB, DocumentType.HTML)

      Parameters:
      username - the username
      password - the password
      properties - a map of record properties and their values
      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.
    • deleteRecord

      public void deleteRecord(String username, String password, String recordName, String categoryName, String folderName)
      Delete a record from the given path
      • 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");
      • 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, "");
      Parameters:
      username - user's username
      password - its password
      recordName - the record name
      categoryName - the name of the category in which the folder is, in case of unfiled record, this will have UNFILED_RECORDS_BREADCRUMB as container
      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.
    • getRecord

      public org.apache.chemistry.opencmis.client.api.CmisObject getRecord(String username, String password, String folderName, String recordName)
      Retrieves the record object in case it exists
      Parameters:
      username - the user's username
      password - its password
      folderName - the folder in which the record is supposed to exist
      recordName - the String with which the record name starts
      Returns:
      the record object in case it exists, null otherwise
    • getRecordFullName

      public String getRecordFullName(String username, String password, String folderName, String recordPartialName)
      Retrieves record full name for given partial name
      Parameters:
      username - the user's username
      password - its password
      folderName - the folder in which the record is supposed to exist
      recordPartialName - the String with which the record name starts
      Returns:
      the record name in case it exists, empty String otherwise
    • shareDocument

      public org.apache.commons.lang3.tuple.Pair<Boolean,String> shareDocument(String user, String password, String nodeId) throws org.json.JSONException
      Share a document
      Parameters:
      user - the user sharing the file
      password - the user's password
      nodeId - the node id of the file
      Returns:
      Pair. on success will be true and the shareId. on failure will be false and the response status code.
      Throws:
      org.json.JSONException
    • hideRecord

      public org.apache.http.HttpResponse hideRecord(String user, String password, String nodeId)
      Hide in place record
      Parameters:
      user - the user
      password - the user's password
      nodeId - the in place record node id
      Returns:
      The HTTP Response.
    • getRecordNodeRef

      public String getRecordNodeRef(String username, String password, String recordName, String recordPath)
      Retrieves the record's nodeRef
      Parameters:
      username - the user's username
      password - its password
      recordName - the record full name
      recordPath - the String with which the record name starts
      Returns:
      the record nodeRef in case it exists, empty string otherwise
    • reOpenRecord

      public org.apache.http.HttpResponse reOpenRecord(String user, String password, String recordName)
      Reopens the record given as parameter
      Parameters:
      user - the user declaring the document as record
      password - the user's password
      recordName - the record name
      Returns:
      The HTTP Response.