public void export(String pid, OutputStream out) throws IOException { StringBuilder uri = new StringBuilder(getBaseUrl()); uri.append("/objects/"); uri.append(pid); uri.append("/export"); GetMethod method = new GetMethod(uri.toString()); int status = executeMethod(method); if (status == HttpStatus.SC_OK) { InputStream in = method.getResponseBodyAsStream(); StreamUtils.copyStream(in, out); in.close(); } else { log.warn("GET " + uri + " returned " + status); } method.releaseConnection(); }
public int get(String pid, String dsId, OutputStream out) throws IOException { StringBuilder uri = new StringBuilder(getBaseUrl()); uri.append("/get/"); uri.append(pid); if (dsId != null) { uri.append("/"); uri.append(dsId); } GetMethod method = new GetMethod(uri.toString()); int status = executeMethod(method); if (status == HttpStatus.SC_OK) { InputStream in = method.getResponseBodyAsStream(); StreamUtils.copyStream(in, out); in.close(); } method.releaseConnection(); return status; }