Package tigase.db.util
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSchemaLoader.Parametersstatic classSchemaLoader.Resultstatic classSchemaLoader.TypeInfo
-
Constructor Summary
Constructors Constructor Description SchemaLoader()
-
Method Summary
-
-
-
Field Detail
-
log
protected static final Logger log
-
-
Method Detail
-
getMainCommandlineParameters
public static List<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<CommandlineParameter> getSetupOptions()
-
getCommandlineParameters
public abstract List<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 byvalidateDBConnection, checks whether desired database exists. If not it creates such database using*-installer-create-db.sqlschema 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 usingAuthRepository.
-
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 setversion- value which should be associated with the component- Returns:
- a
SchemaLoader.Resultobject indicating whether the call was successful
-
getComponentVersionFromDb
public abstract Optional<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 ofStringwith 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<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<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<BareJID> jids, String pwd, Logger log)
-
instantiateClass
protected <T> T instantiateClass(Class<T> clazz)
-
getType
protected String getType()
-
-