Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to jQA 1.7.0 #10

Closed
wants to merge 13 commits into from
Closed
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It enables jQAssistant to scan and to analyze data from **Jira**.

Download the jQAssistant command line tool for your system: [jQAssistant - Get Started](https://jqassistant.org/get-started/).

Next download the latest version from the release tab. Put the `jqa-jira-plugin-*.jar` into the plugins folder of the jQAssistant command
Next download the latest version from the release tab. Put the `jqassistant-jira-plugin-*.jar` into the plugins folder of the jQAssistant command
line tool.

Finally, you need to configure the plugin via XML. The file must be named `jira-plugin-configuration.xml`:
Expand Down Expand Up @@ -40,18 +40,18 @@ you to use your email as login name as well. This is not possible when querying
Now scan your configuration and wait for the plugin to finish:

```bash
jqassistant-commandline-neo4jv3-1.6.0/bin/jqassistant.sh scan -f jira-plugin-configuration.xml
jqassistant.sh scan -f jira-plugin-configuration.xml
```

You can then start a local Neo4j server to start querying the database at [http://localhost:7474](http://localhost:7474):

```bash
jqassistant-commandline-neo4jv3-1.6.0/bin/jqassistant.sh server
bin/jqassistant.sh server
```

## Custom Certificate
## Self-Signed Certificate

If you use a self-signed certificate register it with the [Keytool](http://tutorials.jenkov.com/java-cryptography/keytool.html):
If your JIRA instance uses a self-signed certificate register it with the [Keytool](http://tutorials.jenkov.com/java-cryptography/keytool.html):

```bash
keytool -import -alias JIRA -file jira.crt -keystore $JAVA_HOME/jre/lib/security/cacerts
Expand Down
68 changes: 30 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>org.jqassistant.contrib.common</groupId>
<artifactId>parent</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</parent>

<groupId>org.jqassistant.contrib.plugin</groupId>
<artifactId>jqa-jira-plugin</artifactId>
<version>0.0.1</version>
<artifactId>jqassistant-jira-plugin</artifactId>
<version>1.7.0-SNAPSHOT</version>

<name>jQAssistant Jira Plugin</name>
<description>The jQAssistant plugin to scan and to analyze a Jira instance.</description>
Expand All @@ -34,6 +34,13 @@
</developer>
</developers>

<scm>
<connection>scm:git:git@github.com:softvis-research/jqa-jira-plugin.git</connection>
<developerConnection>scm:git:git@github.com:softvis-research/jqa-jira-plugin.git</developerConnection>
<url>https://github.com/softvis-research/jqa-jira-plugin.git</url>
<tag>HEAD</tag>
</scm>

<licenses>
<license>
<name>GNU General Public License, v3</name>
Expand All @@ -57,10 +64,6 @@
</repository>
</repositories>

<properties>
<org.hamcrest.version>2.0.0.0</org.hamcrest.version>
</properties>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -141,27 +144,8 @@
</plugin>
</plugins>
</build>
<dependencyManagement>

<dependencies>
<!-- jQAssistant -->
<!-- unit tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>

<!-- https://mvnrepository.com/artifact/org.jdom/jdom2 -->
<dependency>
<groupId>org.jdom</groupId>
Expand All @@ -173,6 +157,12 @@
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.1-e0dd194</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- This dependency is needed because the application will throw the following error on startup otherwise:-->
Expand Down Expand Up @@ -238,7 +228,6 @@
<dependency>
<groupId>com.buschmais.xo</groupId>
<artifactId>xo.neo4j.embedded</artifactId>

<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -249,23 +238,26 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<version>${org.hamcrest.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>provided</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<!-- Declared to detect ambiguities between data models of bytecode and src parser -->
<dependency>
<groupId>com.buschmais.jqassistant.plugin</groupId>
<artifactId>java</artifactId>
<scope>test</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.jqassistant.contrib.plugin.jira.jdom;
package org.jqassistant.contrib.plugin.jira.configuration;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class XMLCredentials {
public class Credentials {

private String user;
private String password;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jqassistant.contrib.plugin.jira.configuration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.Optional;

@AllArgsConstructor
@Getter
public class JiraPluginConfiguration {

private String url;
private Optional<Credentials> credentials;
private List<Project> projects;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.jqassistant.contrib.plugin.jira.jdom;
package org.jqassistant.contrib.plugin.jira.configuration;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class XMLJiraProject {
public class Project {

private String key;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jqassistant.contrib.plugin.jira.configuration.Credentials;
import org.jqassistant.contrib.plugin.jira.configuration.JiraPluginConfiguration;
import org.jqassistant.contrib.plugin.jira.configuration.Project;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
* The {@link XMLParser} class contains two functions which parse the configuration file for the Jira plugin.
Expand Down Expand Up @@ -37,16 +41,16 @@ public class XMLParser {
* @throws JDOMException If XML parsing failed.
* @throws IOException If reading the config file failed.
*/
public XMLJiraPluginConfiguration parseConfiguration(InputStream inputStream) throws JDOMException, NullPointerException, IOException {
public JiraPluginConfiguration parseConfiguration(InputStream inputStream) throws JDOMException, NullPointerException, IOException {

SAXBuilder builder = new SAXBuilder();
Document document = builder.build(inputStream);

String jiraUrl = this.parseJiraUrl(document);
XMLCredentials xmlCredentials = this.parseCredentials(document);
List<XMLJiraProject> xmlJiraProjectList = this.parseJiraProjects(document);
Optional<Credentials> xmlCredentials = this.parseCredentials(document);
List<Project> projectList = this.parseJiraProjects(document);

return new XMLJiraPluginConfiguration(jiraUrl, xmlCredentials, xmlJiraProjectList);
return new JiraPluginConfiguration(jiraUrl, xmlCredentials, projectList);
}


Expand All @@ -55,27 +59,31 @@ private String parseJiraUrl(Document document) {
return document.getRootElement().getChildText(URL_ELEMENT_NAME);
}

private XMLCredentials parseCredentials(Document document) {
private Optional<Credentials> parseCredentials(Document document) {

Element credentialsElement = document.getRootElement().getChild(CREDENTIALS_ELEMENT_NAME);

if (credentialsElement == null) {
return Optional.empty();
}

String username = credentialsElement.getChildText(USERNAME_ELEMENT_NAME);
String password = credentialsElement.getChildText(PASSWORD_ELEMENT_NAME);

return new XMLCredentials(username, password);
return Optional.of(new Credentials(username, password));
}

private List<XMLJiraProject> parseJiraProjects(Document document) {
private List<Project> parseJiraProjects(Document document) {

List<XMLJiraProject> xmlJiraProjectList = new ArrayList<>();
List<Project> projectList = new ArrayList<>();

for (Element jiraProject : document.getRootElement().getChild(PROJECTS_ELEMENT_NAME).getChildren()) {

String key = jiraProject.getChildText(PROJECT_KEY_ELEMENT_NAME);

xmlJiraProjectList.add(new XMLJiraProject(key));
projectList.add(new Project(key));
}

return xmlJiraProjectList;
return projectList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.domain.*;
import com.atlassian.jira.rest.client.auth.AnonymousAuthenticationHandler;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import org.jqassistant.contrib.plugin.jira.configuration.Credentials;
import org.jqassistant.contrib.plugin.jira.configuration.JiraPluginConfiguration;

import java.net.URI;
import java.util.Collections;
Expand All @@ -21,10 +24,15 @@ public class DefaultJiraRestClientWrapper implements JiraRestClientWrapper {

private final JiraRestClient jiraRestClient;

public DefaultJiraRestClientWrapper(String url, String username, String password) {

jiraRestClient = new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(URI.create(url), username, password);
public DefaultJiraRestClientWrapper(JiraPluginConfiguration pluginConfiguration) {
AsynchronousJiraRestClientFactory clientFactory = new AsynchronousJiraRestClientFactory();
URI uri = URI.create(pluginConfiguration.getUrl());
if (pluginConfiguration.getCredentials().isPresent()) {
Credentials x = pluginConfiguration.getCredentials().get();
jiraRestClient = clientFactory.createWithBasicHttpAuthentication(uri, x.getUser(), x.getPassword());
} else {
jiraRestClient = clientFactory.create(uri, new AnonymousAuthenticationHandler());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface JiraIssue extends Jira, JiraID, JiraAuditInformation, JiraDescr
JiraUser getAssignee();
void setAssignee(JiraUser jiraUser);

@Relation("CONCERNES")
@Relation("CONCERNS")
List<JiraComponent> getComponents();

@Relation("IS_OF_TYPE")
Expand Down
Loading