diff --git a/bugextractor/.gitignore b/bugextractor/.gitignore deleted file mode 100644 index d6d97e6f..00000000 --- a/bugextractor/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -target/ -tempConfig*.xml -*.log -*.log.* -*~ -#* diff --git a/bugextractor/INSTALL b/bugextractor/INSTALL deleted file mode 100644 index d42b5699..00000000 --- a/bugextractor/INSTALL +++ /dev/null @@ -1,41 +0,0 @@ -1. Install Maven -2. Configure the proxy server for maven. - Add the below lines to $MAVEN_HOME/conf/settings.xml - NOTE: Please check if section already exists and then add - - - - optional - true - http - XXX - XXX - - - -3. Build b4j project (download from http://download.ralph-schuster.eu/b4j/b4j-1.4.0.tar.gz) - - Untar the sources and apply the patches in patches/b4j: - tar xfv /path/to/b4j-1.4.0.tar.gz - cd b4j-1.4.0 - cat /path/to/patches/b4j/* -p1 - - Then build and install the jar: - mvn clean install -Dmaven.javadoc.skip=true \ - -Dgpg.skip=true -DskipTests=true - - This will create a binary jar and source jar plus an executable jar. - To create a javadoc jar, remove the javadoc skip statement. - To execute tests (requires internet connection) use -DskipTests=false - -4. Build BugExtractor - NOTE: This needs http access since numerous files are downloaded - during the process. - - mvn clean assembly:assembly - - The target jar file will be created in "target" directory with the - name "bugExtractor.jar" - -5. Run BugExtractor - java -jar bugExtractor -c -p diff --git a/bugextractor/pom.xml b/bugextractor/pom.xml deleted file mode 100644 index b71a6e5a..00000000 --- a/bugextractor/pom.xml +++ /dev/null @@ -1,170 +0,0 @@ - - 4.0.0 - - de.siemens.quantarch - BugExtractor - 0.0.1-SNAPSHOT - jar - - BugExtractor - http://maven.apache.org - - - UTF-8 - bugExtractor - - - - - onejar-maven-plugin.googlecode.com - http://onejar-maven-plugin.googlecode.com/svn/mavenrepo - - - - - - - maven-compiler-plugin - 2.0.2 - - 1.6 - 1.6 - - - - maven-assembly-plugin - - false - - - de.siemens.quantarch.bugs.IssueTrackerParser - - - - jar-with-dependencies - - ${jarFileName} - - - - make-assembly - package - - single - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - maven-resources-plugin - [2.4.3,) - - resources - testResources - - - - - - - - - - - - - - - - - - eu.ralph-schuster - b4j - 1.4.0-codeface - - - - org.springframework - spring-core - 3.2.1.RELEASE - - - - org.springframework - spring-jdbc - 3.2.1.RELEASE - - - - org.springframework - spring-context - 3.2.1.RELEASE - - - - commons-dbcp - commons-dbcp - 1.4 - - - - org.jsoup - jsoup - 1.7.2 - - - - log4j - log4j - 1.2.17 - - - - org.yaml - snakeyaml - 1.12 - - - - org.apache.httpcomponents - httpclient - 4.2.4 - - - - commons-cli - commons-cli - 1.2 - - - - net.sf.json-lib - json-lib - 2.4 - jdk15 - - - - junit - junit - 4.11 - test - - - diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTracker.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTracker.java deleted file mode 100644 index 2225ad59..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTracker.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs; - -import de.siemens.quantarch.bugs.dao.IssueTrackerDao; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; - -public interface IssueTracker { - - public void setDao(IssueTrackerDao dao); - - public void setConfig(BugExtractorConfig config); - - public void parseIssues(); -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerFactory.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerFactory.java deleted file mode 100644 index de769b4e..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs; - -import de.siemens.quantarch.bugs.impl.BugzillaTracker; -import de.siemens.quantarch.bugs.impl.JiraTracker; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; - -public class IssueTrackerFactory { - - public static IssueTracker getIssueTracker(BugExtractorConfig config) { - IssueTracker issueTracker = null; - if (config.getIssueTrackerType().equalsIgnoreCase("bugzilla")) { - issueTracker = new BugzillaTracker(); - } else if (config.getIssueTrackerType().equalsIgnoreCase("jira")) { - issueTracker = new JiraTracker(); - } - issueTracker.setConfig(config); - return issueTracker; - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerParser.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerParser.java deleted file mode 100644 index 32e89042..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/IssueTrackerParser.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs; - -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.util.Map; - -import javax.sql.DataSource; - -import org.apache.commons.cli.BasicParser; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.apache.commons.dbcp.BasicDataSource; -import org.yaml.snakeyaml.Yaml; - -import de.siemens.quantarch.bugs.dao.IssueTrackerDao; -import de.siemens.quantarch.bugs.dao.IssueTrackerDaoImpl; -import de.siemens.quantarch.bugs.exceptions.CommandLineArgsException; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; -import de.siemens.quantarch.bugs.utils.StringUtils; - -public class IssueTrackerParser { - - private static Options options = new Options(); - - // the project configuration - private BugExtractorConfig projectConfig = null; - - public IssueTrackerParser(BugExtractorConfig projectConfig) { - this.projectConfig = projectConfig; - } - - /** - * Parse the issues - */ - public void parse() { - IssueTrackerDao dao = new IssueTrackerDaoImpl(buildDataSource(), - projectConfig); - IssueTracker tracker = IssueTrackerFactory - .getIssueTracker(projectConfig); - tracker.setDao(dao); - tracker.parseIssues(); - } - - /** - * Build the database connection - * - * @return - */ - private DataSource buildDataSource() { - // create the data source for database - BasicDataSource dataSource = new BasicDataSource(); - dataSource.setDriverClassName("com.mysql.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://" + projectConfig.getDbHost() - + ":3306/" + projectConfig.getDbName()); - dataSource.setUsername(projectConfig.getDbUser()); - dataSource.setPassword(projectConfig.getDbPassword()); - dataSource.setInitialSize(30); - return dataSource; - } - - public static void main(String[] args) { - // build project options - buildOptions(); - - // check if any arguments are given - if (args.length < 1) { - printUsage(); - return; - } - - String globalConfig = null; - String projectConfig = null; - - // ** now lets parse the input - CommandLineParser cliParser = new BasicParser(); - CommandLine cmd = null; - try { - cmd = cliParser.parse(options, args); - } catch (ParseException pe) { - System.out.println("Duh. Parse Exception: " + pe.getMessage()); - - printUsage(); - return; - } - - // check if the options have been provided - if (cmd.hasOption("c") && cmd.hasOption("p")) { - globalConfig = cmd.getOptionValue('c'); - projectConfig = cmd.getOptionValue('p'); - } else { - printUsage(); - return; - } - - BugExtractorConfig config = new BugExtractorConfig(); - // parse the global configuration file - try { - parseGlobalConfiguration(globalConfig, config); - } catch (CommandLineArgsException e) { - System.out.println("Could not parse global config " + - "file: " + e.getMessage()); - return; - } - - // Parse the project specific YAML file - try { - parseProjectConfiguration(projectConfig, config); - } catch (CommandLineArgsException e) { - System.out.println("Could not parse project config " + - "file: " + e.getMessage()); - return; - } - - IssueTrackerParser parser = new IssueTrackerParser(config); - parser.parse(); - } - - /** - * Parse the project specific configuration file provided in the command - * line - * - * @param projectConfigFile - * @param config - */ - private static void parseProjectConfiguration(String projectConfigFile, - BugExtractorConfig config) throws CommandLineArgsException { - Reader projectFileReader = null; - try { - Yaml projectConfigYaml = new Yaml(); - projectFileReader = new FileReader(projectConfigFile); - @SuppressWarnings("unchecked") - Map map = (Map) projectConfigYaml - .load(projectFileReader); - // NOTE: project denotes the identifier name used in - // the database, whereas bugsProject is the name - // used for bugzilla. - String project = (String) map.get("project"); - String bugsProject = (String) map.get("bugsProjectName"); - String issueTrackerType = (String) map.get("issueTrackerType"); - String issueTrackerURL = (String) map.get("issueTrackerURL"); - Boolean productAsProject = (Boolean) map.get("productAsProject"); - if (StringUtils.isBlankOrNull(project) || - StringUtils.isBlankOrNull(bugsProject) - || StringUtils.isBlankOrNull(issueTrackerURL) - || StringUtils.isBlankOrNull(issueTrackerType) - || null == productAsProject) { - throw new CommandLineArgsException( - "Improper Project Configuration file supplied\n\n"); - } - - config.setIssueTrackerType(issueTrackerType); - config.setIssueTrackerURL(issueTrackerURL); - config.setProjectName(project); - config.setBugsProjectName(bugsProject); - config.setProductAsProject(productAsProject); - } catch (FileNotFoundException e) { - throw new CommandLineArgsException("The global configuration file " - + projectConfigFile + " does not exist"); - } finally { - if (null != projectFileReader) { - try { - projectFileReader.close(); - } catch (final IOException ioe) { - System.err - .println("We got the following exception trying to clean up the reader: " - + ioe); - } - } - } - } - - /** - * Parse the global configuration file provided in the command line - * - * @param globalConfigFile - * @param config - * @throws CommandLineArgsException - */ - private static void parseGlobalConfiguration(String globalConfigFile, - BugExtractorConfig config) throws CommandLineArgsException { - // parse the global configuration details - Reader globalFileReader = null; - try { - Yaml globalConfigYaml = new Yaml(); - globalFileReader = new FileReader(globalConfigFile); - @SuppressWarnings("unchecked") - Map map = (Map) globalConfigYaml - .load(globalFileReader); - String dbHost = (String) map.get("dbhost"); - String dbUser = (String) map.get("dbuser"); - String dbPwd = (String) map.get("dbpwd"); - String dbName = (String) map.get("dbname"); - String proxyHost = (String) map.get("proxyHost"); - Integer proxyPort = (Integer) map.get("proxyPort"); - Integer sleepTime = (Integer) map.get("sleepTime"); - String personServiceHostname = (String) map.get("idServiceHostname"); - Integer personServicePort = (Integer) map.get("idServicePort"); - - // Null and empty checks on all the necessary values - if (StringUtils.isBlankOrNull(dbHost) - || StringUtils.isBlankOrNull(dbUser) - || StringUtils.isBlankOrNull(dbPwd) - || StringUtils.isBlankOrNull(dbName) - || StringUtils.isBlankOrNull(personServiceHostname)) { - throw new CommandLineArgsException( - "Improper Global Configuration file supplied"); - } - - // set configuration - config.setDbHost(dbHost); - config.setDbName(dbName); - config.setDbPassword(dbPwd); - config.setDbUser(dbUser); - config.setSleepTimeOut(sleepTime); - config.setPersonServiceURL("http://" + personServiceHostname + ":" + personServicePort); - - // set proxy server configuration if specified - if (null != proxyHost) { - config.setProxyHost(proxyHost); - System.setProperty("http.proxyHost", proxyHost); - System.setProperty("https.proxyHost", proxyHost); - } - if (null != proxyPort) { - config.setProxyPort(proxyPort); - System.setProperty("http.proxyPort", - Integer.toString(proxyPort)); - System.setProperty("https.proxyPort", - Integer.toString(proxyPort)); - } - } catch (FileNotFoundException e) { - throw new CommandLineArgsException("The global configuration file " - + globalConfigFile + " does not exist"); - } finally { - if (null != globalFileReader) { - try { - globalFileReader.close(); - } catch (final IOException ioe) { - System.err - .println("We got the following exception trying to clean up the reader: " - + ioe); - } - } - } - } - - private static void buildOptions() { - options.addOption("c", true, "global configuration file"); - options.addOption("p", true, "project configuration file"); - } - - private static void printUsage() { - // Use the inbuilt formatter class - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("java -jar BugExtractor.jar", options); - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDao.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDao.java deleted file mode 100644 index 3dd82459..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.dao; - -import java.util.List; - -import de.siemens.quantarch.bugs.history.BugHistory; - -import b4j.core.Issue; - -public interface IssueTrackerDao { - - public long addIssue(Issue issue, long projectId, - List bugHistoryList); - - public long getProjectId(String name); - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDaoImpl.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDaoImpl.java deleted file mode 100644 index 8edc74af..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/dao/IssueTrackerDaoImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.dao; - -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.jdbc.core.simple.SimpleJdbcInsert; -import org.springframework.jdbc.core.support.JdbcDaoSupport; - -import b4j.core.Issue; -import b4j.core.LongDescription; -import de.siemens.quantarch.bugs.history.BugHistory; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; -import de.siemens.quantarch.personService.PersonServiceClient; - -public class IssueTrackerDaoImpl extends JdbcDaoSupport implements - IssueTrackerDao { - - private BugExtractorConfig projectConfig = null; - - public IssueTrackerDaoImpl(DataSource dataSource, - BugExtractorConfig projectConfig) { - setDataSource(dataSource); - this.projectConfig = projectConfig; - } - - @Override - public long addIssue(Issue issue, long projectId, - List bugHistoryList) { - - // Step 4: Add the users - // a> Created By - long createdBy = PersonServiceClient.getPerson(issue.getReporterName(), - issue.getReporter(), projectId, - projectConfig.getPersonServiceURL()); - long assignee = PersonServiceClient.getPerson(issue.getAssigneeName(), - issue.getAssignee(), projectId, - projectConfig.getPersonServiceURL()); - - // Step 5: Add the issue - // now add the issue record - SimpleJdbcInsert insertPerson = new SimpleJdbcInsert(getDataSource()) - .withTableName("issue").usingGeneratedKeyColumns("id"); - Map parameters = new HashMap(); - parameters.put("bugId", issue.getId()); - parameters.put("creationDate", issue.getCreationTimestamp()); - parameters.put("modifiedDate", issue.getDeltaTimestamp()); - parameters.put("url", null); - parameters.put("isRegression", 0); - parameters.put("status", issue.getStatus()); - parameters.put("resolution", issue.getResolution()); - parameters.put("severity", issue.getSeverity()); - parameters.put("priority", issue.getPriority()); - parameters.put("createdBy", createdBy); - parameters.put("assignedTo", assignee); - parameters.put("projectId", projectId); - - if (projectConfig.isProductAsProject()) { - // when product is parsed as a project - // component becomes subComponent and subSubComponent is null - parameters.put("subComponent", issue.getComponent()); - } else { - parameters.put("subComponent", issue.getProduct()); - parameters.put("subSubComponent", issue.getComponent()); - } - - parameters.put("version", issue.getVersion()); - - Number newId = insertPerson.executeAndReturnKey(parameters); - long issueId = newId.longValue(); - - // Step 6: Populate cc list of the issue - Iterator iter = issue.getCcIterator(); - while (iter.hasNext()) { - String cc = iter.next(); - long ccUser = PersonServiceClient.getPerson(null, cc, projectId, - projectConfig.getPersonServiceURL()); - getJdbcTemplate().update( - "INSERT INTO cc_list (issueId,who) VALUES(?,?)", issueId, - ccUser); - } - - // Step 7: Populate issue communication / comments - Iterator longDescIter = issue - .getLongDescriptionIterator(); - while (longDescIter.hasNext()) { - LongDescription desc = longDescIter.next(); - Date date = desc.getWhen(); - String who = desc.getWho(); - long commentUser = PersonServiceClient.getPerson( - desc.getAuthorName(), who, projectId, - projectConfig.getPersonServiceURL()); - getJdbcTemplate() - .update("INSERT INTO issue_comment (who,fk_issueId,commentDate) VALUES(?,?,?)", - commentUser, issueId, date); - } - - // Step 8: add the bug history - for (BugHistory record : bugHistoryList) { - addBugHistory(record, issueId, projectId); - } - - return issueId; - } - - /** - * Populate the issue_history table with the history data of the issue - * - * @param history - * @param issueId - * @param projectId - */ - private void addBugHistory(BugHistory history, long issueId, long projectId) { - SimpleJdbcInsert insertPerson = new SimpleJdbcInsert(getDataSource()) - .withTableName("issue_history").usingGeneratedKeyColumns("id"); - Map parameters = new HashMap(2); - parameters.put("field", history.getField()); - parameters.put("changeDate", history.getWhen()); - parameters.put("oldValue", history.getOldValue()); - parameters.put("newValue", history.getNewValue()); - parameters.put("issueId", issueId); - - // get the person who changed the history - long commentUser = PersonServiceClient.getPerson(null, - history.getWho(), projectId, - projectConfig.getPersonServiceURL()); - parameters.put("who", commentUser); - insertPerson.executeAndReturnKey(parameters); - } - - @Override - public long getProjectId(String name) { - long projectId = -1; - try { - projectId = getJdbcTemplate().queryForObject( - "SELECT id FROM project WHERE name = ?", - new Object[] { name }, Long.class); - } catch (EmptyResultDataAccessException e) { - return -1; - } - return projectId; - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/exceptions/CommandLineArgsException.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/exceptions/CommandLineArgsException.java deleted file mode 100644 index 75ca405c..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/exceptions/CommandLineArgsException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.exceptions; - -public class CommandLineArgsException extends Exception { - - private static final long serialVersionUID = -5797860031871610760L; - - public CommandLineArgsException(String msg) { - super(msg); - } - - public CommandLineArgsException() { - super(); - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/BugHistory.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/BugHistory.java deleted file mode 100644 index d2ab3825..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/BugHistory.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.history; - -import java.util.Date; - -public class BugHistory { - - private String who; - private Date when; - private String field; - private String oldValue; - private String newValue; - - /** - * @return the who - */ - public String getWho() { - return who; - } - - /** - * @param who - * the who to set - */ - public void setWho(String who) { - this.who = who; - } - - /** - * @return the when - */ - public Date getWhen() { - return when; - } - - /** - * @param when - * the when to set - */ - public void setWhen(Date when) { - this.when = when; - } - - /** - * @return the field - */ - public String getField() { - return field; - } - - /** - * @param field - * the field to set - */ - public void setField(String field) { - this.field = field; - } - - /** - * @return the oldValue - */ - public String getOldValue() { - return oldValue; - } - - /** - * @param oldValue - * the oldValue to set - */ - public void setOldValue(String oldValue) { - this.oldValue = oldValue; - } - - /** - * @return the newValue - */ - public String getNewValue() { - return newValue; - } - - /** - * @param newValue - * the newValue to set - */ - public void setNewValue(String newValue) { - this.newValue = newValue; - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/FetchHistory.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/FetchHistory.java deleted file mode 100644 index d098b68c..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/FetchHistory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.history; - -import java.util.List; - -public interface FetchHistory { - - /** - * Fetch the bug history given the bugId - * - * @param bugId - * @return List of changes done to the Status and Severity of the bug - */ - public List fetchBugHistory(String bugId); - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/GenericHistoryFetcher.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/GenericHistoryFetcher.java deleted file mode 100644 index 3a332617..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/history/GenericHistoryFetcher.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.history; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -public class GenericHistoryFetcher implements FetchHistory { - - private String bugzillaURL = null; - - public GenericHistoryFetcher(String bugzillaURL) { - this.bugzillaURL = bugzillaURL; - } - - private static Logger log = Logger.getLogger(GenericHistoryFetcher.class); - - @Override - public List fetchBugHistory(String bugId) { - List bugHistoryList = new ArrayList(); - log.info("Fetching history details for bug: " + bugId); - String bugzillaHistoryURL = bugzillaURL + "/show_activity.cgi?id=" - + bugId; - log.debug("Bugzilla URL to fetch history:" + bugzillaHistoryURL); - try { - // set the jsoup connection timeout from 3 seconds to 10 seconds. - Document doc = Jsoup.connect(bugzillaHistoryURL).timeout(10 * 1000) - .get(); - String[] tags = { "Status", "Severity", "Resolution" }; - for (String tag : tags) { - Elements tableRows = doc.select("div#bugzilla-body") - .select("table").select("tbody") - .select("tr td:contains(" + tag + ")"); - for (Element row : tableRows) { - BugHistory history = new BugHistory(); - history.setField(tag); - Element rowEle = row.parent(); - Element pickUpUserDetailsElement = null; - if (rowEle.children().size() != 5) { - Element elem = rowEle.previousElementSibling(); - if (!elem.children().first().hasAttr("rowspan")) { - while (!elem.children().first().hasAttr("rowspan")) { - elem = elem.previousElementSibling(); - } - } - pickUpUserDetailsElement = elem; - } else { - pickUpUserDetailsElement = rowEle; - } - - String who = null; - Element whoEle = pickUpUserDetailsElement.children() - .first(); - who = whoEle.text(); - history.setWho(who); - - String when = null; - Element whenEle = whoEle.nextElementSibling(); - when = whenEle.text().trim(); - history.setWhen(getDateFromString(when)); - - Elements rowEleChildren = rowEle.children(); - for (Element content : rowEleChildren) { - if (content.text().trim().equalsIgnoreCase(tag)) { - history.setField(tag); - history.setOldValue(content.nextElementSibling() - .text()); - history.setNewValue(content.nextElementSibling() - .nextElementSibling().text()); - } - } - bugHistoryList.add(history); - } - } - } catch (IOException e) { - log.error("Error occured while fetching history details for bug : " - + bugId, e); - } - return bugHistoryList; - } - - private static Date getDateFromString(String dateString) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-d HH:mm:ss"); - Date date = null; - try { - date = dateFormat.parse(dateString); - } catch (ParseException e) { - e.printStackTrace(); - } - return date; - } - - public static void main(String[] args) throws IOException { - FetchHistory historyFetcher = new GenericHistoryFetcher( - "https://bugzilla.kernel.org"); - List historyList = historyFetcher.fetchBugHistory("2082"); - for (BugHistory history : historyList) { - System.out.println(history.getWho()); - System.out.println(history.getWhen()); - System.out.println(history.getField()); - System.out.println(history.getOldValue()); - System.out.println(history.getNewValue()); - System.out.println("------------------------------------"); - } - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/BugzillaTracker.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/BugzillaTracker.java deleted file mode 100644 index d29ffd4d..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/BugzillaTracker.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.impl; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.XMLConfiguration; -import org.apache.log4j.Logger; - -import b4j.core.DefaultSearchData; -import b4j.core.Issue; -import b4j.core.session.HttpBugzillaSession; -import de.siemens.quantarch.bugs.IssueTracker; -import de.siemens.quantarch.bugs.dao.IssueTrackerDao; -import de.siemens.quantarch.bugs.history.BugHistory; -import de.siemens.quantarch.bugs.history.FetchHistory; -import de.siemens.quantarch.bugs.history.GenericHistoryFetcher; -import de.siemens.quantarch.bugs.scraper.GenericProductFetcher; -import de.siemens.quantarch.bugs.scraper.GenericStatusFetcher; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; -import de.siemens.quantarch.bugs.utils.StringUtils; - -public class BugzillaTracker implements IssueTracker { - - private IssueTrackerDao dao; - private static final String CONFIG_FILE_WITHOUT_PROXY = "$BUGZILLA_URL$"; - private static final String CONFIG_FILE_WITH_PROXY = "$PROXY_HOST$$BUGZILLA_URL$"; - private static Logger log = Logger.getLogger(BugzillaTracker.class); - - // variables just to keep track - private String stat = null; - private String prod = null; - - private BugExtractorConfig config; - - @Override - public void setDao(IssueTrackerDao dao) { - this.dao = dao; - } - - @Override - public void setConfig(BugExtractorConfig config) { - this.config = config; - } - - @Override - public void parseIssues() { - GenericStatusFetcher statusFetcher = new GenericStatusFetcher(); - GenericProductFetcher productFetcher = new GenericProductFetcher(); - // get the projectId for the given name - long projectId = dao.getProjectId(config.getProjectName()); - if (-1 == projectId) { - log.error("Project with name: " + config.getProjectName() - + " does not exist in the database"); - return; - } - - // history fetcher - FetchHistory historyFetcher = new GenericHistoryFetcher( - config.getIssueTrackerURL()); - - // Step 1: create a temporary xml configuration file - // for b4j using bugzillaURL, proxy server and proxy port - File tempFile = null; - HttpBugzillaSession session = null; - try { - tempFile = new File("tempConfig " + new Date().getTime() + ".xml"); - writeIntoConfigFile(tempFile, config.getIssueTrackerURL(), - config.getProxyHost(), config.getProxyPort()); - - // Step 2: Parse bugs based on Products and Statuses - List products = new ArrayList(); - if (config.isProductAsProject()) { - products.add(config.getBugsProjectName()); - } else { - products.addAll(productFetcher.fetchProducts(config - .getIssueTrackerURL())); - } - - List statuses = statusFetcher.fetchStatus(config - .getIssueTrackerURL()); - - XMLConfiguration myConfig; - myConfig = new XMLConfiguration(tempFile); - - // Create the session - session = new HttpBugzillaSession(); - session.configure(myConfig); - - if (session.open()) { - for (String status : statuses) { - for (String product : products) { - // to maintain the names - stat = status; - prod = product; - - DefaultSearchData searchData = new DefaultSearchData(); - // Don't limit the search to 500 responses, but allow for an arbitrary amount - searchData.add("limit", "0"); - searchData.add("product", - URLEncoder.encode(product, "UTF-8")); - searchData.add("bug_status", status); - Iterator issueIter = session.searchBugs( - searchData, null); - - while (issueIter.hasNext()) { - Issue issue = issueIter.next(); - List bugHistoryList = historyFetcher - .fetchBugHistory(issue.getId()); - dao.addIssue(issue, projectId, bugHistoryList); - - // sleep after parsing every bug (as the proxy - // will block connections) - // Even ISPs would block connections thinkg that - // this is a DDoS attack - try { - Thread.sleep(config.getSleepTimeOut()); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - log.info("Product: " + prod + " Status: " + stat - + " DONE"); - } - } - } - } catch (IOException e) { - log.error(e); - } catch (ConfigurationException e) { - log.error(e); - } finally { - // close the HTTP Session - if (null != session) { - session.close(); - } - - // delete the temporary configuration file - if (null != tempFile) { - if (tempFile.exists()) { - tempFile.delete(); - } - } - } - } - - private void writeIntoConfigFile(File file, String bugzillaURL, - String proxyServer, int proxyPort) throws IOException { - // if file doesn't exists, then create it - if (!file.exists()) { - file.createNewFile(); - } - - // check if proxy configuration is needed - String finalString = null; - if (StringUtils.isBlankOrNull(proxyServer)) { - finalString = CONFIG_FILE_WITHOUT_PROXY.replace("$BUGZILLA_URL$", - bugzillaURL); - } else { - finalString = CONFIG_FILE_WITH_PROXY.replace("$BUGZILLA_URL$", - bugzillaURL).replace("$PROXY_HOST$", - proxyServer + ":" + proxyPort); - } - FileWriter fw = new FileWriter(file.getAbsoluteFile()); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(finalString); - bw.close(); - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/JiraTracker.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/JiraTracker.java deleted file mode 100644 index d40d4ca5..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/impl/JiraTracker.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.impl; - -import de.siemens.quantarch.bugs.IssueTracker; -import de.siemens.quantarch.bugs.dao.IssueTrackerDao; -import de.siemens.quantarch.bugs.utils.BugExtractorConfig; - -@SuppressWarnings("unused") -public class JiraTracker implements IssueTracker { - - private IssueTrackerDao dao; - private BugExtractorConfig config; - - @Override - public void setDao(IssueTrackerDao dao) { - this.dao = dao; - } - - @Override - public void setConfig(BugExtractorConfig config) { - this.config = config; - } - - @Override - public void parseIssues() { - System.out.println("Not yet implemented"); - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericProductFetcher.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericProductFetcher.java deleted file mode 100644 index e2c53835..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericProductFetcher.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.scraper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import de.siemens.quantarch.bugs.utils.StringUtils; - -public class GenericProductFetcher implements ProductFetcher { - - private static Logger log = Logger.getLogger(GenericProductFetcher.class); - - @Override - public List fetchProducts(String bugzillaURL) { - - List products = new ArrayList(); - log.info("Fetching product details"); - String bugzillaProductURL = bugzillaURL + "/query.cgi"; - log.debug("Bugzilla URL to fetch history:" + bugzillaProductURL); - try { - - // set the jsoup connection timeout from 3 seconds to 10 seconds. - Document doc = Jsoup.connect(bugzillaProductURL).timeout(10 * 1000) - .get(); - Elements options = doc.select("#product option"); - for (Element elem : options) { - String value = elem.attr("value"); - if (!StringUtils.isBlankOrNull(value)) { - products.add(value); - } - } - - } catch (IOException e) { - log.error("Error occured while fetching product details for bug"); - } - return products; - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericStatusFetcher.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericStatusFetcher.java deleted file mode 100644 index 82bd1245..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/GenericStatusFetcher.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.scraper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import de.siemens.quantarch.bugs.utils.StringUtils; - -public class GenericStatusFetcher implements StatusFetcher { - - private static Logger log = Logger.getLogger(GenericStatusFetcher.class); - - @Override - public List fetchStatus(String bugzillaURL) { - - List products = new ArrayList(); - log.info("Fetching status details"); - String bugzillaProductURL = bugzillaURL + "/query.cgi?format=advanced"; - log.debug("Bugzilla URL to fetch details:" + bugzillaProductURL); - try { - - // set the jsoup connection timeout from 3 seconds to 10 seconds. - Document doc = Jsoup.connect(bugzillaProductURL).timeout(10 * 1000) - .get(); - Elements options = doc - .select("select[name=bug_status][id=bug_status] option"); - for (Element elem : options) { - String value = elem.attr("value"); - if (!StringUtils.isBlankOrNull(value)) { - products.add(value); - } else { - value = elem.text(); - products.add(value); - } - } - - } catch (IOException e) { - log.error("Error occured while fetching product details for bug", e); - } - return products; - } - - public static void main(String[] args) throws IOException { - StatusFetcher statusFetcher = new GenericStatusFetcher(); - List statuses = statusFetcher - .fetchStatus("https://bugzilla.kernel.org"); - for (String status : statuses) { - System.out.println(status); - } - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ParseProducts.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ParseProducts.java deleted file mode 100644 index fe7c11ae..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ParseProducts.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.scraper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import de.siemens.quantarch.bugs.history.GenericHistoryFetcher; - -public class ParseProducts { - - private String bugzillaURL = null; - - public ParseProducts(String bugzillaURL) { - this.bugzillaURL = bugzillaURL; - } - - private static Logger log = Logger.getLogger(GenericHistoryFetcher.class); - - public List fetchProducts() { - List products = new ArrayList(); - log.info("Fetching product details"); - String bugzillaProductURL = bugzillaURL + "/describecomponents.cgi"; - log.debug("Bugzilla URL to fetch history:" + bugzillaProductURL); - try { - - // set the jsoup connection timeout from 3 seconds to 10 seconds. - Document doc = Jsoup.connect(bugzillaProductURL).timeout(10 * 1000) - .get(); - Elements tableRows = doc.select("div#bugzilla-body") - .select("table").select("tr th a"); - for (Element elem : tableRows) { - String elementText = elem.text().replace("‑", "-") - .replaceAll("\\xA0", " "); - products.add(elementText); - } - - } catch (IOException e) { - log.error("Error occured while fetching product details for bug"); - } - return products; - } - - public static void main(String[] args) throws IOException { - ParseProducts historyFetcher = new ParseProducts( - "https://bugzilla.kernel.org"); - List historyList = historyFetcher.fetchProducts(); - for (String history : historyList) { - System.out.println(history); - } - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ProductFetcher.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ProductFetcher.java deleted file mode 100644 index dc88c07e..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/ProductFetcher.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.scraper; - -import java.util.List; - -public interface ProductFetcher { - - public abstract List fetchProducts(String bugzillaURL); - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/StatusFetcher.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/StatusFetcher.java deleted file mode 100644 index 825e1af5..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/scraper/StatusFetcher.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.scraper; - -import java.util.List; - -public interface StatusFetcher { - - public List fetchStatus(String bugzillaURL); - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/BugExtractorConfig.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/BugExtractorConfig.java deleted file mode 100644 index a299dce9..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/BugExtractorConfig.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.utils; - -public class BugExtractorConfig { - // Obtained from Global properties - private String dbHost = null; - private String dbName = null; - private String dbUser = null; - private String dbPassword = null; - private String proxyHost = null; - private int proxyPort = 33333; - private int sleepTimeOut = 2000; - private String personServiceURL = null; - - // Obtained from project properties - private String issueTrackerType = "bugzilla"; - private String issueTrackerURL = null; - private String projectName = null; - private String bugsProjectName = null; - private long projectId = -1; - private boolean productAsProject = false; - - public BugExtractorConfig() { - super(); - } - - public BugExtractorConfig(String dbHost, String dbName, String dbUser, - String dbPassword, String proxyHost, int proxyPort, - int sleepTimeOut, String personServiceURL, String issueTrackerURL, - String projectName, boolean productAsProject) { - super(); - this.dbHost = dbHost; - this.dbName = dbName; - this.dbUser = dbUser; - this.dbPassword = dbPassword; - this.proxyHost = proxyHost; - this.proxyPort = proxyPort; - this.sleepTimeOut = sleepTimeOut; - this.personServiceURL = personServiceURL; - this.issueTrackerURL = issueTrackerURL; - this.projectName = projectName; - this.productAsProject = productAsProject; - } - - /** - * @return the dbHost - */ - public String getDbHost() { - return dbHost; - } - - /** - * @param dbHost - * the dbHost to set - */ - public void setDbHost(String dbHost) { - this.dbHost = dbHost; - } - - /** - * @return the dbName - */ - public String getDbName() { - return dbName; - } - - /** - * @param dbName - * the dbName to set - */ - public void setDbName(String dbName) { - this.dbName = dbName; - } - - /** - * @return the dbUser - */ - public String getDbUser() { - return dbUser; - } - - /** - * @param dbUser - * the dbUser to set - */ - public void setDbUser(String dbUser) { - this.dbUser = dbUser; - } - - /** - * @return the dbPassword - */ - public String getDbPassword() { - return dbPassword; - } - - /** - * @param dbPassword - * the dbPassword to set - */ - public void setDbPassword(String dbPassword) { - this.dbPassword = dbPassword; - } - - /** - * @return the proxyHost - */ - public String getProxyHost() { - return proxyHost; - } - - /** - * @param proxyHost - * the proxyHost to set - */ - public void setProxyHost(String proxyHost) { - this.proxyHost = proxyHost; - } - - /** - * @return the proxyPort - */ - public int getProxyPort() { - return proxyPort; - } - - /** - * @param proxyPort - * the proxyPort to set - */ - public void setProxyPort(int proxyPort) { - this.proxyPort = proxyPort; - } - - /** - * @return the projectName - */ - public String getProjectName() { - return projectName; - } - - /** - * @param projectName - * the projectName to set - */ - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - /** - * @return the projectName - */ - public String getBugsProjectName() { - return bugsProjectName; - } - - /** - * @param projectName - * the projectName to set - */ - public void setBugsProjectName(String bugsProjectName) { - this.bugsProjectName = bugsProjectName; - } - - /** - * @return the productAsProject - */ - public boolean isProductAsProject() { - return productAsProject; - } - - /** - * @param productAsProject - * the productAsProject to set - */ - public void setProductAsProject(boolean productAsProject) { - this.productAsProject = productAsProject; - } - - /** - * @return the sleepTimeOut - */ - public int getSleepTimeOut() { - return sleepTimeOut; - } - - /** - * @param sleepTimeOut - * the sleepTimeOut to set - */ - public void setSleepTimeOut(int sleepTimeOut) { - this.sleepTimeOut = sleepTimeOut; - } - - /** - * @return the personServiceURL - */ - public String getPersonServiceURL() { - return personServiceURL; - } - - /** - * @param personServiceURL - * the personServiceURL to set - */ - public void setPersonServiceURL(String personServiceURL) { - this.personServiceURL = personServiceURL; - } - - /** - * @return the issueTrackerURL - */ - public String getIssueTrackerURL() { - return issueTrackerURL; - } - - /** - * @param issueTrackerURL - * the issueTrackerURL to set - */ - public void setIssueTrackerURL(String issueTrackerURL) { - this.issueTrackerURL = issueTrackerURL; - } - - /** - * @return the projectId - */ - public long getProjectId() { - return projectId; - } - - /** - * @param projectId - * the projectId to set - */ - public void setProjectId(long projectId) { - this.projectId = projectId; - } - - /** - * @return the issueTrackerType - */ - public String getIssueTrackerType() { - return issueTrackerType; - } - - /** - * @param issueTrackerType - * the issueTrackerType to set - */ - public void setIssueTrackerType(String issueTrackerType) { - this.issueTrackerType = issueTrackerType; - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/MyPartition.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/MyPartition.java deleted file mode 100644 index f3a03883..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/MyPartition.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.utils; - -import java.util.AbstractList; -import java.util.List; - -public class MyPartition { - - /** - * Returns consecutive {@linkplain List#subList(int, int) sublists} of a - * list, each of the same size (the final list may be smaller). For example, - * partitioning a list containing {@code [a, b, c, d, e]} with a partition - * size of 3 yields {@code [[a, b, c], [d, e]]} -- an outer list containing - * two inner lists of three and two elements, all in the original order. - * - *

