Class G2ConfigMgrJNI

    • Constructor Summary

      Constructors 
      Constructor Description
      G2ConfigMgrJNI()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addConfig​(String configStr, String configComments, Result<Long> configID)
      Adds the configuration described by the specified JSON to the repository with the specified comments and returns the ID of the config in the specified Result object.
      void clearLastException()
      Clears the information about the last error the system received.
      int destroy()
      Uninitializes the G2 config manager API.
      int getConfig​(long configID, StringBuffer response)
      Gets the configuration with the specified config ID and writes the JSON text of configuration to the specified StringBuffer.
      int getConfigList​(StringBuffer response)
      Gets the list of saved configuration IDs with their comments and timestamps and writes the JSON text describing the configurations to the specified StringBuffer.
      int getDefaultConfigID​(Result<Long> configID)
      Gets the configuration ID of the default configuration for the repository and sets the value in the specified Result object.
      String getLastException()
      Returns a string about the last error the system received.
      int getLastExceptionCode()
      Returns the exception code of the last error the system received.
      int init​(String moduleName, String iniParams, boolean verboseLogging)
      Initializes the G2 config manager API with the specified module name, init parameters and flag indicating verbose logging.
      int replaceDefaultConfigID​(long oldConfigID, long newConfigID)
      Replaces the current configuration ID of the repository with the specified new configuration ID providing the current configuration ID of the repository is equal to the specified old configuration ID.
      int setDefaultConfigID​(long configID)
      Sets the default configuration for the repository to the specified configuration ID.
    • Constructor Detail

      • G2ConfigMgrJNI

        public G2ConfigMgrJNI()
    • Method Detail

      • init

        public int init​(String moduleName,
                        String iniParams,
                        boolean verboseLogging)
        Initializes the G2 config manager API with the specified module name, init parameters and flag indicating verbose logging.
        Specified by:
        init in interface G2ConfigMgr
        Parameters:
        moduleName - A short name given to this instance of the config manager API.
        iniParams - A JSON string containing configuration parameters.
        verboseLogging - Enable diagnostic logging which will print a massive amount of information to stdout.
        Returns:
        Zero (0) on success and non-zero on failure.
      • destroy

        public int destroy()
        Uninitializes the G2 config manager API.
        Specified by:
        destroy in interface G2ConfigMgr
        Returns:
        Zero (0) on success and non-zero on failure.
      • addConfig

        public int addConfig​(String configStr,
                             String configComments,
                             Result<Long> configID)
        Adds the configuration described by the specified JSON to the repository with the specified comments and returns the ID of the config in the specified Result object.
        Specified by:
        addConfig in interface G2ConfigMgr
        Parameters:
        configStr - The JSON text describing the configuration.
        configComments - The comments for the configuration.
        configID - The configuration ID for the registered config.
        Returns:
        Zero (0) on success and non-zero on failure.
      • getConfig

        public int getConfig​(long configID,
                             StringBuffer response)
        Gets the configuration with the specified config ID and writes the JSON text of configuration to the specified StringBuffer.
        Specified by:
        getConfig in interface G2ConfigMgr
        Parameters:
        configID - The configuration ID of the configuration to retrieve.
        response - The StringBuffer to write the JSON text of the configuration to.
        Returns:
        Zero (0) on success and non-zero on failure.
      • getConfigList

        public int getConfigList​(StringBuffer response)
        Gets the list of saved configuration IDs with their comments and timestamps and writes the JSON text describing the configurations to the specified StringBuffer. The format of the response is:
         {
           "CONFIGS": [
             {
                  "CONFIG_ID": 12345678912345,
                  "SYS_CREATE_DT": "2021-03-25 18:35:00.743",
                  "CONFIG_COMMENTS": "Added EMPLOYEES data source."
             },
             {
                  "CONFIG_ID": 23456789123456,
                  "SYS_CREATE_DT": "2021-02-08 23:27:09.876",
                  "CONFIG_COMMENTS": "Added CUSTOMERS data source."
             },
             {
                  "CONFIG_ID": 34567891234567,
                  "SYS_CREATE_DT": "2021-02-08 23:27:05.212",
                  "CONFIG_COMMENTS": "Initial Config"
             },
             . . .
           ]
         }
         
        Specified by:
        getConfigList in interface G2ConfigMgr
        Parameters:
        response - The StringBuffer to write the JSON text of the configuration list to.
        Returns:
        Zero (0) on success and non-zero on failure.
      • setDefaultConfigID

        public int setDefaultConfigID​(long configID)
        Sets the default configuration for the repository to the specified configuration ID.
        Specified by:
        setDefaultConfigID in interface G2ConfigMgr
        Parameters:
        configID - The configuration ID to set as the default configuration.
        Returns:
        Zero (0) on success and non-zero on failure.
      • getDefaultConfigID

        public int getDefaultConfigID​(Result<Long> configID)
        Gets the configuration ID of the default configuration for the repository and sets the value in the specified Result object.
        Specified by:
        getDefaultConfigID in interface G2ConfigMgr
        Parameters:
        configID - The Result object on which to set the default configuration ID.
        Returns:
        Zero (0) on success and non-zero on failure.
      • replaceDefaultConfigID

        public int replaceDefaultConfigID​(long oldConfigID,
                                          long newConfigID)
        Replaces the current configuration ID of the repository with the specified new configuration ID providing the current configuration ID of the repository is equal to the specified old configuration ID. If the current configuration ID is not the same as the specified old configuration ID then this method fails to replace the default configuration ID with the new value.
        Specified by:
        replaceDefaultConfigID in interface G2ConfigMgr
        Parameters:
        oldConfigID - The configuration ID that is believed to be the current default configuration ID.
        newConfigID - The new configuration ID for the repository.
        Returns:
        Zero (0) on success and non-zero on failure
      • getLastException

        public String getLastException()
        Returns a string about the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)
        Specified by:
        getLastException in interface G2Fallible
        Returns:
        An error message
      • getLastExceptionCode

        public int getLastExceptionCode()
        Returns the exception code of the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)
        Specified by:
        getLastExceptionCode in interface G2Fallible
        Returns:
        An error code
      • clearLastException

        public void clearLastException()
        Clears the information about the last error the system received.
        Specified by:
        clearLastException in interface G2Fallible