com.atlassian.jira.util
Class MantisImportBean

java.lang.Object
  extended bycom.atlassian.jira.util.MantisImportBean
Direct Known Subclasses:
CustomMantisImportBean

public class MantisImportBean
extends java.lang.Object


Nested Class Summary
static class MantisImportBean.DefaultMappingBean
          Class mapping Mantis ids (see lang/strings_english.txt in the Mantis source) to JIRA IDs
protected static interface MantisImportBean.MappingBean
           
 class MantisImportBean.UserRole
           
 
Field Summary
(package private)  java.lang.StringBuffer importLog
           
static java.lang.String MANTIS_ID_CF_NAME
           
static java.text.DecimalFormat MANTIS_ID_FORMAT
           
static java.lang.String MANTIS_ID_TYPE
           
 
Constructor Summary
MantisImportBean()
           
 
Method Summary
 java.lang.String cleanMantisFilename(java.lang.String filename)
          Return a clean filename from Mantis - internal format.
protected static void closePS(java.sql.PreparedStatement ps)
           
protected  void createChangeHistory(int bug_id, org.ofbiz.core.entity.GenericValue issue)
          Store the original mantis bug id in the change history.
protected  boolean createComponent(java.lang.String projectName, java.lang.String componentName, java.lang.String description)
           
protected  void createFixForVersionAssociation(int mantisStatus, org.ofbiz.core.entity.GenericValue issue, java.lang.String project, java.lang.String component)
           
protected  void createMantisCustomField(int bug_id, org.ofbiz.core.entity.GenericValue issue)
           
protected  boolean createProject(java.lang.String product, java.lang.String description)
           
protected  com.opensymphony.user.User createUser(java.lang.String mantisEmail, java.lang.String mantisUsername, int mantisUserid, java.lang.String fullName, java.lang.String password)
           
protected  boolean createVersion(java.lang.String project, java.lang.String versionName)
           
 void doImport(MantisImportBean.MappingBean mappingBean, DatabaseConnectionBean connectionBean, boolean enableNotifications, boolean reuseExistingUsers, boolean addToDevelopersGroup, boolean reindex, java.lang.String[] projectNames, com.opensymphony.user.User importer)
          Main method of this bean.
 java.lang.String escapeMantisString(java.lang.String str)
           
static java.util.List getAllMantisProjects(DatabaseConnectionBean connectionBean)
          Get a list of available Mantis projects.
 java.lang.String getFullNameFromEmail(java.lang.String email, java.lang.String username)
          Infers the user's full name from other information.
 java.lang.String getImportLog()
           
protected  int getMantisFeaturePriority()
          In Mantis, 'features' are just 'bugs' with a priority of 'feature'.
 java.lang.Integer getMantisIdFromString(java.lang.String s)
          Return an integer prefix of a string, if any.
protected  java.lang.String getMantisUsername(java.sql.ResultSet resultSet)
          Return a JIRA username from a row in the Mantis user table.
 java.lang.String getProjectKey(java.lang.String name)
           
 java.lang.String getProjectList(java.lang.String[] selectList)
          Generate SQL-friendly quoted comma-separated list of projects.
protected  void importAttachments(java.sql.Connection conn, java.sql.PreparedStatement attachPrepStatement, int bug_id, org.ofbiz.core.entity.GenericValue issue)
           
protected  void importComments(java.sql.Connection conn, int bug_id, org.ofbiz.core.entity.GenericValue issue)
           
protected  void importComponents(java.sql.Connection conn, java.lang.String projectName, int projectId)
           
protected  org.ofbiz.core.entity.GenericValue importIssue(java.sql.ResultSet resultSet, java.sql.Connection conn, java.sql.ResultSet textResultSet, java.lang.String projectName)
          Import an issue from Mantis
protected  void importIssues(java.sql.Connection conn, java.lang.String projectName, int projectId)
           
protected  void importProjects(java.sql.Connection conn, java.lang.String selectedProjects)
           
protected  void importUser(java.sql.Connection conn, int mantisId)
           
protected  void importVersions(java.sql.Connection conn, java.lang.String projectName, int projectId)
           
protected  void log(java.lang.String s)
           
