com.atlassian.jira.util
Class BugzillaImportBean

java.lang.Object
  extended by com.atlassian.jira.util.BugzillaImportBean

public class BugzillaImportBean
extends Object


Nested Class Summary
static class BugzillaImportBean.DefaultBugzillaMappingBean
           
 
Field Summary
static String BUGZILLA_ID_CF_NAME
           
static String BUGZILLA_ID_SEARCHER
           
static String BUGZILLA_ID_TYPE
           
 
Constructor Summary
BugzillaImportBean(IssueIndexManager indexManager, org.ofbiz.core.entity.GenericDelegator genericDelegator, ProjectManager projectManager, PermissionSchemeManager permissionSchemeManager, CacheManager cacheManager, VersionManager versionManager, VoteManager voteManager, ProjectComponentManager projectComponentManager, CustomFieldManager customFieldManager, IssueManager issueManager, AttachmentManager attachmentManager, IssueTypeScreenSchemeManager issueTypeScreenSchemeManager, PermissionManager permissionManager, IssueLinkManager issueLinkManager, IssueLinkTypeManager issueLinkTypeManager, ConstantsManager constantsManager, ExternalUtils externalUtils, CommentManager commentManager, IssueFactory issueFactory, WorklogManager worklogManager, ApplicationProperties applicationProperties, WatcherManager watcherManager)
           
 
Method Summary
 String commaSeparate(Collection coll)
          Returns comma-separated text values of a list of objects.
 void create(com.atlassian.jira.util.BugzillaImportBean.BugzillaMappingBean bugzillaMappingBean, BugzillaConnectionBean connectionBean, boolean enableNotifications, boolean reuseExistingUsers, boolean onlyNewIssues, boolean reindex, boolean workHistory, String[] projectNames, User importer)
          Main method of this bean.
static Map getAllBugzillaProjects(BugzillaConnectionBean connectionBean)
           
 String getFullNameFromEmail(String email)
           
 Integer getIdFromStartOfString(String s)
          Return an integer prefix of a string, if any.
 String getImportLog()
           
 Set getNonExistentAssociatedUsers(BugzillaConnectionBean connectionBean, String[] projectNames)
          This method will determine all the users that will need to exist in JIRA to successfully import the specified projects and will return the users that do not yet exist.
 String getProjectKey(String name)
           
 Set getTruncSummaryIssueKeys()
          Returns an unmodifiable set of issue keys that have summaries longer that acceptable by JIRA
protected  String getUsernameFromBugzillaProfile(ResultSet bugzillaProfileResultSet)
          Given a Bugzilla 'profile' user record, infer a JIRA username from it.
static boolean isOldBugzilla(Connection conn)
          By examining the schema, determines if we're importing from <=2.16 or 2.17+
protected  Map retrieveImportedIssues()
          Return a map of bugzillaKey (Integer) -> Jira Issues Id (Integer).
 String rewriteBugLinkInText(String str, String parentIssueKey)
          Rewrite inline bug links ('bug #1234' etc) in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUGZILLA_ID_TYPE

public static final String BUGZILLA_ID_TYPE
See Also:
Constant Field Values

BUGZILLA_ID_SEARCHER

public static final String BUGZILLA_ID_SEARCHER
See Also:
Constant Field Values

BUGZILLA_ID_CF_NAME

public static final String BUGZILLA_ID_CF_NAME
See Also:
Constant Field Values
Constructor Detail

BugzillaImportBean

public BugzillaImportBean(IssueIndexManager indexManager,
                          org.ofbiz.core.entity.GenericDelegator genericDelegator,
                          ProjectManager projectManager,
                          PermissionSchemeManager permissionSchemeManager,
                          CacheManager cacheManager,
                          VersionManager versionManager,
                          VoteManager voteManager,
                          ProjectComponentManager projectComponentManager,
                          CustomFieldManager customFieldManager,
                          IssueManager issueManager,
                          AttachmentManager attachmentManager,
                          IssueTypeScreenSchemeManager issueTypeScreenSchemeManager,
                          PermissionManager permissionManager,
                          IssueLinkManager issueLinkManager,
                          IssueLinkTypeManager issueLinkTypeManager,
                          ConstantsManager constantsManager,
                          ExternalUtils externalUtils,
                          CommentManager commentManager,
                          IssueFactory issueFactory,
                          WorklogManager worklogManager,
                          ApplicationProperties applicationProperties,
                          WatcherManager watcherManager)
