/** * Execute the HTTP request */ private CloseableHttpResponse executeRequest(final HttpRequestBase request) throws FcrepoOperationFailedException { try { return httpclient.execute(request); } catch (final IOException ex) { LOGGER.debug("HTTP Operation failed: ", ex); throw new FcrepoOperationFailedException(request.getURI(), -1, ex.getMessage()); } }
builder.filename((String) params.get("filename")); } catch (FcrepoOperationFailedException e) { throw new RuntimeException(e.getMessage(), e);
builder.filename((String) params.get("filename")); } catch (FcrepoOperationFailedException e) { throw new RuntimeException(e.getMessage(), e);
/** * Provide a content disposition header which will be used as the filename * * @param filename the name of the file being provided in the body of the request * @return this builder * @throws FcrepoOperationFailedException if unable to encode filename */ public PostBuilder filename(final String filename) throws FcrepoOperationFailedException { try { final String f = (filename != null) ? "; filename=\"" + URLEncoder.encode(filename, "utf-8") + "\"" : ""; request.addHeader(CONTENT_DISPOSITION, "attachment" + f); } catch (final UnsupportedEncodingException e) { throw new FcrepoOperationFailedException(request.getURI(), -1, e.getMessage()); } return this; }
/** * Provide a content disposition header which will be used as the filename * * @param filename the name of the file being provided in the body of the request * @return this builder * @throws FcrepoOperationFailedException if unable to encode filename */ public PutBuilder filename(final String filename) throws FcrepoOperationFailedException { try { final String f = (filename != null) ? "; filename=\"" + URLEncoder.encode(filename, "utf-8") + "\"" : ""; request.addHeader(CONTENT_DISPOSITION, "attachment" + f); } catch (final UnsupportedEncodingException e) { throw new FcrepoOperationFailedException(request.getURI(), -1, e.getMessage()); } return this; }
/** * Handle the general case with responses. */ private FcrepoResponse fcrepoGenericResponse(final URI url, final CloseableHttpResponse response, final Boolean throwExceptionOnFailure) throws FcrepoOperationFailedException { final int status = response.getStatusLine().getStatusCode(); final Map<String, List<String>> headers = getHeaders(response); if ((status >= HttpStatus.SC_OK && status < HttpStatus.SC_BAD_REQUEST) || !throwExceptionOnFailure) { return new FcrepoResponse(url, status, headers, getEntityContent(response)); } else { free(response); throw new FcrepoOperationFailedException(url, status, response.getStatusLine().getReasonPhrase()); } }