public interface ImportMigrationContext extends MigrationContext
The import migration context is provided to a Migratable
during the import migration
operation. The migratable can retrieve new entries representing files or blobs of information
that may have been exported. It can also retrieve entries for system properties that reference
files on disk. As a result, the migratable can re-import the exported information into the new
system.
For example:
public class MyMigratable implements Migratable { ... public void doImport(ImportMigrationContext context) { // import an exported file and restore it back to disk context.getEntry(Paths.get("etc", "myfile.properties")) .restore(); // get all exported files located under a specific sub-directory and restore them back on disk context.entries(Paths.get("etc", "subdir")) .forEach(ImportMigrationEntry::restore); // restore back on disk the file referenced from the "my.property" system property context.getSystemPropertyReferencedEntry("my.property") .ifPresent(ImportMigrationEntry::restore); } ... }
This code is experimental. While this interface is functional and tested, it may change or be removed in a future version of the library.
Modifier and Type | Method and Description |
---|---|
Stream<ImportMigrationEntry> |
entries()
Retrieves all exported migration entries.
|
Stream<ImportMigrationEntry> |
entries(Path path)
Retrieves all exported migration entries located underneath the provided relative path.
|
Stream<ImportMigrationEntry> |
entries(Path path,
PathMatcher filter)
Retrieves all exported migration entries located underneath the provided relative path that
matches the provided path filter.
|
ImportMigrationEntry |
getEntry(Path path)
Retrieves a migration entry that was exported by the corresponding migratable with the given
path.
|
Optional<ImportMigrationEntry> |
getSystemPropertyReferencedEntry(String name)
Retrieves a migration entry referenced from a given system property that was exported by the
corresponding migratable.
|
getId, getReport
Optional<ImportMigrationEntry> getSystemPropertyReferencedEntry(String name)
The entry returned would be an entry representing the file that was referenced by the specified system property value on the exported system. For example:
If system properties defined the following mapping: javax.net.ssl.keyStore=etc/keystores/serverKeystore.jks
then the following code:
final Optional<ImportMigrationEntry> entry = context.getSystemPropertyReferenceEntry("javax.net.ssl.keyStore");
would return an entry representing the exported file etc/keystores/serverKeystore.jks
allowing the migratable a chance to restore it in its original location and verifying
that the system property is still defined with the same value after the import operation has
completed.
name
- the name of the system property referencing a migration entry to retrieveIllegalArgumentException
- if name
is null
ImportMigrationEntry getEntry(Path path)
A "fake" entry will still be returned if the requested path was not exported. Errors will be
recorded when storing the file later using one of the restore()
methods or an
exception will be thrown out when attempting to retrieve the corresponding input stream.
path
- the path of the file that was exported (must be relative to ${ddf.home} to match an
exported entry otherwise an error or a warning will be recorded later when an attempt is
made to restored to returned migration entry)IllegalArgumentException
- if path
is null
Stream<ImportMigrationEntry> entries()
Stream<ImportMigrationEntry> entries(Path path)
path
- the path to the directory for all recursively exported files (must be relative to
${ddf.home} otherwise no entries will be found)path
IllegalArgumentException
- if path
is null
Stream<ImportMigrationEntry> entries(Path path, PathMatcher filter)
path
- the path to the directory to recursively search for exported files that match the
given filter (must be relative to ${ddf.home} otherwise no entries will be found)filter
- the path filter to usepath
that matches the
given filterIllegalArgumentException
- if path
or filter
is null
This work is licensed under a Creative Commons Attribution 4.0 International License.