com.atlassian.jira.imports.project
Class DefaultProjectImportPersister

java.lang.Object
  extended by com.atlassian.jira.imports.project.DefaultProjectImportPersister
All Implemented Interfaces:
ProjectImportPersister

public class DefaultProjectImportPersister
extends java.lang.Object
implements ProjectImportPersister

Since:
v3.13

Constructor Summary
DefaultProjectImportPersister(UserUtil userUtil, ExternalUtils externalUtils, IssueFactory issueFactory, OfBizDelegator ofBizDelegator, IssueIndexManager issueIndexManager, IssueManager issueManager, ProjectFactory projectFactory, ProjectManager projectManager, VersionManager versionManager, com.atlassian.core.ofbiz.association.AssociationManager associationManager, ProjectComponentManager projectComponentManager, AttachmentManager attachmentManager, ChangeHistoryManager changeHistoryManager, IssueLinkTypeManager issueLinkTypeManager, ApplicationProperties applicationProperties)
           
 
Method Summary
 boolean createAssociation(ExternalNodeAssociation nodeAssociation)
          Creates a NodeAssocation which is used to link the issue to external values such as versions and components.
 Attachment createAttachment(ExternalAttachment externalAttachment)
          Creates an attachment specified by the ExternalAttachment.
 java.lang.String createChangeItemForIssueLinkIfNeeded(java.lang.String issueId, java.lang.String issueLinkTypeId, java.lang.String linkedIssueKey, boolean isSource, com.opensymphony.user.User importAuthor)
          This will look at the issue specified by issueId and add a changeItem for the issue link if it needs to.
 java.util.Map createComponents(BackupProject backupProject)
          Creates the components, specified by BackupProject.getProjectComponents() for the named backup project.
 java.lang.Long createEntity(EntityRepresentation entityRepresentation)
          This will store the provided entity in the database.
 Issue createIssue(ExternalIssue externalIssue, java.util.Date importDate, com.opensymphony.user.User importAuthor)
          Creates an issue based off of the provided ExternalIssue.
 Project createProject(BackupProject backupProject)
          Creates a project, with details based off of the ExternalProject in the backup project.
 com.opensymphony.user.User createUser(ExternalUser externalUser)
          Creates a User in JIRA from the given ExternalUser object.
 java.util.Map createVersions(BackupProject backupProject)
          Creates the versions, specified by BackupProject.getProjectVersions() for the named backup project.
 boolean createVoter(ExternalVoter voter)
          Creates a UserAssociation which is used to link the user to the issue as a voter.
 boolean createWatcher(ExternalWatcher watcher)
          Creates a UserAssociation which is used to link the user to the issue as a watcher.
 void reIndexProject(ProjectImportMapper projectImportMapper, TaskProgressInterval taskProgressInterval, I18nHelper i18n)
          Re-indexes all the new Issues that have just been created in this Project Import.
 Project updateProjectDetails(ExternalProject externalProject)
          Updates the details of an existing Project in JIRA from the given ExternalProject object.
 void updateProjectIssueCounter(BackupProject backupProject, long counter)
          Updates a projects issue counter, which is used to determine the numeric portion of the issue key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultProjectImportPersister

public DefaultProjectImportPersister(UserUtil userUtil,
                                     ExternalUtils externalUtils,
                                     IssueFactory issueFactory,
                                     OfBizDelegator ofBizDelegator,
                                     IssueIndexManager issueIndexManager,
                                     IssueManager issueManager,
                                     ProjectFactory projectFactory,
                                     ProjectManager projectManager,
                                     VersionManager versionManager,
                                     com.atlassian.core.ofbiz.association.AssociationManager associationManager,
                                     ProjectComponentManager projectComponentManager,
                                     AttachmentManager attachmentManager,
                                     ChangeHistoryManager changeHistoryManager,
                                     IssueLinkTypeManager issueLinkTypeManager,
                                     ApplicationProperties applicationProperties)
Method Detail

createIssue

public Issue createIssue(ExternalIssue externalIssue,
                         java.util.Date importDate,
                         com.opensymphony.user.User importAuthor)
Description copied from interface: ProjectImportPersister
Creates an issue based off of the provided ExternalIssue. This method will store the issue and make sure that it is in the correct workflow state. This will preserve the key provided in the issue. NOTE: If you are using this method you will, at a later time, need to fix the projects pcounter to be correct in relation to the manually stored issue keys.

Specified by:
createIssue in interface ProjectImportPersister
Parameters:
externalIssue - contains the issue details that will be persisted and the project id that the issue will be persisted against.
importDate - a date that will be used as the value of the marker change item that is added to the issue to indicate that the issue was created via a project import.
importAuthor - the user who is performing the project import, this is used as the author of the change item marker for created issues
Returns:
an Issue representation of the newly stored issue, null if there is a problem creating the issue.

createEntity

public java.lang.Long createEntity(EntityRepresentation entityRepresentation)
Description copied from interface: ProjectImportPersister
This will store the provided entity in the database. No validation will be performed so it is up to the caller to make certain that the data has integrity. If a DataAccessException occurs during this operation, then we return a null id.

Specified by:
createEntity in interface ProjectImportPersister
Parameters:
entityRepresentation - the data that will be persisted.
Returns:
the id of the newly created entity, or null if the Entity could not be created.

createChangeItemForIssueLinkIfNeeded

public java.lang.String createChangeItemForIssueLinkIfNeeded(java.lang.String issueId,
                                                             java.lang.String issueLinkTypeId,
                                                             java.lang.String linkedIssueKey,
                                                             boolean isSource,
                                                             com.opensymphony.user.User importAuthor)