protected  void logAttachmentLocation(java.lang.String diskfile, java.io.File jiraAttachFile)
          Hook for recording which Mantis attachment filename maps to which JIRA attachment filename.
protected  java.util.Map retrieveImportedIssues()
          Return a map of mantisKey (Integer) -> Jira Issues Id (Integer).
 java.lang.String rewriteMantisBuglinks(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

importLog

java.lang.StringBuffer importLog

MANTIS_ID_CF_NAME

public static final java.lang.String MANTIS_ID_CF_NAME
See Also:
Constant Field Values

MANTIS_ID_FORMAT

public static final java.text.DecimalFormat MANTIS_ID_FORMAT

MANTIS_ID_TYPE

public static final java.lang.String MANTIS_ID_TYPE
See Also:
Constant Field Values
Constructor Detail

MantisImportBean

public MantisImportBean()
Method Detail

getAllMantisProjects

public static java.util.List getAllMantisProjects(DatabaseConnectionBean connectionBean)
                                           throws java.sql.SQLException
Get a list of available Mantis projects.

Throws:
java.sql.SQLException

doImport

public void doImport(MantisImportBean.MappingBean mappingBean,
                     DatabaseConnectionBean connectionBean,
                     boolean enableNotifications,
                     boolean reuseExistingUsers,
                     boolean addToDevelopersGroup,
                     boolean reindex,
                     java.lang.String[] projectNames,
                     com.opensymphony.user.User importer)
              throws java.lang.Exception,
                     IndexException,
                     org.ofbiz.core.entity.GenericEntityException
Main method of this bean. Creates JIRA projects mirroring those found in a Mantis database.

Parameters:
mappingBean - Mappings from Mantis to JIRA, including project key, statuses, etc
enableNotifications - Whether to send email notifications for newly created issues
reuseExistingUsers - Do we try to reuse existing users, or doImport a unique user for every Mantis user?
addToDevelopersGroup - Whether to add new users to the 'jira-developers' group
reindex - Whether to reindex after the import
projectNames - Array of Mantis project names to import
importer - User doing the import
Throws:
java.lang.Exception
IndexException
org.ofbiz.core.entity.GenericEntityException

getProjectList

public java.lang.String getProjectList(java.lang.String[] selectList)
Generate SQL-friendly quoted comma-separated list of projects.


importIssues

protected void importIssues(java.sql.Connection conn,
                            java.lang.String projectName,
                            int projectId)
                     throws java.lang.Exception,
                            com.opensymphony.workflow.InvalidRoleException,
                            com.opensymphony.workflow.InvalidInputException,
                            CreateException,
                            java.sql.SQLException
Throws:
java.lang.Exception
com.opensymphony.workflow.InvalidRoleException
com.opensymphony.workflow.InvalidInputException
CreateException
java.sql.SQLException

importIssue

protected org.ofbiz.core.entity.GenericValue importIssue(java.sql.ResultSet resultSet,
                                                         java.sql.Connection conn,
                                                         java.sql.ResultSet textResultSet,
                                                         java.lang.String projectName)
                                                  throws java.lang.Exception,
                                                         com.opensymphony.workflow.InvalidRoleException,
                                                         com.opensymphony.workflow.InvalidInputException,
                                                         CreateException,
                                                         java.sql.SQLException
Import an issue from Mantis

Parameters:
resultSet - mantis_bug_table row
conn - JDBC Connection
textResultSet - mantis_bug_text_table row
projectName - Name of issue's project
Returns:
Imported Issue
Throws:
java.lang.Exception
com.opensymphony.workflow.InvalidRoleException
com.opensymphony.workflow.InvalidInputException
CreateException
java.sql.SQLException

getMantisFeaturePriority

protected int getMantisFeaturePriority()
In Mantis, 'features' are just 'bugs' with a priority of 'feature'. In JIRA we have a separate 'Feature' entity, which needs to be assigned a priority. This method chooses that default priority.


escapeMantisString

public java.lang.String escapeMantisString(java.lang.String str)

rewriteMantisBuglinks

public java.lang.String rewriteMantisBuglinks(java.lang.String str)

getMantisIdFromString

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


createFixForVersionAssociation

protected void createFixForVersionAssociation(int mantisStatus,
                                              org.ofbiz.core.entity.GenericValue issue,
                                              java.lang.String project,
                                              java.lang.String component)
                                       throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

importComments

protected void importComments(java.sql.Connection conn,
                              int bug_id,
                              org.ofbiz.core.entity.GenericValue issue)
                       throws java.lang.Exception,
                              org.ofbiz.core.entity.GenericEntityException
Throws:
java.lang.Exception
org.ofbiz.core.entity.GenericEntityException

createChangeHistory

protected void createChangeHistory(int bug_id,
                                   org.ofbiz.core.entity.GenericValue issue)
                            throws java.lang.Exception
Store the original mantis bug id in the change history.

Throws:
java.lang.Exception

createMantisCustomField

protected void createMantisCustomField(int bug_id,
                                       org.ofbiz.core.entity.GenericValue issue)
                                throws java.lang.Exception
Throws:
java.lang.Exception

retrieveImportedIssues

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

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

Throws:
org.ofbiz.core.entity.GenericEntityException

importComponents

protected void importComponents(java.sql.Connection conn,
                                java.lang.String projectName,
                                int projectId)
                         throws java.sql.SQLException,
                                org.ofbiz.core.entity.GenericEntityException
Throws:
java.sql.SQLException
org.ofbiz.core.entity.GenericEntityException

createComponent

protected boolean createComponent(java.lang.String projectName,
                                  java.lang.String componentName,
                                  java.lang.String description)
                           throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

importVersions

protected void importVersions(java.sql.Connection conn,
                              java.lang.String projectName,
                              int projectId)
                       throws java.sql.SQLException,
                              org.ofbiz.core.entity.GenericEntityException
Throws:
java.sql.SQLException
org.ofbiz.core.entity.GenericEntityException

createVersion

protected boolean createVersion(java.lang.String project,
                                java.lang.String versionName)
                         throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

importProjects

protected void importProjects(java.sql.Connection conn,
                              java.lang.String selectedProjects)
                       throws java.lang.Exception,
                              org.ofbiz.core.entity.GenericEntityException,
                              com.opensymphony.workflow.InvalidInputException
Throws:
java.lang.Exception
org.ofbiz.core.entity.GenericEntityException
com.opensymphony.workflow.InvalidInputException

createProject

protected boolean createProject(java.lang.String product,
                                java.lang.String description)
                         throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

importUser

protected void importUser(java.sql.Connection conn,
                          int mantisId)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getMantisUsername

protected java.lang.String getMantisUsername(java.sql.ResultSet resultSet)
                                      throws java.sql.SQLException
Return a JIRA username from a row in the Mantis user table.

Throws:
java.sql.SQLException

createUser

protected com.opensymphony.user.User createUser(java.lang.String mantisEmail,
                                                java.lang.String mantisUsername,
                                                int mantisUserid,
                                                java.lang.String fullName,
                                                java.lang.String password)

importAttachments

protected void importAttachments(java.sql.Connection conn,
                                 java.sql.PreparedStatement attachPrepStatement,
                                 int bug_id,
                                 org.ofbiz.core.entity.GenericValue issue)
                          throws java.lang.Exception
Throws:
java.lang.Exception

cleanMantisFilename

public java.lang.String cleanMantisFilename(java.lang.String filename)
Return a clean filename from Mantis - internal format.


logAttachmentLocation

protected void logAttachmentLocation(java.lang.String diskfile,
                                     java.io.File jiraAttachFile)
                              throws java.io.IOException
Hook for recording which Mantis attachment filename maps to which JIRA attachment filename.

Throws:
java.io.IOException

getProjectKey

public java.lang.String getProjectKey(java.lang.String name)

getFullNameFromEmail

public java.lang.String getFullNameFromEmail(java.lang.String email,
                                             java.lang.String username)
Infers the user's full name from other information. This default implementation returns 'John Smith' for john.smith@example.com, and otherwise defaults to the Mantis username.


log

protected void log(java.lang.String s)

closePS

protected static void closePS(java.sql.PreparedStatement ps)

getImportLog

public java.lang.String getImportLog()


Copyright © 2002-2005 Atlassian. All Rights Reserved.