use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TestHttpResource method testHead.
@Test
@Ignore
public void testHead() throws IOException, MappableException, UserException {
BinaryStoreAdapter bsa = new BinaryStoreAdapter();
bsa.load(access);
Binary b = createBinary();
b.setMimeType("text/plain");
boolean exists = bsa.headBinary(b.getHexDigest(), "binstore", "junit");
Assert.assertFalse(exists);
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TestHttpResource method testPut.
@Test
@Ignore
public void testPut() throws IOException, MappableException, UserException {
BinaryStoreAdapter bsa = new BinaryStoreAdapter();
bsa.load(access);
Binary b = createBinary();
bsa.storeBinary(b, "binstore", "junit", false);
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TestHttpResource method testStoreAdapterBasics.
@Test
@Ignore
public void testStoreAdapterBasics() throws IOException, MappableException, UserException, InterruptedException {
BinaryStoreAdapter bsa = new BinaryStoreAdapter();
bsa.load(access);
Binary b = createBinary();
String bb = bsa.storeBinary(b, "binstore", "junit", false);
System.err.println("Result of put: " + bb);
boolean existsNow = bsa.headBinary(b.getHexDigest(), "binstore", "junit");
Assert.assertTrue(existsNow);
System.err.println("exists after insert: " + existsNow);
ReactiveReply result = bsa.deleteBinary(b.getHexDigest(), "binstore", "junit", false);
System.err.println("Delete: " + result.status());
boolean exists = bsa.headBinary(b.getHexDigest(), "binstore", "junit");
Assert.assertFalse(exists);
System.err.println("exists after delete: " + exists);
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TmlHttpServlet method sendResponse.
private static void sendResponse(HttpServletRequest request, HttpServletResponse response, Navajo resultMessage) {
ServletOutputStream outputStream = null;
try {
String dataPath = request.getParameter("dataPath");
outputStream = response.getOutputStream();
if (dataPath != null) {
Property bin = resultMessage.getProperty(dataPath);
if (bin == null) {
java.io.OutputStreamWriter out = new java.io.OutputStreamWriter(outputStream, "UTF-8");
response.setContentType("text/xml; charset=UTF-8");
resultMessage.write(out);
out.flush();
out.close();
} else {
// Will throw cce when not a binary?
if (bin.getTypedValue() instanceof Binary) {
Binary b = (Binary) bin.getTypedValue();
response.setContentType(b.getMimeType());
if (b.getLength() > 0) {
response.setContentLength((int) b.getLength());
response.setHeader("Accept-Ranges", "none");
response.setHeader("Connection", "close");
}
copyResource(outputStream, b.getDataAsStream());
} else {
outputStream.write(bin.getValue().getBytes());
}
outputStream.flush();
}
} else {
java.io.OutputStreamWriter out = new java.io.OutputStreamWriter(outputStream, "UTF-8");
response.setContentType("text/xml; charset=UTF-8");
resultMessage.write(out);
out.flush();
out.close();
}
} catch (NavajoException e) {
logger.error("Error handling response: ", e);
} catch (IOException e) {
logger.error("Error handling response: ", e);
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
logger.warn("Stream closing problem", e);
}
}
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class Access method getRequestNavajo.
public Binary getRequestNavajo() throws UserException {
Binary b = new Binary();
if (inDoc != null) {
try {
OutputStream os = b.getOutputStream();
inDoc.write(os);
os.close();
} catch (IOException t) {
throw new UserException(-1, t.getMessage(), t);
}
}
return b;
}
Aggregations