Description copied from interface: ProjectImportPersister
This will look at the issue specified by issueId and add a changeItem for the issue link if it needs to. If a change item is added then the issues updated date will also be updated. If the issue already has a change item then one will not be added. If the issue has one but also has a change item that says the link was deleted this method will add a new one. If the issue has no change item for this link then one will be added. Please note: this method will add the change item but it does not re-index the issue, this should be handled elsewhere.

Specified by:
createChangeItemForIssueLinkIfNeeded in interface ProjectImportPersister
Parameters:
issueId - the id of the issue that should exist in JIRA. This is the issue that will have the change item added to it if it does not already have one.
issueLinkTypeId - the id of the issue link type in JIRA, this must exist.
linkedIssueKey - the issue key that is part of the created link.
isSource - true if the issue specified by issueId is the source of the issue link, false if it is the destination.
importAuthor - the user who is performing the project import, this is used as the author of the change item marker for created issues.
Returns:
the issue id that was changed if a change item was created, null otherwise.

reIndexProject

public void reIndexProject(ProjectImportMapper projectImportMapper,
                           TaskProgressInterval taskProgressInterval,
                           I18nHelper i18n)
                    throws IndexException
Description copied from interface: ProjectImportPersister
Re-indexes all the new Issues that have just been created in this Project Import. The list of Issues to be indexed is taken from the ProjectImportIdMapper.getAllMappedIds().

Specified by:
reIndexProject in interface ProjectImportPersister
Parameters:
projectImportMapper - ProjectImportMapper which is used to get the new Issue ID
taskProgressInterval - Used to provide progress feedback, can be null.
i18n - used to i18n the task progress messages.
Throws:
IndexException - If an error occurs in the IndexManager.

createAssociation

public boolean createAssociation(ExternalNodeAssociation nodeAssociation)
Description copied from interface: ProjectImportPersister
Creates a NodeAssocation which is used to link the issue to external values such as versions and components.

Specified by:
createAssociation in interface ProjectImportPersister
Parameters:
nodeAssociation - the externalObject that contains the correct values to be persisted to the datastore.
Returns:
true if the association was created false otherwise

createVoter

public boolean createVoter(ExternalVoter voter)
Description copied from interface: ProjectImportPersister
Creates a UserAssociation which is used to link the user to the issue as a voter.

Specified by:
createVoter in interface ProjectImportPersister
Parameters:
voter - contains the issue and user information
Returns:
true if created, false otherwise.

createWatcher

public boolean createWatcher(ExternalWatcher watcher)
Description copied from interface: ProjectImportPersister
Creates a UserAssociation which is used to link the user to the issue as a watcher.

Specified by:
createWatcher in interface ProjectImportPersister
Parameters:
watcher - contains the issue and user information
Returns:
true if created, false otherwise.

updateProjectDetails

public Project updateProjectDetails(ExternalProject externalProject)
Description copied from interface: ProjectImportPersister
Updates the details of an existing Project in JIRA from the given ExternalProject object. This includes the following:

Specified by:
updateProjectDetails in interface ProjectImportPersister
Parameters:
externalProject - ExternalProject containing the data to use to update.
Returns:
a Project object representing the project we just updated

createProject

public Project createProject(BackupProject backupProject)
                      throws ExternalException
Description copied from interface: ProjectImportPersister
Creates a project, with details based off of the ExternalProject in the backup project. The project will be associated with the default schemes.

Specified by:
createProject in interface ProjectImportPersister
Parameters:
backupProject - contains the ExternalProject that holds the details the project will be created with.
Returns:
a Project object representing the project we just created
Throws:
ExternalException - if there is an error creating the project.

createVersions

public java.util.Map createVersions(BackupProject backupProject)
Description copied from interface: ProjectImportPersister
Creates the versions, specified by BackupProject.getProjectVersions() for the named backup project.

Specified by:
createVersions in interface ProjectImportPersister
Parameters:
backupProject - specifies the name of the project to create the versions for and the versions to create
Returns:
a map of Version's that represent the newly created versions keyed by the old version id they were created from.

createComponents

public java.util.Map createComponents(BackupProject backupProject)
Description copied from interface: ProjectImportPersister
Creates the components, specified by BackupProject.getProjectComponents() for the named backup project.

Specified by:
createComponents in interface ProjectImportPersister
Parameters:
backupProject - specifies the name of the project to create the components for and the components to create
Returns:
a map of ProjectComponent's that represent the newly created components keyed by the old component id they were created from.

updateProjectIssueCounter

public void updateProjectIssueCounter(BackupProject backupProject,
                                      long counter)
Description copied from interface: ProjectImportPersister
Updates a projects issue counter, which is used to determine the numeric portion of the issue key.

Specified by:
updateProjectIssueCounter in interface ProjectImportPersister
Parameters:
backupProject - contains the ExternalProject that holds the details
counter - this is a long that the value will be set to in the stored project.

createUser

public com.opensymphony.user.User createUser(ExternalUser externalUser)
Description copied from interface: ProjectImportPersister
Creates a User in JIRA from the given ExternalUser object. This includes the custom properties as well as the standard ones.

Specified by:
createUser in interface ProjectImportPersister
Parameters:
externalUser - ExternalUser containing the data to use to create the new User.
Returns:
The User that was created (null if it couldn't be created).

createAttachment

public Attachment createAttachment(ExternalAttachment externalAttachment)
Description copied from interface: ProjectImportPersister
Creates an attachment specified by the ExternalAttachment. This will create a database entry for the attachment and will copy the file from its current path, specified by ExternalAttachment.getAttachedFile() to the JIRA attachment directory.

Specified by:
createAttachment in interface ProjectImportPersister
Parameters:
externalAttachment - specifies the issue id and attachment details for the attachment to create.
Returns:
the created Attachment, null if the attachment was not created.


Copyright © 2002-2011 Atlassian. All Rights Reserved.