Class BaseAPI

    • Constructor Detail

      • BaseAPI

        public BaseAPI()
    • Method Detail

      • getPropertyValues

        protected List<String> getPropertyValues​(org.json.JSONObject result,
                                                 String propertyName)
        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

        protected String getPropertyValue​(org.json.JSONObject result,
                                          String nodeRef,
                                          String propertyName)
        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

        public String getItemNodeRef​(String username,
                                     String password,
                                     String path)
        Retrieves the nodeRef of an item (category, folder or record) with the given path
        Parameters:
        username - the username
        password - the password
        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 ""
        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 username
        password - its password
        path - 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 username
        password - the password
        parameters - 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 privileges
        adminPassword - password for adminUser
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        requestParams - zero or more endpoint specific request parameters
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        expectedStatusCode - The expected return status code.
        requestParams - zero or more endpoint specific request parameters
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        requestParams - zero or more endpoint specific request parameters
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        expectedStatusCode - The expected return status code.
        requestParams - zero or more endpoint specific request parameters
        urlTemplate - request URL template
        urlTemplateParams - 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 privileges
        adminPassword - password for adminUser
        expectedStatusCode - The expected return status code.
        requestParams - zero or more endpoint specific request parameters
        urlTemplate - request URL template
        urlTemplateParams - zero or more parameters used with urlTemplate
      • getPropertyValue

        public <K extends Enum<?>> String getPropertyValue​(Map<K,​String> properties,
                                                           Enum<?> property)
        Util to return the property value from a map
        Parameters:
        properties - the map containing properties
        property - 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.JSONException
        Retrieves the property value and decides if that gets to be added to the request
        Parameters:
        requestParams - the request parameters
        propertyRequestValue - the property name in the request, eg. "prop_cm_name"
        itemProperties - map of item's properties values
        property - 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

        protected void deleteItem​(String username,
                                  String password,
                                  String itemPath)
        Deletes the category, folder or record given as parameter
        Parameters:
        username - the username with whom the delete is performed
        password - the user's password
        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.
      • getNodeRefSpacesStore

        public static String getNodeRefSpacesStore()
        Retrieve the node ref spaces store value
        Returns:
        node ref spaces store
      • getFilePlanPath

        public static String getFilePlanPath()
        Retrieve the File Plan path
        Returns:
        the File Plan path