Skip to content

Commit

Permalink
JENKINS-19286 - adding some more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rantoniuk committed May 3, 2016
1 parent 2717244 commit dc76db3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 61 deletions.
16 changes: 6 additions & 10 deletions src/main/java/hudson/plugins/jira/JiraSession.java
@@ -1,22 +1,15 @@
package hudson.plugins.jira;

import static org.apache.commons.lang.StringUtils.isNotEmpty;
import com.atlassian.jira.rest.client.api.domain.*;
import com.google.common.collect.Lists;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;

import com.atlassian.jira.rest.client.api.domain.BasicIssue;
import com.atlassian.jira.rest.client.api.domain.Component;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.api.domain.IssueType;
import com.atlassian.jira.rest.client.api.domain.Permissions;
import com.atlassian.jira.rest.client.api.domain.Status;
import com.atlassian.jira.rest.client.api.domain.Transition;
import com.atlassian.jira.rest.client.api.domain.Version;
import com.google.common.collect.Lists;
import static org.apache.commons.lang.StringUtils.isNotEmpty;

/**
* Connection to JIRA.
Expand Down Expand Up @@ -199,6 +192,7 @@ public void migrateIssuesToFixVersion(String projectKey, String version, String

Version newVersion = getVersionByName(projectKey, version);
if (newVersion == null) {
LOGGER.warning("Version " + version + " was not found");
return;
}

Expand Down Expand Up @@ -227,6 +221,7 @@ public void replaceFixVersion(String projectKey, String fromVersion, String toVe

Version newVersion = getVersionByName(projectKey, toVersion);
if (newVersion == null) {
LOGGER.warning("Version " + toVersion + " was not found");
return;
}

Expand Down Expand Up @@ -262,6 +257,7 @@ public void addFixVersion(String projectKey, String version, String query) {

Version newVersion = getVersionByName(projectKey, version);
if (newVersion == null) {
LOGGER.warning("Version " + version + " was not found");
return;
}

Expand Down
62 changes: 30 additions & 32 deletions src/main/java/hudson/plugins/jira/JiraSite.java
@@ -1,20 +1,33 @@
package hudson.plugins.jira;

import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.RestClientException;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.api.domain.Version;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import hudson.Extension;
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Job;
import hudson.util.FormValidation;
import hudson.util.Secret;
import org.joda.time.DateTime;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand All @@ -24,30 +37,8 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;

import javax.annotation.CheckForNull;
import javax.annotation.Nullable;

import org.joda.time.DateTime;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.RestClientException;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.api.domain.IssueType;
import com.atlassian.jira.rest.client.api.domain.Version;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import hudson.Extension;
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Job;
import hudson.util.FormValidation;
import hudson.util.Secret;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;

/**
* Represents an external JIRA installation and configuration
Expand Down Expand Up @@ -480,6 +471,7 @@ public void releaseVersion(String projectKey, String versionName) throws IOExcep
public Set<JiraVersion> getVersions(String projectKey) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return Collections.emptySet();
}

Expand Down Expand Up @@ -522,6 +514,7 @@ public String getReleaseNotesForFixVersion(String projectKey, String versionName
public String getReleaseNotesForFixVersion(String projectKey, String versionName, String filter) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return "";
}

Expand Down Expand Up @@ -609,6 +602,7 @@ public Set<JiraIssue> getIssueWithFixVersion(String projectKey, String versionNa
public void replaceFixVersion(String projectKey, String fromVersion, String toVersion, String query) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return;
}

Expand All @@ -626,6 +620,7 @@ public void replaceFixVersion(String projectKey, String fromVersion, String toVe
public void migrateIssuesToFixVersion(String projectKey, String versionName, String query) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return;
}

Expand All @@ -643,6 +638,7 @@ public void migrateIssuesToFixVersion(String projectKey, String versionName, Str
public void addFixVersionToIssue(String projectKey, String versionName, String query) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return;
}

Expand All @@ -663,6 +659,7 @@ public boolean progressMatchingIssues(String jqlSearch, String workflowActionNam
JiraSession session = getSession();

if (session == null) {
LOGGER.warning("JIRA session could not be established");
console.println(Messages.Updater_FailedToConnect());
return false;
}
Expand Down Expand Up @@ -764,6 +761,7 @@ public FormValidation doValidate(@QueryParameter String userName,
public void addVersion(String version, String projectKey) throws IOException {
JiraSession session = getSession();
if (session == null) {
LOGGER.warning("JIRA session could not be established");
return;
}

Expand Down
35 changes: 16 additions & 19 deletions src/main/java/hudson/plugins/jira/Updater.java
@@ -1,22 +1,5 @@
package hudson.plugins.jira;

import static java.lang.String.format;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang.StringUtils;
import com.atlassian.jira.rest.client.api.RestClientException;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.google.common.base.Strings;
Expand All @@ -27,10 +10,24 @@
import hudson.model.TaskListener;
import hudson.plugins.jira.selector.AbstractIssueSelector;
import hudson.scm.ChangeLogSet;
import hudson.scm.RepositoryBrowser;
import hudson.scm.SCM;
import hudson.scm.ChangeLogSet.AffectedFile;
import hudson.scm.ChangeLogSet.Entry;
import hudson.scm.RepositoryBrowser;
import hudson.scm.SCM;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.lang.String.format;

/**
* Actual JIRA update logic.
Expand Down

0 comments on commit dc76db3

Please sign in to comment.