@Override public T get() throws InterruptedException, ExecutionException { return delegate.get(); }
@Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return delegate.get(timeout, unit); } }
private static void validateProjectKey(JiraRestClient client, String projectKey) { System.out.println("Validating project with key '" + projectKey + "'..."); try { if (client.getProjectClient().getProject(projectKey).get() == null) { throw new RuntimeException("Project with key = '" + projectKey + "' does not exist"); } } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Could not retrieve project data for project with key '" + projectKey + "' from jira", e); } System.out.println("OK"); }
private static void validateProjectKey(JiraRestClient client, String projectKey) { System.out.println("Validating project with key '" + projectKey + "'..."); try { if (client.getProjectClient().getProject(projectKey).get() == null) { throw new RuntimeException("Project with key = '" + projectKey + "' does not exist"); } } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Could not retrieve project data for project with key '" + projectKey + "' from jira", e); } System.out.println("OK"); }
public List<IssueType> getIssueTypes() { try { return Lists.newArrayList(jiraRestClient.getMetadataClient().getIssueTypes().get(timeout, TimeUnit.SECONDS)); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get issue types error. cause: " + e.getMessage(), e); return Collections.emptyList(); } }
public List<Status> getStatuses() { try { final Iterable<Status> statuses = jiraRestClient.getMetadataClient().getStatuses() .get(timeout, TimeUnit.SECONDS); return Lists.newArrayList(statuses); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get statuses error. cause: " + e.getMessage(), e); return Collections.emptyList(); } }
public List<String> getProjectsKeys() { Iterable<BasicProject> projects = Collections.emptyList(); try { projects = jiraRestClient.getProjectClient().getAllProjects().get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get project keys error. cause: " + e.getMessage(), e); } final List<String> keys = new ArrayList<>(); for (BasicProject project : projects) { keys.add(project.getKey()); } return keys; }
public List<Transition> getAvailableActions(String issueKey) { final Issue issue = getIssue(issueKey); try { final Iterable<Transition> transitions = jiraRestClient.getIssueClient() .getTransitions(issue) .get(timeout, TimeUnit.SECONDS); return Lists.newArrayList(transitions); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get available actions error. cause: " + e.getMessage(), e); return Collections.emptyList(); } }
@Override protected Either<ResourceError, ExpandedRoom> fetchCacheLoad(HipChatApiService hipChat, String key) throws Exception { return hipChat.getRoom(key).get().either(); } }
@Override protected Either<ResourceError, User> fetchCacheLoad(HipChatApiService hipChat, String key) throws Exception { return hipChat.getUser(key).get().either(); } }
public Version addVersion(String projectKey, String versionName) { final VersionInput versionInput = new VersionInput(projectKey, versionName, null, null, false, false); try { return jiraRestClient.getVersionRestClient() .createVersion(versionInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client add version error. cause: " + e.getMessage(), e); return null; } }
@Override public Result<InviteUserResult> inviteUserToHipchat(HipChatAPI<?> api, String name, String email, Option<String> title) { try { return api.users().inviteUser(email, name, title).get(); } catch (InterruptedException | ExecutionException e) { return Result.error(e); } }
private String getJQLFromFilter(URL filterUrl) throws NotFoundException { try { // url type example https://issues.jboss.org/rest/api/latest/filter/12322199 SearchRestClient searchClient = restClient.getSearchClient(); Filter filter = searchClient.getFilter(filterUrl.toURI()).get(); return filter.getJql(); } catch (Exception e) { throw new NotFoundException("Unable to retrieve filter with url: " + filterUrl, e); } }
/** * @return the homePageLink (which is the same as the base URL used when the integration was installed) from the stored HipChat addon descriptor, or null if we could not talk to HipChat */ private String getHomePageLink() { try { return storedConnectDescriptorResolver.resolveConnectDescriptor(hipChatLinkProvider.getDefaultLink().get()).get().getHomePageLink().toString(); } catch (Exception e) { return null; } }
private com.atlassian.jira.rest.client.api.domain.Issue getIssue(String trackerId) throws NotFoundException { try { return restClient.getIssueClient().getIssue(trackerId).get(); } catch (Exception e) { throw new NotFoundException(e); } }
public void releaseVersion(String projectKey, Version version) { final URIBuilder builder = new URIBuilder(uri) .setPath(String.format("%s/version/%s", baseApiPath, version.getId())); final VersionInput versionInput = new VersionInput(projectKey, version.getName(), version.getDescription(), version .getReleaseDate(), version.isArchived(), version.isReleased()); try { jiraRestClient.getVersionRestClient().updateVersion(builder.build(), versionInput).get(timeout, TimeUnit.SECONDS); }catch (Exception e) { LOGGER.log(WARNING, "jira rest client release version error. cause: " + e.getMessage(), e); } }
public void updateIssue(String issueKey, List<Version> fixVersions) { final IssueInput issueInput = new IssueInputBuilder().setFixVersions(fixVersions) .build(); try { jiraRestClient.getIssueClient().updateIssue(issueKey, issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client update issue error. cause: " + e.getMessage(), e); } }
@Override protected Either<ResourceError, Message> fetchCacheLoad(HipChatApiService hipChat, MentionMessageKey key) throws Exception { return hipChat.getRoomMessage(key.getRoomId(), key.getMessageId()).get().either(); } }
@Override public Result<Void> deleteUserAccount(HipChatAPI<AddonToken> api, String usernameOrId) throws ExecutionException, InterruptedException { final Result<Void> result = api.users().deleteUser(usernameOrId).get(); if (result.isError()) { return result.asError(); } return result; }
public void setIssueFields(String issueKey, List<JiraIssueField> fields) { IssueInputBuilder builder = new IssueInputBuilder(); for (JiraIssueField field : fields) builder.setFieldValue(field.getId(), field.getValue()); final IssueInput issueInput = builder.build(); try { jiraRestClient.getIssueClient().updateIssue(issueKey, issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client update fields error for issue " + issueKey, e); } }