public class ImportMigrationEntryImpl extends MigrationEntryImpl implements ImportMigrationEntry
ImportMigrationEntry
interface.Modifier and Type | Field and Description |
---|---|
protected Boolean |
restored
Will track if restore was attempted along with its result.
|
METADATA_CHECKSUM, METADATA_FILES, METADATA_FILTERED, METADATA_FOLDER, METADATA_LAST_MODIFIED, METADATA_NAME, METADATA_PROPERTY, METADATA_REFERENCE, METADATA_SOFTLINK
Modifier | Constructor and Description |
---|---|
protected |
ImportMigrationEntryImpl(ImportMigrationContextImpl context,
Path path,
boolean isFile)
Instantiates a new migration entry with the given path.
|
protected |
ImportMigrationEntryImpl(ImportMigrationContextImpl context,
String name,
boolean isFile)
Instantiates a new migration entry with the given name.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
The superclass implementation is sufficient for our needs.
|
protected Path |
getAbsolutePath() |
protected ImportMigrationContextImpl |
getContext() |
protected File |
getFile() |
Optional<InputStream> |
getInputStream()
Gets an input stream for this entry.
|
protected Optional<InputStream> |
getInputStream(boolean checkAccess) |
long |
getLastModifiedTime()
Gets the last modification time of the entry.
|
String |
getName()
Gets name for this entry.
|
Path |
getPath()
Gets a
Path for this entry. |
Optional<ImportMigrationEntry> |
getPropertyReferencedEntry(String pname)
Retrieves a migration entry referenced from a property value defined in the properties file
associated with this migration entry.
|
MigrationReport |
getReport()
Gets the migration report associated with this entry.
|
int |
hashCode()
The superclass implementation is sufficient for our needs.
|
boolean |
isDirectory()
Tests whether this entry represents a directory.
|
boolean |
isFile()
Tests whether this entry represents a file.
|
boolean |
restore(BiThrowingConsumer<MigrationReport,Optional<InputStream>,IOException> consumer)
Restores this required entry's content appropriately based on this entry's path which can
include sub-directories using the specified consumer.
|
boolean |
restore(boolean required)
Restores this entry's content underneath the distribution root directory based on this entry's
path which can include sub-directories.
|
boolean |
restore(boolean required,
PathMatcher filter)
Restores all entries that recursively match the provided path filter underneath the
distribution root directory based on this entry's path which can include sub-directories.
|
protected String |
toDebugString()
Gets a debug string to represent this entry.
|
compareTo, getId, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
restore, restore
getId
compareTo
protected Boolean restored
null
until
restore() is attempted, at which point it will start tracking the first restore() result.protected ImportMigrationEntryImpl(ImportMigrationContextImpl context, String name, boolean isFile)
context
- the migration context associated with this entryname
- the entry's relative nameisFile
- true
if the entry represents a file; false
if it
represents a directoryprotected ImportMigrationEntryImpl(ImportMigrationContextImpl context, Path path, boolean isFile)
context
- the migration context associated with this entrypath
- the entry's relative pathisFile
- true
if the entry represents a file; false
if it
represents a directorypublic MigrationReport getReport()
MigrationEntry
getReport
in interface MigrationEntry
getReport
in class MigrationEntryImpl
public String getName()
MigrationEntry
getName
in interface MigrationEntry
public Path getPath()
MigrationEntry
Path
for this entry.
Note: Absolute paths that are under ${ddf.home} are automatically relativized.
getPath
in interface MigrationEntry
public long getLastModifiedTime()
MigrationEntry
getLastModifiedTime
in interface MigrationEntry
public boolean isDirectory()
MigrationEntry
isDirectory
in interface MigrationEntry
true
if and only if the entry represents a directory; false
otherwisepublic boolean isFile()
MigrationEntry
isFile
in interface MigrationEntry
true
if and only if the entry represents a file; false
otherwisepublic final Optional<InputStream> getInputStream() throws IOException
ImportMigrationEntry
Note: The input stream provided will automatically be closed (if not closed already) regardless of whether or not the operation completes successfully for the associated migratable.
getInputStream
in interface ImportMigrationEntry
IOException
- if an I/O error has occurredpublic boolean restore(boolean required)
ImportMigrationEntry
This entry's sub-directories (if any) will be created if they don't already exist. The destination file will be overwritten if it already exists.
All errors and warnings are automatically recorded with the associated migration report.
Errors can be reported in two ways:
MigrationException
(e.g. failure to write to the exported file)
false
is returned from this method. This allows for the accumulation of as many issues
as possible to report to the user before aborting the operation.
Note: If this entry represents a directory which had been completely exported using
ExportMigrationEntry.store()
or ExportMigrationEntry.store(boolean)
then in
addition to restoring all entries recursively, calling this method will also remove any
existing files or directories that were not on the original system.
Note: Calling restore()
twice will not restore the entry two times. The
second time it is called, the same result will be returned as the first time no matter which
restore()
method was called.
restore
in interface ImportMigrationEntry
required
- true
if the file or directory is required to exist in the export
and if it doesn't an error should be recorded; false
if the file or directory
is optional and may not be exported in which case calling this method will do nothingtrue
if no errors were recorded as a result of processing this command;
false
otherwisepublic boolean restore(boolean required, PathMatcher filter)
ImportMigrationEntry
required
parameter is interpreted for recording errors and deciding what to return.
This entry's sub-directories (if any) will be created if they don't already exist. The destination file will be overwritten if it already exists.
All errors and warnings are automatically recorded with the associated migration report.
Errors can be reported in two ways:
MigrationException
(e.g. failure to write to the exported file)
false
is returned from this method. This allows for the accumulation of as many issues
as possible to report to the user before aborting the operation.
Note: Calling restore()
twice will not restore the entry two times. The
second time it is called, the same result will be returned as the first time no matter which
restore()
method was called.
restore
in interface ImportMigrationEntry
required
- true
if the file or directory is required to exist in the export
and if it doesn't an error should be recorded; false
if the file or directory
is optional and may not be exported in which case calling this method will do nothingfilter
- the path filter to usetrue
if no errors were recorded as a result of processing this command;
false
otherwisepublic boolean restore(BiThrowingConsumer<MigrationReport,Optional<InputStream>,IOException> consumer)
ImportMigrationEntry
All errors and warnings are automatically recorded with the associated migration report including those thrown by the consumer logic.
Errors can be reported in two ways:
MigrationException
(e.g. failure to read from the exported file)
false
is returned from this method. This allows for the accumulation of as many issues
as possible to report to the user before aborting the operation.
Note: The input stream will automatically be closed (if not closed already) when the operation completes successfully or not.
restore
in interface ImportMigrationEntry
consumer
- a consumer capable of importing the content of this entry from a provided input
stream which might be empty if the entry was not exported or if the entry represents a
directory (otherwise an error will automatically be recorded)true
if no errors were recorded as a result of processing this command;
false
otherwisepublic Optional<ImportMigrationEntry> getPropertyReferencedEntry(String pname)
ImportMigrationEntry
The entry returned would be an entry representing the file that was referenced by the specified property value in the java properties file represented by this entry on the exported system. For example:
If the properties file (e.g. etc/ws-security/server/encryption.properties) represented by this entry defined the following mapping: org.apache.ws.security.crypto.merlin.x509crl.file=etc/certs/demoCA/crl/crl.pem
then the following code:
final ImportMigrationEntry entry = context.getEntry("etc/ws-security/server/encryption.properties"); final Optional<ImportMigrationEntry> entry2 = entry.getPropertyReferenceEntry("org.apache.ws.security.crypto.merlin.x509crl.file");
would return an entry representing the exported file etc/certs/demoCA/crl/crl.pem
allowing the migratable a chance to restore it in its original location and verifying
that the property in the local etc/ws-security/server/encryption.properties file is still
defined with the same value after the import operation has completed.
getPropertyReferencedEntry
in interface ImportMigrationEntry
pname
- the name of the property that contains the reference to a migration entryname
in
the properties file referenced by this entry or empty if it was not exportedprotected ImportMigrationContextImpl getContext()
getContext
in class MigrationEntryImpl
protected Path getAbsolutePath()
protected File getFile()
protected Optional<InputStream> getInputStream(boolean checkAccess) throws IOException
IOException
protected String toDebugString()
public boolean equals(Object o)
equals
in class MigrationEntryImpl
o
- the object to checkpublic int hashCode()
hashCode
in class MigrationEntryImpl
This work is licensed under a Creative Commons Attribution 4.0 International License.