@Override
protected Response handlePut(Contact src, Key key, Request request,
InputStream in) throws IOException {
Context context = request.getContext();
MessageDigest md5 = MessageDigestUtils.createMD5();
MessageDigest sha1 = MessageDigestUtils.createSHA1();
DigestInputStream dis = new DigestInputStream(
in, MessageDigestUtils.wrap(md5, sha1));
// Create a random ID
KUID valueId = KUID.createRandom(key.getId());
File contentFile = null;
boolean success = false;
try {
contentFile = mkContentFile(key, valueId, true);
writeContent(context, contentFile, dis);
if (!digest(context, Constants.CONTENT_MD5, md5)) {
return ResponseFactory.INTERNAL_SERVER_ERROR;
}
if (!digest(context, Constants.CONTENT_SHA1, sha1)) {
return ResponseFactory.INTERNAL_SERVER_ERROR;
}
context.addHeader(Constants.VALUE_ID,
valueId.toHexString());
upsertVclock(key, context);
try {