/** * Build a URI from a path. * * @param path Path to append to the base URI * * @return the full URI * * @throws URISyntaxException when the path is invalid */ public URI buildURI(String path) throws URISyntaxException { return buildURI(path, null); }
/** * Build a URI from a path. * * @param path Path to append to the base URI * * @return the full URI * * @throws URISyntaxException when the path is invalid */ public URI buildURI(String path) throws URISyntaxException { return buildURI(path, null); }
/** * Executes an HTTP POST with the given path and file payload. * * @param path Full URI of the remote endpoint * @param file java.io.File * * @throws URISyntaxException * @throws IOException * @throws RestException */ public JSON post(String path, File file) throws RestException, IOException, URISyntaxException{ return request(new HttpPost(buildURI(path)), file); }
/** * Executes an HTTP POST with the given path and file payload. * * @param uri Full URI of the remote endpoint * @param file java.io.File * * @throws URISyntaxException * @throws IOException * @throws RestException */ public JSON post(String path, File file) throws RestException, IOException, URISyntaxException{ return request(new HttpPost(buildURI(path)), file); }
/** * Executes an HTTP POST with the given path and file payloads. * * @param path Full URI of the remote endpoint * @param attachments the name of the attachment * * @throws URISyntaxException * @throws IOException * @throws RestException */ public JSON post(String path, Issue.NewAttachment... attachments) throws RestException, IOException, URISyntaxException { return request(new HttpPost(buildURI(path)), attachments); }
/** * Executes an HTTP GET with the given path. * * @param path Path to be appended to the URI supplied in the construtor * @param params Map of key value pairs * * @return JSON-encoded result or null when there's no content returned * * @throws RestException when an HTTP-level error occurs * @throws IOException when an error reading the response occurs * @throws URISyntaxException when an error occurred appending the path to the URI */ public JSON get(String path, Map<String, String> params) throws RestException, IOException, URISyntaxException { return get(buildURI(path, params)); }
/** * Executes an HTTP DELETE with the given path. * * @param path Path to be appended to the URI supplied in the construtor * * @return JSON-encoded result or null when there's no content returned * * @throws RestException when an HTTP-level error occurs * @throws IOException when an error reading the response occurs * @throws URISyntaxException when an error occurred appending the path to the URI */ public JSON delete(String path) throws RestException, IOException, URISyntaxException { return delete(buildURI(path)); }
/** * Executes an HTTP PUT with the given path and payload. * * @param path Path to be appended to the URI supplied in the construtor * @param payload JSON-encoded data to send to the remote service * * @return JSON-encoded result or null when there's no content returned * * @throws RestException when an HTTP-level error occurs * @throws IOException when an error reading the response occurs * @throws URISyntaxException when an error occurred appending the path to the URI */ public JSON put(String path, JSON payload) throws RestException, IOException, URISyntaxException { return put(buildURI(path), payload); }
/** * Executes an HTTP DELETE with the given path. * * @param path Path to be appended to the URI supplied in the construtor * * @return JSON-encoded result or null when there's no content returned * * @throws RestException when an HTTP-level error occurs * @throws IOException when an error reading the response occurs * @throws URISyntaxException when an error occurred appending the path to the URI */ public JSON delete(String path) throws RestException, IOException, URISyntaxException { return delete(buildURI(path)); }
private JSON getNextPortion(Issue issue, Integer startAt) throws URISyntaxException, RestException, IOException { Map<String, String> params = new HashMap<String, String>(); if (startAt != null) { params.put("startAt", String.valueOf(startAt)); } params.put("expand","changelog.fields"); URI uri = restclient.buildURI(Issue.getBaseUri() + "issue/" + issue.id, params); return restclient.get(uri); } }
/** * Executes an HTTP POST with the given path. * * @param path Path to be appended to the URI supplied in the construtor * * @return JSON-encoded result or null when there's no content returned * * @throws RestException when an HTTP-level error occurs * @throws IOException when an error reading the response occurs * @throws URISyntaxException when an error occurred appending the path to the URI */ public JSON post(String path) throws RestException, IOException, URISyntaxException { return post(buildURI(path), new JSONObject()); }
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<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); }
/** * Obtains information about a project, given its project key. * @param key the project key * @return the project * @throws JiraException failed to obtain the project */ public Project getProject(String key) throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project/" + key); JSON response = restclient.get(uri); return new Project(restclient, (JSONObject) response); } catch (Exception ex) { throw new JiraException(ex.getMessage(), ex); } }
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); }
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 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); }