private Transition getTransition(String id, boolean isName) throws JiraException { Transition result = null; for (Transition transition : transitions) { if((isName && id.equals(transition.getName()) || (!isName && id.equals(transition.getId())))){ result = transition; } } if (result == null) { final String allTransitionNames = Arrays.toString(transitions.toArray()); throw new JiraException("Transition '" + id + "' was not found. Known transitions are:" + allTransitionNames); } return result; }
private static JSONObject realGet(RestClient restclient, String key, Map<String, String> queryParams) throws JiraException { JSON result = null; try { URI uri = restclient.buildURI(getBaseUri() + "issue/" + key, queryParams); result = restclient.get(uri); } catch (Exception ex) { throw new JiraException("Failed to retrieve issue " + key, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return (JSONObject) result; }
private static JSONObject realGet(RestClient restclient, String key, Map<String, String> queryParams) throws JiraException { JSON result = null; try { URI uri = restclient.buildURI(getBaseUri() + "issue/" + key, queryParams); result = restclient.get(uri); } catch (Exception ex) { throw new JiraException("Failed to retrieve issue " + key, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return (JSONObject) result; }
public List<User> getAssignableUsers() throws JiraException { JSON result = null; try { Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put("project", this.key); URI searchUri = restclient.buildURI(getBaseUri() + "user/assignable/search", queryParams); result = restclient.get(searchUri); } catch (Exception ex) { throw new JiraException("Failed to retrieve assignable users", ex); } if (!(result instanceof JSONArray)) throw new JiraException("JSON payload is malformed"); return Field.getResourceArray(User.class, result, restclient); }
/** * Casts a vote in favour of an issue. * * @throws JiraException when the voting fails */ public void vote() throws JiraException { try { restclient.post(getRestUri(key) + "/votes"); } catch (Exception ex) { throw new JiraException("Failed to vote on issue " + key, ex); } }
/** * Removes the current user's vote from the issue. * * @throws JiraException when the voting fails */ public void unvote() throws JiraException { try { restclient.delete(getRestUri(key) + "/votes"); } catch (Exception ex) { throw new JiraException("Failed to unvote on issue " + key, ex); } }
/** * Deletes this issue link record. * * @throws JiraException when the delete fails */ public void delete() throws JiraException { try { restclient.delete(getBaseUri() + "issueLink/" + id); } catch (Exception ex) { throw new JiraException("Failed to delete issue link " + id, ex); } }
public void logout(RestClient client) throws JiraException { if (token != null) { try { client.delete(Resource.getAuthUri() + "session"); } catch (Exception e) { throw new JiraException("Failed to logout", e); } } }
/** * Removes the current user's vote from the issue. * * @throws JiraException when the voting fails */ public void unvote() throws JiraException { try { restclient.delete(getRestUri(key) + "/votes"); } catch (Exception ex) { throw new JiraException("Failed to unvote on issue " + key, ex); } }
/** * Deletes this issue link record. * * @throws JiraException when the delete fails */ public void delete() throws JiraException { try { restclient.delete(getBaseUri() + "issueLink/" + id); } catch (Exception ex) { throw new JiraException("Failed to delete issue link " + id, ex); } }
/** * Creates or updates the remote link if a {@link #globalId(String) global id} is given and there is already * a remote link for the specified global id. * @throws JiraException when the remote link creation fails */ public void create() throws JiraException { try { request.put("object", object); restclient.post(getRestUri(key) + "/remotelink", request); } catch (Exception ex) { throw new JiraException("Failed add remote link to issue " + key, ex); } }
/** * Casts a vote in favour of an issue. * * @throws JiraException when the voting fails */ public void vote() throws JiraException { try { restclient.post(getRestUri(key) + "/votes"); } catch (Exception ex) { throw new JiraException("Failed to vote on issue " + key, ex); } }
/** * Deletes a component from a project. * * @throws JiraException failed to delete the component */ public void delete() throws JiraException { try { restclient.delete(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to delete component " + id, ex); } } }
public static Filter get(final RestClient restclient, final String id) throws JiraException { JSON result = null; try { URI uri = restclient.buildURI(getBaseUri() + "filter/" + id); result = restclient.get(uri); } catch (Exception ex) { throw new JiraException("Failed to retrieve filter with id " + id, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return new Filter(restclient, (JSONObject) result); }
/** * Deletes a component from a project. * * @throws JiraException failed to delete the component */ public void delete() throws JiraException { try { restclient.delete(getRestUri(id)); } catch (Exception ex) { throw new JiraException("Failed to delete component " + id, ex); } } }
/** * Adds an attachment to this issue. * * @param file java.io.File * * @throws JiraException when the attachment creation fails */ public void addAttachment(File file) throws JiraException { try { restclient.post(getRestUri(key) + "/attachments", file); } catch (Exception ex) { throw new JiraException("Failed add attachment to issue " + key, ex); } }
public boolean delete(final boolean deleteSubtasks) throws JiraException { boolean result; try { URI uri = restclient.buildURI(getBaseUri() + "issue/" + this.key, new HashMap<String, String>() {{ put("deleteSubtasks", String.valueOf(deleteSubtasks)); }}); result = (restclient.delete(uri) == null); } catch (Exception ex) { throw new JiraException("Failed to delete issue " + key, ex); } return result; }
public List<RemoteLink> getRemoteLinks() throws JiraException { JSONArray obj; try { URI uri = restclient.buildURI(getRestUri(key) + "/remotelink"); JSON json = restclient.get(uri); obj = (JSONArray) json; } catch (Exception ex) { throw new JiraException("Failed to get remote links for issue " + key, ex); } return Field.getRemoteLinks(obj, restclient); }
public List<WorkLog> getAllWorkLogs() throws JiraException { JSONObject obj; try { URI uri = restclient.buildURI(getRestUri(key) + "/worklog"); JSON json = restclient.get(uri); obj = (JSONObject) json; } catch (Exception ex) { throw new JiraException("Failed to get worklog for issue " + key, ex); } return Field.getWorkLogs(obj, restclient); }
public List<WorkLog> getAllWorkLogs() throws JiraException { JSONObject obj; try { URI uri = restclient.buildURI(getRestUri(key) + "/worklog"); JSON json = restclient.get(uri); obj = (JSONObject) json; } catch (Exception ex) { throw new JiraException("Failed to get worklog for issue " + key, ex); } return Field.getWorkLogs(obj, restclient); }