LookAheadInputStream lis = new LookAheadInputStream(is, 16);
if(!lis.startsWith("PK")) {
result(req, resp, HttpServletResponse.SC_BAD_REQUEST, "The uploaded file is not a zip file");
return;
}
JsonImport imp = new JsonImport(new JsonImport.ZipImportSource(lis));
// Delete all the documents
View view = DominoUtils.getCurrentDatabase().getView("AllSnippetsById");
try {
view.getAllEntriesByKey(key).removeAll(true);
} finally {
view.recycle();
}
// And import the new ones
imp.importDocuments(DominoUtils.getCurrentDatabase());
result(req, resp, HttpServletResponse.SC_OK, "");
} finally {
StreamUtil.close(is);
}