}
int docId = Integer.parseInt(id);
LOGGER.info("获取文档权限...");
Permissions permissions = DocViewer.getAttachmentService().getDocPermissionsById(docId, request);
LOGGER.info("文档权限:" + permissions);
if (permissions.equals(Permissions.NONE)) {
//response.setStatus(404);
LOGGER.info("无权查看该文档!");
return;
}
response.setContentType("application/json");
response.setStatus(202);
response.setHeader("Keep-Alive", "600");
response.flushBuffer();
writer = response.getWriter();
writer.flush();
LOGGER.info("获取文档页数...");
int pageCount = DocViewer.getDocPageCount(docId);
if (pageCount == 0) {
response.setStatus(404);
LOGGER.info("空白文档!");
return;
}
LOGGER.info("文档页数:" + pageCount + "页.");
String docUri;
String url = "/docviewer?doc=";
if (!DocViewer.isSplitPage()) {
docUri = request.getContextPath() + url + id;
} else {
docUri = request.getContextPath() + url + id + "-{[*,0]," + pageCount + "}";
}
LOGGER.info("回传文档信息...");
if (DocViewer.isEncryption()) {
String secretKey = DocViewer.getCurrentSecretKey();
request.getSession().setAttribute("secretKey", secretKey);
writer.write("{\"uri\":\"" + docUri + "\",\"key\":\"" + secretKey + "\",\"permissions\":" + permissions.ordinal() + "}");
} else {
writer.write("{\"uri\":\"" + docUri + "\",\"permissions\":" + permissions.ordinal() + "}");
}
} catch (Exception e) {
LOGGER.error(e);
response.setStatus(404);
} finally {