All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.thucydides.plugins.jira.service.JIRAConnection Maven / Gradle / Ivy

There is a newer version: 0.9.268
Show newest version
package net.thucydides.plugins.jira.service;

import net.thucydides.plugins.jira.client.SOAPSession;
import net.thucydides.plugins.jira.guice.Injectors;
import thucydides.plugins.jira.soap.JiraSoapService;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

public class JIRAConnection {

    private final JIRAConfiguration configuration;
    private SOAPSession soapSession;

    public JIRAConnection() {
        this(Injectors.getInjector().getInstance(JIRAConfiguration.class));
    }

    public JIRAConnection(JIRAConfiguration configuration) {
        this.configuration = configuration;
    }

    private SOAPSession getSoapSession() throws MalformedURLException, RemoteException {
        if (soapSession == null) {
            soapSession = SOAPSession.openConnectionTo(new URL(getJiraWebserviceUrl()))
                    .usingCredentials(getJiraUser(), getJiraPassword());
        }
        return soapSession;
    }
    public JiraSoapService getJiraSoapService() throws MalformedURLException, RemoteException {
        return getSoapSession().getJiraSoapService();
    }

    protected JIRAConfiguration getConfiguration() {
        return configuration;
    }

    public String getJiraUser() {
        return getConfiguration().getJiraUser();
    }

    public String getJiraPassword() {
        return getConfiguration().getJiraPassword();
    }

    public String getJiraWebserviceUrl() {
        return getConfiguration().getJiraWebserviceUrl();
    }

    public String getAuthenticationToken() throws MalformedURLException, RemoteException {
        return getSoapSession().getAuthenticationToken();
    }

    public String getProject() {
        return getConfiguration().getProject();
    }
    public void logout() {
        this.soapSession = null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy