Class SchemaLoader<P extends SchemaLoader.Parameters>

java.lang.Object
tigase.db.util.SchemaLoader<P>
Direct Known Subclasses:
DBSchemaLoader

public abstract class SchemaLoader<P extends SchemaLoader.Parameters> extends Object
Author:
andrzej
  • Field Details

    • log

      protected static final Logger log
  • Constructor Details

    • SchemaLoader

      public SchemaLoader()
  • Method Details

    • getMainCommandlineParameters

      public static List<tigase.util.ui.console.CommandlineParameter> getMainCommandlineParameters(boolean forceNotRequired)
    • getAllSupportedTypesStream

      public static Stream<SchemaLoader.TypeInfo> getAllSupportedTypesStream()
    • getAllSupportedTypes

      public static List<SchemaLoader.TypeInfo> getAllSupportedTypes()
    • main

      public static void main(String[] args)
      Main method allowing pass arguments to the class and setting all logging to be printed to console.
      Parameters:
      args - key-value (in the form of "-<variable> value") parameters.
    • newInstance

      public static SchemaLoader newInstance(String type)
    • newInstanceForURI

      public static SchemaLoader newInstanceForURI(String uri)
    • createParameters

      public abstract P createParameters()
    • execute

      public abstract void execute(SchemaLoader.Parameters params)
    • init

      public abstract void init(P props, Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache)
    • init

      public void init(P props)
    • getSupportedTypes

      public abstract List<SchemaLoader.TypeInfo> getSupportedTypes()
    • isSupported

      public boolean isSupported(String dbType)
    • getDBUri

      public abstract String getDBUri()
    • getSetupOptions

      public abstract List<tigase.util.ui.console.CommandlineParameter> getSetupOptions()
    • getCommandlineParameters

      public abstract List<tigase.util.ui.console.CommandlineParameter> getCommandlineParameters()
    • validateDBConnection

      public abstract SchemaLoader.Result validateDBConnection()
      Method validates whether the connection can at least be eI stablished. If yes then appropriate flag is set.
    • validateDBExists

      public abstract SchemaLoader.Result validateDBExists()
      Method, if the connection is validated by validateDBConnection, checks whether desired database exists. If not it creates such database using *-installer-create-db.sql schema file substituting it's variables with ones provided.
    • postInstallation

      public abstract SchemaLoader.Result postInstallation()
    • getConfigString

      protected String getConfigString() throws IOException
      Throws:
      IOException
    • printInfo

      public SchemaLoader.Result printInfo()
    • addXmppAdminAccount

      public abstract SchemaLoader.Result addXmppAdminAccount(SchemaManager.SchemaInfo schemaInfo)
      Method attempts to add XMPP admin user account to the database using AuthRepository.
    • setComponentVersion

      public abstract SchemaLoader.Result setComponentVersion(String component, String version)
      Methods attempt to write to database loaded schema version for particular component
      Parameters:
      component - name of the component for which version should be set
      version - value which should be associated with the component
      Returns:
      a SchemaLoader.Result object indicating whether the call was successful
    • getComponentVersionFromDb

      public abstract Optional<tigase.util.Version> getComponentVersionFromDb(String component)
    • loadSchemaFile

      public abstract SchemaLoader.Result loadSchemaFile(String fileName)
      Method checks whether the connection to the database is possible and that database of specified name exists. If yes then a schema file from properties is loaded.
      Parameters:
      fileName - set of String with path to file
    • shutdown

      public abstract SchemaLoader.Result shutdown()
    • loadCommonSchema

      public SchemaLoader.Result loadCommonSchema()
    • loadSchema

      public abstract SchemaLoader.Result loadSchema(SchemaManager.SchemaInfo schemaInfo, String version)
    • getMinimalRequiredComponentVersionForUpgrade

      public abstract Optional<tigase.util.Version> getMinimalRequiredComponentVersionForUpgrade(SchemaManager.SchemaInfo schema)
    • destroyDataSource

      public abstract SchemaLoader.Result destroyDataSource()
    • addUsersToRepository

      protected <T extends DataSource> SchemaLoader.Result addUsersToRepository(SchemaManager.SchemaInfo schemaInfo, T dataSource, Class<T> dataSourceClass, List<tigase.xmpp.jid.BareJID> jids, String password, Logger log)
    • getDataSourceAwareClassesForSchemaInfo

      protected <DS extends DataSource> Stream<Class<DataSourceAware<DS>>> getDataSourceAwareClassesForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DS> dataSourceIfc)
    • getInitializedDataSourceAwareForSchemaInfo

      protected <DSIFC extends DataSource, DS extends DSIFC> Stream<DataSourceAware> getInitializedDataSourceAwareForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DSIFC> dataSourceIfc, DS dataSource, Logger log)
    • initializeAuthRepository

      protected AuthRepository initializeAuthRepository(AuthRepository authRepository)
    • initializeDataSourceAwareFunction

      protected <T extends DataSource> Function<DataSourceAware<T>,DataSourceAware<T>> initializeDataSourceAwareFunction(T dataSource, Logger log)
    • addUsersToRepositoryFunction

      protected Function<AuthRepository,SchemaLoader.Result> addUsersToRepositoryFunction(List<tigase.xmpp.jid.BareJID> jids, String pwd, Logger log)
    • instantiateClass

      protected <T> T instantiateClass(Class<T> clazz)
    • getType

      protected String getType()