public T handleResponse(HttpResponse response) throws IOException { int respCode = response.getStatusLine().getStatusCode(); if (respCode == 200 || respCode == 201 || respCode == 203 || respCode == 204 || respCode == 205) { return handler.handleResponse(response); } else { throw error(request, respCode); } } }, context);
private void readHttpEntity(final URI uri, final String accept, final String overrideContentType, final DataReader handler) throws IOException, ClientProtocolException, Error { final HttpContext localContext = new BasicHttpContext(); HttpGet get = new HttpGet(uri); get.setHeader("Accept", accept); execute(get, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException { URI contentId = getContentId(localContext); HttpEntity entity = response.getEntity(); Header hd = entity.getContentType(); String type = null; if (hd != null) { type = hd.getValue(); } if (overrideContentType != null) { type = overrideContentType; } handler.load(contentId, type, entity.getContent(), entity.getContentLength()); return null; } }, localContext); }
private <T> T execute(final HttpUriRequest request, final ResponseHandler<? extends T> handler, HttpContext context) throws IOException, ClientProtocolException { return getHttpClient().execute(request, new ResponseHandler<T>() { public T handleResponse(HttpResponse response) throws IOException { int respCode = response.getStatusLine().getStatusCode(); if (respCode == 200 || respCode == 201 || respCode == 203 || respCode == 204 || respCode == 205) { return handler.handleResponse(response); } else { throw error(request, respCode); } } }, context); }
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { readHttpEntity(uri, accept, overrideContentType, handler); } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
public synchronized DataStore getDataStore() { if (dataStore == null) { DataStore fallback = new URLDataStore(new FallbackDataStore()); if (!getSafeMode()) { fallback = new FileDataStore(fallback); } dataStore = new HttpClientDataStore(getHttpClient(), fallback); } return dataStore; }
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { readHttpEntity(uri, accept, overrideContentType, handler); } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
public synchronized DataStore getDataStore() { if (dataStore == null) { DataStore fallback = new URLDataStore(new FallbackDataStore()); if (!getSafeMode()) { fallback = new FileDataStore(fallback); } dataStore = new HttpClientDataStore(getHttpClient(), fallback); } return dataStore; }
private void readHttpEntity(final URI uri, final String accept, final String overrideContentType, final DataReader handler) throws IOException, ClientProtocolException, Error { final HttpContext localContext = new BasicHttpContext(); HttpGet get = new HttpGet(uri); get.setHeader("Accept", accept); execute(get, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException { URI contentId = getContentId(localContext); HttpEntity entity = response.getEntity(); Header hd = entity.getContentType(); String type = null; if (hd != null) { type = hd.getValue(); } if (overrideContentType != null) { type = overrideContentType; } handler.load(contentId, type, entity.getContent(), entity.getContentLength()); return null; } }, localContext); }
public T handleResponse(HttpResponse response) throws IOException { int respCode = response.getStatusLine().getStatusCode(); if (respCode == 200 || respCode == 201 || respCode == 203 || respCode == 204 || respCode == 205) { return handler.handleResponse(response); } else { throw error(request, respCode); } } }, context);
private <T> T execute(final HttpUriRequest request, final ResponseHandler<? extends T> handler, HttpContext context) throws IOException, ClientProtocolException { return getHttpClient().execute(request, new ResponseHandler<T>() { public T handleResponse(HttpResponse response) throws IOException { int respCode = response.getStatusLine().getStatusCode(); if (respCode == 200 || respCode == 201 || respCode == 203 || respCode == 204 || respCode == 205) { return handler.handleResponse(response); } else { throw error(request, respCode); } } }, context); }
public void deleteEntry(String href, String base) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { final HttpContext localContext = new BasicHttpContext(); execute(new HttpDelete(uri), new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException { return null; } }, localContext); } else { fallback.deleteEntry(href, base); } }
public void deleteEntry(String href, String base) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { final HttpContext localContext = new BasicHttpContext(); execute(new HttpDelete(uri), new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException { return null; } }, localContext); } else { fallback.deleteEntry(href, base); } }
return execute(post, new ResponseHandler<URI>() { public URI handleResponse(HttpResponse response) throws IOException {
return execute(post, new ResponseHandler<URI>() { public URI handleResponse(HttpResponse response) throws IOException {
HttpHead head = new HttpHead(uri); head.setHeader("Accept", accept); execute(head, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException {
HttpHead head = new HttpHead(uri); head.setHeader("Accept", accept); execute(head, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response) throws IOException {