List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:br.com.mv.modulo.utils.ModuloEmailSender.java
public void sendException(Exception exception) { StringBuilder str = new StringBuilder(); str.append("Erro: " + exception.toString() + System.lineSeparator()); str.append("Mensagem: " + exception.getLocalizedMessage() + System.lineSeparator()); str.append("Stack: " + System.lineSeparator()); for (StackTraceElement element : exception.getStackTrace()) { str.append(element.toString() + System.lineSeparator()); }//from ww w .ja v a2s .c o m sendEmail(str.toString()); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetLabelsOntologyListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> headers = this.setLabelsOntologyUI.getHeaders(); Vector<String> newLabels = this.setLabelsOntologyUI.getNewLabels(); Vector<String> codes = this.setLabelsOntologyUI.getCodes(); if (((ClinicalData) this.dataType).getCMF() == null) { this.setLabelsOntologyUI.displayMessage("Error: no column mapping file"); return;//w w w.ja v a 2 s . c om } File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n"); try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { if (line.split("\t", -1)[3].compareTo("SUBJ_ID") == 0 || line.split("\t", -1)[3].compareTo("VISIT_NAME") == 0 || line.split("\t", -1)[3].compareTo("SITE_ID") == 0 || line.split("\t", -1)[3].compareTo("\\") == 0 || line.split("\t", -1)[3].compareTo("DATA_LABEL") == 0 || line.split("\t", -1)[3].compareTo("OMIT") == 0) { out.write(line + "\n"); } else { File rawFile = new File(this.dataType.getPath() + File.separator + line.split("\t", -1)[0]); String header = FileHandler.getColumnByNumber(rawFile, Integer.parseInt(line.split("\t", -1)[2])); String newLabel = newLabels.elementAt(headers.indexOf(rawFile.getName() + " - " + header)); if (newLabel.compareTo("") == 0) { newLabel = header; } out.write(line.split("\t", -1)[0] + "\t" + line.split("\t", -1)[1] + "\t" + line.split("\t", -1)[2] + "\t" + newLabel + "\t\t" + codes.elementAt(headers.indexOf(rawFile.getName() + " - " + header)) + "\n"); } } br.close(); } catch (Exception e) { this.setLabelsOntologyUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } out.close(); String fileName = ((ClinicalData) this.dataType).getCMF().getName(); FileUtils.deleteQuietly(((ClinicalData) this.dataType).getCMF()); try { File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (Exception ioe) { this.setLabelsOntologyUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setLabelsOntologyUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setLabelsOntologyUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:uk.ac.ebi.emma.controller.BackgroundManagementListController.java
/** * Deletes the background 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 a 2s. c om*/ * @param background_key primary key of the background 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 = "/deleteBackground", method = RequestMethod.GET) @ResponseBody public ResponseEntity<String> deleteBackground(@RequestParam int background_key) { String status, message; try { backgroundManager.delete(background_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.sastix.cms.common.services.web.ExceptionHandlingController.java
@ExceptionHandler({ CommonException.class }) public void handleBadRequests(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException { LOG.error("Bad request: {} from {}, Exception: {} {}", request.getRequestURI(), request.getRemoteHost(), e.getStackTrace()[0].toString(), e.getLocalizedMessage()); response.sendError(HttpStatus.BAD_REQUEST.value(), e.getLocalizedMessage()); }
From source file:com.kylinolap.rest.controller.ProjectController.java
@RequestMapping(value = "", method = { RequestMethod.POST }) @ResponseBody// ww w. java 2 s .c om @Metered(name = "saveProject") public ProjectInstance saveProject(@RequestBody CreateProjectRequest projectRequest) { if (StringUtils.isEmpty(projectRequest.getName())) { throw new InternalErrorException("A project name must be given to create a project"); } ProjectInstance createdProj = null; try { createdProj = projectService.createProject(projectRequest); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage()); } return createdProj; }
From source file:com.kylinolap.rest.controller.ProjectController.java
@RequestMapping(value = "", method = { RequestMethod.PUT }) @ResponseBody/*from w w w. ja v a2s. com*/ @Metered(name = "updateProject") public ProjectInstance updateProject(@RequestBody UpdateProjectRequest projectRequest) { if (StringUtils.isEmpty(projectRequest.getFormerProjectName())) { throw new InternalErrorException("A project name must be given to update a project"); } ProjectInstance updatedProj = null; try { updatedProj = projectService.updateProject(projectRequest); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage()); } return updatedProj; }
From source file:com.worklight.ibmmobilefirstplatformfoundationliveupdate.LiveUpdatePlugin.java
/** * @param action the action to execute. currently only "getConfiguration" is supported * @param args JSON Array of arguments for the plugin. The JSON can contains three elements: segmentId, useClientCache and params. * For example : {"params": { "a": 2, "c": true} , "useClientCache": true } , or {"segmentId": "vip" , "useClientCache": true } * In normal flow only one of the two will be used: either 'segmentId' or 'params'. * If , accidentally user supplies both, the method will ignore the params. * @param callbackContext the callbackContext used when calling back into JavaScript. * @return A PluginResult object with a status and message along with boolean success result. *///from ww w . j a v a 2 s .com public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { LOG.d("execute", "entering with action:" + action); try { if (ACTION_GET_CONFIG.equals(action)) { final String firstParam = args.getString(0); // if the user sent non-JSON object , the parser will throw an exception JSONObject actionParams = new JSONObject(firstParam); LOG.d("execute", "json parameters are:" + actionParams.toString()); String segmentId = actionParams.optString(SEG_PARAM_KEY, null); final Boolean useClientCache = actionParams.optBoolean(CACHE_PARAM_KEY, true); // cache will be enabled by default final JSONObject params = actionParams.optJSONObject(PARAMETERS_PARAM_KEY); if (segmentId != null) { segmentId = java.net.URLEncoder.encode(segmentId, "UTF-8"); // If the user supplied segment ID, we'll use it and ignore the params. getBySegmentId(callbackContext, segmentId, useClientCache); } else { LOG.d("execute", "trying to find configuration from:" + params); // if user supplied params, use it. getByMap(callbackContext, params, useClientCache); } } else { LOG.d("execute", "unsupported action " + action + " for this plugin"); PluginResult pluginResult = new PluginResult(PluginResult.Status.INVALID_ACTION, action); callbackContext.sendPluginResult(pluginResult); } return true; } catch (Exception e) { String errorMsg = e.getLocalizedMessage(); if (e.getMessage().startsWith("End of input")) { // the JSON exception message for empty string is not helpful so we'll replace it: errorMsg = "Invalid JSON format for first parameter"; } LOG.d("exception:", e.getLocalizedMessage()); callbackContext.error(errorMsg); return false; } }
From source file:it.geosolutions.geobatch.annotations.GenericActionService.java
/** * Istantiate an action class from the Class type and the ActionConfig provided. * <p/>/* ww w .j a va 2s. c o m*/ * Once the class is instantiated: <ol> * <li>{@code @autowire} fields are autowired</li> * <li>{@code afterPropertiesSet()} is called if {@code InitializingBean} is declared</li> * </ol> * @param actionClass * @param actionConfig * @return */ public <T extends BaseAction<? extends EventObject>> T createAction(Class<T> actionClass, ActionConfiguration actionConfig) { try { LOGGER.info("Instantiating action " + actionClass.getSimpleName()); Constructor<T> constructor = actionClass.getConstructor(actionConfig.getClass()); T newInstance = constructor.newInstance(actionConfig); ((AbstractRefreshableApplicationContext) applicationContext).getBeanFactory().autowireBean(newInstance); if (InitializingBean.class.isAssignableFrom(actionClass)) { ((InitializingBean) newInstance).afterPropertiesSet(); } return newInstance; } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getLocalizedMessage(), e); } throw new IllegalStateException("A fatal error occurred while instantiate the action class " + actionClass.getSimpleName() + ": " + e.getLocalizedMessage()); } }
From source file:com.ugam.collage.plus.controller.people_count.TrackUpdatesController.java
@RequestMapping(value = "/updateReportingsTrackDetails", method = RequestMethod.POST, headers = "Accept=application/json") public @ResponseBody Map<String, Object> updateReportingsTrackDetails(HttpServletRequest httpServletRequest, @RequestBody ReportTrackVo reportTractdetail, Model model) { Map<String, Object> returnData = new HashMap<>(); try {//from w ww. j a v a 2s. c o m trackUpdatesService.updateReportingsTrackDetails(reportTractdetail); returnData.put("success", "true"); returnData.put("message", "Saved Successfully"); } catch (Exception e) { returnData.put("success", "false"); returnData.put("message", "Error in Adding Data from UI - " + e.getLocalizedMessage()); logger.error("Error Adding Data from UI", e); } return returnData; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectIdentifiersListener.java
@Override public void handleEvent(Event event) { //write in a new file File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try {/*www.jav a 2s. c o m*/ Vector<String> subjectIds = this.setSubjectsIdUI.getSubjectIds(); for (String s : subjectIds) { if (s.compareTo("") == 0) { this.setSubjectsIdUI.displayMessage("Subjects identifier columns have to be choosen"); return; } } FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n"); //subject identifier Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles(); for (int i = 0; i < rawFiles.size(); i++) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), subjectIds.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSUBJ_ID\t\t\n"); } } if (((ClinicalData) this.dataType).getCMF() == null) { out.close(); File fileDest = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns"); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); WorkPart.updateSteps(); } else { try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] s = line.split("\t", -1); if (s[3].compareTo("SUBJ_ID") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } out.close(); try { String fileName = ((ClinicalData) this.dataType).getCMF().getName(); ((ClinicalData) this.dataType).getCMF().delete(); File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (IOException ioe) { this.setSubjectsIdUI.displayMessage("File errorrror: " + ioe.getLocalizedMessage()); return; } } } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSubjectsIdUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }