List of usage examples for javax.servlet ServletOutputStream write
public abstract void write(int b) throws IOException;
From source file:org.kitodo.services.data.ProcessService.java
private void writeToOutputStream(FacesContext facesContext, File file, String fileName) throws IOException { HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext(); String contentType = servletContext.getMimeType(fileName); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); ServletOutputStream outputStream = response.getOutputStream(); FileInputStream fileInputStream = new FileInputStream(file); byte[] bytes = IOUtils.toByteArray(fileInputStream); fileInputStream.close();/*from ww w .ja v a2 s.c om*/ outputStream.write(bytes); outputStream.flush(); facesContext.responseComplete(); }
From source file:com.fluidops.iwb.server.SparqlServlet.java
/** * Print the sparql query interface if not query is provided. Uses * com.fluidops.iwb.server.sparqlinterface.st as template * /* w ww . j av a 2 s . c o m*/ * @param resp * @param out */ protected void printQueryInterface(HttpServletRequest req, HttpServletResponse resp, ServletOutputStream out, String template) throws IOException { // register search page String uri = req.getRequestURI(); FSession.registerPage(uri, FPage.class); FSession.removePage(req); // get session and page FSession session = FSession.getSession(req); FPage page; try { page = (FPage) session.getComponentById(uri, req); } catch (Exception e) { log.warn("Could not get the page for request: " + uri, e); resp.sendRedirect(RedirectService.getRedirectURL(RedirectType.PAGE_NOT_FOUND, req)); return; } PageContext pc = getPageContext(); pc.page = page; pc.title = "SPARQL Query Interface"; resp.setContentType("text/html"); resp.setStatus(200); String initQuery = req.getParameter("initQuery"); if (initQuery == null) initQuery = ""; ServletPageParameters pageParams = ServletPageParameters.computePageParameter(pc); Map<String, Object> templateParams = pageParams.toServletStringBuilderArgs(); templateParams.put("namespaces", getNamespacesAsJSONList()); templateParams.put("classes", this.getURIListAsJSONList(classesList)); templateParams.put("properties", this.getURIListAsJSONList(propertiesList)); templateParams.put("initQuery", StringEscapeUtils.escapeJavaScript(initQuery)); //TODO: check ACL query rights and, if allowed, generate security token TemplateBuilder tb = new TemplateBuilder("tplForClass", template); out.write(tb.renderTemplate(templateParams).getBytes("UTF-8")); }
From source file:org.tomitribe.tribestream.registryng.resources.ClientResource.java
@GET @Path("invoke/stream") @Produces("text/event-stream") // will be part of JAX-RS 2.1, for now just making it working public void invokeScenario(@Suspended final AsyncResponse asyncResponse, @Context final Providers providers, @Context final HttpServletRequest httpServletRequest, // base64 encoded json with the request and identify since EventSource doesnt handle it very well // TODO: use a ciphering with a POST endpoint to avoid to have it readable (or other) @QueryParam("request") final String requestBytes) { final SseRequest in = loadPayload(SseRequest.class, providers, requestBytes); final String auth = in.getIdentity(); security.check(auth, httpServletRequest, () -> { }, () -> {//from w ww.java 2 s. c o m throw new WebApplicationException(Response.Status.FORBIDDEN); }); final GenericClientService.Request req = toRequest(in.getHttp()); final Scenario scenario = in.getHttp().getScenario(); final MultivaluedHashMap<String, Object> fakeHttpHeaders = new MultivaluedHashMap<>(); final ConcurrentMap<Future<?>, Boolean> computations = new ConcurrentHashMap<>(); final MessageBodyWriter<LightHttpResponse> writerResponse = providers.getMessageBodyWriter( LightHttpResponse.class, LightHttpResponse.class, annotations, APPLICATION_JSON_TYPE); final MessageBodyWriter<ScenarioEnd> writerEnd = providers.getMessageBodyWriter(ScenarioEnd.class, ScenarioEnd.class, annotations, APPLICATION_JSON_TYPE); // not jaxrs one cause cxf wraps this one and prevents the flush() to works final HttpServletResponse httpServletResponse = HttpServletResponse.class .cast(httpServletRequest.getAttribute("tribe.registry.response")); httpServletResponse.setHeader("Content-Type", "text/event-stream"); try { httpServletResponse.flushBuffer(); } catch (final IOException e) { throw new IllegalStateException(e); } final ServletOutputStream out; try { out = httpServletResponse.getOutputStream(); } catch (final IOException e) { throw new IllegalStateException(e); } mes.submit(() -> { final AtomicReference<Invoker.Handle> handleRef = new AtomicReference<>(); try { // we compute some easy stats asynchronously final Map<Integer, AtomicInteger> sumPerResponse = new HashMap<>(); final AtomicInteger total = new AtomicInteger(); final AtomicLong min = new AtomicLong(); final AtomicLong max = new AtomicLong(); final AtomicLong sum = new AtomicLong(); final AtomicInteger writeErrors = new AtomicInteger(0); final long start = System.currentTimeMillis(); handleRef.set(invoker.invoke(scenario.getThreads(), scenario.getInvocations(), scenario.getDuration(), timeout, () -> { if (handleRef.get().isCancelled()) { return; } LightHttpResponse resp; try { final GenericClientService.Response invoke = service.invoke(req); resp = new LightHttpResponse(invoke.getStatus(), null, invoke.getClientExecutionDurationMs()); } catch (final RuntimeException e) { resp = new LightHttpResponse(-1, e.getMessage(), -1); } // let's process it in an environment where synchronisation is fine final LightHttpResponse respRef = resp; computations.put(mes.submit(() -> { synchronized (out) { try { out.write(dataStart); writerResponse.writeTo(respRef, LightHttpResponse.class, LightHttpResponse.class, annotations, APPLICATION_JSON_TYPE, fakeHttpHeaders, out); out.write(dataEnd); out.flush(); } catch (final IOException e) { if (writeErrors.incrementAndGet() > toleratedWriteErrors) { handleRef.get().cancel(); } throw new IllegalStateException(e); } } if (handleRef.get().isCancelled()) { return; } final long clientExecutionDurationMs = respRef.getClientExecutionDurationMs(); total.incrementAndGet(); sumPerResponse.computeIfAbsent(respRef.getStatus(), k -> new AtomicInteger()) .incrementAndGet(); sum.addAndGet(clientExecutionDurationMs); { long m = min.get(); do { m = min.get(); if (min.compareAndSet(m, clientExecutionDurationMs)) { break; } } while (m > clientExecutionDurationMs); } { long m = max.get(); do { m = max.get(); if (max.compareAndSet(m, clientExecutionDurationMs)) { break; } } while (m < clientExecutionDurationMs); } }), true); })); handleRef.get().await(); final long end = System.currentTimeMillis(); do { // wait all threads finished to compute the stats final Iterator<Future<?>> iterator = computations.keySet().iterator(); while (iterator.hasNext()) { try { iterator.next().get(timeout, TimeUnit.MILLISECONDS); } catch (final InterruptedException e) { Thread.interrupted(); } catch (final ExecutionException | TimeoutException e) { throw new IllegalStateException(e.getCause()); } finally { iterator.remove(); } } } while (!computations.isEmpty()); if (handleRef.get().isCancelled()) { return; } try { out.write(dataStart); writerEnd.writeTo( new ScenarioEnd( sumPerResponse.entrySet().stream() .collect(toMap(Map.Entry::getKey, t -> t.getValue().get())), end - start, total.get(), min.get(), max.get(), sum.get() * 1. / total.get()), ScenarioEnd.class, ScenarioEnd.class, annotations, APPLICATION_JSON_TYPE, new MultivaluedHashMap<>(), out); out.write(dataEnd); out.flush(); } catch (final IOException e) { throw new IllegalStateException(e); } } finally { try { // cxf will skip it since we already write ourself asyncResponse.resume(""); } catch (final RuntimeException re) { // no-op: not that important } } }); }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * forward to the page displaying a edna file * //from w ww. ja va2s. c om * @param mapping * @param actForm * @param request * @param response * @return */ public ActionForward displayEDNAFile(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) { try { String filePath = request.getParameter(Constants.EDNA_FILE_PATH); LOG.debug("displayEDNAFile: " + filePath); if (Constants.SITE_IS_DLS()) { byte[] fileContent = FileUtil.fileToString(filePath).getBytes(); // --- Write Image to output --- response.setContentType("text/plain"); try { ServletOutputStream out = response.getOutputStream(); out.write(fileContent); out.flush(); out.close(); } catch (IOException ioe) { LOG.error("Unable to write to outputStream. (IOException)"); ioe.printStackTrace(); return mapping.findForward("error"); } } else { // String fileContent = FileUtil.fileToString(filePath); // // // Populate form // form.setDNAContent(fileContent); // FormUtils.setFormDisplayMode(request, actForm, FormUtils.INSPECT_MODE); byte[] fileContent = FileUtil.fileToString(filePath).getBytes(); // --- Write Image to output --- response.setContentType("text/plain"); try { ServletOutputStream out = response.getOutputStream(); out.write(fileContent); out.flush(); out.close(); } catch (IOException ioe) { LOG.error("Unable to write to outputStream. (IOException)"); ioe.printStackTrace(); return mapping.findForward("error"); } } } catch (Exception e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewDNA")); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.detail", e.toString())); e.printStackTrace(); } if (!errors.isEmpty()) { saveErrors(request, errors); return (mapping.findForward("error")); } else // return Constants.SITE_IS_DLS() ? null : mapping.findForward("viewTextFile"); return null; }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * Display EDNA results content on the page * // w w w . j av a2 s. co m * @param mapping * @param actForm * @param request * @param response * @return * @throws Exception */ public ActionForward displayEDNAPagesContent(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); dataCollectionIdst = request.getParameter(Constants.DATA_COLLECTION_ID); Integer dataCollectionId = new Integer(dataCollectionIdst); DataCollection3VO dc = dataCollectionService.findByPk(dataCollectionId, false, false); String archivePath = Constants.SITE_IS_DLS() ? PathUtils.getFullEDNAPath(dc) : PathUtils.getFullDNAPath(dc); // String fullEDNAPath = archivePath + Constants.EDNA_FILES_SUFIX; if (Constants.SITE_IS_EMBL()) { String[] archivePathDir = archivePath.split("/"); String beamLineName = dc.getDataCollectionGroupVO().getSessionVO().getBeamlineName().toLowerCase(); archivePath = Constants.DATA_FILEPATH_START + beamLineName + "/"; for (int k = 4; k < archivePathDir.length; k++) { archivePath = archivePath + archivePathDir[k] + "/"; } } boolean isFileExist = new File(archivePath + Constants.EDNA_FILES_SUFIX).exists(); String fullEDNAPath = archivePath; if (Constants.SITE_IS_DLS() || (isFileExist)) { fullEDNAPath += Constants.EDNA_FILES_SUFIX; } String indexPath = Constants.SITE_IS_DLS() ? archivePath + EDNA_FILES_INDEX_FILE : archivePath + getEdna_index_file(dc); LOG.debug("Check if the Characterisation results index file " + indexPath + " exists... "); boolean isFileExist2 = new File(indexPath).exists(); String fileContent = null; if (isFileExist2) fileContent = FileUtil.fileToString(indexPath); else { fileContent = "Sorry, but no EDNA files can be retrieved for this data collection."; } // new path to view images // String pathImageUrl = request.getContextPath() + "/user/imageDownload.do?reqCode=getEDNAImage"; String pathImageUrl = "imageDownload.do?reqCode=getEDNAImage"; // String hrefImageUrl = request.getContextPath() + "/user/viewResults.do?reqCode=viewEDNAImage"; String hrefImageUrl = "viewResults.do?reqCode=viewEDNAImage"; String hrefFileUrl = "viewResults.do?reqCode=displayEDNAFile"; // Case where the file is not found if (fileContent == null) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewDNA")); return this.display(mapping, actForm, request, response); } // Format the file: change the <a href and <img src tags byte[] fileContentChanged = (UrlUtils.formatEDNApageURL(fileContent, pathImageUrl, hrefImageUrl, hrefFileUrl, fullEDNAPath)).getBytes(); // --- Write Image to output --- response.setContentType("text/html"); try { ServletOutputStream out = response.getOutputStream(); out.write(fileContentChanged); out.flush(); out.close(); } catch (IOException ioe) { LOG.error("Unable to write to outputStream. (IOException)"); ioe.printStackTrace(); return mapping.findForward("error"); } return null; }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * getDataFromFile/*from w w w . ja va 2 s. co m*/ * * @param mapping * @param actForm * @param request * @param response * @return */ public ActionForward getDataFromFile(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) { ActionMessages errors = new ActionMessages(); boolean isWindows = (System.getProperty("os.name").indexOf("Win") != -1) ? true : false; String tmpDirectory = ((isWindows) ? Constants.BZIP2_PATH_W : Constants.BZIP2_PATH_OUT); try { Integer proposalId = (Integer) request.getSession().getAttribute(Constants.PROPOSAL_ID); Integer imageId = new Integer(request.getParameter(Constants.IMAGE_ID)); List<Image3VO> imageFetchedList = imageService.findByImageIdAndProposalId(imageId, proposalId); if (imageFetchedList.size() == 1) { Image3VO selectedImage = (imageFetchedList.get(0)); // --- Create File Names --- String _sourceFileName = selectedImage.getFileLocation() + "/" + selectedImage.getFileName(); _sourceFileName = (isWindows) ? "C:" + _sourceFileName : _sourceFileName; String _destinationFileName = selectedImage.getFileName(); String _destinationfullFilename = tmpDirectory + "/" + _destinationFileName; String _bz2FileName = _destinationFileName + ".bz2"; String _bz2FullFileName = _destinationfullFilename + ".bz2"; // --- Copy Files --- File source = new File(_sourceFileName); File destination = new File(_destinationfullFilename); File bz2File = new File(_bz2FullFileName); FileUtils.copyFile(source, destination, false); // --- BZIP2 File --- String cmd = ((isWindows) ? Constants.BZIP2_PATH_W : Constants.BZIP2_PATH); String argument = Constants.BZIP2_ARGS; argument = " " + argument + " " + _destinationfullFilename; cmd = cmd + argument; this.CmdExec(cmd, false); // --- Active Wait for the .bz2 File to be created + timeout --- Date now = new Date(); long startTime = now.getTime(); long timeNow = now.getTime(); long timeOut = 60000; boolean filePresent = false; while (!filePresent && (timeNow - startTime) < timeOut) { Date d2 = new Date(); timeNow = d2.getTime(); filePresent = bz2File.exists(); } if (filePresent) Thread.sleep(10000); // --- Write Image to output --- byte[] imageBytes = FileUtil.readBytes(_bz2FullFileName); response.setContentLength(imageBytes.length); response.setHeader("Content-Disposition", "attachment; filename=" + _bz2FileName); response.setContentType("application/x-bzip"); ServletOutputStream out = response.getOutputStream(); out.write(imageBytes); out.flush(); out.close(); // --- Clean up things --- FileCleaner fileCleaner = new FileCleaner(60000, _bz2FullFileName); fileCleaner.start(); return null; } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewImageId", imageId)); LOG.warn("List fetched has a size != 1!!"); } FormUtils.setFormDisplayMode(request, actForm, FormUtils.INSPECT_MODE); } catch (Exception e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.general.image")); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.detail", e.toString())); e.printStackTrace(); } if (!errors.isEmpty()) { saveErrors(request, errors); return (mapping.findForward("error")); } else return mapping.findForward("viewJpegImage"); }
From source file:com.globalsight.connector.eloqua.EloquaCreateJobHandler.java
@ActionHandler(action = "getFileProfile", formClass = "") public void getFileProfile(HttpServletRequest request, HttpServletResponse response, Object form) throws Exception { ServletOutputStream out = response.getOutputStream(); try {/* w w w.j a v a2 s . c o m*/ String currentCompanyId = CompanyThreadLocal.getInstance().getValue(); HttpSession session = request.getSession(false); SessionManager sessionMgr = (SessionManager) session.getAttribute(SESSION_MANAGER); User user = (User) sessionMgr.getAttribute(WebAppConstants.USER); if (user == null) { String userName = request.getParameter("userName"); if (userName != null && !"".equals(userName)) { user = ServerProxy.getUserManager().getUserByName(userName); sessionMgr.setAttribute(WebAppConstants.USER, user); } } ArrayList<FileProfileImpl> fileProfileListOfUser = new ArrayList<FileProfileImpl>(); List<String> extensionList = new ArrayList<String>(); extensionList.add("html"); List<FileProfileImpl> fileProfileListOfCompany = (List) ServerProxy.getFileProfilePersistenceManager() .getFileProfilesByExtension(extensionList, Long.valueOf(currentCompanyId)); SortUtil.sort(fileProfileListOfCompany, new Comparator<Object>() { public int compare(Object arg0, Object arg1) { FileProfileImpl a0 = (FileProfileImpl) arg0; FileProfileImpl a1 = (FileProfileImpl) arg1; return a0.getName().compareToIgnoreCase(a1.getName()); } }); List projectsOfCurrentUser = ServerProxy.getProjectHandler().getProjectsByUser(user.getUserId()); for (FileProfileImpl fp : fileProfileListOfCompany) { Project fpProj = getProject(fp); // get the project and check if it is in the group of // user's projects if (projectsOfCurrentUser.contains(fpProj)) { fileProfileListOfUser.add(fp); } } List l = new ArrayList(); for (FileProfileImpl fp : fileProfileListOfUser) { Map m = new HashMap(); m.put("id", fp.getId()); m.put("name", fp.getName()); m.put("lid", fp.getL10nProfileId()); l.add(m); } out.write(JsonUtil.toJson(l).getBytes("UTF-8")); } catch (ValidateException ve) { ResourceBundle bundle = PageHandler.getBundle(request.getSession()); String s = "({\"error\" : " + JsonUtil.toJson(ve.getMessage(bundle)) + "})"; out.write(s.getBytes("UTF-8")); } catch (Exception e) { String s = "({\"error\" : " + JsonUtil.toObjectJson(e.getMessage()) + "})"; out.write(s.getBytes("UTF-8")); } finally { out.close(); pageReturn(); } }
From source file:com.ibm.ioes.actions.NewOrderAction.java
public ActionForward goToDownloadFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { NewOrderBean formBean = (NewOrderBean) form; //String fileName=formBean.getFileName(); ActionForward forward = new ActionForward(); ActionMessages messages = new ActionMessages(); FileAttachmentDto downloadedFile = new FileAttachmentDto(); CommonBaseModel commonBaseModel = new CommonBaseModel(); byte[] File = null; FileAttachmentDto fileDto = new FileAttachmentDto(); fileDto.setHdnOrderNo(request.getParameter("hdnOrderNo")); fileDto.setHdnAccountNo(request.getParameter("accountID")); //--Added & modified by vijay--// /*these code is modify for solving the error of downloading file whose name contain special characters */ //fileDto.setFileName(request.getParameter("fileName")); fileDto.setFileName(request.getParameter("hdnFileName")); fileDto.setCreateDate(request.getParameter("createDate")); //String slNO=request.getParameter("sLNO"); //fileDto.setSlno(Integer.parseInt(slNO)); String slNO = request.getParameter("hdnslno"); fileDto.setSlno(Integer.parseInt(slNO)); //--end of code--// NewOrderModel objModel = new NewOrderModel(); downloadedFile = objModel.getDownloadedFile(fileDto); //java.sql.Blob blob=null; File = commonBaseModel.blobToByteArray(downloadedFile.getFile()); String ContentType = commonBaseModel.setContentTypeForFile(downloadedFile.getFileName());//CHANGES FOR SYSTEM TESTING DEFECTS response.setContentType(ContentType); //---added by vijay--// //response.setHeader("Content-Disposition","attachment;filename=" + downloadedFile.getFileName());//CHANGES FOR SYSTEM TESTING DEFECTS /*//from ww w. j a v a 2 s.co m * Here file name is encoded and space is replace by special secequence of charcters, * because if file name contain space then bydefault space is converting in a plus sign (+) while downloading, * so for recognize any space in file name, space is replacing by this string @%20@ */ String encodedFileName = java.net.URLEncoder.encode(downloadedFile.getFileName().replace(" ", "@%20@"), "ISO-8859-1"); System.out.println("encoded file name is - " + encodedFileName); /* * After encoding file name, for maintaing the space character, again replace this special sequence %40%2520%40% with space character. * This sequence of characters %40%2520%40% means file name containg space space */ response.setHeader("Content-Disposition", "attachment;filename=" + encodedFileName.replace("%40%2520%40", " ")); //--end of code--// ServletOutputStream outs = response.getOutputStream(); outs.write(File); outs.flush(); outs.close(); if (downloadedFile.getIsDownload().equalsIgnoreCase("1")) { formBean.setIsDownload("successDownload"); forward = mapping.findForward(""); } else { messages.add("saveDownloadFile", new ActionMessage("FileDownloadFailed")); saveMessages(request, messages); forward = mapping.findForward(""); } try { } catch (Exception e) { AppConstants.IOES_LOGGER.error(AppUtility.getStackTrace(e)); } return forward; }
From source file:com.globalsight.everest.webapp.pagehandler.edit.online.EditorPageHandler.java
private void renderJson(HttpServletRequest p_request, HttpServletResponse p_response, EditorState state, boolean isAssignee) throws IOException { EditorState.Layout layout = state.getLayout(); String jsonStr = ""; p_response.setContentType("text/html;charset=UTF-8"); String value = "3"; // comment button if ((value = p_request.getParameter(WebAppConstants.REVIEW_MODE)) != null) { if ("Show Comments".equals(value)) { state.setReviewMode();//w w w.j a v a2 s.c o m } else if (state.getUserIsPm()) { state.setViewerMode(); } else { state.setEditorMode(); } } // lock button if ((value = p_request.getParameter("editAll")) != null) { if (state.canEditAll()) { state.setEditAllState(Integer.parseInt(value)); } else { // is not json format so jquery will no back jsonStr = "false"; } } // show segment datails if ((value = p_request.getParameter("param")) != null) { SegmentView view; String param[] = value.split("&"); String tuid[] = param[0].split("="); String tuvid[] = param[1].split("="); String subid[] = param[2].split("="); long tuId = Long.valueOf(tuid[1]).longValue(); long tuvId = Long.valueOf(tuvid[1]).longValue(); long subId = Long.valueOf(subid[1]).longValue(); Long targetPageId = state.getTargetPageId(); long sourceLocaleId = state.getSourceLocale().getId(); long targetLocaleId = state.getTargetLocale().getId(); view = EditorHelper.getSegmentView(state, tuId, tuvId, subId, targetPageId.longValue(), sourceLocaleId, targetLocaleId); JSONObject json = new JSONObject(); ServletOutputStream out = p_response.getOutputStream(); try { json.put("str_segmentId", tuvid[1]); json.put("str_segmentFormat", view.getDataType()); json.put("str_segmentType", view.getItemType()); json.put("str_wordCount", String.valueOf(view.getWordCount())); String str_sid = view.getTargetTuv().getSid(); if (str_sid == null || str_sid.trim().length() == 0) { str_sid = "N/A"; } json.put("str_sid", str_sid);// view.getTargetTuv().getSid() String str_lastModifyUser = view.getTargetTuv().getLastModifiedUser(); if (str_lastModifyUser == null || str_lastModifyUser.equalsIgnoreCase("xlf") || str_lastModifyUser.equalsIgnoreCase("Xliff")) { str_lastModifyUser = "N/A"; } json.put("str_lastModifyUser", str_lastModifyUser); try { OnlineHelper helper = new OnlineHelper(); String str_sourceSegment = GxmlUtil.getInnerXml(view.getSourceSegment()); String str_dataType = view.getDataType(); helper.setInputSegment(str_sourceSegment, "", str_dataType); if (EditorConstants.PTAGS_VERBOSE.equals(state.getPTagFormat())) { helper.getVerbose(); } else { helper.getCompact(); } String str_segementPtag = helper.getPtagToNativeMappingTable(); if (StringUtil.isEmpty(str_segementPtag)) { str_segementPtag = "N/A"; } else { str_segementPtag = str_segementPtag.replace("<TR>", "<TR valign=top>").replace("<TD", "<TD noWrap"); str_segementPtag = str_segementPtag.replace("<tr>", "<TR valign=top>").replace("<td", "<TD noWrap"); } json.put("str_segementPtag", str_segementPtag); } catch (Exception e1) { CATEGORY.error("Get segement tag information. ", e1); throw new EnvoyServletException(e1); } out.write(json.toString().getBytes("UTF-8")); } catch (JSONException e) { CATEGORY.error("Get segement detail. ", e); throw new EnvoyServletException(e); } return; } // Find Repeated Segments if ((value = p_request.getParameter(WebAppConstants.PROPAGATE_ACTION)) != null) { if (value.equalsIgnoreCase("Unmark Repeated")) { state.setNeedFindRepeatedSegments(false); } else { state.setNeedFindRepeatedSegments(true); } } // Show/Hide PTags if ((value = p_request.getParameter("pTagsAction")) != null) { if (value.equalsIgnoreCase("Show PTags")) { state.setNeedShowPTags(true); } else { state.setNeedShowPTags(false); } } boolean isGetJsonData = false; if ((value = p_request.getParameter("trgViewMode")) != null) { layout.setTargetViewMode(Integer.parseInt(value)); isGetJsonData = true; } else if ((value = p_request.getParameter("srcViewMode")) != null) { layout.setSourceViewMode(Integer.parseInt(value)); isGetJsonData = true; } else if (getSearchParamsInMap(p_request).size() > 0) { isGetJsonData = true; } if (isGetJsonData) { jsonStr = state.getEditorManager().getTargetJsonData(state, isAssignee, getSearchParamsInMap(p_request)); } p_response.getWriter().write(jsonStr); }