public interface ExportContext extends ExportSection
Exporter
that wishes to make state available for the
lifetime of an export will use the facilities provided by this class such as getAttributeMap()
and
getEntityMapping(MigrationEntityType)
. This class also provides a facility for storing error and warning
messages that an Exporter
may raise during the export process.Modifier and Type | Method and Description |
---|---|
void |
abortIfCanceled()
Ensures that the export has not been canceled.
|
void |
addError(com.atlassian.bitbucket.i18n.KeyedMessage message,
Object entity)
Report a failed export of the provided entity
|
void |
addError(com.atlassian.bitbucket.i18n.KeyedMessage message,
Object entity,
Throwable t)
Report an error during an export for the provided entity and with an optional
Throwable
to log |
boolean |
addSectionIfAbsent(Path path,
Consumer<ExportSection> exportSection)
Creates a
section with the given relative path inside the export archive. |
void |
addWarning(com.atlassian.bitbucket.i18n.KeyedMessage message,
Object entity)
Report a warning during an export for the provided entity
|
void |
addWarning(com.atlassian.bitbucket.i18n.KeyedMessage message,
Object entity,
Throwable t)
Report a warning during an export for the provided entity and with an optional
Throwable
to log |
com.atlassian.bitbucket.attribute.AttributeMap |
getAttributeMap()
Returns the
AttributeMap object for this context. |
<T> EntityExportMapping<T> |
getEntityMapping(MigrationEntityType<T> entityType)
Returns the
EntityExportMapping of the MigrationEntityType for this context. |
boolean |
hasErrors() |
boolean |
hasSection(Path path)
Does this
export context contain a section with the given path |
addEntriesAsArchive, addEntry, emptyArchive, emptyEntry
void abortIfCanceled()
Note: Exporter.onEnd(ExportContext)
will always be called, even if this method throws an exception.
Additional cleanup can be done there as well.
Example:
try { context.abortIfCanceled(); } catch (Exception e) { // cleanup code throw e; }
CanceledMigrationException
- if the job for this context has been canceledvoid addError(@Nonnull com.atlassian.bitbucket.i18n.KeyedMessage message, @Nullable Object entity)
message
- the failure messageentity
- the entity for which export failed, or null
for general failuresvoid addError(@Nonnull com.atlassian.bitbucket.i18n.KeyedMessage message, @Nullable Object entity, @Nullable Throwable t)
Throwable
to logmessage
- the failure messageentity
- the entity for which export failed, or null
for general failurest
- an optional Throwable
for the errorboolean addSectionIfAbsent(@Nonnull Path path, @Nonnull Consumer<ExportSection> exportSection)
section
with the given relative path inside the export archive. If a section
with this name has already been added in the export, it will not be added.path
- a path relative to the export root directory specific to the caller, inside the export
archive. Use Paths.get(String, String...)
to use this method
efficiently.exportSection
- consumer
that writes the contents of the section
relative to the section pathsection
did not exist and has been created as a result of this call,
false otherwisevoid addWarning(@Nonnull com.atlassian.bitbucket.i18n.KeyedMessage message, @Nullable Object entity, @Nullable Throwable t)
Throwable
to logmessage
- the failure messageentity
- the entity for which export failed, or null
for general failurest
- an optional Throwable
for the warningvoid addWarning(@Nonnull com.atlassian.bitbucket.i18n.KeyedMessage message, @Nullable Object entity)
message
- the failure messageentity
- the entity for which export failed, or null
for general failures@Nonnull com.atlassian.bitbucket.attribute.AttributeMap getAttributeMap()
AttributeMap
object for this context. This allows storage of attributes associated with this
context for the lifetime of this context.AttributeMap
object for this contextAttributeMap
@Nonnull <T> EntityExportMapping<T> getEntityMapping(@Nonnull MigrationEntityType<T> entityType)
EntityExportMapping
of the MigrationEntityType
for this context. If the mapping
does not exist for the type, it'll be created.T
- Type of the IDs in the mappingentityType
- Entity type that this mapping should map, e.g. Repository or ProjectEntityExportMapping
of the MigrationEntityType
for this contextboolean hasErrors()
addError(KeyedMessage, Object)
has been calledboolean hasSection(@Nonnull Path path)
export context
contain a section
with the given pathpath
- the path of the section to check forexport context
contain a section
with the given
path, false otherwiseCopyright © 2024 Atlassian. All rights reserved.