Search in sources :

Example 1 with JiraRestClientFactory

use of com.atlassian.jira.rest.client.api.JiraRestClientFactory in project syndesis-qe by syndesisio.

the class IssueHooksUtils method getJiraClient.

private static JiraRestClient getJiraClient(Scenario scenario) {
    String userName = "";
    String password = "";
    String instanceUrl = "";
    URI uri = null;
    Optional<Account> account = AccountsDirectory.getInstance().getAccount(Account.Name.JIRA_HOOK);
    if (account.isPresent()) {
        if (!account.get().getProperties().keySet().containsAll(Arrays.asList("username", "password", "instanceUrl"))) {
            logError(scenario, "Account with name \"Jira\" and properties \"username\", \"password\", \"instanceUrl\" is required in credentials.json file.");
            logError(scenario, "If you want to get known issues from Jira in logs in case of scenario fails, update your credentials.");
            return null;
        } else {
            userName = account.get().getProperty("username");
            password = account.get().getProperty("password");
            instanceUrl = account.get().getProperty("instanceUrl");
        }
    }
    JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
    try {
        uri = new URI(instanceUrl);
    } catch (URISyntaxException e) {
        log.error("URL {} is a malformed URL", instanceUrl);
        e.printStackTrace();
    }
    return factory.createWithBasicHttpAuthentication(uri, userName, password);
}
Also used : Account(io.syndesis.qe.account.Account) AsynchronousJiraRestClientFactory(com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory) JiraRestClientFactory(com.atlassian.jira.rest.client.api.JiraRestClientFactory) AsynchronousJiraRestClientFactory(com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

JiraRestClientFactory (com.atlassian.jira.rest.client.api.JiraRestClientFactory)1 AsynchronousJiraRestClientFactory (com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory)1 Account (io.syndesis.qe.account.Account)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1