Class ModuleRoles


  • public class ModuleRoles
    extends java.lang.Object
    This module contains all the role options available to this SDK.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  ModuleRoles.Async
      Handler for asynchronous requests.
    • Constructor Summary

      Constructors 
      Constructor Description
      ModuleRoles​(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)
      Create a new role module.
    • Constructor Detail

      • ModuleRoles

        public ModuleRoles​(retrofit2.Retrofit retrofit,
                           java.util.concurrent.Executor callbackExecutor,
                           java.lang.String spaceId,
                           java.lang.String environmentId,
                           boolean environmentIdConfigured)
        Create a new role module.
        Parameters:
        retrofit - the retrofit instance to be used to create the service.
        callbackExecutor - to tell on which thread it should run.
        spaceId - id of the space to be configured.
        environmentId - id of the environment to be configured.
        environmentIdConfigured - internal helper to see if environment was set.
    • Method Detail

      • createService

        protected ServiceRoles createService​(retrofit2.Retrofit retrofit)
        Initialize retrofit with the current service.
        Parameters:
        retrofit - the instance to use the service with.
        Returns:
        a populated instance of the service to be used.
      • async

        public ModuleRoles.Async async()
        Use all functionalities of this module asynchronously.
        Returns:
        an asynchronous handling instance.
      • fetchAll

        public CMAArray<CMARole> fetchAll​(java.lang.String spaceId,
                                          java.util.Map<java.lang.String,​java.lang.String> query)
        Fetch specific roles of this space.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - the space identifier identifying the space.
        query - the search criteria to search for.
        Returns:
        the array of roles.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
      • fetchOne

        public CMARole fetchOne​(java.lang.String spaceId,
                                java.lang.String roleId)
        Fetches one role by its id from Contentful.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - the space this role is hosted by.
        roleId - the id of the role to be found.
        Returns:
        null if no role was found, otherwise the found role.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if role id is null.
      • create

        public CMARole create​(java.lang.String spaceId,
                              CMARole role)
        Create a new role.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - the space id to host the role.
        role - the new role to be created.
        Returns:
        the newly created role.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if role is null.
      • update

        public CMARole update​(CMARole role)
        Update the given role instance on Contentful.

        Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.

        Parameters:
        role - the role fetched from Contentful, updated by caller, to be updated.
        Returns:
        the updated role.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if role is null.
        java.lang.IllegalArgumentException - if role id is null.
        java.lang.IllegalArgumentException - if role does not have a version attached.
      • delete

        public int delete​(CMARole role)
        Delete the given role instance.

        Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.

        Parameters:
        role - the role fetched from Contentful, updated by caller, to be deleted.
        Returns:
        the code of the response (204 means success).
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if role id is null.