Method Detail

getNonExistentAssociatedUsers

public Set getNonExistentAssociatedUsers(BugzillaConnectionBean connectionBean,
                                         String[] projectNames)
This method will determine all the users that will need to exist in JIRA to successfully import the specified projects and will return the users that do not yet exist.

Parameters:
connectionBean - initialized connection bean
projectNames - the projects, by bugzilla project name, that you want to import.
Returns:
Set all the users that will need to exist in JIRA but do not yet.

create

public void create(com.atlassian.jira.util.BugzillaImportBean.BugzillaMappingBean bugzillaMappingBean,
                   BugzillaConnectionBean connectionBean,
                   boolean enableNotifications,
                   boolean reuseExistingUsers,
                   boolean onlyNewIssues,
                   boolean reindex,
                   boolean workHistory,
                   String[] projectNames,
                   User importer)
            throws Exception
Main method of this bean. Creates JIRA projects mirroring those found in a Bugzilla database.

Parameters:
bugzillaMappingBean - Mappings from Bugzilla to JIRA, including project key, statuses, etc
connectionBean - Bugzilla connection bean
enableNotifications - Whether to send email notifications for newly created issues
reuseExistingUsers - Do we try to reuse existing users, or create a unique user for every Bugzilla user?
onlyNewIssues - Should we only import issues that haven't previously been imported (to avoid duplicates)?
reindex - Whether to reindex after the import
workHistory - Whether to import work history as well
projectNames - Array of Bugzilla project names to import
importer - User performing the import operation
Throws:
Exception - if something goes wrong

retrieveImportedIssues

protected Map retrieveImportedIssues()
                              throws org.ofbiz.core.entity.GenericEntityException
Return a map of bugzillaKey (Integer) -> Jira Issues Id (Integer).

It does this by looking through the change items for the bugzilla import key.

Returns:
map of previously imported keys (old to new)
Throws:
org.ofbiz.core.entity.GenericEntityException - if cannot read from change items

commaSeparate

public String commaSeparate(Collection coll)
Returns comma-separated text values of a list of objects.

Parameters:
coll - collection of objects to comma separate
Returns:
comma separated list of Strings of objects from the given collection

getUsernameFromBugzillaProfile

protected String getUsernameFromBugzillaProfile(ResultSet bugzillaProfileResultSet)
                                         throws SQLException
Given a Bugzilla 'profile' user record, infer a JIRA username from it. In Bugzilla your username is your email address, and this will become your JIRA username, unless this method is overridden to implement a different scheme.

Parameters:
bugzillaProfileResultSet - profile result set
Returns:
username
Throws:
SQLException - if reading from result set fails

rewriteBugLinkInText

public String rewriteBugLinkInText(String str,
                                   String parentIssueKey)
Rewrite inline bug links ('bug #1234' etc) in a string.

Parameters:
str - The text to rewrite
parentIssueKey - Issue this text came from (purely for logging).
Returns:
str, with links rewritten.

getIdFromStartOfString

public Integer getIdFromStartOfString(String s)
Return an integer prefix of a string, if any.

Parameters:
s - String containing id
Returns:
id

getProjectKey

public String getProjectKey(String name)
                     throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

getFullNameFromEmail

public String getFullNameFromEmail(String email)

isOldBugzilla

public static boolean isOldBugzilla(Connection conn)
                             throws SQLException
By examining the schema, determines if we're importing from <=2.16 or 2.17+

Parameters:
conn - connection
Returns:
true if connecting to Bugzilla 2.16 or lower
Throws:
SQLException - if cannot read from the database

getImportLog

public String getImportLog()

getAllBugzillaProjects

public static Map getAllBugzillaProjects(BugzillaConnectionBean connectionBean)
                                  throws SQLException
Throws:
SQLException

getTruncSummaryIssueKeys

public Set getTruncSummaryIssueKeys()
Returns an unmodifiable set of issue keys that have summaries longer that acceptable by JIRA

Returns:
an unmodifiable set of issue keys as Strings


Copyright © 2002-2007 Atlassian. All Rights Reserved.