List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetSubjectsIdListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setSubjectsIdUI.getValues(); Vector<String> samples = this.setSubjectsIdUI.getSamples(); for (String v : values) { if (v.compareTo("") == 0) { this.setSubjectsIdUI.displayMessage("All identifiers have to be set"); return; }/*ww w . j a v a2s . c o m*/ } File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { for (int i = 0; i < samples.size(); i++) { out.write(this.dataType.getStudy().toString() + "\t" + "\t" + values.elementAt(i) + "\t" + samples.elementAt(i) + "\t" + "\t" + "\t" + "\t" + "\t" + "\n"); } } else { try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String subject; if (samples.contains(sample)) { subject = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + subject + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setSubjectsIdUI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setSubjectsIdUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSubjectsIdUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.RequestHandler.java
@Override public final void run() { JSONObject o;// w w w . j ava 2s . co m try (Connection conn = ds.getConnection()) { //System.out.println("Handler method being called!"); checkAuthentication(); o = handle(conn, stmts, req, dispatcher.getClient()); //System.out.println("Handler method returned."); o.put("status", "OK"); } catch (Exception e) { e.printStackTrace(System.err); o = new JSONObject(); o.put("status", "ERROR"); o.put("status_msg", e.getLocalizedMessage()); } o.put("response_to", getResponseID()); //System.out.println("Queueing the response from handler."); dispatcher.queueResponse(o); }
From source file:com.primeleaf.krystal.web.action.console.UpdateProfilePictureAction.java
@SuppressWarnings("rawtypes") public WebView execute(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding(HTTPConstants.CHARACTER_ENCODING); HttpSession session = request.getSession(); User loggedInUser = (User) session.getAttribute(HTTPConstants.SESSION_KRYSTAL); if (request.getMethod().equalsIgnoreCase("POST")) { try {/* w w w. j a v a 2 s .com*/ String userName = loggedInUser.getUserName(); String sessionid = (String) session.getId(); String tempFilePath = System.getProperty("java.io.tmpdir"); if (!(tempFilePath.endsWith("/") || tempFilePath.endsWith("\\"))) { tempFilePath += System.getProperty("file.separator"); } tempFilePath += userName + "_" + sessionid; //variables String fileName = "", ext = ""; File file = null; // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); request.setCharacterEncoding(HTTPConstants.CHARACTER_ENCODING); upload.setHeaderEncoding(HTTPConstants.CHARACTER_ENCODING); List listItems = upload.parseRequest((HttpServletRequest) request); Iterator iter = listItems.iterator(); FileItem fileItem = null; while (iter.hasNext()) { fileItem = (FileItem) iter.next(); if (!fileItem.isFormField()) { try { fileName = fileItem.getName(); file = new File(fileName); fileName = file.getName(); ext = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase(); if (!"JPEG".equalsIgnoreCase(ext) && !"JPG".equalsIgnoreCase(ext) && !"PNG".equalsIgnoreCase(ext)) { request.setAttribute(HTTPConstants.REQUEST_ERROR, "Invalid image. Please upload JPG or PNG file"); return (new MyProfileAction().execute(request, response)); } file = new File(tempFilePath + "." + ext); fileItem.write(file); } catch (Exception ex) { session.setAttribute("UPLOAD_ERROR", ex.getLocalizedMessage()); return (new MyProfileAction().execute(request, response)); } } } //if if (file.length() <= 0) { //code for checking minimum size of file request.setAttribute(HTTPConstants.REQUEST_ERROR, "Zero length document"); return (new MyProfileAction().execute(request, response)); } if (file.length() > (1024 * 1024 * 2)) { //code for checking minimum size of file request.setAttribute(HTTPConstants.REQUEST_ERROR, "Image size too large. Upload upto 2MB file"); return (new MyProfileAction().execute(request, response)); } User user = loggedInUser; user.setProfilePicture(file); UserDAO.getInstance().setProfilePicture(user); AuditLogManager.log(new AuditLogRecord(user.getUserId(), AuditLogRecord.OBJECT_USER, AuditLogRecord.ACTION_EDITED, loggedInUser.getUserName(), request.getRemoteAddr(), AuditLogRecord.LEVEL_INFO, "", "Profile picture update")); } catch (Exception e) { e.printStackTrace(System.out); } } request.setAttribute(HTTPConstants.REQUEST_MESSAGE, "Profile picture uploaded successfully"); return (new MyProfileAction().execute(request, response)); }
From source file:uk.ac.ebi.emma.controller.MutationManagementListController.java
/** * Deletes the mutations identified by <b>id</b>. This method is configured as * a GET because it is intended to be called as an ajax call. Using GET * avoids re-posting problems with the back button. NOTE: It is the caller's * responsibility to insure there are no foreign key constraints. * //from w ww . ja v a2 s . c o m * @param mutation_key primary key of the mutation to be deleted * @return a JSON string containing 'status' [ok or fail], and a message [ * empty string if status is ok; error message otherwise] */ @RequestMapping(value = "/deleteMutation", method = RequestMethod.GET) @ResponseBody public ResponseEntity<String> deleteMutation(@RequestParam int mutation_key) { String status, message; try { mutationsManager.delete(mutation_key); status = "ok"; message = ""; } catch (Exception e) { status = "fail"; message = e.getLocalizedMessage(); } JSONObject returnStatus = new JSONObject(); returnStatus.put("status", status); returnStatus.put("message", message); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=utf-8"); return new ResponseEntity(returnStatus.toJSONString(), headers, HttpStatus.OK); }
From source file:com.github.richardwilly98.esdms.services.ParameterProvider.java
@Override public Object getParameterValue(String name) throws ServiceException { checkNotNull(name);//from www . ja va 2 s . c om if (name.contains(".")) { String id = name.substring(0, name.indexOf(".")); String propertyName = name.substring(name.indexOf(".") + 1); Parameter parameter = super.get(id); try { return PropertyUtils.getProperty(parameter, propertyName); } catch (Exception ex) { log.error(String.format("getParameterValue %s failed", name), ex); throw new ServiceException(ex.getLocalizedMessage()); } } else return super.get(name); }
From source file:com.wonders.bud.freshmommy.web.user.controller.UserController.java
/** * <p>/* www .j ava2 s . c om*/ * Description:[?id?] * </p> * * Created by linqin [2014-11-20] * Midified by [] [] * @param request * @return */ @RequestMapping(value = "/user", method = RequestMethod.GET) @ResponseBody public RestMsg<UserVO> findUserById(HttpServletRequest request) { RestMsg<UserVO> rm = new RestMsg<UserVO>(); String uId = request.getParameter("uId"); try { if (StringUtils.isBlank(uId)) { rm.errorMsg("??"); return rm; } UserPO po = userService.findUserById(Integer.valueOf(uId)); UserVO vo = new UserVO(); BeanUtils.copyProperties(vo, po); rm.setResult(vo); rm.successMsg(); } catch (Exception e) { rm.errorMsg("??"); log.error(e.getLocalizedMessage()); } return rm; }
From source file:uk.ac.ebi.emma.controller.GeneManagementListController.java
/** * Deletes the gene identified by <b>id</b>. This method is configured as * a GET because it is intended to be called as an ajax call. Using GET * avoids re-posting problems with the back button. NOTE: It is the caller's * responsibility to insure there are no foreign key constraints. * /*from ww w . j av a 2 s. c o m*/ * @param gene_key primary key of the gene to be deleted * @return a JSON string containing 'status' [ok or fail], and a message [ * empty string if status is ok; error message otherwise] */ @RequestMapping(value = "/deleteGene", method = RequestMethod.GET) @ResponseBody public ResponseEntity<String> deleteGene(@RequestParam int gene_key) { String status, message; try { genesManager.delete(gene_key); status = "ok"; message = ""; } catch (Exception e) { status = "fail"; message = e.getLocalizedMessage(); } JSONObject returnStatus = new JSONObject(); returnStatus.put("status", status); returnStatus.put("message", message); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=utf-8"); return new ResponseEntity(returnStatus.toJSONString(), headers, HttpStatus.OK); }
From source file:com.github.richardwilly98.esdms.services.ParameterProvider.java
@Override public Parameter setParameterValue(Parameter parameter, String name, Object value) throws ServiceException { checkNotNull(parameter);//from www . j a v a 2 s. co m checkNotNull(name); try { PropertyUtils.setProperty(parameter, name, value); return update(parameter); } catch (Exception ex) { log.error(String.format("setParameterValue %s - %s failed", parameter, name), ex); throw new ServiceException(ex.getLocalizedMessage()); } }
From source file:com.vmware.demo.EditController.java
@RequestMapping(value = "/edit", method = RequestMethod.POST) public String save(HttpServletRequest request, Locale locale, Model model, Integer id, String name, String horizonUrl, String metaData) { logger.info("Edit save " + name); IdentityProvider idp;/* www . j a va 2 s .c om*/ if (0 == id) { idp = new IdentityProvider(); } else { idp = organizationHandler.load(id); } // Cleanup input before saving metaData = StringUtils.remove(metaData, '\r'); metaData = StringUtils.remove(metaData, '\n'); try { // Initialize the SAML libraries by grabbing an instance of the service SamlService.getInstance(); try { horizonUrl = SamlUtils.validate(metaData); } catch (Exception e) { if (e instanceof SSLHandshakeException) { model.addAttribute(ATTRIBUTE_ERROR_MSG, e.getLocalizedMessage()); } else { throw e; } } if (null != horizonUrl) { idp.setMetaData(metaData); idp.setHorizonUrl(horizonUrl); organizationHandler.save(idp); } } catch (Exception e) { model.addAttribute(ATTRIBUTE_ERROR_MSG, e.getLocalizedMessage()); return "edit"; } model.addAttribute("identityProviders", organizationHandler.getAllIdentityProviders()); model.addAttribute("spMetaDataUsername", ListController.generateMetaData(request, "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified")); model.addAttribute("spMetaDataEmail", ListController.generateMetaData(request, "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")); return "list"; }
From source file:com.orange.mmp.mvc.actions.CertifAction.java
/** * ACTIONS/*from w w w. j a va2 s .c o m*/ */ @SuppressWarnings("unchecked") /* (non-Javadoc) * @see com.opensymphony.xwork2.ActionSupport#execute() */ @Override public String execute() throws Exception { // List certificates try { Vector certs = MidletManager.getInstance().getCertificates(); this.certifList = new ArrayList<X509Certificate>(); if (certs.size() > 0) { for (int i = 0; i < certs.size(); i++) { Object aobj[] = (Object[]) (Object[]) certs.elementAt(i); X509Certificate thisCert = (X509Certificate) aobj[AppDescriptor.CERT]; certifList.add(thisCert); } } } catch (Exception e) { addActionError(getText("error.certif.list", new String[] { e.getLocalizedMessage() })); } return super.execute(); }