/** * 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); } }
/** * 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); } }
/** * Adds an attachments to this issue. * * @param attachments the attachments to add * * @throws JiraException when the attachments creation fails */ public void addAttachments(NewAttachment... attachments) throws JiraException { if (attachments == null) { throw new NullPointerException("attachments may not be null"); } if (attachments.length == 0) { return; } try { restclient.post(getRestUri(key) + "/attachments", attachments); } catch (Exception ex) { throw new JiraException("Failed add attachment to issue " + key, ex); } }
/** * Adds an attachment to this issue. * * @param file java.io.File * * @throws JiraException when the comment 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); } }
/** * 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); } }
/** * Removes a watcher to the issue. * * @param username Username of the watcher to remove * * @throws JiraException when the operation fails */ public void deleteWatcher(String username) throws JiraException { try { final String u = username; Map<String, String> connectionParams = new HashMap<String, String>(); connectionParams.put("username", u); URI uri = restclient.buildURI( getRestUri(key) + "/watchers", connectionParams); restclient.delete(uri); } catch (Exception ex) { throw new JiraException( "Failed to remove watch (" + username + ") from issue " + key, ex ); } }
/** * Adds a watcher to the issue. * * @param username Username of the watcher to add * * @throws JiraException when the operation fails */ public void addWatcher(String username) throws JiraException { try { URI uri = restclient.buildURI(getRestUri(key) + "/watchers"); restclient.post(uri, username); } catch (Exception ex) { throw new JiraException( "Failed to add watcher (" + username + ") to issue " + key, ex ); } }
/** * Adds a watcher to the issue. * * @param username Username of the watcher to add * * @throws JiraException when the operation fails */ public void addWatcher(String username) throws JiraException { try { URI uri = restclient.buildURI(getRestUri(key) + "/watchers"); restclient.post(uri, username); } catch (Exception ex) { throw new JiraException( "Failed to add watcher (" + username + ") to issue " + key, ex ); } }
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<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<Transition> getTransitions() throws JiraException { JSON result = null; try { Map<String, String> params = new HashMap<String, String>(); params.put("expand", "transitions.fields"); URI transuri = restclient.buildURI( getRestUri(key) + "/transitions",params); result = restclient.get(transuri); } catch (Exception ex) { throw new JiraException("Failed to retrieve transitions", ex); } JSONObject jo = (JSONObject)result; if (jo.isNullObject() || !jo.containsKey("transitions") || !(jo.get("transitions") instanceof JSONArray)) throw new JiraException("Transition metadata is missing."); JSONArray transitions = (JSONArray) jo.get("transitions"); List<Transition> trans = new ArrayList<Transition>(); for(Object obj: transitions){ JSONObject ob = (JSONObject) obj; trans.add(new Transition(restclient, ob)); } return trans; }
/** * Removes a watcher to the issue. * * @param username Username of the watcher to remove * * @throws JiraException when the operation fails */ public void deleteWatcher(String username) throws JiraException { try { final String u = username; URI uri = restclient.buildURI( getRestUri(key) + "/watchers", new HashMap<String, String>() {{ put("username", u); }}); restclient.delete(uri); } catch (Exception ex) { throw new JiraException( "Failed to remove watch (" + username + ") from issue " + key, ex ); } }
private JSONObject getEditMetadata() throws JiraException { JSON result = null; try { result = restclient.get(getRestUri(key) + "/editmeta"); } catch (Exception ex) { throw new JiraException("Failed to retrieve issue metadata", ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); JSONObject jo = (JSONObject)result; if (jo.isNullObject() || !jo.containsKey("fields") || !(jo.get("fields") instanceof JSONObject)) throw new JiraException("Edit metadata is malformed"); return (JSONObject)jo.get("fields"); }
private JSONObject getEditMetadata() throws JiraException { JSON result = null; try { result = restclient.get(getRestUri(key) + "/editmeta"); } catch (Exception ex) { throw new JiraException("Failed to retrieve issue metadata", ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); JSONObject jo = (JSONObject)result; if (jo.isNullObject() || !jo.containsKey("fields") || !(jo.get("fields") instanceof JSONObject)) throw new JiraException("Edit metadata is malformed"); return (JSONObject)jo.get("fields"); }
/** * Adds a comment to this issue with limited visibility. * * @param body Comment text * @param visType Target audience type (role or group) * @param visName Name of the role or group to limit visibility to * * @throws JiraException when the comment creation fails */ public void addComment(String body, String visType, String visName) throws JiraException { JSONObject req = new JSONObject(); req.put("body", body); if (visType != null && visName != null) { JSONObject vis = new JSONObject(); vis.put("type", visType); vis.put("value", visName); req.put("visibility", vis); } try { restclient.post(getRestUri(key) + "/comment", req); } catch (Exception ex) { throw new JiraException("Failed add comment to issue " + key, ex); } }
private JSONArray getTransitions() throws JiraException { JSON result = null; try { URI transuri = restclient.buildURI( getRestUri(key) + "/transitions", new HashMap<String, String>() {{ put("expand", "transitions.fields"); }}); result = restclient.get(transuri); } catch (Exception ex) { throw new JiraException("Failed to retrieve transitions", ex); } JSONObject jo = (JSONObject)result; if (jo.isNullObject() || !jo.containsKey("transitions") || !(jo.get("transitions") instanceof JSONArray)) throw new JiraException("Transition metadata is missing from jos"); return (JSONArray)jo.get("transitions"); }
/** * Adds a comment to this issue with limited visibility. * * @param body Comment text * @param visType Target audience type (role or group) * @param visName Name of the role or group to limit visibility to * * @throws JiraException when the comment creation fails */ public Comment addComment(String body, String visType, String visName) throws JiraException { JSONObject req = new JSONObject(); req.put("body", body); if (visType != null && visName != null) { JSONObject vis = new JSONObject(); vis.put("type", visType); vis.put("value", visName); req.put("visibility", vis); } JSON result = null; try { result = restclient.post(getRestUri(key) + "/comment", req); } catch (Exception ex) { throw new JiraException("Failed add comment to issue " + key, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return new Comment(restclient, (JSONObject) result, key); }