Class DefaultProjectImportService
- All Implemented Interfaces:
ProjectImportService
- Since:
- v3.13
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultProjectImportService
(PermissionManager permissionManager, ProjectImportManager projectImportManager, ProjectManager projectManager, UserManager userManager, IssueManager issueManager, VersionManager versionManager, ProjectComponentManager projectComponentManager, com.atlassian.plugin.PluginAccessor pluginAccessor, ApplicationProperties applicationProperties, AttachmentConfigStore attachmentConfigStore, UpgradeConstraints upgradeConstraints, com.atlassian.event.api.EventPublisher eventPublisher, ProjectTypeValidator projectTypeValidator) -
Method Summary
Modifier and TypeMethodDescriptiondoImport
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, ProjectImportData projectImportData, TaskProgressInterval taskProgressInterval) Imports the passed in project using the provided, populated and validated, project import mapper.doMapping
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, ProjectImportData projectImportData, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Will use the initial data in the ProjectImportData to perform automappings based on the current state of JIRA and then will validate those mappings.getBackupOverview
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, TaskProgressSink taskProgressSink) Returns a BackupOverview object containing the overview of information from the backup file if the backup files build number and edition match those of the running instance of JIRA.getProjectImportData
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Makes a pass through the provided JIRA ZIP backup data and creates a ProjectImportMapper and partitions the XML data for the project.preProcessAoImportData
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Makes a pass through the provided AO XML backup data and partitions the XML allowing plugins to process listen to each element as it passes,validateBackupProjectImportableSystemLevel
(JiraServiceContext jiraServiceContext, BackupProject backupProject, BackupSystemInformation backupSystemInformation) Returns a MessageSet which reports if the provided BackupProject meets the JIRA system requirements to be imported.void
validateDoMapping
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation) Validates if the user has permission to create a project import mapper and partition the input data and if the provided path's and backup project exist.void
validateGetBackupOverview
(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions) Validates if the user has permission to start a project import and if the provided path's exist.
-
Constructor Details
-
DefaultProjectImportService
public DefaultProjectImportService(PermissionManager permissionManager, ProjectImportManager projectImportManager, ProjectManager projectManager, UserManager userManager, IssueManager issueManager, VersionManager versionManager, ProjectComponentManager projectComponentManager, com.atlassian.plugin.PluginAccessor pluginAccessor, ApplicationProperties applicationProperties, AttachmentConfigStore attachmentConfigStore, UpgradeConstraints upgradeConstraints, com.atlassian.event.api.EventPublisher eventPublisher, ProjectTypeValidator projectTypeValidator)
-
-
Method Details
-
validateGetBackupOverview
public void validateGetBackupOverview(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions) Description copied from interface:ProjectImportService
Validates if the user has permission to start a project import and if the provided path's exist.- Specified by:
validateGetBackupOverview
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- user inputted options that contains the pathToBackupZIP, the fully qualified path, on the server, to the JIRA ZIP backup file that will be used to provide the data for a project import, this must not be null and must resolve to a valid JIRA ZIP backup file. This also contains the pathToAttachmentBackup which is the fully qualified path, on the server, to the backed-up JIRA attachments directory that will be used to import project data. This is an optional parameter, if a backup attachment path is not provided this should be null. If non-null then this must resolve to a valid directory that
-
getBackupOverview
@Nullable public BackupOverview getBackupOverview(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, TaskProgressSink taskProgressSink) Description copied from interface:ProjectImportService
Returns a BackupOverview object containing the overview of information from the backup file if the backup files build number and edition match those of the running instance of JIRA.If the optional parameter taskProgressSink is provided, then it is used to send information about the progress of this operation. This is used for the "Long Running Task" progress bar.
- Specified by:
getBackupOverview
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- user inputed options that contains the pathToBackupZIP, the fully qualified path, on the server, to the JIRA ZIP backup file that will be used to provide the data for a project import, this must not be null and must resolve to a valid JIRA ZIP backup file. This also contains the pathToAttachmentBackup which is the fully qualified path, on the server, to the backed-up JIRA attachments directory that will be used to import project data. This is an optional parameter, if a backup attachment path is not provided this should be null. If non-null then this must resolve to a valid directory thattaskProgressSink
- Used to provide progress feedback, can be null.- Returns:
- a BackupOverview object containing the overview of information from the backup file, null if the backup file is from a different edition or build number than the running instance of JIRA.
-
validateBackupProjectImportableSystemLevel
public MessageSet validateBackupProjectImportableSystemLevel(JiraServiceContext jiraServiceContext, BackupProject backupProject, BackupSystemInformation backupSystemInformation) Description copied from interface:ProjectImportService
Returns a MessageSet which reports if the provided BackupProject meets the JIRA system requirements to be imported.This method will return errors if:
- The custom fields for the selected project exist but are not at the same version as in the backup project
- The backupProject has a corresponding project that exists in JIRA, BUT, the project contains issues
- The backupProject has a corresponding project that exists in JIRA, BUT, the project contains versions
- The backupProject has a corresponding project that exists in JIRA, BUT, the project contains components
- The backupProject is configured with a default assignee of Unassigned, BUT, the JIRA instance does not allow unassigned issues
- The selected project does not yet exist in the JIRA instance
- Specified by:
validateBackupProjectImportableSystemLevel
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user). The error collection will contain the same information as the error messages in the returned MessageSet.backupProject
- the BackupProject we want validatebackupSystemInformation
- system-wide info form the backup file.- Returns:
- a MessageSet which contains any errors or warnings raised in trying to map required System values for this Project Import.
-
validateDoMapping
public void validateDoMapping(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation) Description copied from interface:ProjectImportService
Validates if the user has permission to create a project import mapper and partition the input data and if the provided path's and backup project exist.- Specified by:
validateDoMapping
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.backupProject
- the backup project we want to create a ProjectImportMapper for and partition thebackupSystemInformation
- system-wide info form the backup file.
-
doMapping
public MappingResult doMapping(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, ProjectImportData projectImportData, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Description copied from interface:ProjectImportService
Will use the initial data in the ProjectImportData to perform automappings based on the current state of JIRA and then will validate those mappings. Any warnings or errors that may have been generated will be communicated through the mapping result.NOTE: The import should not be allowed to proceed if
MappingResult.canImport()
is false.- Specified by:
doMapping
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.projectImportData
- which holds the initial projectImportMapper and the partitioned XML file paths for the project XML data that was partitioned from the main XML backup.backupProject
- the backup project we want to create a ProjectImportMapper for and partition the JIRA XML data.backupSystemInformation
- system-wide info form the backup file.taskProgressInterval
- Used to provide progress feedback, can be null.- Returns:
- a MappingResult that will contain the initial mapper and paths to the partitioned XML files, null if there is an error processing the data.
-
preProcessAoImportData
public MessageSet preProcessAoImportData(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Description copied from interface:ProjectImportService
Makes a pass through the provided AO XML backup data and partitions the XML allowing plugins to process listen to each element as it passes,- Specified by:
preProcessAoImportData
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.backupProject
- the backup project we want to create a ProjectImportMapper for and partition the JIRA XML data.backupSystemInformation
- system-wide info form the backup file.taskProgressInterval
- Used to provide progress feedback, can be null.- Returns:
- a MappingResult that will contain the initial mapper and paths to the partitioned XML files, null if there is an error processing the data.
-
doImport
public ProjectImportResults doImport(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, ProjectImportData projectImportData, TaskProgressInterval taskProgressInterval) Description copied from interface:ProjectImportService
Imports the passed in project using the provided, populated and validated, project import mapper.This method will create/update the project, versions, components, role membership, as needed and will then import the issues and all their related values. This will also cause the project that is being imported to be reIndexed.
NOTE: this method does NO validation of the project import mapper. This method must only be called with a project import mapper that has been returned from
ProjectImportService.doMapping(com.atlassian.jira.bc.JiraServiceContext, com.atlassian.jira.imports.project.core.ProjectImportOptions, com.atlassian.jira.imports.project.core.ProjectImportData, com.atlassian.jira.imports.project.core.BackupProject, com.atlassian.jira.imports.project.core.BackupSystemInformation, com.atlassian.jira.imports.project.taskprogress.TaskProgressInterval)
without any errors being generated.- Specified by:
doImport
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.backupProject
- the backup project we want to create a ProjectImportMapper for and partition the JIRA XML data.backupSystemInformation
- system-wide info form the backup file.projectImportData
- contains the projectImportMapper, that has been through the automatic mapping and validation process, and the path, on disk, to the partitioned xml files.taskProgressInterval
- Used to provide progress feedback, can be null.- Returns:
- projectImportResults contains the statistics of what was created during the import, if it was a success, and any errors that may have occurred.
-
getProjectImportData
public ProjectImportData getProjectImportData(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval) Description copied from interface:ProjectImportService
Makes a pass through the provided JIRA ZIP backup data and creates a ProjectImportMapper and partitions the XML data for the project.- Specified by:
getProjectImportData
in interfaceProjectImportService
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodprojectImportOptions
- User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.backupProject
- the backup project we want to create a ProjectImportMapper for and partition the JIRA XML data.backupSystemInformation
- system-wide info form the backup file.taskProgressInterval
- Used to provide progress feedback, can be null.- Returns:
- a MappingResult that will contain the initial mapper and paths to the partitioned XML files, null if there is an error processing the data.
-