public static Document getDocument(Long id, boolean checkUser) { DocumentDaoImpl dao = DB.getDocumentDao(); DocumentModel model = null; if (checkUser) { model = dao.getDocumentByIdAndUser(id, SessionHelper.getCurrentUser().getUserId()); } else { model = dao.getById(id); } return getDoc(model); }
private String getDocUrl(Long docId) { return SessionHelper.generateDocUrl(docId); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException { // super.doGet(req, resp); HttpSession session = null; Request wiraRequest = new Request(); try { session = request.getSession(true); SessionHelper.setHttpRequest(request); } catch (Exception e) { e.printStackTrace(); } Response response = new Response(); try { DB.beginTransaction(); wiraRequest.setCommandName(IncomingRequestImpl.NEWAPPROVALREQUESTCOMMAND); String parameter = request.getParameter("docType"); RequestType requestType = RequestType.getRequestType(parameter); // Create Context and set it wiraRequest.setContext(createContext(request, requestType, wiraRequest)); HTUser user = new HTUser(); user.setUserId(wiraRequest.getContext("ownerId").toString()); if (session != null) session.setAttribute(ServerConstants.USER, user); // Submit IncomingRequestImpl handler = new IncomingRequestImpl(); handler.executeClientRequest(wiraRequest, response); // Response PrintWriter out = resp.getWriter(); BusinessKey key = response.getBusinessKey(); assert key != null; resp.setContentType("text/json"); out.println( "Response:" + key.getDocumentId() + " : " + key.getProcessInstanceId() + ":" + key.getSessionId() + "</b>"); out.close(); DB.commitTransaction(); } catch (Exception e) { DB.rollback(); e.printStackTrace(); throw new RuntimeException(e); } finally { if (session != null) { session.invalidate(); } DB.closeSession(); SessionHelper.setHttpRequest(null); JBPMHelper.clearRequestData(); } }