Package com.illumon.iris.db.schema
Class LegacySchemaImporter
java.lang.Object
com.illumon.iris.db.schema.LegacySchemaImporter
One-time (?) bridge to import schema stored on disk into the schema service.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddoMigration(com.fishlib.io.logger.Logger log, SchemaService schemaService, org.apache.commons.cli.CommandLine commandLine) gatherSchemaFiles(com.fishlib.io.logger.Logger log, com.fishlib.configuration.Configuration configuration, List<String> errorMessages, Collection<String> includeNamespaces, Collection<String> excludeNamespaces, boolean allowErrors, String[] schemaFileNames, SchemaService schemaService, String directory, List<NamespaceSet> namespaceSets, boolean migrateOption, boolean verbose, boolean lenientValidation, boolean compileListeners) Search the (legacy) schema resource locations for schema files.static voidstatic voidmaybeCompileLoggersListeners(boolean compileListeners, SchemaXml newSchema) Maybe try to compile the loggers and listeners for the new schema.static org.jdom2.ElementpreValidateSchema(String namespace, String tableName, org.jdom2.Element element) Validate that the schema file is properly formatted and contains the correct internal Table element.
-
Constructor Details
-
LegacySchemaImporter
public LegacySchemaImporter()
-
-
Method Details
-
preValidateSchema
public static org.jdom2.Element preValidateSchema(String namespace, String tableName, org.jdom2.Element element) throws SchemaValidationException Validate that the schema file is properly formatted and contains the correct internal Table element. This does _not_ validate the schema itself; that is handled by the Schema implementations. This verifies that:- The
SchemaConstants.NAMESPACE_NAME_ATTRIBUTEandSchemaConstants.TABLE_NAME_ATTRIBUTEattributes are set - The
SchemaConstants.NAMESPACE_NAME_ATTRIBUTEandSchemaConstants.TABLE_NAME_ATTRIBUTEattributes match the corresponding parameters - If a CopyTable, the
SchemaConstants.SOURCE_NAMESPACE_ATTRIBUTEandSchemaConstants.SOURCE_NAME_ATTRIBUTEattributes are present
- Parameters:
namespace- The namespace defined by the file nametableName- The table name defined by the file nameelement- The root element of the file to validate- Returns:
- The validated root element.
- Throws:
SchemaValidationException- If the root element was incorrect or missing.
- The
-
doMigration
public static void doMigration(@NotNull com.fishlib.io.logger.Logger log, @NotNull SchemaService schemaService, @NotNull org.apache.commons.cli.CommandLine commandLine) -
gatherSchemaFiles
public static Map<String,Map<String, gatherSchemaFilesSchemaXml>> (@NotNull com.fishlib.io.logger.Logger log, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull List<String> errorMessages, @NotNull Collection<String> includeNamespaces, @NotNull Collection<String> excludeNamespaces, boolean allowErrors, @Nullable String[] schemaFileNames, @Nullable SchemaService schemaService, @Nullable String directory, @Nullable List<NamespaceSet> namespaceSets, boolean migrateOption, boolean verbose, boolean lenientValidation, boolean compileListeners) Search the (legacy) schema resource locations for schema files. If locations are specified, only those locations will be used. Otherwise, migration mode must be enabled and the legacy locations are searched for schema files.- Parameters:
log- for logging warningsconfiguration- the configuration to useerrorMessages- any errors found while parsing schema filesincludeNamespaces- if non-empty, only these namespaces will be processed and all will be included (even if empty)excludeNamespaces- namespaces in this list will not be processedallowErrors- if false, any error parsing a schema file will be fatal. If true, valid schemas will be processed even if some schemas have errorsschemaFileNames- an optional array of schema file names to be imported (this takes priority over legacy schema resolution)schemaService- an optional schema service that can be used to see if copy table sources already existdirectory- an optional directory in which to find schema files (this takes priority over schemaFileNames and legacy resource resolution)namespaceSets- if specified, the namespace sets to addmigrateOption- if true, schemas will be gathered from legacy resource locations if no directory or files are specifiedverbose- if true, log full exception textlenientValidation- if true, ClassNotFoundExceptions will be ignored when validatingcompileListeners- if true, try to compile listeners- Returns:
- a map of namespace to table to schema
-
maybeCompileLoggersListeners
public static void maybeCompileLoggersListeners(boolean compileListeners, SchemaXml newSchema) throws IOException, ClassNotFoundException Maybe try to compile the loggers and listeners for the new schema. This is public so it can be used as a validation step.- Parameters:
compileListeners- don't compile loggers or listeners if falsenewSchema- the schema source for loggers and listeners- Throws:
IOException- passed along from the generate methodsClassNotFoundException- passed along from the generate methods
-
main
-