/** * Executes an HTTP GET 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 get(String path) throws RestException, IOException, URISyntaxException { return get(path, null); }
RestClient client = RestClient.builder().build(); String url = ... Person person = client.get(url, null, Person.class); //no queryParams
/** * Executes an HTTP GET 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 get(String path) throws RestException, IOException, URISyntaxException { return get(path, null); }
class YourClass { @Inject private RestClient restClient; //Injecting RestClient public Address getOfficeLocation(String id){ String url = String.format(officeAddress, id); JSONObject jsonObject = restClient.get(url, null, credentials); return AddressParser.parseOfficeAddress(jsonObject); } }
RestClient client = RestClient.builder().build(); String geocoderUrl = "http://maps.googleapis.com/maps/api/geocode/json" Map<String, String> params = Maps.newHashMap(); params.put("address", "beverly hills 90210"); params.put("sensor", "false"); JsonNode node = client.get(geocoderUrl, params, JsonNode.class);
/** * 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 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)); }
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); } }
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); } }
/** * 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); }
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"); }
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"); }