List of usage examples for javax.servlet ServletContext getMimeType
public String getMimeType(String file);
null
if the MIME type is not known. From source file:controller.CommercialController.java
@RequestMapping(value = "regub/commercial/contrats/deviscom", method = RequestMethod.POST) //public @ResponseBody String devisAction(HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model) throws IOException { Client cli = (Client) request.getAttribute("clicom"); int idvideo = Integer.parseInt(request.getParameter("idvideo")); Devis devis = new Devis(); devis.Consulter(VidBDD.VideoPrec(idvideo).get(0).getClient(), VidBDD.VideoPrec(idvideo).get(0), request.getServletContext()); //if(request.getSession()){ //int test = Integer.parseInt(request.getParameter("select")) ; //request.setAttribute("Modify", this.modif.modifcontrat(id)); //}/*from ww w.j a v a 2s .co m*/ //session.setAttribute("Modify", this.modif.modifcontrat(id)); int BUFFER_SIZE = 4096; ServletContext context = request.getServletContext(); String appPath = context.getRealPath(""); System.out.println(appPath); try { File downloadFile = new File(appPath + "\\resources\\reports\\devis.pdf"); FileInputStream fis = new FileInputStream(downloadFile); // get MIME type of the file String mimeType = context.getMimeType(appPath + "\\resources\\reports\\devis.pdf"); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } System.out.println("MIME type: " + mimeType); // set content attributes for the response response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); // set headers for the response String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // get output stream of the response OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; // write bytes read from the input stream into the output stream while ((bytesRead = fis.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } fis.close(); outStream.close(); } catch (Exception ex) { ex.printStackTrace(); } return "redirect:/regub/commercial/contrats/" + cli.getIdClient(); }
From source file:controller.CommercialController.java
@RequestMapping(value = "regub/commercial/contrats/facturecom", method = RequestMethod.POST) //public @ResponseBody String factureAction(HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model) throws IOException { int idvideo = Integer.parseInt(request.getParameter("idvideo")); Facture facture = new Facture(); facture.Consulter(VidBDD.VideoPrec(idvideo).get(0).getClient(), VidBDD.VideoPrec(idvideo).get(0), request.getServletContext()); //if(request.getSession()){ //int test = Integer.parseInt(request.getParameter("select")) ; //request.setAttribute("Modify", this.modif.modifcontrat(id)); //}// w w w .j a va 2 s . c om //session.setAttribute("Modify", this.modif.modifcontrat(id)); int BUFFER_SIZE = 4096; ServletContext context = request.getServletContext(); String appPath = context.getRealPath(""); System.out.println(appPath); try { File downloadFile = new File(appPath + "\\resources\\reports\\facture.pdf"); FileInputStream fis = new FileInputStream(downloadFile); // get MIME type of the file String mimeType = context.getMimeType(appPath + "\\resources\\reports\\facture.pdf"); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } System.out.println("MIME type: " + mimeType); // set content attributes for the response response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); // set headers for the response String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // get output stream of the response OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; // write bytes read from the input stream into the output stream while ((bytesRead = fis.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } fis.close(); outStream.close(); } catch (Exception ex) { ex.printStackTrace(); } return "redirect:/regub/commercial/contrats/" + VidBDD.VideoPrec(idvideo).get(0).getClient().getIdClient(); }
From source file:controller.CommercialController.java
@RequestMapping(value = "regub/commercial/deviscom", method = RequestMethod.POST) //public @ResponseBody String devis2Action(HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model) throws IOException { Client cli = (Client) request.getAttribute("clicom"); int idvideo = Integer.parseInt(request.getParameter("idvideo")); Devis devis = new Devis(); devis.Consulter(VidBDD.VideoPrec(idvideo).get(0).getClient(), VidBDD.VideoPrec(idvideo).get(0), request.getServletContext()); //if(request.getSession()){ //int test = Integer.parseInt(request.getParameter("select")) ; //request.setAttribute("Modify", this.modif.modifcontrat(id)); //}/*from w ww. j a va 2 s. co m*/ //session.setAttribute("Modify", this.modif.modifcontrat(id)); int BUFFER_SIZE = 4096; ServletContext context = request.getServletContext(); String appPath = context.getRealPath(""); System.out.println(appPath); try { File downloadFile = new File(appPath + "\\resources\\reports\\devis.pdf"); FileInputStream fis = new FileInputStream(downloadFile); // get MIME type of the file String mimeType = context.getMimeType(appPath + "\\resources\\reports\\devis.pdf"); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } System.out.println("MIME type: " + mimeType); // set content attributes for the response response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); // set headers for the response String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // get output stream of the response OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; // write bytes read from the input stream into the output stream while ((bytesRead = fis.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } fis.close(); outStream.close(); } catch (Exception ex) { ex.printStackTrace(); } return "redirect:/regub/commercial/derniercontras"; }
From source file:controller.CommercialController.java
@RequestMapping(value = "regub/commercial/facturecom", method = RequestMethod.POST) //public @ResponseBody String facture2Action(HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model) throws IOException { int idvideo = Integer.parseInt(request.getParameter("idvideo")); Facture facture = new Facture(); facture.Consulter(VidBDD.VideoPrec(idvideo).get(0).getClient(), VidBDD.VideoPrec(idvideo).get(0), request.getServletContext()); //if(request.getSession()){ //int test = Integer.parseInt(request.getParameter("select")) ; //request.setAttribute("Modify", this.modif.modifcontrat(id)); //}/* w w w. j av a 2 s . co m*/ //session.setAttribute("Modify", this.modif.modifcontrat(id)); int BUFFER_SIZE = 4096; ServletContext context = request.getServletContext(); String appPath = context.getRealPath(""); System.out.println(appPath); try { File downloadFile = new File(appPath + "\\resources\\reports\\facture.pdf"); FileInputStream fis = new FileInputStream(downloadFile); // get MIME type of the file String mimeType = context.getMimeType(appPath + "\\resources\\reports\\facture.pdf"); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } System.out.println("MIME type: " + mimeType); // set content attributes for the response response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); // set headers for the response String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // get output stream of the response OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; // write bytes read from the input stream into the output stream while ((bytesRead = fis.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } fis.close(); outStream.close(); } catch (Exception ex) { ex.printStackTrace(); } return "redirect:/regub/commercial/contrats/derniercontrats"; }
From source file:com.rr.wabshs.ui.calendar.calendarController.java
/** * The '/ical-events' GET request will create the iCal .ics file to be uploaded to a calendar * @param session//from ww w . j a v a2s . c om * @param response * @return */ @RequestMapping(value = "/ical-events", method = RequestMethod.GET) public ModelAndView getEventsForIcal(HttpServletRequest request, HttpSession session, HttpServletResponse response) throws Exception { /* List Calender Events */ List<calendarEvents> calendarEvents = calendarManager.getPublicCalendarEvents(programId); if (calendarEvents != null && calendarEvents.size() > 0) { fileSystem dir = new fileSystem(); dir.setDir(registryName, ""); String fileName = "ical-nyopce-events.ics"; File newFile = new File(dir.getDir() + fileName); /* Create the empty file in the correct location */ try { if (newFile.exists()) { newFile.delete(); newFile.createNewFile(); } else { newFile.createNewFile(); } } catch (IOException e) { e.printStackTrace(); } /* Read in the file */ FileInputStream fileInput = null; File file = new File(dir.getDir() + fileName); fileInput = new FileInputStream(file); FileWriter fw = null; try { fw = new FileWriter(file, true); } catch (IOException ex) { Logger.getLogger(exportManager.class.getName()).log(Level.SEVERE, null, ex); } SimpleDateFormat iCaldateFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat iCalTimeFormat = new SimpleDateFormat("hh:mm a"); SimpleDateFormat iCalTimeFormatToTime = new SimpleDateFormat("HHmmss"); StringBuilder iCalRow = new StringBuilder(); iCalRow.append("BEGIN:VCALENDAR"); iCalRow.append("\r\n"); iCalRow.append("VERSION:2.0"); iCalRow.append("\r\n"); iCalRow.append("PRODID:-//NYOPCE - ECPv4.0.4//NONSGML v1.0//EN"); iCalRow.append("\r\n"); iCalRow.append("CALSCALE:GREGORIAN"); iCalRow.append("\r\n"); iCalRow.append("METHOD:PUBLISH"); iCalRow.append("\r\n"); iCalRow.append("X-WR-CALNAME:NYOPCE"); iCalRow.append("\r\n"); iCalRow.append("X-ORIGINAL-URL:http://nyopce.wpengine.com"); iCalRow.append("\r\n"); iCalRow.append("X-WR-CALDESC:Events for NYOPCE"); iCalRow.append("\r\n"); for (calendarEvents event : calendarEvents) { Date startTime = iCalTimeFormat .parse(event.getEventStartTime().replace("am", " AM").replace("pm", " PM")); Date endTime = iCalTimeFormat .parse(event.getEventEndTime().replace("am", " AM").replace("pm", " PM")); iCalRow.append("BEGIN:VEVENT"); iCalRow.append("\r\n"); iCalRow.append("DTSTART:").append(iCaldateFormat.format(event.getEventStartDate())).append("T") .append(iCalTimeFormatToTime.format(startTime)); iCalRow.append("\r\n"); iCalRow.append("DTEND:").append(iCaldateFormat.format(event.getEventEndDate())).append("T") .append(iCalTimeFormatToTime.format(endTime)); iCalRow.append("\r\n"); iCalRow.append("DTSTAMP:").append("20160107T132605"); iCalRow.append("\r\n"); iCalRow.append("CREATED:").append(iCaldateFormat.format(event.getDateCreated())); iCalRow.append("\r\n"); iCalRow.append("LAST-MODIFIED:").append(iCaldateFormat.format(event.getDateCreated())); iCalRow.append("\r\n"); iCalRow.append("UID:").append(""); iCalRow.append("\r\n"); iCalRow.append("SUMMARY:").append(event.getEventTitle().replace("&", "and")); iCalRow.append("\r\n"); iCalRow.append("DESCRIPTION:").append(event.getEventNotes()); iCalRow.append("\r\n"); iCalRow.append("URL:").append(""); iCalRow.append("\r\n"); iCalRow.append("LOCATION:").append(event.getEventLocation()); iCalRow.append("\r\n"); iCalRow.append("GEO:").append(""); iCalRow.append("\r\n"); iCalRow.append("X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=").append(""); iCalRow.append("\r\n"); iCalRow.append("CATEGORIES:").append(event.getCategoryName()); iCalRow.append("\r\n"); iCalRow.append("END:VEVENT"); iCalRow.append("\r\n"); } iCalRow.append("END:VCALENDAR"); fw.write(iCalRow.toString()); fw.close(); ServletContext context = request.getServletContext(); String mimeType = context.getMimeType(dir.getDir() + fileName); File f = new File(dir.getDir() + fileName); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } response.setContentType(mimeType); OutputStream outputStream = null; InputStream in = null; in = new FileInputStream(dir.getDir() + fileName); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = 0; response.setContentLength((int) f.length()); response.setHeader("Content-Transfer-Encoding", "binary"); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); outputStream = response.getOutputStream(); while (0 < (bytesRead = in.read(buffer))) { outputStream.write(buffer, 0, bytesRead); } in.close(); outputStream.close(); } return null; }
From source file:net.urosk.reportEngine.ReportsServlet.java
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String reportDesign = request.getParameter("__report"); String type = request.getParameter("__format"); String outputFilename = request.getParameter("__filename"); String attachment = request.getParameter("attachment"); //check parameters StringBuffer msg = new StringBuffer(); // checkers//from w w w . j a va 2 s .c o m if (isEmpty(reportDesign)) { msg.append("<BR>__report can not be empty"); } OutputType outputType = null; try { outputType = OutputType.valueOf(type.toUpperCase()); } catch (Exception e) { msg.append("Undefined report __format: " + type + ". Set __format=" + OutputType.values()); } // checkers if (isEmpty(outputFilename)) { msg.append("<BR>__filename can not be empty"); } try { ServletOutputStream out = response.getOutputStream(); ServletContext context = request.getSession().getServletContext(); // output error if (StringUtils.isNotEmpty(msg.toString())) { out.print(msg.toString()); return; } ReportDef def = new ReportDef(); def.setDesignFileName(reportDesign); def.setOutputType(outputType); @SuppressWarnings("unchecked") Map<String, String[]> params = request.getParameterMap(); Iterator<String> i = params.keySet().iterator(); while (i.hasNext()) { String key = i.next(); String value = params.get(key)[0]; def.getParameters().put(key, value); } try { String createdFile = birtReportEngine.createReport(def); File file = new File(createdFile); String mimetype = context.getMimeType(file.getAbsolutePath()); String inlineOrAttachment = (attachment != null) ? "attachment" : "inline"; response.setContentType((mimetype != null) ? mimetype : "application/octet-stream"); response.setContentLength((int) file.length()); response.setHeader("Content-Disposition", inlineOrAttachment + "; filename=\"" + outputFilename + "\""); DataInputStream in = new DataInputStream(new FileInputStream(file)); byte[] bbuf = new byte[1024]; int length; while ((in != null) && ((length = in.read(bbuf)) != -1)) { out.write(bbuf, 0, length); } in.close(); } catch (Exception e) { logger.error(e, e); out.print(e.getMessage()); } finally { out.flush(); out.close(); } logger.info("Free memory: " + (Runtime.getRuntime().freeMemory() / 1024L * 1024L)); } catch (Exception e) { logger.error(e, e); } finally { } }
From source file:org.mycore.common.content.util.MCRServletContentHelper.java
/** * Serve the specified content, optionally including the data content. * This method handles both GET and HEAD requests. *///from w ww . ja va 2s . c o m public static void serveContent(final MCRContent content, final HttpServletRequest request, final HttpServletResponse response, final ServletContext context, final Config config, final boolean withContent) throws IOException { boolean serveContent = withContent; final String path = getRequestPath(request); if (LOGGER.isDebugEnabled()) { if (serveContent) { LOGGER.debug("Serving '" + path + "' headers and data"); } else { LOGGER.debug("Serving '" + path + "' headers only"); } } if (response.isCommitted()) { //getContent has access to response return; } final boolean isError = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST; if (content == null && !isError) { response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI()); return; } //Check if all conditional header validate if (!isError && !checkIfHeaders(request, response, content)) { return; } // Find content type. String contentType = content.getMimeType(); final String filename = getFileName(request, content); if (contentType == null) { contentType = context.getMimeType(filename); content.setMimeType(contentType); } String enc = content.getEncoding(); if (enc != null) { contentType = String.format(Locale.ROOT, "%s; charset=%s", contentType, enc); } String eTag = null; ArrayList<Range> ranges = null; if (!isError) { eTag = content.getETag(); if (config.useAcceptRanges) { response.setHeader("Accept-Ranges", "bytes"); } ranges = parseRange(request, response, content); response.setHeader("ETag", eTag); long lastModified = content.lastModified(); if (lastModified >= 0) { response.setDateHeader("Last-Modified", lastModified); } if (serveContent) { String dispositionType = request.getParameter("dl") == null ? "inline" : "attachment"; response.setHeader("Content-Disposition", dispositionType + ";filename=\"" + filename + "\""); } } final long contentLength = content.length(); //No Content to serve? if (contentLength == 0) { serveContent = false; } if (content.isUsingSession()) { response.addHeader("Cache-Control", "private, max-age=0, must-revalidate"); response.addHeader("Vary", "*"); } try (ServletOutputStream out = serveContent ? response.getOutputStream() : null) { if (serveContent) { try { response.setBufferSize(config.outputBufferSize); } catch (final IllegalStateException e) { //does not matter if we fail } } if (response instanceof ServletResponseWrapper) { if (request.getHeader("Range") != null) { LOGGER.warn("Response is wrapped by ServletResponseWrapper, no 'Range' requests supported."); } ranges = FULL; } if (isError || (ranges == null || ranges.isEmpty()) && request.getHeader("Range") == null || ranges == FULL) { //No ranges if (contentType != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("contentType='" + contentType + "'"); } response.setContentType(contentType); } if (contentLength >= 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("contentLength=" + contentLength); } setContentLengthLong(response, contentLength); } if (serveContent) { copy(content, out, config.inputBufferSize, config.outputBufferSize); } } else { if (ranges == null || ranges.isEmpty()) { return; } // Partial content response. response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); if (ranges.size() == 1) { final Range range = ranges.get(0); response.addHeader("Content-Range", "bytes " + range.start + "-" + range.end + "/" + range.length); final long length = range.end - range.start + 1; setContentLengthLong(response, length); if (contentType != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("contentType='" + contentType + "'"); } response.setContentType(contentType); } if (serveContent) { copy(content, out, range, config.inputBufferSize, config.outputBufferSize); } } else { response.setContentType("multipart/byteranges; boundary=" + MIME_BOUNDARY); if (serveContent) { copy(content, out, ranges.iterator(), contentType, config.inputBufferSize, config.outputBufferSize); } } } } }
From source file:org.egov.egf.web.controller.expensebill.CreateExpenseBillController.java
@RequestMapping(value = "/downloadBillDoc", method = RequestMethod.GET) public void getBillDoc(final HttpServletRequest request, final HttpServletResponse response) throws IOException { final ServletContext context = request.getServletContext(); final String fileStoreId = request.getParameter("fileStoreId"); String fileName = ""; final File downloadFile = fileStoreService.fetch(fileStoreId, FinancialConstants.FILESTORE_MODULECODE); final FileInputStream inputStream = new FileInputStream(downloadFile); EgBillregister egBillregister = expenseBillService .getById(Long.parseLong(request.getParameter("egBillRegisterId"))); egBillregister = getBillDocuments(egBillregister); for (final DocumentUpload doc : egBillregister.getDocumentDetail()) if (doc.getFileStore().getFileStoreId().equalsIgnoreCase(fileStoreId)) fileName = doc.getFileStore().getFileName(); // get MIME type of the file String mimeType = context.getMimeType(downloadFile.getAbsolutePath()); if (mimeType == null) // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; // set content attributes for the response response.setContentType(mimeType);/*from w w w .j ava 2s . c om*/ response.setContentLength((int) downloadFile.length()); // set headers for the response final String headerKey = "Content-Disposition"; final String headerValue = String.format("attachment; filename=\"%s\"", fileName); response.setHeader(headerKey, headerValue); // get output stream of the response final OutputStream outStream = response.getOutputStream(); final byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; // write bytes read from the input stream into the output stream while ((bytesRead = inputStream.read(buffer)) != -1) outStream.write(buffer, 0, bytesRead); inputStream.close(); outStream.close(); }
From source file:org.kitodo.services.ProcessService.java
/** * Download docket.//from www . ja va2s . c om * * @param process object * @return empty string? */ public String downloadDocket(Process process) { if (myLogger.isDebugEnabled()) { myLogger.debug("generate docket for process " + process.getId()); } String rootPath = ConfigMain.getParameter("xsltFolder"); SafeFile xsltFile = new SafeFile(rootPath, "docket.xsl"); if (process.getDocket() != null) { xsltFile = new SafeFile(rootPath, process.getDocket().getFile()); if (!xsltFile.exists()) { Helper.setFehlerMeldung("docketMissing"); return ""; } } FacesContext facesContext = FacesContext.getCurrentInstance(); if (!facesContext.getResponseComplete()) { HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); String fileName = process.getTitle() + ".pdf"; ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext(); String contentType = servletContext.getMimeType(fileName); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); // write run note to servlet output stream try { ServletOutputStream out = response.getOutputStream(); ExportDocket ern = new ExportDocket(); ern.startExport(process, out, xsltFile.getAbsolutePath()); out.flush(); facesContext.responseComplete(); } catch (Exception e) { Helper.setFehlerMeldung("Exception while exporting run note.", e.getMessage()); response.reset(); } } return ""; }
From source file:com.krawler.spring.documents.documentDAOImpl.java
/** * @param filePath//from w ww .j a v a2s .c o m * @param docObj * @param servletContext * @throws ServiceException */ public void indexDocument(String filePath, Docs docObj, String companyId, ServletContext servletContext) throws ServiceException { try { File uploadFile = new File(filePath); FileInputStream fin = null; byte[] b = null; try { fin = new FileInputStream(uploadFile); b = new byte[(int) uploadFile.length()]; fin.read(b); } finally { if (fin != null) { fin.close(); } } String fileType = servletContext.getMimeType(filePath); String contentType = KrawlerApp.getContentType(fileType, filePath, b); int flag1 = 0; if (!StringUtil.isNullOrEmpty(contentType)) { if (contentType.equals("application/vnd.ms-excel") || contentType.equals("application/msword") || contentType.equals("application/vnd.ms-word") || contentType.equals("application/vnd.ms-powerpoint") || contentType.equals("text/plain") || contentType.equals("text/csv") || contentType.equals("text/xml") || contentType.equals("text/css") || contentType.equals("text/html") || contentType.equals("text/cs") || contentType.equals("text/x-javascript") || contentType.equals("File") || contentType.equals("application/pdf") || contentType .equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document") || contentType .equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) { flag1 = 1; } } if (flag1 == 1) { Hashtable ht = new Hashtable(); ht.put(DOCUMENT_FilePath, filePath); ht.put(DOCUMENT_FileName, docObj.getDocname()); if (docObj.getUserid() != null) ht.put(DOCUMENT_Author, docObj.getUserid().getUserId()); else ht.put(DOCUMENT_Author, "Unknown"); ht.put(DOCUMENT_DateModified, new java.util.Date()); ht.put(DOCUMENT_Size, uploadFile.length()); ht.put(DOCUMENT_Type, contentType); ht.put(DOCUMENT_DocumentId, docObj.getDocid()); ht.put(DOCUMENT_Revision_No, 1); ht.put(DOCUMENT_IndexPath, StorageHandler.GetDocIndexPath()); ht.put(DOCUMENT_CompanyId, companyId); LuceneSearchObj.createDocumentIndex(ht, servletContext); } } catch (java.io.IOException ex) { throw ServiceException.FAILURE("fileUploader.indexDocument", ex); } catch (Exception ex) { throw ServiceException.FAILURE("fileUploader.indexDocument", ex); } }