- * The outer list is unmodifiable, but reflects the latest state of the - * source list. The inner lists are sublist views of the original list, - * produced on demand using {@link List#subList(int, int)}, and are subject - * to all the usual caveats about modification as explained in that API. - * - * * Adapted from http://code.google.com/p/google-collections/ - * - * @param list - * the list to return consecutive sublists of - * @param size - * the desired size of each sublist (the last may be smaller) - * @return a list of consecutive sublists - * @throws IllegalArgumentException - * if {@code partitionSize} is nonpositive - * - */ - - public static List> partition(List list, int size) { - - if (list == null) - throw new NullPointerException("'list' must not be null"); - if (!(size > 0)) - throw new IllegalArgumentException("'size' must be greater than 0"); - - return new Partition(list, size); - } - - private static class Partition extends AbstractList> { - - final List list; - final int size; - - Partition(List list, int size) { - this.list = list; - this.size = size; - } - - @Override - public List get(int index) { - int listSize = size(); - if (listSize < 0) - throw new IllegalArgumentException("negative size: " + listSize); - if (index < 0) - throw new IndexOutOfBoundsException("index " + index - + " must not be negative"); - if (index >= listSize) - throw new IndexOutOfBoundsException("index " + index - + " must be less than size " + listSize); - int start = index * size; - int end = Math.min(start + size, list.size()); - return list.subList(start, end); - } - - @Override - public int size() { - return (list.size() + size - 1) / size; - } - - @Override - public boolean isEmpty() { - return list.isEmpty(); - } - } - -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/StringUtils.java b/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/StringUtils.java deleted file mode 100644 index dd2dcea1..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/bugs/utils/StringUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.bugs.utils; - -/** - * Helper class for string manipulations - * - * @author Deepak Srinathan - * - */ -public final class StringUtils { - - /** - * Check if the string is NULL or blank - * - * @param input - * the input string - * @return true if the string is null or blank , false otherwise - */ - public static boolean isBlankOrNull(String input) { - boolean flag = false; - if (null == input || input.equalsIgnoreCase("")) { - flag = true; - } - return flag; - } -} diff --git a/bugextractor/src/main/java/de/siemens/quantarch/personService/PersonServiceClient.java b/bugextractor/src/main/java/de/siemens/quantarch/personService/PersonServiceClient.java deleted file mode 100644 index 815a3b7d..00000000 --- a/bugextractor/src/main/java/de/siemens/quantarch/personService/PersonServiceClient.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of Codeface. Codeface is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - * Copyright 2013 by Siemens AG. All Rights Reserved. - */ - -package de.siemens.quantarch.personService; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import net.sf.json.JSONObject; - -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.message.BasicNameValuePair; - -public final class PersonServiceClient { - - public static final long getPerson(String name, String email, - long projectId, String personServiceUrl) { - long userId = 0; - HttpClient client = new DefaultHttpClient(); - HttpPost post = new HttpPost(personServiceUrl + "/post_user_id"); - try { - List nameValuePairs = new ArrayList(1); - nameValuePairs.add(new BasicNameValuePair("projectID", Long - .toString(projectId))); - nameValuePairs.add(new BasicNameValuePair("name", name)); - nameValuePairs.add(new BasicNameValuePair("email", email)); - post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); - - HttpResponse response = client.execute(post); - BufferedReader rd = new BufferedReader(new InputStreamReader( - response.getEntity().getContent())); - - // read output - StringBuilder builder = new StringBuilder(); - String line = null; - while ((line = rd.readLine()) != null) { - builder.append(line); - } - - JSONObject json = JSONObject.fromObject(builder.toString()); - userId = json.getLong("id"); - return userId; - } catch (IOException e) { - e.printStackTrace(); - } - return userId; - } -} diff --git a/bugextractor/src/main/resources/beans.xml b/bugextractor/src/main/resources/beans.xml deleted file mode 100644 index a6e95493..00000000 --- a/bugextractor/src/main/resources/beans.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bugextractor/src/main/resources/log4j.properties b/bugextractor/src/main/resources/log4j.properties deleted file mode 100644 index 48fe2297..00000000 --- a/bugextractor/src/main/resources/log4j.properties +++ /dev/null @@ -1,17 +0,0 @@ -# Root logger option -log4j.rootLogger=ALL, file, file1, stdout - -# Direct log messages to a log file -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=bugExtractor.log -log4j.appender.file.MaxFileSize=5MB -log4j.appender.file.MaxBackupIndex=1 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Threshold=INFO -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file