List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.ibm.cics.ca1y.JavaHTTP.java
public boolean send() { if (props.getPropertyMime(JAVA_HTTP_CONTENT) == null) { props.setPropertyMime(JAVA_HTTP_CONTENT, JAVA_HTTP_CONTENT_MIME_TEXT_DEFAULT); }/*from ww w.j a v a 2s . c om*/ int retry = JAVA_HTTP_RETRY_DEFAULT; if (props.containsKey(JAVA_HTTP_RETRY)) { try { retry = Integer.parseUnsignedInt(props.getProperty(JAVA_HTTP_RETRY)); } catch (NumberFormatException e) { // Ignore invalid values and use default } } // Prepare HTTP request Client client = ClientBuilder.newClient(); WebTarget target = client.target(props.getProperty(JAVA_HTTP_URI)); // Prepare HTTP filter if (props.getProperty(JAVA_HTTP_FILTER_CLASS) != null) { logger.fine(Emit.messages.getString("HTTPRegisteringFilterClass") + " - " + props.getProperty(JAVA_HTTP_FILTER_CLASS)); try { target.register(Class.forName(props.getProperty(JAVA_HTTP_FILTER_CLASS))); } catch (ClassNotFoundException e) { logger.warning(Emit.messages.getString("HTTPFilterClassNotFound") + " - " + props.getProperty(JAVA_HTTP_FILTER_CLASS)); } } // Add all properties that start with the prefix as HTTP headers to the // HTTP request Builder builder = target.request(props.getPropertyMime(JAVA_HTTP_CONTENT)); Enumeration<?> list = props.propertyNames(); while (list.hasMoreElements()) { String key = (String) list.nextElement(); if (key.startsWith(JAVA_HTTP_HEADER_PREFIX)) { // Set the HTTP header builder.header(key.substring(JAVA_HTTP_HEADER_PREFIX.length()), props.getProperty(key)); } else if (key.startsWith(JAVA_HTTP_FILTER_PREFIX)) { // Set the HTTP request property for use by the HTTP filter builder.property(key, props.getProperty(key)); } } // Prepare the HTTP content in an entity Entity<String> entity = Entity.entity(props.getProperty(JAVA_HTTP_CONTENT), props.getPropertyMime(JAVA_HTTP_CONTENT)); // Send HTTP request long retryDelay; Response response = null; for (; retry >= 0; retry--) { // Send the HTTP request response = builder.method(props.getProperty(JAVA_HTTP_METHOD, JAVA_HTTP_METHOD_DEFAULT), entity); if ((response.getStatus() == Response.Status.OK.getStatusCode()) || (response.getStatus() == Response.Status.CREATED.getStatusCode()) || (response.getStatus() == Response.Status.ACCEPTED.getStatusCode())) { // HTTP request was processed successfully // Get the HTTP response body String responseHttpBody = ""; if (response.getEntity() != null) { try { responseHttpBody = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); } } // Log the HTTP request was successful if (logger.isLoggable(Level.INFO)) { logger.info(Emit.messages.getString("HTTPLogSuccess") + " - " + getMessageSummary() + ",HTTP response status:" + response.getStatus() + ",HTTP response body:" + responseHttpBody); } return true; } if (retry > 0) { // Delay for the specified period retryDelay = JAVA_HTTP_RETRY_DELAY_DEFAULT; if (props.containsKey(JAVA_HTTP_RETRY_DELAY)) { try { retryDelay = Integer.parseUnsignedInt(props.getProperty(JAVA_HTTP_RETRY_DELAY)); } catch (NumberFormatException e) { // Ignore invalid values and use default } } if (logger.isLoggable(Level.FINE)) { logger.fine(Emit.messages.getString("HTTP_RETRYING") + " " + retryDelay + "ms"); } try { Thread.sleep(retryDelay); } catch (InterruptedException e) { // Thread cancelled so do not retry break; } } } if (logger.isLoggable(Level.INFO)) { logger.info(Emit.messages.getString("HTTPLogFail") + " - " + getMessageSummary() + ",HTTP response status:" + response.getStatus()); } return false; }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * forward to the page with autoproc results * //from w ww .ja va 2 s.c o m * @param mapping * @param actForm * @param request * @param response * @return * * If the filename ends in .lp or .log we display it inline, else it is offered as a download */ public ActionForward displayAutoProcProgAttachment(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) { ActionMessages errors = new ActionMessages(); ViewResultsForm form = (ViewResultsForm) actForm; Integer autoProcProgramAttachmentId; try { autoProcProgramAttachmentId = Integer.parseInt(form.getAutoProcProgramAttachmentId()); } catch (NumberFormatException e) { e.printStackTrace(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewAutoProcAttachments")); return this.display(mapping, actForm, request, response); } String filename = ""; String fullFilePath = ""; try { AutoProcProgramAttachment3VO appalv = appaService.findByPk(autoProcProgramAttachmentId); filename = appalv.getFileName(); String filetype = filename.substring(filename.lastIndexOf('.')); fullFilePath = appalv.getFilePath().trim() + "/" + filename; fullFilePath = PathUtils.FitPathToOS(fullFilePath); if (filetype.toUpperCase().equals(new String(".log").toUpperCase()) || filetype.toUpperCase().equals(new String(".lp").toUpperCase())) { // display inline // inline String outFile = FileUtil.fileToString(fullFilePath); if (outFile == null || outFile.equals("") || outFile.equals("nofile")) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.detail", "Unable to open file: " + fullFilePath)); saveErrors(request, errors); return mapping.findForward("error"); } Integer dataCollectionId = form.getDataCollectionId(); if (BreadCrumbsForm.getIt(request).getSelectedDataCollection() != null) { dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); } form.setAutoProcAttachmentContent(outFile); form.setAutoProcAttachmentName(filename); form.setAutoProcProgramAttachmentId(appalv.getAutoProcProgramAttachmentId().toString()); form.setDataCollectionId(dataCollectionId); return mapping.findForward("viewAutoProcAttachments"); } else { // offer for download // catch the file not found error to change the name of the file accordingly // xxx.mtz.gz becomes xxx.mtz or xxx.mtz becomes xxx.mtz.gz // xxx.sca.gz becomes xxx.sca or xxx.sca becomes xxx.sca.gz HashMap<String, String> filesToZip = new HashMap<String, String>(); File f; String finalFilePath = fullFilePath; try { f = new File(fullFilePath); if (!f.canRead()) { String otherPath = fullFilePath; if (filename.contains(".mtz")) { if (filename.contains(".mtz.gz")) { otherPath = fullFilePath.substring(0, fullFilePath.length() - 3); filename = filename.substring(0, filename.length() - 3); } else { otherPath = fullFilePath + ".gz"; filename = filename + ".gz"; } } else if (filename.contains(".sca")) { if (filename.contains(".sca.gz")) { otherPath = fullFilePath.substring(0, fullFilePath.length() - 3); filename = filename.substring(0, filename.length() - 3); } else { otherPath = fullFilePath + ".gz"; filename = filename + ".gz"; } } finalFilePath = otherPath; f = new File(otherPath); } if (f.canRead()) { filesToZip.put(f.getName(), finalFilePath); String info = ""; if (filename != null && !filename.contains("_run")) { Integer dataCollectionId = form.getDataCollectionId(); if (BreadCrumbsForm.getIt(request).getSelectedDataCollection() != null) { dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); } if (dataCollectionId != null) { DataCollection3VO dc = dataCollectionService.findByPk(dataCollectionId, false, false); if (dc != null) { info = dc.getImagePrefix() + "_run" + dc.getDataCollectionNumber() + "_"; } } } String newfilename = info + filename + ".zip"; byte[] zippedFiles = HashMapToZip.doZip(filesToZip); response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment;filename=" + newfilename); OutputStream output; try { output = response.getOutputStream(); output.write(zippedFiles); output.close(); } catch (java.io.IOException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.detail", "Unable to open file: " + fullFilePath)); saveErrors(request, errors); e.printStackTrace(); return mapping.findForward("error"); } } } catch (Exception e) { e.printStackTrace(); return mapping.findForward("error"); } } } catch (Exception e) { e.printStackTrace(); return mapping.findForward("error"); } return null; }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * /* w ww . j a va2 s .com*/ * @param mapping * @param actForm * @param request * @param response * @return */ public ActionForward downloadAttachment(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) { LOG.debug("download files..."); ViewResultsForm form = (ViewResultsForm) actForm; // attachments to download ActionMessages errors = new ActionMessages(); Integer autoProcProgramId = null; List<File> listFilesToDownload = new ArrayList<File>(); Integer proposalId = (Integer) request.getSession().getAttribute(Constants.PROPOSAL_ID); HashMap<String, String> filesToZip = new HashMap<String, String>(); try { // auto proc attachment // Get an object list. // List<IspybAutoProcAttachment3VO> listOfAutoProcAttachment = ispybAutoProcAttachmentService.findAll(); List<IspybAutoProcAttachment3VO> listOfAutoProcAttachment = (List<IspybAutoProcAttachment3VO>) request .getSession().getAttribute(Constants.ISPYB_AUTOPROC_ATTACH_LIST); Integer autoProcId = Integer.parseInt(request.getParameter("autoProcId").toString()); AutoProc3VO apv = apService.findByPk(autoProcId); if (apv != null) autoProcProgramId = apv.getAutoProcProgramVOId(); if (!Confidentiality.isAccessAllowedToAutoProcProgram(request, autoProcProgramId)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.detail", "Access denied")); saveErrors(request, errors); return (mapping.findForward("error")); } List<AutoProcProgramAttachment3VO> attachments = null; AutoProcAttachmentWebBean[] attachmentWebBeans = null; if (autoProcProgramId != null) { attachments = appService.findByPk(autoProcProgramId, true).getAttachmentListVOs(); if (!attachments.isEmpty()) { attachmentWebBeans = new AutoProcAttachmentWebBean[attachments.size()]; int i = 0; for (Iterator<AutoProcProgramAttachment3VO> iterator = attachments.iterator(); iterator .hasNext();) { AutoProcProgramAttachment3VO att = iterator.next(); AutoProcAttachmentWebBean attBean = new AutoProcAttachmentWebBean(att); // gets the ispyb auto proc attachment file IspybAutoProcAttachment3VO aAutoProcAttachment = getAutoProcAttachment( attBean.getFileName(), listOfAutoProcAttachment); attBean.setIspybAutoProcAttachment(aAutoProcAttachment); attachmentWebBeans[i] = attBean; LOG.debug("attBean = " + attBean.toString()); String fullFilePath = attBean.getFilePath().trim() + "/" + attBean.getFileName(); fullFilePath = PathUtils.FitPathToOS(fullFilePath); File f = new File(fullFilePath); if (f.canRead()) { listFilesToDownload.add(f); filesToZip.put(f.getName(), fullFilePath); LOG.debug("Put in zip : " + f.getName() + " file: " + fullFilePath); } i = i + 1; } } else LOG.debug("attachments is empty"); } // Issue 1507: Correction files for ID29 & ID23-1 if (Constants.SITE_IS_ESRF()) { Integer dataCollectionId = null; if (BreadCrumbsForm.getIt(request).getSelectedDataCollection() != null) dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); if (dataCollectionId != null) { DataCollection3VO dataCollection = dataCollectionService.findByPk(dataCollectionId, false, false); String beamLineName = dataCollection.getDataCollectionGroupVO().getSessionVO() .getBeamlineName(); String[] correctionFiles = ESRFBeamlineEnum.retrieveCorrectionFilesNameWithName(beamLineName); if (correctionFiles != null) { for (int k = 0; k < correctionFiles.length; k++) { String correctionFileName = correctionFiles[k]; String dir = ESRFBeamlineEnum.retrieveDirectoryNameWithName(beamLineName); if (dir != null) { String correctionFilePath = "/data/pyarch/" + dir + "/" + correctionFileName; String fullFilePath = PathUtils.FitPathToOS(correctionFilePath); File f = new File(fullFilePath); if (f.canRead()) { listFilesToDownload.add(f); filesToZip.put(f.getName(), fullFilePath); LOG.debug("Put in zip : " + f.getName() + " file: " + fullFilePath); } } } } } } } catch (NumberFormatException e) { e.printStackTrace(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewResults")); return this.display(mapping, actForm, request, response); } catch (Exception e) { e.printStackTrace(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewResults")); return this.display(mapping, actForm, request, response); } // create zip if (autoProcProgramId != null) { String genericFilename = "autoProcessingFiles.zip"; byte[] zippedFiles = HashMapToZip.doZip(filesToZip); String info = ""; Integer dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); if (dataCollectionId != null) { try { DataCollection3VO dc = dataCollectionService.findByPk(dataCollectionId, false, false); if (dc != null) { info = dc.getImagePrefix() + "_run" + dc.getDataCollectionNumber() + "_"; } } catch (Exception e) { e.printStackTrace(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewResults")); return this.display(mapping, actForm, request, response); } } String newfilename = info + genericFilename; response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment;filename=" + newfilename); OutputStream output; try { output = response.getOutputStream(); output.write(zippedFiles); output.close(); } catch (IOException e) { e.printStackTrace(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewResults")); return this.display(mapping, actForm, request, response); } } return null; }
From source file:org.monome.pages.MIDISequencerPagePoly.java
public void actionPerformed(ActionEvent e) { //System.out.println(e.getActionCommand()); if (e.getActionCommand().equals("Set MIDI Output")) { String[] midiOutOptions = this.monome.getMidiOutOptions(); String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to use", "Set MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, ""); if (deviceName == null) { return; }//from w ww . j a v a2s .com this.addMidiOutDevice(deviceName); } if (e.getActionCommand().equals("Update Preferences")) { this.noteNumbers[0] = this.noteToMidiNumber(this.row1tf.getText()); this.noteNumbers[1] = this.noteToMidiNumber(this.row2tf.getText()); this.noteNumbers[2] = this.noteToMidiNumber(this.row3tf.getText()); this.noteNumbers[3] = this.noteToMidiNumber(this.row4tf.getText()); this.noteNumbers[4] = this.noteToMidiNumber(this.row5tf.getText()); this.noteNumbers[5] = this.noteToMidiNumber(this.row6tf.getText()); this.noteNumbers[6] = this.noteToMidiNumber(this.row7tf.getText()); this.noteNumbers[7] = this.noteToMidiNumber(this.row8tf.getText()); this.noteNumbers[8] = this.noteToMidiNumber(this.row9tf.getText()); this.noteNumbers[9] = this.noteToMidiNumber(this.row10tf.getText()); this.noteNumbers[10] = this.noteToMidiNumber(this.row11tf.getText()); this.noteNumbers[11] = this.noteToMidiNumber(this.row12tf.getText()); this.noteNumbers[12] = this.noteToMidiNumber(this.row13tf.getText()); this.noteNumbers[13] = this.noteToMidiNumber(this.row14tf.getText()); this.noteNumbers[14] = this.noteToMidiNumber(this.row15tf.getText()); this.midiChannel = this.channelTF.getText(); if (Integer.parseInt(this.midiChannel) < 1) { this.midiChannel = "1"; this.channelTF.setText("1"); } try { this.setBankSize(Integer.parseInt(this.bankSizeTF.getText())); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } } }
From source file:ispyb.client.mx.results.ViewResultsAction.java
public void getAutoprocessingInfo(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) {//from w w w . j a v a 2s . c o m LOG.debug("getAutoprocessingInfo"); try { List<AutoProcessingInformation> autoProcList = new ArrayList<AutoProcessingInformation>(); BreadCrumbsForm bar = BreadCrumbsForm.getIt(request); String rMerge = (String) request.getSession().getAttribute("rMerge"); String iSigma = (String) request.getSession().getAttribute("iSigma"); double rMerge_d = DEFAULT_RMERGE; double iSigma_d = DEFAULT_ISIGMA; int nbRemoved = 0; try { if (rMerge != null && !rMerge.equals("undefined") && !rMerge.equals("")) rMerge_d = Double.parseDouble(rMerge); if (iSigma != null && !iSigma.equals("undefined") && !iSigma.equals("")) iSigma_d = Double.parseDouble(iSigma); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } Integer dataCollectionId = null; List<List<AutoProcStatus3VO>> interruptedAutoProcEvents = new ArrayList<List<AutoProcStatus3VO>>(); // Just one of them could be visible on the bar if (bar.getSelectedDataCollection() != null) { dataCollectionId = bar.getSelectedDataCollection().getDataCollectionId(); for (int i = 0; i < 2; i++) { boolean anomalous = (i > 0); List<AutoProc3VO> autoProcsAnomalous = apService .findByAnomalousDataCollectionIdAndOrderBySpaceGroupNumber(dataCollectionId, anomalous); if (autoProcsAnomalous != null) { LOG.debug( "..nbAutoProc " + anomalous + " found before rMerge =" + autoProcsAnomalous.size()); nbRemoved = 0; for (Iterator<AutoProc3VO> a = autoProcsAnomalous.iterator(); a.hasNext();) { AutoProc3VO apv = a.next(); List<AutoProcScalingStatistics3VO> scalingStatistics = apssService .findByAutoProcId(apv.getAutoProcId(), "innerShell"); boolean existsUnderRmergeAndOverSigma = false; for (Iterator<AutoProcScalingStatistics3VO> j = scalingStatistics.iterator(); j .hasNext();) { AutoProcScalingStatistics3VO stats = j.next(); if (stats.getRmerge() != null && stats.getRmerge() < rMerge_d && stats.getMeanIoverSigI() > iSigma_d) existsUnderRmergeAndOverSigma = true; } if (!existsUnderRmergeAndOverSigma) { a.remove(); nbRemoved = nbRemoved + 1; } } LOG.debug("..nbAutoProc " + anomalous + " found=" + autoProcsAnomalous.size()); for (Iterator<AutoProc3VO> iterator = autoProcsAnomalous.iterator(); iterator.hasNext();) { AutoProc3VO o = iterator.next(); String cmdLine = ""; if (o.getAutoProcProgramVO() != null && o.getAutoProcProgramVO().getProcessingPrograms() != null) { cmdLine = o.getAutoProcProgramVO().getProcessingPrograms(); } float refinedCellA = ((float) ((int) (o.getRefinedCellA() * 10))) / 10; // round to 1 dp float refinedCellB = ((float) ((int) (o.getRefinedCellB() * 10))) / 10; // round to 1 dp float refinedCellC = ((float) ((int) (o.getRefinedCellC() * 10))) / 10; // round to 1 dp float refinedCellAlpha = ((float) ((int) (o.getRefinedCellAlpha() * 10))) / 10; // round to // 1 dp float refinedCellBeta = ((float) ((int) (o.getRefinedCellBeta() * 10))) / 10; // round to 1 // dp float refinedCellGamma = ((float) ((int) (o.getRefinedCellGamma() * 10))) / 10; // round to // 1 dp String anoTxt = "Anomalous pairs merged (false)"; if (anomalous) { anoTxt = "Anomalous pairs unmerged (true)"; } // String anomalousS = anomalous+"= "+anoTxt; AutoProcessingInformation info = new AutoProcessingInformation(o.getAutoProcId(), cmdLine, o.getSpaceGroup(), anoTxt, refinedCellA, refinedCellB, refinedCellC, refinedCellAlpha, refinedCellBeta, refinedCellGamma); autoProcList.add(info); } } } // interrupted autoProc DataCollection3VO dc = dataCollectionService.findByPk(dataCollectionId, false, false); if (dc != null) { List<AutoProcIntegration3VO> autoProcIntegrationList = dc.getAutoProcIntegrationsList(); if (autoProcIntegrationList != null) { for (Iterator<AutoProcIntegration3VO> au = autoProcIntegrationList.iterator(); au .hasNext();) { AutoProcIntegration3VO autoProcIntegration = au.next(); if (autoProcIntegration.getAutoProcProgramVO() == null && autoProcIntegration.getAutoProcStatusList() != null) { List<AutoProcStatus3VO> events = autoProcIntegration.getAutoProcStatusList(); interruptedAutoProcEvents.add(events); } } } } } Integer autoProcIdSelected = (Integer) request.getSession().getAttribute("lastAutoProcIdSelected"); // check if autoProcIdSelected is in the list boolean idExists = false; if (autoProcIdSelected != null) { for (Iterator<AutoProcessingInformation> iterator = autoProcList.iterator(); iterator.hasNext();) { AutoProcessingInformation info = iterator.next(); if (info.getAutoProcId().equals(autoProcIdSelected)) { idExists = true; break; } } } if (!idExists) { autoProcIdSelected = null; } // HashMap<String, Object> data = new HashMap<String, Object>(); // context path data.put("contextPath", request.getContextPath()); // autoProcList data.put("autoProcList", autoProcList); // autoProcIdSelected data.put("autoProcIdSelected", autoProcIdSelected); // rMerge & iSigma data.put("rMerge", rMerge); data.put("iSigma", iSigma); data.put("nbRemoved", nbRemoved); data.put("dataCollectionId", dataCollectionId); // interrupted autoProc data.put("interruptedAutoProcEvents", interruptedAutoProcEvents); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); } catch (Exception e) { e.printStackTrace(); } }
From source file:ispyb.client.mx.results.ViewResultsAction.java
/** * Display EDNA results content on the page * // w ww . j a v a 2 s .c om * @param mapping * @param actForm * @param request * @param response * @return * @throws Exception */ public ActionForward displayEDNA(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response, ActionMessages errors) throws Exception { ViewResultsForm form = (ViewResultsForm) actForm; dataCollectionIdst = request.getParameter(Constants.DATA_COLLECTION_ID); try { // Integer dataCollectionId = new Integer(dataCollectionIdst); Integer dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); 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; 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); boolean isFileExist2 = new File(indexPath).exists(); String fileContent = ""; if (isFileExist2) fileContent = FileUtil.fileToString(indexPath); // Case where the file is not found if (fileContent == null) { // errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.user.results.viewDNA")); form.setDNAContent("Sorry, but no EDNA files can be retrieved for this data collection."); return null; } // // String fullDNAFileContent = FileUtil.fileToString(indexPath); // Populate form form.setDataCollectionId(dataCollectionId); form.setDNAContent("<iframe scrolling='yes' frameborder='0' width='790' height='600' src='" + request.getContextPath() + "/user/viewResults.do?reqCode=displayEDNAPagesContent&dataCollectionId=" + dataCollectionId.toString() + "'>" + fileContent + "</iframe>"); FormUtils.setFormDisplayMode(request, actForm, FormUtils.INSPECT_MODE); return null; } catch (NumberFormatException e) { form.setDNAContent("Sorry, an error occurs while retrieving the EDNA file:" + dataCollectionIdst); e.printStackTrace(); return null; } }
From source file:Controller.UserController.java
@RequestMapping(value = "/Payment", method = RequestMethod.POST) public String payment(HttpServletRequest request) { try {/*from w w w . j a v a 2s . c o m*/ boolean validate = false; boolean makePayment = false; AccountSession account = (AccountSession) request.getSession().getAttribute("account"); String selectedDate = request.getParameter("selectedDate"); String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); int numberOfAdults, numberOfChilds, packageID; int cvv = 0; String paymentType = request.getParameter("paymentMethod"); PackageDTO packgeDTO = null; List<Double> prices = new ArrayList<Double>(); Double total = (Double) 0.0; try { numberOfAdults = Integer.parseInt(request.getParameter("numberOfAdults")); } catch (NumberFormatException e) { numberOfAdults = 0; } try { numberOfChilds = Integer.parseInt(request.getParameter("numberOfChilds")); } catch (NumberFormatException e) { numberOfChilds = 0; } try { packageID = Integer.parseInt(request.getParameter("packageID")); } catch (NumberFormatException e) { packageID = 0; } if (packageID > 0 && numberOfAdults > 0) { packgeDTO = tripperService.getPackageForPayment(packageID); prices = tripperService.getPriceOfSelectedDate(selectedDate, packgeDTO); if (prices.get(0) > 0) { if (prices.get(1) <= 0 || (prices.get(1) > 0 && numberOfChilds > 0)) { if (!packgeDTO.isIsPrivateTour()) { total = ((prices.get(0) * numberOfAdults + numberOfChilds * prices.get(1)) * (100 - packgeDTO.getYoutripperPercentage()) / 100); } else { int noOfPackages = (int) Math.round(Math .ceil((float) (numberOfAdults + numberOfChilds) / packgeDTO.getMinTripper())); total = (noOfPackages * prices.get(0) * (100 - packgeDTO.getYoutripperPercentage()) / 100); } validate = true; } } } //Make credit Card payment if (validate) { if (paymentType.equals("creditCard")) { String cardType = request.getParameter("cardType"); String cardNumber = request.getParameter("cardNumber"); int expireMonth = Integer.parseInt(request.getParameter("expireMonth")); int expireYear = Integer.parseInt(request.getParameter("expireYear")); try { cvv = Integer.parseInt(request.getParameter("cvv")); } catch (Exception e) { e.printStackTrace(); } makePayment = tripperService.paywithCreditCard(cardType, cardNumber, expireMonth, expireYear, cvv, firstName, lastName, "USD", String.format(Locale.US, "%.2f", total), "Booking Trip:" + packageID); } else if (paymentType.equals("paypal")) { request.setAttribute("packageID", packageID); request.setAttribute("selectedDate", selectedDate); request.setAttribute("numberOfChilds", numberOfChilds); request.setAttribute("numberOfAdults", numberOfAdults); request.setAttribute("prices", prices); request.setAttribute("totalPrice", String.format(Locale.US, "%.2f", total)); return "forward:/Tripper/PaywithPaypal"; } if (makePayment) { String code = tripperService.getBookingCode(); tripperService.insertBooking(code, packageID, selectedDate, numberOfChilds, numberOfAdults, account.getId()); int providerID = packgeDTO.getProviderID(); int tripperID = account.getId(); boolean notifyForProvider = providerService .insertNewProviderSystemNotification("{\"URL\":\"Noti/ProviderViewBooking/" + code + "\",\"Message\":\"You have a new booking\"}", false, providerID); boolean notifyForTripper = tripperService .insertNewTripperSystemNotification("{\"URL\":\"Noti/TripperViewBooking/" + code + "\",\"Message\":\"You had booked a trip!\"}", false, tripperID); String providerNoti = providerService.getProviderNewNotification(providerID); template.convertAndSend("/topic/Notifications/Provider/" + providerID, providerNoti); String tripperNoti = tripperService.getTripperNewNotification(tripperID); template.convertAndSend("/topic/Notifications/Tripper/" + tripperID, tripperNoti); return "/tripper/paymentSuccess"; } else { request.setAttribute("message", "Your credit card is declined"); request.setAttribute("selectedDate", selectedDate); request.setAttribute("numberOfAdults", numberOfAdults); request.setAttribute("numberOfChilds", numberOfChilds); request.setAttribute("packageID", packageID); return "forward:/Tripper/Book"; } } if (request.getParameter("language") != null) { return "redirect:/Common" + "?language=" + request.getParameter("language"); } else { return "redirect:/Common"; } } catch (Exception e) { HttpSession session = request.getSession(true); String content = "Function: UserController - payment\n" + "***Input***\n" + "selectedDate: " + request.getParameter("selectedDate") + "\n" + "firstName: " + request.getParameter("firstName") + "\n" + "lastName: " + request.getParameter("lastName") + "\n" + "paymentMethod: " + request.getParameter("paymentMethod") + "\n" + "numberOfAdults: " + request.getParameter("numberOfAdults") + "\n" + "numberOfChilds: " + request.getParameter("numberOfChilds") + "\n" + "packageID: " + request.getParameter("packageID") + "\n" + "**********\n" + "****Error****\n" + e.getMessage() + "\n" + "**********"; request.setAttribute("errorID", session.getId()); request.setAttribute("errorTime", errorService.logBugWithAccount(content, session, e)); return "forward:/Common/Error"; } }
From source file:ispyb.client.mx.results.ViewResultsAction.java
public void getResultData(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) {//from w w w. ja v a 2 s . c om LOG.debug("getResultData"); List<String> errors = new ArrayList<String>(); try { List<AutoProcessingInformation> autoProcList = new ArrayList<AutoProcessingInformation>(); BreadCrumbsForm bar = BreadCrumbsForm.getIt(request); boolean displayOutputParam = false; boolean displayDenzoContent = false; // booleans to fix which tab will be selected by default boolean isEDNACharacterisation = false; boolean isAutoprocessing = false; String rMerge = (String) request.getSession().getAttribute(Constants.RSYMM); String iSigma = (String) request.getSession().getAttribute(Constants.ISIGMA); double rMerge_d = DEFAULT_RMERGE; double iSigma_d = DEFAULT_ISIGMA; int nbRemoved = 0; try { if (rMerge != null && !rMerge.equals("undefined") && !rMerge.equals("")) rMerge_d = Double.parseDouble(rMerge); if (iSigma != null && !iSigma.equals("undefined") && !iSigma.equals("")) iSigma_d = Double.parseDouble(iSigma); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } Integer dataCollectionId = null; List<List<AutoProcStatus3VO>> interruptedAutoProcEvents1 = new ArrayList<List<AutoProcStatus3VO>>(); DataCollection3VO dc = null; // Just one of them could be visible on the bar if (bar.getSelectedDataCollection() != null) { dataCollectionId = bar.getSelectedDataCollection().getDataCollectionId(); } if (dataCollectionId == null && request.getParameter(Constants.DATA_COLLECTION_ID) != null) dataCollectionId = new Integer(request.getParameter(Constants.DATA_COLLECTION_ID)); if (dataCollectionId == null && request.getSession().getAttribute(Constants.DATA_COLLECTION_ID) != null) dataCollectionId = new Integer( (Integer) request.getSession().getAttribute(Constants.DATA_COLLECTION_ID)); if (dataCollectionId == null) { errors.add("dataCollectionId is null"); HashMap<String, Object> data = new HashMap<String, Object>(); data.put("errors", errors); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); return; } dc = dataCollectionService.findByPk(dataCollectionId, false, true); // interrupted autoProc if (dc != null) { List<AutoProcIntegration3VO> autoProcIntegrationList = dc.getAutoProcIntegrationsList(); if (autoProcIntegrationList != null) { for (Iterator<AutoProcIntegration3VO> au = autoProcIntegrationList.iterator(); au.hasNext();) { AutoProcIntegration3VO autoProcIntegration = au.next(); if (autoProcIntegration.getAutoProcProgramVO() == null && autoProcIntegration.getAutoProcStatusList() != null) { List<AutoProcStatus3VO> events = autoProcIntegration.getAutoProcStatusList(); interruptedAutoProcEvents1.add(events); } } } } for (int i = 0; i < 2; i++) { boolean anomalous = (i > 0); List<AutoProc3VO> autoProcsAnomalous = apService .findByAnomalousDataCollectionIdAndOrderBySpaceGroupNumber(dataCollectionId, anomalous); if (autoProcsAnomalous != null) { nbRemoved = 0; LOG.debug("..nbAutoProc " + anomalous + " found before rMerge =" + autoProcsAnomalous.size()); for (Iterator<AutoProc3VO> a = autoProcsAnomalous.iterator(); a.hasNext();) { AutoProc3VO apv = a.next(); List<AutoProcScalingStatistics3VO> scalingStatistics = apssService .findByAutoProcId(apv.getAutoProcId(), "innerShell"); boolean existsUnderRmergeAndOverSigma = false; for (Iterator<AutoProcScalingStatistics3VO> j = scalingStatistics.iterator(); j .hasNext();) { AutoProcScalingStatistics3VO stats = j.next(); if (stats.getRmerge() != null && stats.getRmerge() < rMerge_d && stats.getMeanIoverSigI() > iSigma_d) existsUnderRmergeAndOverSigma = true; } if (!existsUnderRmergeAndOverSigma) { a.remove(); nbRemoved = nbRemoved + 1; } } LOG.debug("..nbAutoProc " + anomalous + " found=" + autoProcsAnomalous.size()); for (Iterator<AutoProc3VO> iterator = autoProcsAnomalous.iterator(); iterator.hasNext();) { AutoProc3VO o = iterator.next(); String cmdLine = ""; if (o.getAutoProcProgramVO() != null && o.getAutoProcProgramVO().getProcessingPrograms() != null) { cmdLine = o.getAutoProcProgramVO().getProcessingPrograms(); } float refinedCellA = ((float) ((int) (o.getRefinedCellA() * 10))) / 10; // round to 1 dp float refinedCellB = ((float) ((int) (o.getRefinedCellB() * 10))) / 10; // round to 1 dp float refinedCellC = ((float) ((int) (o.getRefinedCellC() * 10))) / 10; // round to 1 dp float refinedCellAlpha = ((float) ((int) (o.getRefinedCellAlpha() * 10))) / 10; // round to 1 dp float refinedCellBeta = ((float) ((int) (o.getRefinedCellBeta() * 10))) / 10; // round to 1 dp float refinedCellGamma = ((float) ((int) (o.getRefinedCellGamma() * 10))) / 10; // round to 1 dp String anoTxt = "OFF (Friedel pairs merged)"; // false if (anomalous) { anoTxt = "ON (Friedel pairs unmerged)"; // true } // String anomalousS = anomalous+"= "+anoTxt; AutoProcessingInformation info = new AutoProcessingInformation(o.getAutoProcId(), cmdLine, o.getSpaceGroup(), anoTxt, refinedCellA, refinedCellB, refinedCellC, refinedCellAlpha, refinedCellBeta, refinedCellGamma); autoProcList.add(info); } } } Integer autoProcIdSelected = (Integer) request.getSession().getAttribute("lastAutoProcIdSelected"); // check if autoProcIdSelected is in the list boolean idExists = false; if (autoProcIdSelected != null) { for (Iterator<AutoProcessingInformation> iterator = autoProcList.iterator(); iterator.hasNext();) { AutoProcessingInformation info = iterator.next(); if (info.getAutoProcId().equals(autoProcIdSelected)) { idExists = true; break; } } } if (!idExists) { autoProcIdSelected = null; } List<DataCollection3VO> listLastCollectVO = new ArrayList<DataCollection3VO>(); if (dc != null) listLastCollectVO.add(dc); AutoProcShellWrapper wrapper = ViewDataCollectionAction.getAutoProcStatistics(listLastCollectVO, rMerge_d, iSigma_d); int dcIndex = 0; // is autoproc ? List<AutoProc3VO> autoProcs = apService.findByDataCollectionId(dataCollectionId); if (autoProcs != null && autoProcs.size() > 0) isAutoprocessing = true; String beamLineName = ""; String proposal = ""; String proteinAcronym = ""; String pdbFileName = ""; String experimentType = ""; if (dc != null) { beamLineName = dc.getDataCollectionGroupVO().getSessionVO().getBeamlineName(); proposal = dc.getDataCollectionGroupVO().getSessionVO().getProposalVO().getCode() + dc.getDataCollectionGroupVO().getSessionVO().getProposalVO().getNumber(); BLSample3VO sample = dc.getDataCollectionGroupVO().getBlSampleVO(); if (sample != null && sample.getCrystalVO() != null && sample.getCrystalVO().getProteinVO() != null) proteinAcronym = sample.getCrystalVO().getProteinVO().getAcronym(); if (sample != null && sample.getCrystalVO() != null && sample.getCrystalVO().hasPdbFile()) { pdbFileName = sample.getCrystalVO().getPdbFileName(); } experimentType = dc.getDataCollectionGroupVO().getExperimentType(); } AutoProc3VO autoProc = null; AutoProcScalingStatistics3VO autoProcStatisticsOverall = null; AutoProcScalingStatistics3VO autoProcStatisticsInner = null; AutoProcScalingStatistics3VO autoProcStatisticsOuter = null; ScreeningOutputLattice3VO lattice = null; ScreeningOutput3VO screeningOutput = null; String snapshotFullPath = ""; boolean hasSnapshot = false; Screening3VO[] tabScreening = null; if (dc != null) { snapshotFullPath = dc.getXtalSnapshotFullPath1(); snapshotFullPath = PathUtils.FitPathToOS(snapshotFullPath); if (snapshotFullPath != null) hasSnapshot = (new File(snapshotFullPath)).exists(); autoProc = wrapper.getAutoProcs()[dcIndex]; autoProcStatisticsOverall = wrapper.getScalingStatsOverall()[dcIndex]; autoProcStatisticsInner = wrapper.getScalingStatsInner()[dcIndex]; autoProcStatisticsOuter = wrapper.getScalingStatsOuter()[dcIndex]; DataCollectionGroup3VO dcGroup = dataCollectionGroupService .findByPk(dc.getDataCollectionGroupVOId(), false, true); tabScreening = dcGroup.getScreeningsTab(); } if (tabScreening != null && tabScreening.length > 0) { displayOutputParam = true;// there is at least 1 screening so we display the output params Screening3VO screeningVO = tabScreening[0]; ScreeningOutput3VO[] screeningOutputTab = screeningVO.getScreeningOutputsTab(); if (screeningOutputTab != null && screeningOutputTab.length > 0) { if (screeningOutputTab[0].getScreeningOutputLatticesTab() != null && screeningOutputTab[0].getScreeningOutputLatticesTab().length > 0) { lattice = screeningOutputTab[0].getScreeningOutputLatticesTab()[0]; } screeningOutput = screeningOutputTab[0]; } } String autoprocessingStatus = ""; String autoprocessingStep = ""; if (wrapper != null && wrapper.getAutoProcs() != null && wrapper.getAutoProcs().length > dcIndex) { AutoProcIntegration3VO autoProcIntegration = wrapper.getAutoProcIntegrations()[dcIndex]; if (autoProcIntegration != null) { List<AutoProcStatus3VO> autoProcEvents = autoProcIntegration.getAutoProcStatusList(); if (autoProcEvents != null && autoProcEvents.size() > 0) { AutoProcStatus3VO st = autoProcEvents.get(autoProcEvents.size() - 1); autoprocessingStatus = st.getStatus(); autoprocessingStep = st.getStep(); } } } boolean hasAutoProcAttachment = false; if (wrapper != null && wrapper.getAutoProcs() != null) { for (int a = 0; a < autoProcs.size(); a++) { Integer autoProcProgramId = autoProcs.get(a).getAutoProcProgramVOId(); if (autoProcProgramId != null) { List<AutoProcProgramAttachment3VO> attachments = appService .findByPk(autoProcProgramId, true).getAttachmentListVOs(); if (attachments != null && attachments.size() > 0) { hasAutoProcAttachment = true; break; } } } } DataCollectionBean dataCollection = null; if (dc != null) { dataCollection = new DataCollectionBean(dc, beamLineName, proposal, proteinAcronym, pdbFileName, experimentType, hasSnapshot, autoProc, autoProcStatisticsOverall, autoProcStatisticsInner, autoProcStatisticsOuter, screeningOutput, lattice, autoprocessingStatus, autoprocessingStep, hasAutoProcAttachment); } BeamLineSetup3VO beamline = null; Session3VO session = null; Detector3VO detector = null; String fullDenzoPath = null; boolean DenzonContentPresent = false; if (dc != null) { // beamline setup beamline = dc.getDataCollectionGroupVO().getSessionVO().getBeamLineSetupVO(); // Session session = dc.getDataCollectionGroupVO().getSessionVO(); // Detector detector = dc.getDetectorVO(); // energy DecimalFormat df3 = (DecimalFormat) NumberFormat.getInstance(Locale.US); df3.applyPattern("#####0.000"); Double energy = null; if (dc.getWavelength() != null && dc.getWavelength().compareTo(new Double(0)) != 0) energy = Constants.WAVELENGTH_TO_ENERGY_CONSTANT / dc.getWavelength(); if (energy != null) dataCollection.setEnergy(new Double(df3.format(energy))); else dataCollection.setEnergy(null); // axis start label String axisStartLabel = dc.getRotationAxis() == null ? "" : dc.getRotationAxis() + " start"; dataCollection.setAxisStartLabel(axisStartLabel); // totalExposureTime if (dc.getExposureTime() != null && dc.getNumberOfImages() != null) { dataCollection.setTotalExposureTime( new Double(df3.format(dataCollection.getExposureTime() * dc.getNumberOfImages()))); } // kappa Double kappa = dc.getKappaStart(); String kappaStr = ""; if (kappa == null || kappa.equals(Constants.SILLY_NUMBER)) kappaStr = new String("0"); else kappaStr = new String(kappa.toString()); dataCollection.setKappa(kappaStr); // phi Double phi = dc.getPhiStart(); String phiStr = ""; if (phi == null || phi.equals(Constants.SILLY_NUMBER)) phiStr = new String("0"); else phiStr = new String(phi.toString()); dataCollection.setPhi(phiStr); // undulatorGaps DecimalFormat df2 = (DecimalFormat) NumberFormat.getInstance(Locale.US); // DecimalFormat df2 = new DecimalFormat("##0.##"); df2.applyPattern("##0.##"); StringBuffer buf = new StringBuffer(); // if no type then there is no meaningful value // if no undulator 1 then no 2 and no 3 if (beamline.getUndulatorType1() != null && beamline.getUndulatorType1().length() > 0) { if (dc.getUndulatorGap1() != null && !dc.getUndulatorGap1().equals(Constants.SILLY_NUMBER)) { Double gap1 = new Double(df2.format(dc.getUndulatorGap1())); buf.append(gap1.toString()).append(" mm "); } if (beamline.getUndulatorType2() != null && beamline.getUndulatorType2().length() > 0) { if (dc.getUndulatorGap2() != null && !dc.getUndulatorGap2().equals(Constants.SILLY_NUMBER)) { Double gap2 = new Double(df2.format(dc.getUndulatorGap2())); buf.append(gap2.toString()).append(" mm "); } if (beamline.getUndulatorType3() != null && beamline.getUndulatorType3().length() > 0) { if (dc.getUndulatorGap3() != null && !dc.getUndulatorGap3().equals(Constants.SILLY_NUMBER)) { Double gap3 = new Double(df2.format(dc.getUndulatorGap3())); buf.append(gap3.toString()).append(" mm "); } } } } String undulatorGaps = buf.toString(); dataCollection.setUndulatorGaps(undulatorGaps); DecimalFormat nf1 = (DecimalFormat) NumberFormat.getInstance(Locale.UK); nf1.applyPattern("#"); DecimalFormat df5 = (DecimalFormat) NumberFormat.getInstance(Locale.US); df5.applyPattern("#####0.00000"); // slitGapHorizontalMicro Integer slitGapHorizontalMicro = null; if (dc.getSlitGapHorizontal() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion slitGapHorizontalMicro = new Integer( nf1.format(dc.getSlitGapHorizontal().doubleValue() * 1000)); } dataCollection.setSlitGapHorizontalMicro(slitGapHorizontalMicro); // slitGapVerticalMicro Integer slitGapVerticalMicro = null; if (dc.getSlitGapVertical() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion slitGapVerticalMicro = new Integer(nf1.format(dc.getSlitGapVertical().doubleValue() * 1000)); } dataCollection.setSlitGapVerticalMicro(slitGapVerticalMicro); // detectorPixelSizeHorizontalMicro Double detectorPixelSizeHorizontalMicro = null; if (detector != null && detector.getDetectorPixelSizeHorizontal() != null) { // in DB pixel size unit is mm, detectorPixelSizeHorizontalMicro = new Double( df5.format(detector.getDetectorPixelSizeHorizontal())); } dataCollection.setDetectorPixelSizeHorizontalMicro(detectorPixelSizeHorizontalMicro); // detectorPixelSizeHorizontalMicro Double detectorPixelSizeVerticalMicro = null; if (detector != null && detector.getDetectorPixelSizeVertical() != null) { // in DB pixel size unit is mm, detectorPixelSizeVerticalMicro = new Double( df5.format(detector.getDetectorPixelSizeVertical())); } dataCollection.setDetectorPixelSizeVerticalMicro(detectorPixelSizeVerticalMicro); // beamSizeAtSampleXMicro Integer beamSizeAtSampleXMicro = null; if (dc.getBeamSizeAtSampleX() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion beamSizeAtSampleXMicro = new Integer( nf1.format(dc.getBeamSizeAtSampleX().doubleValue() * 1000)); } dataCollection.setBeamSizeAtSampleXMicro(beamSizeAtSampleXMicro); // beamSizeAtSampleYMicro Integer beamSizeAtSampleYMicro = null; if (dc.getBeamSizeAtSampleY() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion beamSizeAtSampleYMicro = new Integer( nf1.format(dc.getBeamSizeAtSampleY().doubleValue() * 1000)); } dataCollection.setBeamSizeAtSampleYMicro(beamSizeAtSampleYMicro); // beamDivergenceHorizontalInt Integer beamDivergenceHorizontalInt = null; if (beamline.getBeamDivergenceHorizontal() != null) { beamDivergenceHorizontalInt = new Integer(nf1.format(beamline.getBeamDivergenceHorizontal())); } dataCollection.setBeamDivergenceHorizontalInt(beamDivergenceHorizontalInt); // beamDivergenceVerticalInt Integer beamDivergenceVerticalInt = null; if (beamline.getBeamDivergenceVertical() != null) { beamDivergenceVerticalInt = new Integer(nf1.format(beamline.getBeamDivergenceVertical())); } dataCollection.setBeamDivergenceVerticalInt(beamDivergenceVerticalInt); // DNA or EDNA Content present ? String fullDNAPath = PathUtils.getFullDNAPath(dc); String fullEDNAPath = PathUtils.getFullEDNAPath(dc); boolean EDNAContentPresent = (new File(fullEDNAPath + EDNA_FILES_INDEX_FILE)).exists() || (new File(fullDNAPath + Constants.DNA_FILES_INDEX_FILE)).exists(); isEDNACharacterisation = EDNAContentPresent; // Denzo Content present ? if (Constants.DENZO_ENABLED) { fullDenzoPath = FileUtil.GetFullDenzoPath(dc); DenzonContentPresent = (new File(fullDenzoPath)).exists(); displayDenzoContent = DisplayDenzoContent(dc); if (DenzonContentPresent) // Check html file present { File denzoIndex = new File(fullDenzoPath + DENZO_HTML_INDEX); if (!denzoIndex.exists()) { errors.add("Denzo File does not exist " + denzoIndex); DenzonContentPresent = false; } } } } // HashMap<String, Object> data = new HashMap<String, Object>(); // context path data.put("contextPath", request.getContextPath()); // autoProcList data.put("autoProcList", autoProcList); // autoProcIdSelected data.put("autoProcIdSelected", autoProcIdSelected); // rMerge & iSigma data.put("rMerge", rMerge); data.put("iSigma", iSigma); data.put("nbRemoved", nbRemoved); data.put("dataCollectionId", dataCollectionId); data.put("dataCollection", dataCollection); // beamlinesetup data.put("beamline", beamline); // session data.put("session", session); // detector data.put("detector", detector); // interrupted autoProc data.put("interruptedAutoProcEvents", interruptedAutoProcEvents1); // displayOutputParam data.put("displayOutputParam", displayOutputParam); // isEDNACharacterisation data.put("isEDNACharacterisation", isEDNACharacterisation); // isAutoprocessing data.put("isAutoprocessing", isAutoprocessing); // displayDenzoContent data.put("displayDenzoContent", displayDenzoContent); // DenzonContentPresent data.put("DenzonContentPresent", DenzonContentPresent); // fullDenzoPath data.put("fullDenzoPath", fullDenzoPath); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); } catch (Exception e) { e.printStackTrace(); } }
From source file:me.azenet.UHPlugin.UHPluginCommand.java
/** * Handles a command.// w ww . j av a2 s .c om * * @param sender The sender * @param command The executed command * @param label The alias used for this command * @param args The arguments given to the command * * @author Amaury Carrade */ @SuppressWarnings("rawtypes") @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { boolean ourCommand = false; for (String commandName : p.getDescription().getCommands().keySet()) { if (commandName.equalsIgnoreCase(command.getName())) { ourCommand = true; break; } } if (!ourCommand) { return false; } /** Team chat commands **/ if (command.getName().equalsIgnoreCase("t")) { doTeamMessage(sender, command, label, args); return true; } if (command.getName().equalsIgnoreCase("g")) { doGlobalMessage(sender, command, label, args); return true; } if (command.getName().equalsIgnoreCase("togglechat")) { doToggleTeamChat(sender, command, label, args); return true; } /** /join & /leave commands **/ if (command.getName().equalsIgnoreCase("join")) { doJoin(sender, command, label, args); return true; } if (command.getName().equalsIgnoreCase("leave")) { doLeave(sender, command, label, args); return true; } if (args.length == 0) { help(sender, args, false); return true; } String subcommandName = args[0].toLowerCase(); // First: subcommand existence. if (!this.commands.contains(subcommandName)) { try { Integer.valueOf(subcommandName); help(sender, args, false); } catch (NumberFormatException e) { // If the subcommand isn't a number, it's an error. help(sender, args, true); } return true; } // Second: is the sender allowed? if (!isAllowed(sender, subcommandName)) { unauthorized(sender, command); return true; } // Third: instantiation try { Class<? extends UHPluginCommand> cl = this.getClass(); Class[] parametersTypes = new Class[] { CommandSender.class, Command.class, String.class, String[].class }; Method doMethod = cl.getDeclaredMethod("do" + WordUtils.capitalize(subcommandName), parametersTypes); doMethod.invoke(this, new Object[] { sender, command, label, args }); return true; } catch (NoSuchMethodException e) { // Unknown method => unknown subcommand. help(sender, args, true); return true; } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { sender.sendMessage(i.t("cmd.errorLoad")); e.printStackTrace(); return false; } }
From source file:fsl.ta.toms.roms.service.impl.RoadCompliancyServiceImpl.java
private VehicleCheckResultBO processMVCheck(VehicleCheckResultBO mvCheckRequest, Vehicle mvDetails, Integer vehicleID, boolean isQuickQuery, RoadLicenceBO roadLicBO) throws InvalidFieldException, ErrorSavingException { DateFormat formatter;//from ww w . j ava 2 s .c o m formatter = new SimpleDateFormat("yyyy-MM-dd"); Date expiryDate = null; Date issueDate = null; //boolean errorGettingAddress = false; AuditEntry audit = null; //prepare audit entry audit = new AuditEntry(); audit = new AuditEntry(); audit.setCreateUsername(mvCheckRequest.getCurrentUserName()); audit.setCreateDTime(Calendar.getInstance().getTime()); ComplianceDO complianceDO = null; if (!isQuickQuery) { //Check if valid ComplianceID entered complianceDO = daoFactory.getRoadCompliancyDAO().find(ComplianceDO.class, mvCheckRequest.getComplianceID()); if (complianceDO == null) { throw new InvalidFieldException("Compliance ID Invalid"); } } //create Road Check Record RoadCheckDO roadCheckDO = new RoadCheckDO( daoFactory.getRoadCompliancyDAO().find(CDRoadCheckTypeDO.class, RoadCheckType.MOTOR_VEHICLE), complianceDO, 'Y', mvCheckRequest.getComment(), audit); Integer roadCheckID = null; RoadCheckDO savedRoadCheckDO = null; if (!isQuickQuery) { roadCheckID = (Integer) daoFactory.getRoadCompliancyDAO().save(roadCheckDO); savedRoadCheckDO = daoFactory.getRoadCompliancyDAO().find(RoadCheckDO.class, roadCheckID); } else { savedRoadCheckDO = roadCheckDO; } //Get Road Licence Information...... Call LMIS Road Licence service LMISService lmisService = serviceFactory.getLMISService(); RoadLicenceBO roadLicDetails = roadLicBO; //new RoadLicenceBO(); //I-143826 - There was duplicate work being done here. // try{ // roadLicDetails = lmisService.getRoadLicenceDetails(mvCheckRequest.getPlateRegNo()); // } catch (RequiredFieldMissingException e2) { // // TODO Auto-generated catch block // e2.printStackTrace(); // } catch (NoRecordFoundException e2) { // // TODO Auto-generated catch block // e2.printStackTrace(); // } //populate ResultDOs and Save try { if (mvDetails.getVehMvrc() != null) { if (mvDetails.getVehMvrc().getMvrcExpiryDate() != null) { expiryDate = formatter.parse(mvDetails.getVehMvrc().getMvrcExpiryDate()); } if (mvDetails.getVehMvrc().getMvrcIssueDate() != null) { issueDate = formatter.parse(mvDetails.getVehMvrc().getMvrcIssueDate()); } } } catch (ParseException pe) { pe.printStackTrace(); } //1.Save MVCheck Results VehicleCheckResultDO mvCheckResultDO = new VehicleCheckResultDO(savedRoadCheckDO, mvCheckRequest.getPlateRegNo(), mvDetails.getVehInfo().getEngineNo(), mvDetails.getVehInfo().getChassisNo(), mvDetails.getVehInfo().getVehicleColour(), mvDetails.getVehInfo().getVehicleMakeDesc(), mvDetails.getVehInfo().getVehicleModel(), mvDetails.getVehInfo().getVehicleTypeDesc(), mvDetails.getVehMvrc() != null ? mvDetails.getVehMvrc().getMvrcNo() : null, expiryDate, new Integer(mvDetails.getVehInfo().getVehicleYear()), roadLicDetails != null ? roadLicDetails.getLicenceNo() : null, roadLicDetails != null && roadLicDetails.getLicenceOwners() != null && roadLicDetails.getLicenceOwners().size() > 0 ? roadLicDetails.getLicenceOwners() != null ? roadLicDetails.getLicenceOwners().get(0).getFirstName() + " " + roadLicDetails.getLicenceOwners().get(0).getLastName() : null : null, roadLicDetails != null ? roadLicDetails.getStatusDesc() : null, audit, issueDate); Integer mvCheckResultID = null; VehicleCheckResultDO savedVehicleChkRslt = null; if (!isQuickQuery) { mvCheckResultID = (Integer) daoFactory.getRoadCompliancyDAO().save(mvCheckResultDO); savedVehicleChkRslt = daoFactory.getRoadCompliancyDAO().find(VehicleCheckResultDO.class, mvCheckResultID); } else { savedVehicleChkRslt = mvCheckResultDO; } //2.Save Vehicle Owner Information List<VehOwner> vehOwners = new ArrayList<VehOwner>(); if (mvDetails.getVehOwners() != null) { vehOwners = mvDetails.getVehOwners().getVehOwner(); } //VehicleOwnerDO vehicleOwnerDO = new VehicleOwnerDO(); VehicleCheckResultOwnerDO vehicleCheckResultOwnerDO = null; //new VehicleCheckResultOwnerDO(); //DLWebService dlService = new DLWebService(); //TRNWebService trnWebService = new TRNWebService(); List<VehicleCheckResultOwnerDO> listOfvehicleChkOwners = new ArrayList<VehicleCheckResultOwnerDO>(); if (vehOwners != null) { for (VehOwner vehicleOwner : vehOwners) { String trnNbr = vehicleOwner.getTrnNo(); String trnBranch = vehicleOwner.getTrnBranch(); /************** * I-143826 - 1. Look in database for owner details first. * 2. If details do not exist, go straight to TRN service, as opposed to going to DL then TRN(which previously existed). **************/ /*** * Check if person exists in database */ AddressDO retrievedPersonAddress = null; ParishDO parishDO = null; AddressDO serviceAddressDO = null; try { /////////////////////////////////////////// retrievedPersonAddress = getPersonAddress(trnNbr, trnBranch); } catch (Exception ex) { ex.printStackTrace(); } //retrievedPersonAddress = null; if (retrievedPersonAddress != null) { parishDO = retrievedPersonAddress.getParish(); vehicleCheckResultOwnerDO = new VehicleCheckResultOwnerDO(savedVehicleChkRslt, vehicleOwner.getTrnNo(), vehicleOwner.getTrnBranch(), vehicleOwner.getFirstName(), null, vehicleOwner.getLastName(), retrievedPersonAddress, null, null, null, audit); //personDTO.getAddrPoLocName(),personDTO.getAddrParishDesc(), personDTO.getAddrCountryDesc(),audit); } else { //Check vehicle owner table //System.err.println("Check TRN Service"); //System.err.println("Point L " + Calendar.getInstance().getTime()); //if(!isQuickQuery){ TrnDTO personDTO = null; try { Integer trnInt = Integer.parseInt(trnNbr); personDTO = trnService.validateTRN(trnInt, (short) 0); if (personDTO != null) { parishDO = null; if (StringUtil.isSet(personDTO.getAddrParishCode())) { parishDO = daoFactory.getRoadCompliancyDAO().find(ParishDO.class, personDTO.getAddrParishCode()); } //set Address based on values retrieved from TRN serviceAddressDO = new AddressDO(personDTO.getAddrMarkText(), personDTO.getAddrStreetNo(), personDTO.getAddrStreetName(), personDTO.getAddrPoLocName(), personDTO.getAddrPoBoxNo(), parishDO); vehicleCheckResultOwnerDO = new VehicleCheckResultOwnerDO(savedVehicleChkRslt, vehicleOwner.getTrnNo(), vehicleOwner.getTrnBranch(), vehicleOwner.getFirstName(), null, vehicleOwner.getLastName(), serviceAddressDO, personDTO.getAddrPoLocName(), personDTO.getAddrParishDesc(), personDTO.getAddrCountryDesc(), audit); } } catch (NumberFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); //errorGettingAddress = true; } catch (InvalidTrnBranchException_Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); //errorGettingAddress = true; } catch (NotValidTrnTypeException_Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); //errorGettingAddress = true; } catch (SystemErrorException_Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); //errorGettingAddress = true; } catch (Exception ex) { ex.printStackTrace(); } } if (vehicleCheckResultOwnerDO == null) { vehicleCheckResultOwnerDO = new VehicleCheckResultOwnerDO(savedVehicleChkRslt, vehicleOwner.getTrnNo(), vehicleOwner.getTrnBranch(), vehicleOwner.getFirstName(), null, vehicleOwner.getLastName(), null, null, null, null, audit); } listOfvehicleChkOwners.add(vehicleCheckResultOwnerDO); if (!isQuickQuery) { daoFactory.getRoadCompliancyDAO().save(vehicleCheckResultOwnerDO); } } } if (!isQuickQuery) { //save current owner information and link to the vehicle. this will be used as the most recent user and placed on warning notice saveCurrentOwners(listOfvehicleChkOwners, vehicleID, mvCheckRequest.getCurrentUserName()); } //3.Save Insurance Information VehInsurance mvInsuranceDetails = mvDetails.getVehInsurance(); VehicleInsuranceDO vehicleInsDO = null; if (mvInsuranceDetails != null) { vehicleInsDO = new VehicleInsuranceDO(savedVehicleChkRslt, mvInsuranceDetails.getPolicyNo(), mvInsuranceDetails.getCompName(), DateUtils.stringToDate(mvInsuranceDetails.getIssueDate()), DateUtils.stringToDate(mvInsuranceDetails.getExpDate()), audit); if (!isQuickQuery) { daoFactory.getRoadCompliancyDAO().save(vehicleInsDO); } } //4.Save Fitness Information VehFitness mvFitnessDetails = mvDetails.getVehFitness(); VehicleFitnessDO vehicleFitnessDO = null; if (mvFitnessDetails != null) { vehicleFitnessDO = new VehicleFitnessDO(savedVehicleChkRslt, mvFitnessDetails.getFitnessNo(), mvFitnessDetails.getExamDepot(), DateUtils.stringToDate(mvFitnessDetails.getIssueDate()), DateUtils.stringToDate(mvFitnessDetails.getExpDate()), audit); if (!isQuickQuery) { daoFactory.getRoadCompliancyDAO().save(vehicleFitnessDO); } } //do event audit doMVCheckEventAudit(isQuickQuery, mvCheckRequest, complianceDO, audit); VehicleCheckResultBO mvCheckResult = null; //Return Results to User if (!isQuickQuery) { mvCheckResult = convertVehChckRsltDOtoBO(mvCheckResultDO); } else { mvCheckResult = convertVehChckRsltDOtoBO(mvCheckResultDO, vehicleFitnessDO, vehicleInsDO, listOfvehicleChkOwners); } mvCheckResult.setTypeCode(mvDetails.getVehInfo().getPlateTypeCode()); return mvCheckResult; }