Class StaticSchemaServiceImpl

java.lang.Object
com.illumon.iris.db.schema.StaticSchemaServiceImpl
All Implemented Interfaces:
SchemaService, NamedImplementation, AutoCloseable
Direct Known Subclasses:
SchemaServiceLegacyTransientImpl

public abstract class StaticSchemaServiceImpl
extends Object
implements SchemaService
Implement the SchemaService interface based on an immutable map of schemas. Derived classes are expected to handle initialization of the map.
  • Field Details

    • log

      protected final com.fishlib.io.logger.Logger log
    • configuration

      protected final com.fishlib.configuration.Configuration configuration
  • Constructor Details

    • StaticSchemaServiceImpl

      public StaticSchemaServiceImpl​(@NotNull com.fishlib.io.logger.Logger log, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.base.Function.Nullary<Map<String,​Map<String,​SchemaXml>>> initializer)
  • Method Details

    • authenticate

      public boolean authenticate​(@NotNull String user, @NotNull String password, @NotNull String operateAs)
      Description copied from interface: SchemaService
      Authenticate using the given user and password, operating as the operateAs user. Implementations are not required to allow re-authentication.
      Specified by:
      authenticate in interface SchemaService
      Parameters:
      user - the user to authenticate
      password - the password for the user
      operateAs - attempt to operate as this effective user
      Returns:
      true only if the authentication succeeded
    • authenticate

      public boolean authenticate()
      Description copied from interface: SchemaService
      Authenticate using default authentication. This will be using the default private key or however WAuthenticationClientManager.DEFAULT has been authenticated.
      Specified by:
      authenticate in interface SchemaService
      Returns:
      true only if the authentication succeeded
    • getLatestSchema

      @Nullable public Schema getLatestSchema​(@NotNull String namespace, @NotNull String tableName)
      Description copied from interface: SchemaService
      Get the latest version of the Schema defined by namespace and table name
      Specified by:
      getLatestSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the table
      tableName - the table name
      Returns:
      the latest version of namespace.tablename or null if none was found
    • getLatestSchemaXml

      @Nullable public SchemaXml getLatestSchemaXml​(@NotNull String namespace, @NotNull String tableName)
      Description copied from interface: SchemaService
      Get the latest version of the Schema defined by namespace and table name, as an implementation supporting SchemaXml.
      Specified by:
      getLatestSchemaXml in interface SchemaService
      Parameters:
      namespace - the namespace of the table
      tableName - the table name
      Returns:
      the latest version of namespace.tablename or null if none was found
    • getSchema

      @Nullable public Schema getSchema​(@NotNull String namespace, @NotNull String tableName, @NotNull SchemaVersion version)
      Description copied from interface: SchemaService
      Get the specified version of the Schema defined by namespace and table name
      Specified by:
      getSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the table
      tableName - the table name
      version - the version of this schema to retrieve
      Returns:
      the requested version of the schema for namespace.tableName or null if none was found
    • getAllSchemas

      @NotNull public Collection<Schema> getAllSchemas()
      Description copied from interface: SchemaService
      Get a collection of all known schemas in the system. The latest version of each will be returned. // TODO: subject to ACL visibility?
      Specified by:
      getAllSchemas in interface SchemaService
      Returns:
      a collection of all known schemas
    • getSchemas

      @NotNull public Collection<Schema> getSchemas​(@NotNull NamespaceSet namespaceSet)
      Description copied from interface: SchemaService
      Get a collection of all known schemas in the system, with the given namespace set. The latest version of each will be returned.
      Specified by:
      getSchemas in interface SchemaService
      Returns:
      a collection of all known schemas in the given namespace set
    • getSchemas

      @NotNull public Collection<Schema> getSchemas​(@NotNull String namespace)
      Description copied from interface: SchemaService
      Get a collection of all known schemas in the given namespace. The latest version of each will be returned.
      Specified by:
      getSchemas in interface SchemaService
      Returns:
      a collection of all known schemas in the given namespace
    • getLatestTableDefinitionSchema

      @Nullable public TableDefinitionSchema getLatestTableDefinitionSchema​(@NotNull String namespace, @NotNull String tableName)
      Description copied from interface: SchemaService
      Get the latest version of the TableDefinitionSchema defined by namespace and table name
      Specified by:
      getLatestTableDefinitionSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the table
      tableName - the table name
      Returns:
      the latest version of namespace.tableName or null if none was found
    • getNamespaceSet

      @NotNull public NamespaceSet getNamespaceSet​(@NotNull String namespace) throws IllegalArgumentException
      Description copied from interface: SchemaService
      Get the NamespaceSet for a particular namespace.
      Specified by:
      getNamespaceSet in interface SchemaService
      Parameters:
      namespace - The namespace name
      Returns:
      the namespace set of the namespace
      Throws:
      IllegalArgumentException - if the namespace does not exist
    • containsNamespace

      public boolean containsNamespace​(@NotNull String namespace, boolean includeDeleted)
      Description copied from interface: SchemaService
      Find out whether the given namespace is known to the schema service.
      Specified by:
      containsNamespace in interface SchemaService
      Parameters:
      namespace - the namespace in question
      includeDeleted - true if deleted namespaces should be considered
      Returns:
      true if the namespace is found
    • containsSchema

      public boolean containsSchema​(@NotNull String namespace, @NotNull String tableName)
      Description copied from interface: SchemaService
      Find out if the given schema exists. Does not check for deleted schemas.
      Specified by:
      containsSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the table
      tableName - the table name
      Returns:
      true if a schema is found for namespace.tableName
    • listNamespaces

      @NotNull public Collection<String> listNamespaces​(boolean includeDeleted)
      Description copied from interface: SchemaService
      Get a collection of the namespaces available.
      Specified by:
      listNamespaces in interface SchemaService
      Parameters:
      includeDeleted - true if deleted namespaces should be included
      Returns:
      a collection of namespace names
    • listNamespaces

      @NotNull public Collection<String> listNamespaces​(@NotNull NamespaceSet namespaceSet, boolean includeDeleted)
      Description copied from interface: SchemaService
      Get a collection of the namespaces available in the given namespace set.
      Specified by:
      listNamespaces in interface SchemaService
      Parameters:
      namespaceSet - list namespaces in this set (User, System)
      includeDeleted - true if deleted namespaces should be included
      Returns:
      a collection of namespace names
    • listTableNames

      @NotNull public Collection<String> listTableNames​(@NotNull String namespace, boolean includeDeleted)
      Description copied from interface: SchemaService
      Get a collection of all table names in the specified namespace.
      Specified by:
      listTableNames in interface SchemaService
      Parameters:
      namespace - the name of the namespace
      includeDeleted - tf deleted schemas should be included
      Returns:
      a collection of all available schemas in namespace, empty list if namespace does not exit
    • listAllTables

      @NotNull public Map<NamespaceSet,​Map<String,​Collection<String>>> listAllTables()
      Description copied from interface: SchemaService
      Get a map of all known tables in all known namespaces for all namespace sets.
      Specified by:
      listAllTables in interface SchemaService
      Returns:
      all the table names, mapped by namespace set and namespace
    • createNamespace

      public boolean createNamespace​(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName) throws SchemaException
      Description copied from interface: SchemaService
      Add a namespace with the given name to the schema service, in the requested namespace set. Returns true if the namespace was added, false if it already exists. Throws a SchemaException if the namespace could not be added.
      Specified by:
      createNamespace in interface SchemaService
      Parameters:
      namespaceSet - add namespaceName to this namespace set
      namespaceName - name of the new namespace
      Returns:
      true if the namespace was added, false if it already exists.
      Throws:
      SchemaException - if the namespace could not be added to the given namespace set
    • createNamespace

      public boolean createNamespace​(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName, @NotNull String code, @NotNull String comment) throws SchemaException
      Description copied from interface: SchemaService
      Add a namespace with the given name to the schema service, in the requested namespace set. Returns true if the namespace was added, false if it already exists. Throws a SchemaException if the namespace could not be added.
      Specified by:
      createNamespace in interface SchemaService
      Parameters:
      namespaceSet - add namespaceName to this namespace set
      namespaceName - name of the new namespace
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      Returns:
      true if the namespace was added, false if it already exists.
      Throws:
      SchemaException - if the namespace could not be added to the given namespace set
    • removeNamespace

      public void removeNamespace​(@NotNull String namespaceName, @NotNull String code, @NotNull String comment) throws SchemaException
      Description copied from interface: SchemaService
      Remove the given namespace. The namespace must be empty (contain no schemas).
      Specified by:
      removeNamespace in interface SchemaService
      Parameters:
      namespaceName - the namespace to remove
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      Throws:
      SchemaException - if the namespace cannot be removed
    • removeNamespace

      public void removeNamespace​(@NotNull String namespaceName)
      Description copied from interface: SchemaService
      Remove the given namespace. The namespace must be empty (contain no schemas).
      Specified by:
      removeNamespace in interface SchemaService
      Parameters:
      namespaceName - the namespace to remove
    • addSchema

      @NotNull public Schema addSchema​(@NotNull Schema newSchema) throws SchemaException
      Description copied from interface: SchemaService
      Add the specified schema to the service.
      Specified by:
      addSchema in interface SchemaService
      Parameters:
      newSchema - the schema to add
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      SchemaException - if the schema could not be added
    • addSchema

      @NotNull public Schema addSchema​(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws SchemaException
      Description copied from interface: SchemaService
      Add the specified schema to the service.
      Specified by:
      addSchema in interface SchemaService
      Parameters:
      newSchema - the schema to add
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update * @return the schema actually stored in the SchemaService
      Throws:
      SchemaException - if the schema could not be added
    • addSchema

      @NotNull public Schema addSchema​(@NotNull TableDefinitionSchema newSchema) throws SchemaException
      Description copied from interface: SchemaService
      Add the specified schema to the service.
      Specified by:
      addSchema in interface SchemaService
      Parameters:
      newSchema - the schema to add
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      SchemaException - if the schema could not be added or already exists
    • addSchema

      @NotNull public Schema addSchema​(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws SchemaException
      Description copied from interface: SchemaService
      Add the specified schema to the service.
      Specified by:
      addSchema in interface SchemaService
      Parameters:
      newSchema - the schema to add
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      SchemaException - if the schema could not be added or already exists
    • updateSchema

      @NotNull public Schema updateSchema​(@NotNull Schema newSchema) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Update the schema with the same namespace and table name with the specified new schema.
      Specified by:
      updateSchema in interface SchemaService
      Parameters:
      newSchema - the schema to update with
      Throws:
      IllegalArgumentException - if the namespace or table does not exist
      SchemaException - if the schema could not be updated
    • updateSchema

      @NotNull public Schema updateSchema​(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Update the schema with the same namespace and table name with the specified new schema.
      Specified by:
      updateSchema in interface SchemaService
      Parameters:
      newSchema - the schema to update with
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      IllegalArgumentException - if the namespace or table does not exist
      SchemaException - if the schema could not be updated
    • updateSchema

      @NotNull public Schema updateSchema​(@NotNull TableDefinitionSchema newSchema) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Update the schema with the same namespace and table name with the specified new schema.
      Specified by:
      updateSchema in interface SchemaService
      Parameters:
      newSchema - the schema to update with.
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      IllegalArgumentException - if the namespace or table does not exist
      SchemaException - if the schema could not be updated
    • updateSchema

      @NotNull public Schema updateSchema​(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Update the schema with the same namespace and table name with the specified new schema.
      Specified by:
      updateSchema in interface SchemaService
      Parameters:
      newSchema - the schema to update with.
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      Returns:
      the schema actually stored in the SchemaService
      Throws:
      IllegalArgumentException - if the namespace or table does not exist
      SchemaException - if the schema could not be updated
    • deleteSchema

      public void deleteSchema​(@NotNull String namespace, @NotNull String tableName) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Delete the specified schema.
      Specified by:
      deleteSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the schema to delete
      tableName - the name of the schema to delete
      Throws:
      IllegalArgumentException - if the namespace or table could not be found
      SchemaException - if the schema could not be deleted
    • deleteSchema

      public void deleteSchema​(@NotNull String namespace, @NotNull String tableName, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaException
      Description copied from interface: SchemaService
      Delete the specified schema.
      Specified by:
      deleteSchema in interface SchemaService
      Parameters:
      namespace - the namespace of the schema to delete
      tableName - the name of the schema to delete
      code - pass-thru to kv persistence, indicates the code source of this delete
      comment - pass-thru to kv persistence - a comment for this delete
      Throws:
      IllegalArgumentException - if the namespace or table could not be found
      SchemaException - if the schema could not be deleted