public interface Exporter
Implement this interface to export data so that it can be imported by an Importer
.
Migration archives are read and written sequentially. Entries added by this exporter will be read in the same order
by the corresponding Importer
.
There are two different types of entries:
File entries
Used to migrate data that has been generated in memory, for example, JSON data.
Archive entries
Used to migrate data that already exists on the file system.
Exporters
are required to be stateless, as they are essentially singletons. State, which
should persist over the whole lifetime of a job, can be stored in ExportContext.getAttributeMap()
. This data
is kept in memory and care should be taken that memory usage in this attribute map does not grow considerably over
time.
References to entities during the export
References to entities, such as repositories
or projects
, should be exported
using their export ID
.
Importers
can use this export ID to retrieve the local ID of the entity using the
import entity mapping
.
StandardMigrationEntityTypes
define mappings for
projects
and repositories
.
Custom entity types should implement the MigrationEntityType
interface.
Plugin definition
A plugin has to define a <migration-handler>
module in its atlassian-plugin.xml
for the migration
process to include it. Migration handlers always define a pair of exporters
and
importers
. Only entries added by the corresponding Exporter
will be consumed by its
Importer
.
Example module definition:
<migration-handler key="handler" weight="150">
<exporter class="org.foo.bar.PluginExporter"/>
<importer class="org.foo.bar.PluginImporter"/>
</migration-handler>
A migration handler's weight defines the order in which it is called in relation to other migration handlers. A higher
weight signifies a dependency on a lower weight handler. All core handlers have a weight lower than 100
.Importer
,
ExportContext
,
ExportContext.getEntityMapping(MigrationEntityType)
Modifier and Type | Field and Description |
---|---|
static int |
ARCHIVE_VERSION
Archive version that this version of the product generates.
|
Modifier and Type | Method and Description |
---|---|
default void |
export(ExportContext exportContext,
com.atlassian.bitbucket.project.Project project)
Called when a project is exported.
|
default void |
export(ExportContext exportContext,
com.atlassian.bitbucket.pull.PullRequest pullRequest)
Called when a pull request is exported.
|
default void |
export(ExportContext exportContext,
com.atlassian.bitbucket.repository.Repository repository)
Called when a repository is exported.
|
default void |
onEnd(ExportContext exportContext)
Called after the export is finished.
|
default void |
onStart(ExportContext exportContext)
Called before the export is started.
|
static final int ARCHIVE_VERSION
default void export(@Nonnull ExportContext exportContext, @Nonnull com.atlassian.bitbucket.project.Project project)
exportContext
- the context
for this export operationproject
- the project that is exporteddefault void export(@Nonnull ExportContext exportContext, @Nonnull com.atlassian.bitbucket.pull.PullRequest pullRequest)
exportContext
- the context
for this export operationpullRequest
- the pull request that is exporteddefault void export(@Nonnull ExportContext exportContext, @Nonnull com.atlassian.bitbucket.repository.Repository repository)
exportContext
- the context
for this export operationrepository
- the repository that is exporteddefault void onEnd(@Nonnull ExportContext exportContext)
exportContext
- the context
for this export operationdefault void onStart(@Nonnull ExportContext exportContext)
exportContext
- the context
for this export operationCopyright © 2024 Atlassian. All rights reserved.