public interface

Exporter

com.atlassian.bitbucket.migration.Exporter

Class Overview

Data Center Migration Exporter SPI

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.

Important:

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 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 Project 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.

Summary

Public Methods
void export(ExportContext exportContext, Repository repository)
Called when a repository is exported.
void export(ExportContext exportContext, Project project)
Called when a project is exported.
void export(ExportContext exportContext, PullRequest pullRequest)
Called when a pull request is exported.
void onEnd(ExportContext exportContext)
Called after the export is finished.
void onStart(ExportContext exportContext)
Called before the export is started.

Public Methods

public void export (ExportContext exportContext, Repository repository)

Called when a repository is exported. Implementors should implement this method to export all relevant data that is associated with the repository.

Parameters
exportContext the context for this export operation
repository the repository that is exported

public void export (ExportContext exportContext, Project project)

Called when a project is exported. Implementors should implement this method to export all relevant data that is associated with the project.

Parameters
exportContext the context for this export operation
project the project that is exported

public void export (ExportContext exportContext, PullRequest pullRequest)

Called when a pull request is exported. Implementors should implement this method to export all relevant data that is associated with the pull request.

Parameters
exportContext the context for this export operation
pullRequest the pull request that is exported

public void onEnd (ExportContext exportContext)

Called after the export is finished.

Parameters
exportContext the context for this export operation

public void onStart (ExportContext exportContext)

Called before the export is started.

Parameters
exportContext the context for this export operation