forked from rtcTo/rtc2jira
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace jirarestaccess with autoclosablerestclient (wrapper around
jirarestclient) see rtcTo#10
- Loading branch information
Showing
5 changed files
with
114 additions
and
179 deletions.
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
src/main/java/to/rtc/rtc2jira/exporter/jira/JiraRestAccess.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
src/main/java/to/rtc/rtc2jira/exporter/jira/entities/Project.java
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
src/main/java/to/rtc/rtc2jira/exporter/jira/entities/ProjectOverview.java
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
src/main/java/to/rtc/rtc2jira/exporter/jira/rest/AutoClosableRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package to.rtc.rtc2jira.exporter.jira.rest; | ||
|
||
import java.io.IOException; | ||
|
||
import com.atlassian.jira.rest.client.api.AuditRestClient; | ||
import com.atlassian.jira.rest.client.api.ComponentRestClient; | ||
import com.atlassian.jira.rest.client.api.IssueRestClient; | ||
import com.atlassian.jira.rest.client.api.JiraRestClient; | ||
import com.atlassian.jira.rest.client.api.MetadataRestClient; | ||
import com.atlassian.jira.rest.client.api.MyPermissionsRestClient; | ||
import com.atlassian.jira.rest.client.api.ProjectRestClient; | ||
import com.atlassian.jira.rest.client.api.ProjectRolesRestClient; | ||
import com.atlassian.jira.rest.client.api.SearchRestClient; | ||
import com.atlassian.jira.rest.client.api.SessionRestClient; | ||
import com.atlassian.jira.rest.client.api.UserRestClient; | ||
import com.atlassian.jira.rest.client.api.VersionRestClient; | ||
|
||
/** | ||
* Wraps an {@link JiraRestClient} with an {@link AutoCloseable} | ||
* | ||
* @author Manuel | ||
*/ | ||
public class AutoClosableRestClient implements AutoCloseable, JiraRestClient { | ||
|
||
private JiraRestClient client; | ||
|
||
AutoClosableRestClient(JiraRestClient client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
client.close(); | ||
} | ||
|
||
@Override | ||
public IssueRestClient getIssueClient() { | ||
return client.getIssueClient(); | ||
} | ||
|
||
@Override | ||
public SessionRestClient getSessionClient() { | ||
return client.getSessionClient(); | ||
} | ||
|
||
@Override | ||
public UserRestClient getUserClient() { | ||
return client.getUserClient(); | ||
} | ||
|
||
@Override | ||
public ProjectRestClient getProjectClient() { | ||
return client.getProjectClient(); | ||
} | ||
|
||
@Override | ||
public ComponentRestClient getComponentClient() { | ||
return client.getComponentClient(); | ||
} | ||
|
||
@Override | ||
public MetadataRestClient getMetadataClient() { | ||
return client.getMetadataClient(); | ||
} | ||
|
||
@Override | ||
public SearchRestClient getSearchClient() { | ||
return client.getSearchClient(); | ||
} | ||
|
||
@Override | ||
public VersionRestClient getVersionRestClient() { | ||
return client.getVersionRestClient(); | ||
} | ||
|
||
@Override | ||
public ProjectRolesRestClient getProjectRolesRestClient() { | ||
return client.getProjectRolesRestClient(); | ||
} | ||
|
||
@Override | ||
public AuditRestClient getAuditRestClient() { | ||
return client.getAuditRestClient(); | ||
} | ||
|
||
@Override | ||
public MyPermissionsRestClient getMyPermissionsRestClient() { | ||
return client.getMyPermissionsRestClient(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/to/rtc/rtc2jira/exporter/jira/rest/RestClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package to.rtc.rtc2jira.exporter.jira.rest; | ||
|
||
import java.net.URI; | ||
|
||
import to.rtc.rtc2jira.Settings; | ||
|
||
import com.atlassian.jira.rest.client.api.JiraRestClient; | ||
import com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler; | ||
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory; | ||
|
||
public abstract class RestClientFactory { | ||
|
||
|
||
public static JiraRestClient create(String urlAsString, String user, String password) { | ||
JiraRestClient restClient = | ||
new AsynchronousJiraRestClientFactory().create(URI.create(urlAsString), | ||
new BasicHttpAuthenticationHandler(user, password)); | ||
return new AutoClosableRestClient(restClient); | ||
} | ||
|
||
public static JiraRestClient create(Settings settings) { | ||
return create(settings.getJiraUrl(), settings.getJiraUser(), settings.getJiraPassword()); | ||
} | ||
} |