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

Support wont fix resolution #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Created by .ignore support plugin (hsz.mobi)
.idea
*.iml
target/classes
4 changes: 2 additions & 2 deletions src/main/java/org/jmf/client/CommandLineClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(final String... args) {
List<Issue> flaggedIssues;

// Create Sonar Client for flagged issues server
SonarClientService sClientFlagged = new SonarClientService(props.get("flagged_issues_url"));
SonarClientService sClientFlagged = new SonarClientService(props.get("flagged_issues_url"), props.getOrDefault("flagged_issues_contextroot",""));

if (sClientFlagged.getBaseUrl() == null) {
CONSOLE_LOGGER.info("No URL found in configuration file for 'flagged' issues server (empty or malformed URL?). Exiting.");
Expand All @@ -53,7 +53,7 @@ public static void main(final String... args) {
if (flaggedIssues != null && !flaggedIssues.isEmpty()) {
CONSOLE_LOGGER.info("Flagged issues list size: {}\n ", flaggedIssues.size());
// Create Sonar Client for open issues
SonarClientService sClientOpen = new SonarClientService(props.get("open_issues_host"));
SonarClientService sClientOpen = new SonarClientService(props.get("open_issues_host"),props.getOrDefault("open_issues_contextroot",""));

if (sClientOpen.getBaseUrl() == null) {
CONSOLE_LOGGER.info("No URL found in configuration file for open issues server (empty or malformed URL?). Exiting.");
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/jmf/services/SonarClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ public class SonarClientService {

private static final String FALSE_POSITIVE = "FALSE-POSITIVE";

private static final String WONTFIX = "WONTFIX";

private static final String TRANSITION = "transition";

private static final String JWT_SESSION = "JWT-SESSION";

private static final String XSRF_TOKEN = "XSRF-TOKEN";

private static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
private static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";


private final MultiValuedMap<String, String> headers; // Cookie and auth info
Expand All @@ -67,12 +69,12 @@ public class SonarClientService {
/**
* Constructor.
*/
public SonarClientService(String url) {
public SonarClientService(String url, String contextRoot) {

this.headers = new ArrayListValuedHashMap<>();

try {
this.baseUrl = HttpUtils.getBaseUrl(url);
this.baseUrl = HttpUtils.getBaseUrl(url)+contextRoot;
} catch (java.lang.ArrayIndexOutOfBoundsException e ) {
FILE_LOGGER.error("Error parsing flagged issues URL.", e);
}
Expand Down Expand Up @@ -209,8 +211,13 @@ public final boolean updateIssue(Issue openIssue, Issue flaggedIssue) {

// Then, set transition
if (OPEN.equals(openIssue.getStatus()) || REOPENED.equals(openIssue.getStatus())) {
if (RESOLVED.equals(flaggedStatus) && FALSE_POSITIVE.equals(resolution)) {
params.put(TRANSITION, "falsepositive");
if (RESOLVED.equals(flaggedStatus)){
if(FALSE_POSITIVE.equals(resolution)) {
params.put(TRANSITION, "falsepositive");
} else if(WONTFIX.equals(resolution))
{
params.put(TRANSITION, "wontfix");
}
} else if (CONFIRMED.equals(flaggedStatus)) {
params.put(TRANSITION, "confirm");
}
Expand Down
38 changes: 38 additions & 0 deletions src/main/resources/configuration.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# URL POINTING TO LIST OF FLAGGED ISSUES
# MANDATORY
# Example 1: http://localhost:9000/api/issues/search?componentRoots=com.org:project:branch&resolutions=FALSE-POSITIVE,WONTFIX
# Example 2: http://localhost:9000/api/issues/search?projectKeys=projectkey&resolutions=FALSE-POSITIVE,WONTFIX
# It should be a Sonar Web-Services URL
flagged_issues_url=

# FLAGGED-ISSUES SERVER, SONAR CREDENTIALS
# MANDATORY
flagged_sonar_user=
flagged_sonar_passw=

# FLAGGED-ISSUES SERVER, HTTP SERVER CREDENTIALS
# OPTIONAL.
# Credentials for HTTP server.
flagged_http_user=
flagged_http_passw=

###################################################################################################

# URL OF SONAR INSTANCE WITH OPEN (NON-FLAGGED) ISSUES. EXAMPLE -> http://localhost:9000
# MANDATORY .
open_issues_host=

# ID OF PROJECT WITH OPEN NON-FLAGGED ISSUES
# MANDATORY
open_issues_project=com.ikea.nwp:nwp-parent:4.10.0-DEV

# OPEN-ISSUES SERVER, SONAR CREDENTIALS
open_sonar_user=
open_sonar_passw=

# OPEN-ISSUES SERVER, HTTP SERVER CREDENTIALS
# OPTIONAL. Credentials for HTTP server.
open_http_user=
open_http_passw=


18 changes: 18 additions & 0 deletions src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Redirect log messages to a log file, support file rolling.
log4j.logger.file = INFO, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log4j-application.log
log4j.appender.file.MaxFileSize=15MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n

# console
log4j.logger.console = INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern= %m

log4j.logger.org.apache.http=WARN
log4j.logger.org.apache.http.headers=WARN
log4j.logger.org.apache.http.wire=WARN
2 changes: 1 addition & 1 deletion target/assembly/conf/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ log4j.appender.console.layout.ConversionPattern= %m

log4j.logger.org.apache.http=WARN
log4j.logger.org.apache.http.headers=WARN
log4j.logger.org.apache.http.wire=WARN
log4j.logger.org.apache.http.wire=WARN