List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding
public void setCharacterEncoding(String env) throws UnsupportedEncodingException;
From source file:org.kawanfw.file.servlet.ServerFileManager.java
/** * Post request./*from w w w. j a v a2 s .c om*/ */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); // Store the host info in RequestInfoStore // Important to do it before Exception, otw will throw Exception in // DefaultCommonsConfigurator.getServletNameFromServletPath() will throw Exception RequestInfoStore.init(request); // If init fail, say it cleanly client, instead of bad 500 Servlet Error if (exception != null) { OutputStream out = response.getOutputStream(); writeLine(out, TransferStatus.SEND_FAILED); writeLine(out, exception.getClass().getName()); // Exception class name writeLine(out, initErrrorMesage + " Reason: " + exception.getMessage()); // Exception message writeLine(out, ExceptionUtils.getStackTrace(exception)); // stack trace return; } // Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = this.getServletConfig().getServletContext(); File servletContextTempDir = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); // Wrap the HttpServletRequest with HttpServletRequestEncrypted for // parameters decryption HttpServletRequestConvertor requestEncrypted = new HttpServletRequestConvertor(request, commonsConfigurator); ServerFileDispatch dispatch = new ServerFileDispatch(); dispatch.executeRequest(requestEncrypted, response, servletContextTempDir, commonsConfigurator, fileConfigurator); }
From source file:com.kingcore.cms.clipper.controller.ClipperUploadAction.java
@RequestMapping(value = "/openPanel.jspx", method = RequestMethod.POST) // public String openPanel(HttpServletRequest request, HttpServletResponse response, ModelMap model) { log.debug("begin open ..."); CmsSite site = CmsUtils.getSite(request); //??/*w w w . j a v a 2s. c om*/ List<Channel> channelList = service.getAllChannelList(site.getId(), true); String encodee = request.getParameter("encodee"); String title = ""; if (encodee != null) { //gbk gb2312 try { request.setCharacterEncoding(encodee); title = request.getParameter("title"); title = java.net.URLDecoder.decode(title, "utf-8"); //?encodeURI?? } catch (UnsupportedEncodingException e) { title = ""; log.error(e); } } // try { // System.out.println(""+ title ); // System.out.println(""+ new String( title.getBytes(encodee),"utf-8" ) ); // System.out.println(""+ new String( title.getBytes("utf-8"), encodee) ); // System.out.println(""+ new String( title.getBytes("iso8859-1"), encodee) ); // System.out.println(""+ java.net.URLDecoder.decode(title, "utf-8") ); // } catch (UnsupportedEncodingException e) { // log.error(e); // } model.addAttribute("channelList", channelList); model.addAttribute("title", title); //? request.setAttribute("model", model); requestForward(request, response, "/clipper/upload.jsp"); return null; }
From source file:com.ikon.servlet.admin.MimeTypeServlet.java
@SuppressWarnings("unchecked") public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doPost({}, {})", request, response); request.setCharacterEncoding("UTF-8"); String action = WebUtils.getString(request, "action"); String userId = request.getRemoteUser(); Session dbSession = null;//from ww w. java 2 s.c o m updateSessionManager(request); try { if (ServletFileUpload.isMultipartContent(request)) { InputStream is = null; FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); MimeType mt = new MimeType(); byte data[] = null; for (Iterator<FileItem> it = items.iterator(); it.hasNext();) { FileItem item = it.next(); if (item.isFormField()) { if (item.getFieldName().equals("action")) { action = item.getString("UTF-8"); } else if (item.getFieldName().equals("mt_id")) { mt.setId(Integer.parseInt(item.getString("UTF-8"))); } else if (item.getFieldName().equals("mt_name")) { mt.setName(item.getString("UTF-8").toLowerCase()); } else if (item.getFieldName().equals("mt_extensions")) { String[] extensions = item.getString("UTF-8").split(" "); for (int i = 0; i < extensions.length; i++) { mt.getExtensions().add(extensions[i].toLowerCase()); } } } else { is = item.getInputStream(); data = IOUtils.toByteArray(is); mt.setImageMime(MimeTypeConfig.mimeTypes.getContentType(item.getName())); is.close(); } } if (action.equals("create")) { // Because this servlet is also used for SQL import and in that case I don't // want to waste a b64Encode conversion. Call it a sort of optimization. mt.setImageContent(SecureStore.b64Encode(data)); long id = MimeTypeDAO.create(mt); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_CREATE", Long.toString(id), null, mt.toString()); list(userId, request, response); } else if (action.equals("edit")) { // Because this servlet is also used for SQL import and in that case I don't // want to waste a b64Encode conversion. Call it a sort of optimization. mt.setImageContent(SecureStore.b64Encode(data)); MimeTypeDAO.update(mt); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_EDIT", Long.toString(mt.getId()), null, mt.toString()); list(userId, request, response); } else if (action.equals("delete")) { MimeTypeDAO.delete(mt.getId()); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_DELETE", Long.toString(mt.getId()), null, null); list(userId, request, response); } else if (action.equals("import")) { dbSession = HibernateUtil.getSessionFactory().openSession(); importMimeTypes(userId, request, response, data, dbSession); list(userId, request, response); } } } catch (DatabaseException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } catch (FileUploadException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } catch (SQLException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } finally { HibernateUtil.close(dbSession); } }
From source file:br.unicamp.cotuca.dpd.pd12.acinet.vagalmail.servlet.Configuracoes.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); request.setCharacterEncoding("UTF-8"); if (request.getRequestURI().contains("/pasta")) { String acao = request.getParameter("acao"), url = request.getParameter("url"), novo = request.getParameter("novo"); JSONObject obj = new JSONObject(); if (acao == null || url == null) { obj.put("erro", "Solicitao invlida"); obj.writeJSONString(response.getWriter()); return; }/* w w w .ja v a2 s. co m*/ if ((acao.equals("renomear") || acao.equals("nova")) && novo == null) { obj.put("erro", "Solicitao invlida"); obj.writeJSONString(response.getWriter()); return; } try { Conta conta = (Conta) request.getSession().getAttribute("conta"); Store store = Logar.getImapStore(conta); Folder pasta = null; if (!acao.equals("nova")) { URLName urln = new URLName(url); pasta = store.getFolder(urln); if (pasta.isOpen()) pasta.close(false); } switch (acao) { case "renomear": if (pasta.renameTo(store.getFolder(novo))) { obj.put("sucesso", "Renomeado com sucesso"); } else { obj.put("erro", "Erro ao renomear a pasta"); } break; case "esvaziar": pasta.open(Folder.READ_WRITE); pasta.setFlags(1, pasta.getMessageCount(), new Flags(Flags.Flag.DELETED), true); pasta.expunge(); obj.put("sucesso", "Esvaziado com sucesso"); break; case "excluir": if (pasta.delete(true)) { obj.put("sucesso", "Excludo com sucesso"); } else { obj.put("erro", "Erro ao excluir a pasta"); } break; case "nova": pasta = store.getFolder(novo); if (!pasta.exists()) { if (pasta.create(Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES)) { obj.put("sucesso", "Criado com sucesso"); } else { obj.put("erro", "Erro ao criar a pasta"); } } else { obj.put("erro", "Erro ao criar a pasta"); } break; } } catch (MessagingException ex) { obj.put("erro", "Erro ao processar solicitao"); } obj.writeJSONString(response.getWriter()); return; } String metodo = request.getParameter("acao"); if (metodo == null) { return; } else if (metodo.equals("nova")) { EntityManager em = BD.getEntityManager(); try { em.getTransaction().begin(); Login usuario = Logar.getLogin(request.getSession()); Conta conta = new Conta(); conta.setEmail(request.getParameter("email")); conta.setImapHost(request.getParameter("imapHost")); conta.setImapPort(Integer.parseInt(request.getParameter("imapPort"))); conta.setImapPassword(request.getParameter("imapPassword")); conta.setImapUser(request.getParameter("imapLogin")); conta.setSmtpHost(request.getParameter("smtpHost")); conta.setSmtpPort(Integer.parseInt(request.getParameter("smtpPort"))); conta.setSmtpPassword(request.getParameter("smtpPassword")); conta.setSmtpUser(request.getParameter("smtpLogin")); conta.setIdLogin(usuario); em.persist(conta); em.merge(usuario); em.getTransaction().commit(); em.refresh(conta); em.refresh(usuario); request.setAttribute("mensagem", "sucesso"); } catch (Logar.NaoAutenticadoException | PersistenceException ex) { em.getTransaction().rollback(); request.setAttribute("mensagem", "erro"); } request.getRequestDispatcher("/conf.jsp?metodo=nova").forward(request, response); } else if (metodo.equals("conta")) { EntityManager em = BD.getEntityManager(); try { em.getTransaction().begin(); Conta conta = (Conta) request.getSession().getAttribute("conta"); em.refresh(conta); conta.setEmail(request.getParameter("email")); conta.setImapHost(request.getParameter("imapHost")); conta.setImapPort(Integer.parseInt(request.getParameter("imapPort"))); conta.setImapPassword(request.getParameter("imapPassword")); conta.setImapUser(request.getParameter("imapLogin")); conta.setSmtpHost(request.getParameter("smtpHost")); conta.setSmtpPort(Integer.parseInt(request.getParameter("smtpPort"))); conta.setSmtpPassword(request.getParameter("smtpPassword")); conta.setSmtpUser(request.getParameter("smtpLogin")); em.getTransaction().commit(); request.setAttribute("mensagem", "sucesso"); } catch (PersistenceException ex) { em.getTransaction().rollback(); request.setAttribute("mensagem", "erro"); } request.getRequestDispatcher("/conf.jsp?metodo=conta").forward(request, response); } else if (metodo.equals("senha")) { EntityManager em = BD.getEntityManager(); try { Login usuario = Logar.getLogin(request.getSession()); em.refresh(usuario); String senatu = request.getParameter("senAtu"), novasen = request.getParameter("senNova"), novasen2 = request.getParameter("senNova2"); if (novasen.equals(novasen2) && senatu.equals(usuario.getSenha())) { em.getTransaction().begin(); usuario.setSenha(novasen); em.getTransaction().commit(); request.setAttribute("mensagem", "sucesso"); } else { if (!novasen.equals(novasen2)) request.setAttribute("mensagem", "senneq"); else request.setAttribute("mensagem", "antsen"); } } catch (Logar.NaoAutenticadoException | PersistenceException ex) { em.getTransaction().rollback(); request.setAttribute("mensagem", "erro"); } request.getRequestDispatcher("/conf.jsp?metodo=senha").forward(request, response); } }
From source file:com.wx.CoacherWXServlet.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from w w w . ja va2 s. c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //processRequest(request, response); //? response.setContentType("text/html;charset=utf-8"); //response.setCharacterEncoding("utf-8"); request.setCharacterEncoding("utf-8"); //???? String sToken = "testToken1"; String sCorpID = "wxe706b25abb1216c0"; String sEncodingAESKey = "R5zQRNXirEIQsSGL5Hs5ydZdSuu7EkRLWLViul1P7si"; try { WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID); // ?url? //URLDecoder.decode(request.getParameter("echostr"),"utf-8"); String sVerifyMsgSig = URLDecoder.decode(request.getParameter("msg_signature"), "utf-8"); String sVerifyTimeStamp = URLDecoder.decode(request.getParameter("timestamp"), "utf-8"); String sVerifyNonce = URLDecoder.decode(request.getParameter("nonce"), "utf-8"); String sVerifyEchoStr = URLDecoder.decode(request.getParameter("echostr"), "utf-8"); PrintWriter out = response.getWriter(); String sEchoStr; //? try { sEchoStr = wxcpt.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp, sVerifyNonce, sVerifyEchoStr); System.out.println("verifyurl echostr: " + sEchoStr); // ?URL?sEchoStr out.print(sEchoStr); out.close(); out = null; } catch (Exception e) { //?URL e.printStackTrace(); } } catch (AesException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:cn.itcast.bbs.controller.BbsServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); String method = request.getParameter("method"); if (method.equals("login")) { this.login(request, response); } else if (method.equals("register")) { this.register(request, response); } else if (method.equals("addTopic")) { this.addTopic(request, response); } else if (method.equals("addReply")) { this.addReply(request, response); } else if (method.equals("editTopic")) { this.editTopic(request, response); }/*from w w w .j a v a 2 s .c o m*/ }
From source file:de.ingrid.server.opensearch.servlet.OpensearchServerServlet.java
/** * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */// ww w . j a va 2 s. c o m @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { IngridHits hits = null; long overallStartTime = 0; if (log.isDebugEnabled()) { overallStartTime = System.currentTimeMillis(); } final RequestWrapper reqWrapper = new RequestWrapper(request); // set content Type request.setCharacterEncoding("UTF-8"); response.setContentType("text/xml"); response.setCharacterEncoding("UTF-8"); OSSearcher osSearcher = OSSearcher.getInstance(); if (osSearcher == null) { // redirect or show error page or empty result final PrintWriter pout = response.getWriter(); pout.write("Error: no index file found"); return; } int page = reqWrapper.getRequestedPage(); final int hitsPerPage = reqWrapper.getHitsPerPage(); if (page <= 0) { page = 1; } final int startHit = (page - 1) * hitsPerPage; try { // Hits also need Details which has title and summary!!! hits = osSearcher.searchAndDetails(reqWrapper.getQuery(), startHit, reqWrapper.getHitsPerPage()); } catch (final Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // transform hits into target format final OpensearchMapper mapper = (new SpringUtil("spring/spring.xml")).getBean("mapper", OpensearchMapper.class); final HashMap<String, Object> parameter = new HashMap<String, Object>(); parameter.put(OpensearchMapper.REQUEST_WRAPPER, reqWrapper); final Document doc = mapper.mapToXML(hits, parameter); // write target format final PrintWriter pout = response.getWriter(); pout.write(doc.asXML()); pout.close(); request.getInputStream().close(); doc.clearContent(); if (log.isDebugEnabled()) { log.debug("Time for complete search: " + (System.currentTimeMillis() - overallStartTime) + " ms"); } }
From source file:com.openkm.servlet.admin.MimeTypeServlet.java
@SuppressWarnings("unchecked") public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doPost({}, {})", request, response); request.setCharacterEncoding("UTF-8"); String action = WebUtils.getString(request, "action"); String userId = request.getRemoteUser(); Session dbSession = null;/*from w w w. j av a 2 s . c o m*/ updateSessionManager(request); try { if (ServletFileUpload.isMultipartContent(request)) { InputStream is = null; FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); MimeType mt = new MimeType(); byte data[] = null; for (Iterator<FileItem> it = items.iterator(); it.hasNext();) { FileItem item = it.next(); if (item.isFormField()) { if (item.getFieldName().equals("action")) { action = item.getString("UTF-8"); } else if (item.getFieldName().equals("mt_id")) { mt.setId(Integer.parseInt(item.getString("UTF-8"))); } else if (item.getFieldName().equals("mt_name")) { mt.setName(item.getString("UTF-8").toLowerCase()); } else if (item.getFieldName().equals("mt_description")) { mt.setDescription(item.getString("UTF-8").toLowerCase()); } else if (item.getFieldName().equals("mt_search")) { mt.setSearch(true); } else if (item.getFieldName().equals("mt_extensions")) { String[] extensions = item.getString("UTF-8").split(" "); for (int i = 0; i < extensions.length; i++) { mt.getExtensions().add(extensions[i].toLowerCase()); } } } else { is = item.getInputStream(); data = IOUtils.toByteArray(is); mt.setImageMime(MimeTypeConfig.mimeTypes.getContentType(item.getName())); is.close(); } } if (action.equals("create")) { // Because this servlet is also used for SQL import and in that case I don't // want to waste a b64Encode conversion. Call it a sort of optimization. mt.setImageContent(SecureStore.b64Encode(data)); long id = MimeTypeDAO.create(mt); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_CREATE", Long.toString(id), null, mt.toString()); list(userId, request, response); } else if (action.equals("edit")) { // Because this servlet is also used for SQL import and in that case I don't // want to waste a b64Encode conversion. Call it a sort of optimization. mt.setImageContent(SecureStore.b64Encode(data)); MimeTypeDAO.update(mt); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_EDIT", Long.toString(mt.getId()), null, mt.toString()); list(userId, request, response); } else if (action.equals("delete")) { MimeTypeDAO.delete(mt.getId()); MimeTypeConfig.loadMimeTypes(); // Activity log UserActivity.log(userId, "ADMIN_MIME_TYPE_DELETE", Long.toString(mt.getId()), null, null); list(userId, request, response); } else if (action.equals("import")) { dbSession = HibernateUtil.getSessionFactory().openSession(); importMimeTypes(userId, request, response, data, dbSession); list(userId, request, response); } } } catch (DatabaseException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } catch (FileUploadException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } catch (SQLException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } finally { HibernateUtil.close(dbSession); } }
From source file:com.edgenius.core.webapp.filter.LocaleFilter.java
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { // if(log.isDebugEnabled()){ // log.debug("Request URL: " + request.getRequestURI()); // }/*from w w w . j a va 2s . co m*/ //charset encoding if (!StringUtils.isEmpty(this.encoding)) request.setCharacterEncoding(encoding); else request.setCharacterEncoding(Constants.UTF8); String direction = null; Locale preferredLocale = null; TimeZone timezone = null; HttpSession session = request.getSession(false); if (getUserService() != null) { //for Install mode, it will return null User user = getUserService().getUserByName(request.getRemoteUser()); if (user != null && !user.isAnonymous()) { //locale UserSetting set = user.getSetting(); String userLang = set.getLocaleLanguage(); String userCountry = set.getLocaleCountry(); if (userLang != null && userCountry != null) { preferredLocale = new Locale(userLang, userCountry); } //text direction in HTML direction = set.getDirection(); //timezone if (set.getTimeZone() != null) timezone = TimeZone.getTimeZone(set.getTimeZone()); } } if (preferredLocale == null) { if (Global.DetectLocaleFromRequest) { Locale locale = request.getLocale(); if (locale != null) { preferredLocale = locale; } } if (preferredLocale == null) { preferredLocale = Global.getDefaultLocale(); } } if (direction == null) { direction = Global.DefaultDirection; } if (timezone == null) { if (session != null) { //try to get timezone from HttpSession, which will be intial set in SecurityControllerImpl.checkLogin() method timezone = (TimeZone) session.getAttribute(Constants.TIMEZONE); } if (timezone == null) timezone = TimeZone.getTimeZone(Global.DefaultTimeZone); } //set locale for STURTS and JSTL // set the time zone - must be set for dates to display the time zone if (session != null) { Config.set(session, Config.FMT_LOCALE, preferredLocale); session.setAttribute(Constants.DIRECTION, direction); Config.set(session, Config.FMT_TIME_ZONE, timezone); } //replace request by LocaleRequestWrapper if (!(request instanceof LocaleRequestWrapper)) { request = new LocaleRequestWrapper(request, preferredLocale); LocaleContextConfHolder.setLocale(preferredLocale); } if (chain != null) { request.setAttribute(PREFERRED_LOCALE, preferredLocale.toString()); chain.doFilter(request, response); } // Reset thread-bound LocaleContext. LocaleContextConfHolder.setLocaleContext(null); }
From source file:com.ikon.servlet.frontend.DownloadServlet.java
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("service({}, {})", request, response); request.setCharacterEncoding("UTF-8"); String path = request.getParameter("path"); String uuid = request.getParameter("uuid"); String[] uuidList = request.getParameterValues("uuidList"); String[] pathList = request.getParameterValues("pathList"); String checkout = request.getParameter("checkout"); String ver = request.getParameter("ver"); boolean export = request.getParameter("export") != null; boolean inline = request.getParameter("inline") != null; File tmp = File.createTempFile("okm", ".tmp"); Document doc = null;//from w w w . j av a2 s.com InputStream is = null; updateSessionManager(request); try { // Now an document can be located by UUID if (uuid != null && !uuid.equals("")) { path = OKMRepository.getInstance().getNodePath(null, uuid); } else if (path != null) { path = new String(path.getBytes("ISO-8859-1"), "UTF-8"); } if (export) { if (exportZip) { String fileName = "export.zip"; // Get document FileOutputStream os = new FileOutputStream(tmp); if (path != null) { exportFolderAsZip(path, os); fileName = PathUtils.getName(path) + ".zip"; } else if (uuidList != null || pathList != null) { // Export into a zip file multiple documents List<String> paths = new ArrayList<String>(); if (uuidList != null) { for (String uuidElto : uuidList) { String foo = new String(uuidElto.getBytes("ISO-8859-1"), "UTF-8"); paths.add(OKMRepository.getInstance().getNodePath(null, foo)); } } else if (pathList != null) { for (String pathElto : pathList) { String foo = new String(pathElto.getBytes("ISO-8859-1"), "UTF-8"); paths.add(foo); } } fileName = PathUtils.getName(PathUtils.getParent(paths.get(0))); exportDocumentsAsZip(paths, os, fileName); fileName += ".zip"; } os.flush(); os.close(); is = new FileInputStream(tmp); // Send document WebUtils.sendFile(request, response, fileName, MimeTypeConfig.MIME_ZIP, inline, is); } else if (exportJar) { // Get document FileOutputStream os = new FileOutputStream(tmp); exportFolderAsJar(path, os); os.flush(); os.close(); is = new FileInputStream(tmp); // Send document String fileName = PathUtils.getName(path) + ".jar"; WebUtils.sendFile(request, response, fileName, "application/x-java-archive", inline, is); } } else { // Get document doc = OKMDocument.getInstance().getProperties(null, path); if (ver != null && !ver.equals("")) { is = OKMDocument.getInstance().getContentByVersion(null, path, ver); } else { is = OKMDocument.getInstance().getContent(null, path, checkout != null); } // Send document String fileName = PathUtils.getName(doc.getPath()); WebUtils.sendFile(request, response, fileName, doc.getMimeType(), inline, is); UserActivity.log(request.getRemoteUser(), "DOWNLOAD_DOCUMENT", uuid, path, null); } } catch (PathNotFoundException e) { log.warn(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_PathNotFound), e.getMessage())); } catch (RepositoryException e) { log.warn(e.getMessage(), e); throw new ServletException( new OKMException(ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_Repository), e.getMessage())); } catch (IOException e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_IO), e.getMessage())); } catch (DatabaseException e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_Database), e.getMessage())); } catch (Exception e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_General), e.getMessage())); } finally { IOUtils.closeQuietly(is); FileUtils.deleteQuietly(tmp); } log.debug("service: void"); }