/** * Sets the {@code Accept} header. * * @param mimeTypes the items to pass into the accept header * @return this */ public Builder setAccept(List<String> mimeTypes) { headers.setAccept(String.join(",", mimeTypes)); return this; }
private void delete(String url) { HttpHeaders headers = new HttpHeaders(); headers.setAccept("text/turtle"); headers.setCookie(authCookie); try { HttpRequest deleteRequest = factory.buildDeleteRequest(new GenericUrl(url)) .setThrowExceptionOnExecuteError(false); deleteRequest.setHeaders(headers); validateResponse(deleteRequest.execute(), 200); logger.debug("Deleted: {}", url); } catch (IOException e) { throw new IllegalStateException("Couldn't delete: " + url, e); } }
/** * Parses the contents of a URL to produce an RDF model. */ public Model getModel(String url) throws IOException { HttpRequestFactory factory = TRANSPORT.createRequestFactory(); HttpRequest rootGetRequest = factory.buildGetRequest( new GenericUrl(url)); HttpHeaders headers = new HttpHeaders(); headers.setCookie(authCookie); headers.setAccept("text/turtle"); rootGetRequest.setHeaders(headers); HttpResponse response = rootGetRequest.execute(); if (response.getStatusCode() != 200) { throw new IOException("Unexpected return code: " + response.getStatusCode() + "\nMessage:\n" + response.getStatusMessage()); } StringWriter writer = new StringWriter(); IOUtils.copy(response.getContent(), writer, "UTF-8"); String fixedString = fixProblematicPeriods(writer.toString()); Model defaultModel = ModelFactory.createDefaultModel(); return defaultModel.read( new StringReader(fixedString), url, "TURTLE"); }
/** * Sets the {@code Accept} header. * * @param mimeTypes the items to pass into the accept header * @return this */ public Builder setAccept(List<String> mimeTypes) { headers.setAccept(String.join(",", mimeTypes)); return this; }
/** * Sets the {@code Accept} header. * * @param mimeTypes the items to pass into the accept header * @return this */ public Builder setAccept(List<String> mimeTypes) { headers.setAccept(String.join(",", mimeTypes)); return this; }
@Override protected HttpHeaders getHttpHeaders() { return new HttpHeaders().setAccept(ACCEPT_HEADER); } }
@Override protected HttpHeaders getHttpHeaders() { return new HttpHeaders().setAccept(ACCEPT_HEADER).setBasicAuthentication(apiKey, ""); } }
request.setHeaders(new HttpHeaders().setAccept("application/json"));
restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers);
headers.setAccept("application/json");
public static String getLatestRevision(ServerProfile profile) throws IOException { // trying to construct the URL like // https://api.enterprise.apigee.com/v1/organizations/apigee-cs/apis/taskservice/ // response is like // { // "name" : "taskservice1", // "revision" : [ "1" ] // } String revision = ""; HttpRequest restRequest = REQUEST_FACTORY .buildGetRequest(new GenericUrl(profile.getHostUrl() + "/" + profile.getApi_version() + "/organizations/" + profile.getOrg() + "/apis/" + profile.getApplication() + "/")); restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers); try { HttpResponse response = executeAPI(profile, restRequest); AppRevision apprev = response.parseAs(AppRevision.class); Collections.sort(apprev.revision, new StringToIntComparator()); revision = apprev.revision.get(0); logger.info(PrintUtil.formatResponse(response, gson.toJson(apprev).toString())); } catch (HttpResponseException e) { logger.error(e.getMessage()); } return revision; }
restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers);
restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers);
public static void getRevision(ServerProfile profile) throws IOException { // trying to construct the URL like // https://api.enterprise.apigee.com/v1/organizations/apigee-cs/apis/taskservice/ // response is like // { // "name" : "taskservice1", // "revision" : [ "1" ] // } HttpRequest restRequest = REQUEST_FACTORY .buildGetRequest(new GenericUrl(profile.getHostUrl() + "/" + profile.getApi_version() + "/organizations/" + profile.getOrg() + "/apis/" + profile.getApplication() + "/")); restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers); try { HttpResponse response = executeAPI(profile, restRequest); AppRevision apprev = response.parseAs(AppRevision.class); Collections.sort(apprev.revision, new StringToIntComparator()); setVersionRevision(apprev.revision.get(0)); logger.info(PrintUtil.formatResponse(response, gson.toJson(apprev).toString())); } catch (HttpResponseException e) { logger.error(e.getMessage()); } }
headers.setAccept("application/json"); headers.setContentType("application/octet-stream"); HttpRequest deleteRestRequest = REQUEST_FACTORY.buildDeleteRequest(
undeployRestRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); undeployRestRequest.setHeaders(headers);
restRequest.setReadTimeout(0); HttpHeaders headers = new HttpHeaders(); headers.setAccept("application/json"); restRequest.setHeaders(headers);
request.setParser(flow.getJsonFactory().createJsonObjectParser()); request.getHeaders().setAccept(MediaType.APPLICATION_JSON); }) .setRedirectUri(findRedirectUrl(requestUrl))