Class ModuleLocales


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

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

      Constructors 
      Constructor Description
      ModuleLocales​(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)
      Create a new locale module.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ModuleLocales.Async async()
      Use all functionalities of this module asynchronously.
      CMALocale create​(CMALocale locale)
      Create a new locale in the configured space and environment.
      CMALocale create​(java.lang.String spaceId, java.lang.String environmentId, CMALocale locale)
      Create a new locale in the given space and environment.
      protected ServiceLocales createService​(retrofit2.Retrofit retrofit)
      Initialize retrofit with the current service.
      int delete​(CMALocale locale)
      Delete the given locale instance.
      CMAArray<CMALocale> fetchAll()
      Fetch all locales of the configured space.
      CMAArray<CMALocale> fetchAll​(java.lang.String spaceId, java.lang.String environmentId)
      Fetch all locales of the given space and environment.
      CMALocale fetchOne​(java.lang.String localeId)
      Fetches one locale by its id using the configured space and environment.
      CMALocale fetchOne​(java.lang.String spaceId, java.lang.String environmentId, java.lang.String localeId)
      Fetches one locale by its id from the given space and environment.
      CMALocale update​(CMALocale locale)
      Update the given locale instance on Contentful.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ModuleLocales

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

      • createService

        protected ServiceLocales 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 ModuleLocales.Async async()
        Use all functionalities of this module asynchronously.
        Returns:
        an asynchronous handling instance.
      • fetchAll

        public CMAArray<CMALocale> fetchAll​(java.lang.String spaceId,
                                            java.lang.String environmentId)
        Fetch all locales of the given space and environment.

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

        Parameters:
        spaceId - the space identifier, identifying the space.
        environmentId - the environment identifier, identifying the environment.
        Returns:
        the array of locales.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if environmentId is null.
      • fetchOne

        public CMALocale fetchOne​(java.lang.String localeId)
        Fetches one locale by its id using the configured space and environment.
        Parameters:
        localeId - the id of the locale to be found.
        Returns:
        null if no locale was found, otherwise the found locale.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if locale id is null.
        See Also:
        CMAClient.Builder.setSpaceId(String), CMAClient.Builder.setEnvironmentId(String)
      • fetchOne

        public CMALocale fetchOne​(java.lang.String spaceId,
                                  java.lang.String environmentId,
                                  java.lang.String localeId)
        Fetches one locale by its id from the given space and environment.

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

        Parameters:
        spaceId - the space this environment is hosted in.
        environmentId - the environment this locale is hosted in.
        localeId - the id of the locale to be found.
        Returns:
        null if no locale was found, otherwise the found locale.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if environment id is null.
        java.lang.IllegalArgumentException - if locale id is null.
      • create

        public CMALocale create​(java.lang.String spaceId,
                                java.lang.String environmentId,
                                CMALocale locale)
        Create a new locale in the given space and environment.

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

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

        public CMALocale update​(CMALocale locale)
        Update the given locale instance on Contentful.

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

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

        public int delete​(CMALocale locale)
        Delete the given locale instance.

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

        Parameters:
        locale - the locale 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 locale id is null.