Skip to content

Commit

Permalink
Replace jirarestaccess with autoclosablerestclient (wrapper around
Browse files Browse the repository at this point in the history
jirarestclient) see rtcTo#10
  • Loading branch information
WtfJoke committed Jul 29, 2015
1 parent 6b81893 commit 4e73e7b
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 179 deletions.
68 changes: 0 additions & 68 deletions src/main/java/to/rtc/rtc2jira/exporter/jira/JiraRestAccess.java

This file was deleted.

46 changes: 0 additions & 46 deletions src/main/java/to/rtc/rtc2jira/exporter/jira/entities/Project.java

This file was deleted.

This file was deleted.

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();
}
}
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());
}
}

0 comments on commit 4e73e7b

Please sign in to comment.