PageRenderTime 25ms CodeModel.GetById 69ms RepoModel.GetById 0ms app.codeStats 0ms

/jira-project/jira-components/jira-core/src/main/java/com/atlassian/jira/bc/imports/project/ProjectImportService.java

https://bitbucket.org/ahmed_bilal_360factors/jira7-core
Java | 176 lines | 24 code | 10 blank | 142 comment | 0 complexity | 68e2ddfe1ce8b47d6e8e43cc5764bfdf MD5 | raw file
Possible License(s): Apache-2.0
  1. package com.atlassian.jira.bc.imports.project;
  2. import com.atlassian.jira.bc.JiraServiceContext;
  3. import com.atlassian.jira.imports.project.core.BackupOverview;
  4. import com.atlassian.jira.imports.project.core.BackupProject;
  5. import com.atlassian.jira.imports.project.core.BackupSystemInformation;
  6. import com.atlassian.jira.imports.project.core.MappingResult;
  7. import com.atlassian.jira.imports.project.core.ProjectImportData;
  8. import com.atlassian.jira.imports.project.core.ProjectImportOptions;
  9. import com.atlassian.jira.imports.project.core.ProjectImportResults;
  10. import com.atlassian.jira.imports.project.taskprogress.TaskProgressInterval;
  11. import com.atlassian.jira.task.TaskProgressSink;
  12. import com.atlassian.jira.util.MessageSet;
  13. import javax.annotation.Nullable;
  14. /**
  15. * The ProjectImportService contains methods related to performing a project import in JIRA.
  16. *
  17. * @since v3.13
  18. */
  19. public interface ProjectImportService {
  20. /**
  21. * Validates if the user has permission to start a project import and if the provided path's exist.
  22. *
  23. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  24. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  25. * @param projectImportOptions user inputted options that contains the pathToBackupZIP, the fully qualified path, on the server, to the
  26. * JIRA ZIP backup file that will be used to provide the data for a project import, this must not be null
  27. * and must resolve to a valid JIRA ZIP backup file. This also contains the pathToAttachmentBackup which
  28. * is the fully qualified path, on the server, to the backed-up JIRA attachments
  29. * directory that will be used to import project data. This is an optional parameter, if a backup attachment
  30. * path is not provided this should be null. If non-null then this must resolve to a valid directory that
  31. */
  32. void validateGetBackupOverview(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions);
  33. /**
  34. * Returns a BackupOverview object containing the overview of information from the backup file if the backup files
  35. * build number and edition match those of the running instance of JIRA.
  36. * <p>
  37. * If the optional parameter taskProgressSink is provided, then it is used to send information about the progress of this operation.
  38. * This is used for the "Long Running Task" progress bar.
  39. * </p>
  40. *
  41. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  42. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  43. * @param projectImportOptions user inputed options that contains the pathToBackupZIP, the fully qualified path, on the server, to the
  44. * JIRA ZIP backup file that will be used to provide the data for a project import, this must not be null
  45. * and must resolve to a valid JIRA ZIP backup file. This also contains the pathToAttachmentBackup which
  46. * is the fully qualified path, on the server, to the backed-up JIRA attachments
  47. * directory that will be used to import project data. This is an optional parameter, if a backup attachment
  48. * path is not provided this should be null. If non-null then this must resolve to a valid directory that
  49. * @param taskProgressSink Used to provide progress feedback, can be null.
  50. * @return a BackupOverview object containing the overview of information from the backup file, null if the
  51. * backup file is from a different edition or build number than the running instance of JIRA.
  52. */
  53. @Nullable
  54. BackupOverview getBackupOverview(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, TaskProgressSink taskProgressSink);
  55. /**
  56. * Returns a MessageSet which reports if the provided BackupProject meets the JIRA system requirements
  57. * to be imported.
  58. * <p>
  59. * This method will return errors if:
  60. * <ul>
  61. * <li>The custom fields for the selected project exist but are not at the same version as in the backup project</li>
  62. * <li>The backupProject has a corresponding project that exists in JIRA, BUT, the project contains issues</li>
  63. * <li>The backupProject has a corresponding project that exists in JIRA, BUT, the project contains versions</li>
  64. * <li>The backupProject has a corresponding project that exists in JIRA, BUT, the project contains components</li>
  65. * <li>The backupProject is configured with a default assignee of Unassigned, BUT, the JIRA instance does not allow unassigned issues</li>
  66. * </ul>
  67. * This method will return a warning if:
  68. * <ul>
  69. * <li>The selected project does not yet exist in the JIRA instance</li>
  70. * </ul>
  71. * </p>
  72. *
  73. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  74. * indicating an anonymous user). The error collection will contain the same information
  75. * as the error messages in the returned MessageSet.
  76. * @param project the BackupProject we want validate
  77. * @param backupSystemInformation system-wide info form the backup file.
  78. * @return a MessageSet which contains any errors or warnings raised in trying to map required System values for this Project Import.
  79. */
  80. MessageSet validateBackupProjectImportableSystemLevel(JiraServiceContext jiraServiceContext, BackupProject project, BackupSystemInformation backupSystemInformation);
  81. /**
  82. * Validates if the user has permission to create a project import mapper and partition the input data and if the
  83. * provided path's and backup project exist.
  84. *
  85. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  86. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  87. * @param projectImportOptions User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.
  88. * @param backupProject the backup project we want to create a ProjectImportMapper for and partition the
  89. * @param backupSystemInformation system-wide info form the backup file.
  90. */
  91. void validateDoMapping(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation);
  92. /**
  93. * Makes a pass through the provided JIRA ZIP backup data and creates a ProjectImportMapper and partitions the XML
  94. * data for the project.
  95. *
  96. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  97. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  98. * @param projectImportOptions User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.
  99. * @param backupProject the backup project we want to create a ProjectImportMapper for and partition the
  100. * JIRA XML data.
  101. * @param backupSystemInformation system-wide info form the backup file.
  102. * @param taskProgressInterval Used to provide progress feedback, can be null.
  103. * @return a MappingResult that will contain the initial mapper and paths to the partitioned XML
  104. * files, null if there is an error processing the data.
  105. */
  106. ProjectImportData getProjectImportData(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval);
  107. /**
  108. * Will use the initial data in the ProjectImportData to perform automappings based on the current state of JIRA
  109. * and then will validate those mappings. Any warnings or errors that may have been generated will be communicated
  110. * through the mapping result.
  111. * <p>
  112. * NOTE: The import should not be allowed to proceed if {@link com.atlassian.jira.imports.project.core.MappingResult#canImport()}
  113. * is false.
  114. *
  115. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  116. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  117. * @param projectImportOptions User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.
  118. * @param 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.
  119. * @param backupProject the backup project we want to create a ProjectImportMapper for and partition the
  120. * JIRA XML data.
  121. * @param backupSystemInformation system-wide info form the backup file.
  122. * @param taskProgressInterval Used to provide progress feedback, can be null.
  123. * @return a MappingResult that will contain the initial mapper and paths to the partitioned XML
  124. * files, null if there is an error processing the data.
  125. */
  126. MappingResult doMapping(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, final ProjectImportData projectImportData, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval);
  127. /**
  128. * Makes a pass through the provided AO XML backup data and partitions the XML allowing plugins to process listen to
  129. * each element as it passes,
  130. *
  131. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  132. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  133. * @param projectImportOptions User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.
  134. * @param backupProject the backup project we want to create a ProjectImportMapper for and partition the
  135. * JIRA XML data.
  136. * @param backupSystemInformation system-wide info form the backup file.
  137. * @param taskProgressInterval Used to provide progress feedback, can be null.
  138. * @return a MappingResult that will contain the initial mapper and paths to the partitioned XML
  139. * files, null if there is an error processing the data.
  140. */
  141. MessageSet preProcessAoImportData(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, TaskProgressInterval taskProgressInterval);
  142. /**
  143. * Imports the passed in project using the provided, populated and validated, project import mapper.
  144. * <p>
  145. * This method will create/update the project, versions, components, role membership, as needed and will
  146. * then import the issues and all their related values. This will also cause the project that is being
  147. * imported to be reIndexed.
  148. * <p>
  149. * NOTE: this method does NO validation of the project import mapper. This method must only be called with a project
  150. * import mapper that has been returned from
  151. * {@link #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)}
  152. * without any errors being generated.
  153. *
  154. * @param jiraServiceContext containing the user who the permission checks will be run against (can be null,
  155. * indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
  156. * @param projectImportOptions User options for the project import, including the pathToBackupZIP, attachmentPath, and "overwriteProjectDetails" flag.
  157. * @param backupProject the backup project we want to create a ProjectImportMapper for and partition the
  158. * JIRA XML data.
  159. * @param backupSystemInformation system-wide info form the backup file.
  160. * @param projectImportData contains the projectImportMapper, that has been through the automatic mapping and validation process, and the
  161. * path, on disk, to the partitioned xml files.
  162. * @param taskProgressInterval Used to provide progress feedback, can be null.
  163. * @return projectImportResults contains the statistics of what was created during the import, if it was a success, and any errors that may have occurred.
  164. */
  165. ProjectImportResults doImport(JiraServiceContext jiraServiceContext, ProjectImportOptions projectImportOptions, BackupProject backupProject, BackupSystemInformation backupSystemInformation, ProjectImportData projectImportData, TaskProgressInterval taskProgressInterval);
  166. }