HttpRemotePipeline implements RemotePipeline { public DocumentFile<Local> getFile(String fileName, DocumentID<Local> docid) { try { HttpResponse response = core.get(getFileUrl(fileName, docid)); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { Object o; try { o = SerializationUtils.toObject(EntityUtils.toString(response.getEntity())); } catch (JsonException e) { throw new IOException(e); } if (!(o instanceof Map)) { return null; } @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) o; Date d = (Date) map.get("uploadDate"); String encoding = (String) map.get("encoding"); String mimetype = (String) map.get("mimetype"); String savedByStage = (String) map.get("savedByStage"); InputStream is; if (encoding == null) { is = new ByteArrayInputStream(Base64.decodeBase64(((String) map.get("stream")).getBytes("UTF-8"))); } else { is = new ByteArrayInputStream(Base64.decodeBase64(((String) map.get("stream")).getBytes(encoding))); } DocumentFile<Local> df = new DocumentFile<Local>(docid, fileName, is, savedByStage, d); df.setEncoding(encoding); df.setMimetype(mimetype); return df; } else { logUnexpected("getFile()", response); return null; } } catch (IOException e) { throw new RuntimeException(e); } } HttpRemotePipeline(String stageName);  HttpRemotePipeline(String hostName, int port, String stageName);  HttpRemotePipeline(String hostName, int port, String stageName, boolean performanceLogging); @Override LocalDocument getDocument(LocalQuery query); @Override boolean saveFull(LocalDocument d); @Override boolean save(LocalDocument d); @Override boolean markPending(LocalDocument d); @Override boolean markFailed(LocalDocument d); @Override boolean markFailed(LocalDocument d, Throwable t); @Override boolean markProcessed(LocalDocument d); @Override boolean markDiscarded(LocalDocument d); @Override AbstractProcessStage getStageInstance(); DocumentFile<Local> getFile(String fileName, DocumentID<Local> docid); boolean saveFile(DocumentFile<Local> df); boolean deleteFile(String fileName, DocumentID<Local> docid); @SuppressWarnings("unchecked") List<String> getFileNames(DocumentID<?> docid); List<DocumentFile<Local>> getFiles(DocumentID<Local> docid); @Override String getStageName(); @Override boolean isPerformanceLogging();  }
@Test public void testGetFile() throws IOException { String fileName = "file1"; byte[] bytes = "file content".getBytes("UTF-8"); Date date = new Date(); String encoding = "UTF-8"; String mimetype = "text"; stubFile(fileName, doc.getID(), bytes, date, encoding, mimetype); DocumentFile<Local> expected = new DocumentFile<Local>(doc.getID(), fileName, new ByteArrayInputStream(bytes), stageName, date); expected.setEncoding(encoding); expected.setMimetype(mimetype); DocumentFile<Local> actual = rp.getFile(fileName, doc.getID()); documentFileEquals(expected, actual); }