Class StructuredTextReader

java.lang.Object
org.eso.ias.cdb.structuredtext.StructuredTextReader
All Implemented Interfaces:
CdbReader

public class StructuredTextReader extends Object implements CdbReader
  • Field Details

    • initialized

      protected final AtomicBoolean initialized
      Signal if the reader has been initialized
    • cdbFilesType

      public final TextFileType cdbFilesType
      The type of the files of the CDB
    • closed

      protected final AtomicBoolean closed
      Signal if the reader has been closed
  • Constructor Details

    • StructuredTextReader

      public StructuredTextReader(CdbFiles cdbFiles)
      Constructor
      Parameters:
      cdbFiles - The files of the CDB
    • StructuredTextReader

      public StructuredTextReader(File parentFolder) throws IasCdbException
      Constructor that guesses the type of the folder from the content of the CDB folder from the content of the parentFolder.
      Parameters:
      parentFolder - the parent folder of the CDB
      Throws:
      IasCdbException - if it was not possible to get the type of CDB from the passed parent folder
  • Method Details

    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Get the ObjectMapper depending on the type of files in the CDB
      Returns:
      The ObjectMapper to parse the files
    • canReadFromFile

      protected boolean canReadFromFile(File inF)
      Check if the passed file is readable
      Parameters:
      inF - The file to check
      Returns:
      true if the file exists and is readable
    • init

      public void init() throws IasCdbException
      Initialize the CDB
      Specified by:
      init in interface CdbReader
      Throws:
      IasCdbException
    • shutdown

      public void shutdown() throws IasCdbException
      Close the CDB and release the associated resources
      Specified by:
      shutdown in interface CdbReader
      Throws:
      IasCdbException
    • getIas

      public Optional<IasDao> getIas() throws IasCdbException
      Get the Ias configuration from a CDB.
      Specified by:
      getIas in interface CdbReader
      Returns:
      The ias configuration read from the CDB
      Throws:
      IasCdbException - In case of error getting the IAS
    • getSupervisor

      public Optional<SupervisorDao> getSupervisor(String id) throws IasCdbException
      Read the supervisor configuration from the CDB. This methods reads the JsonSupervisorDao and convert it to SupervisorDao. The tricky part is the conversion of the JsonDasuToDeployDao of the JsonSupervisorDao to a DasuToDeployDao that needs to replace the ID of the DASU to deploy with a DasuDao. The DasuDao can be easily retrieved by calling getDasu(String). In the same way, the instance of TemplateDao can be easily retrieved by calling getTemplate(String)
      Specified by:
      getSupervisor in interface CdbReader
      Parameters:
      id - The not null nor empty supervisor identifier
      Returns:
      The Supervisor read from the CDB
      Throws:
      IasCdbException - if the supervisor file does not exist or is unreadable
    • getDasu

      public Optional<DasuDao> getDasu(String id) throws IasCdbException
      Read the DASU configuration from the file.
      Specified by:
      getDasu in interface CdbReader
      Parameters:
      id - The not null nor empty DASU identifier
      Returns:
      The DASU read from the file
      Throws:
      IasCdbException - In case of error getting the DASU
    • getAsce

      public Optional<AsceDao> getAsce(String id) throws IasCdbException
      Read the ASCE configuration from the file.
      Specified by:
      getAsce in interface CdbReader
      Parameters:
      id - The not null nor empty ASCE identifier
      Returns:
      The ASCE read from the file
      Throws:
      IasCdbException - In case of error getting the ASCE
    • getIasios

      public Optional<Set<IasioDao>> getIasios() throws IasCdbException
      Get the IASIOs from the file.
      Specified by:
      getIasios in interface CdbReader
      Returns:
      The IASIOs read from the configuration file
      Throws:
      IasCdbException - In case of error getting the IASIOs
      See Also:
    • getIasio

      public Optional<IasioDao> getIasio(String id) throws IasCdbException
      Get the IASIO with the given ID The implementation is not optimized for performances and memory usage because it gets all the IASIOs delegating to getIasios() then look for the one with the given ID if present.
      It should be ok for a testing CDB but can be an issue importing/exporting the production CDB.
      Specified by:
      getIasio in interface CdbReader
      Parameters:
      id - The ID of the IASIO to read the configuration
      Returns:
      The IASIO red from the file
      Throws:
      IasCdbException - In case of error getting the IASIO
    • getTransferFunction

      public Optional<TransferFunctionDao> getTransferFunction(String tf_id) throws IasCdbException
      Description copied from interface: CdbReader
      Read the transfer function configuration from the CDB.
      Specified by:
      getTransferFunction in interface CdbReader
      Parameters:
      tf_id - The not null nor empty transfer function identifier
      Returns:
      The transfer function read from the CDB
      Throws:
      IasCdbException - in case of error reading from the CDB
    • getTransferFunctions

      public Optional<Set<TransferFunctionDao>> getTransferFunctions() throws IasCdbException
      Get all the TFs.
      Specified by:
      getTransferFunctions in interface CdbReader
      Returns:
      The TFs read from the configuration file
      Throws:
      IasCdbException - In case of error getting the IASIOs
    • getTemplates

      public Optional<Set<TemplateDao>> getTemplates() throws IasCdbException
      Get the all the templates from the file.
      Specified by:
      getTemplates in interface CdbReader
      Returns:
      The templates read from the configuration file
      Throws:
      IasCdbException - In case of error getting the IASIOs
    • getTemplate

      public Optional<TemplateDao> getTemplate(String template_id) throws IasCdbException
      Read the template configuration from the CDB.
      Specified by:
      getTemplate in interface CdbReader
      Parameters:
      template_id - The not null nor empty identifier of the template
      Returns:
      The template read from the CDB
      Throws:
      IasCdbException - in case of error reading from the CDB
    • getAscesForDasu

      public Set<AsceDao> getAscesForDasu(String id) throws IasCdbException
      Return the ASCEs belonging to the given DASU.
      Specified by:
      getAscesForDasu in interface CdbReader
      Parameters:
      id - The not null nor empty identifier of the supervisor
      Returns:
      A set of DASUs running in the supervisor with the passed id
      Throws:
      IasCdbException - in case of error reading CDB or if the DASU with the give identifier does not exist
    • getDasusToDeployInSupervisor

      public Set<DasuToDeployDao> getDasusToDeployInSupervisor(String id) throws IasCdbException
      Return the DASUs belonging to the given Supervisor.
      Specified by:
      getDasusToDeployInSupervisor in interface CdbReader
      Parameters:
      id - The not null nor empty identifier of the supervisor
      Returns:
      A set of DASUs running in the supervisor with the passed id
      Throws:
      IasCdbException - in case of error reading CDB or if the supervisor with the give identifier does not exist
    • getIasiosForAsce

      public Collection<IasioDao> getIasiosForAsce(String id) throws IasCdbException
      Return the IASIOs in input to the given ASCE.
      Specified by:
      getIasiosForAsce in interface CdbReader
      Parameters:
      id - The not null nor empty identifier of the ASCE
      Returns:
      A set of IASIOs running in the ASCE with the passed id
      Throws:
      IasCdbException - in case of error reading CDB or if the ASCE with the give identifier does not exist
    • getSupervisorIds

      public Optional<Set<String>> getSupervisorIds() throws IasCdbException
      Get the IDs of the Supervisors. This method is useful to deploy the supervisors
      Specified by:
      getSupervisorIds in interface CdbReader
      Returns:
      The the IDs of the supervisors read from the CDB
      Throws:
      IasCdbException - In case of error getting the IDs of the supervisors
    • getDasuIds

      public Optional<Set<String>> getDasuIds() throws IasCdbException
      Get the IDs of the DASUs.
      Specified by:
      getDasuIds in interface CdbReader
      Returns:
      The IDs of the DASUs read from the CDB
      Throws:
      IasCdbException - In case of error getting the IDs of the DASUs
    • getAsceIds

      public Optional<Set<String>> getAsceIds() throws IasCdbException
      Get the IDs of the ASCEs.
      Specified by:
      getAsceIds in interface CdbReader
      Returns:
      The IDs of the ASCEs read from the CDB
      Throws:
      IasCdbException - In case of error getting the IDs of the ASCEs
    • getPluginIds

      public Optional<Set<String>> getPluginIds() throws IasCdbException
      Specified by:
      getPluginIds in interface CdbReader
      Returns:
      The IDs of all the plugins in the CDB
      Throws:
      IasCdbException - In case of error getting the IDs of the plugins
    • getClientIds

      public Optional<Set<String>> getClientIds() throws IasCdbException
      Specified by:
      getClientIds in interface CdbReader
      Returns:
      The IDs of all the plugins in the CDB
      Throws:
      IasCdbException - In case of error getting the IDs of the clients
    • getPlugin

      public Optional<PluginConfigDao> getPlugin(String id) throws IasCdbException
      Get the configuration of the plugin with the passed identifier.

      The configuration of the plugin can be read from a file or from the CDB. In both cases, the configuration is returned as #PluginConfigDao. This m,ethod returns the configuration from the CDB; reading from file is not implemented here.

      Specified by:
      getPlugin in interface CdbReader
      Parameters:
      id - The not null nor empty ID of the IAS plugin
      Returns:
      The configuration of the plugin
      Throws:
      IasCdbException - In case of error getting the configuration of the plugin
    • getClientConfig

      public Optional<ClientConfigDao> getClientConfig(String id) throws IasCdbException
      Get the configuration of the client with the passed identifier. The configuration is passed as a string whose format depends on the client implementation.
      Specified by:
      getClientConfig in interface CdbReader
      Parameters:
      id - The not null nor empty ID of the IAS client
      Returns:
      The configuration of the client
      Throws:
      IasCdbException - In case of error getting the configuration of the client
    • getTemplateInstancesIasiosForAsce

      public Collection<TemplateInstanceIasioDao> getTemplateInstancesIasiosForAsce(String id) throws IasCdbException
      Return the templated IASIOs in input to the given ASCE. These inputs are the one generated by a different template than that of the ASCE (@see #!@$)
      Specified by:
      getTemplateInstancesIasiosForAsce in interface CdbReader
      Parameters:
      id - The not null nor empty identifier of the ASCE
      Returns:
      A set of template instance of IASIOs in input to the ASCE
      Throws:
      IasCdbException - in case of error reading CDB or if the ASCE with the give identifier does not exist