List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:fr.sanofi.fcl4transmart.controllers.listeners.snpData.SetTissueListener.java
@Override public void handleEvent(Event event) { Vector<String> values = this.ui.getValues(); Vector<String> samples = this.ui.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File mappingFile = ((SnpData) this.dataType).getMappingFile(); if (mappingFile == null) { this.ui.displayMessage("Error: no subject to sample mapping file"); }//from w w w . ja v a 2 s . c o m try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); try { BufferedReader br = new BufferedReader(new FileReader(mappingFile)); String line; while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String tissueType; if (samples.contains(sample)) { tissueType = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + tissueType + "\t" + fields[6] + "\t" + fields[7] + "\t" + "PLATFORM+TISSUETYPE" + "\n"); } br.close(); } catch (Exception e) { this.ui.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (mappingFile != null) { String fileName = mappingFile.getName(); mappingFile.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); ((SnpData) this.dataType).setMappingFile(fileDest); } catch (IOException ioe) { this.ui.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.ui.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.ui.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.FetchExperiments.java
/** * Method, where all experiments are read from server. * All heavy lifting is made here.// ww w .j ava 2s. c o m * * @param params not used (omitted) here * @return list of fetched experiments */ @Override protected List<Experiment> doInBackground(Void... params) { SharedPreferences credentials = getCredentials(); String username = credentials.getString("username", null); String password = credentials.getString("password", null); String url = credentials.getString("url", null) + Values.SERVICE_EXPERIMENTS; setState(RUNNING, R.string.working_ws_experiments); HttpAuthentication authHeader = new HttpBasicAuthentication(username, password); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAuthorization(authHeader); requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_XML)); HttpEntity<Object> entity = new HttpEntity<Object>(requestHeaders); SSLSimpleClientHttpRequestFactory factory = new SSLSimpleClientHttpRequestFactory(); // Create a new RestTemplate instance RestTemplate restTemplate = new RestTemplate(factory); restTemplate.getMessageConverters().add(new SimpleXmlHttpMessageConverter()); try { //obtain all public records if qualifier is all if (Values.SERVICE_QUALIFIER_ALL.equals(qualifier)) { String countUrl = url + "count"; ResponseEntity<RecordCount> count = restTemplate.exchange(countUrl, HttpMethod.GET, entity, RecordCount.class); url += "public/" + count.getBody().getPublicRecords(); } else url += qualifier; // Make the network request Log.d(TAG, url); ResponseEntity<ExperimentList> response = restTemplate.exchange(url, HttpMethod.GET, entity, ExperimentList.class); ExperimentList body = response.getBody(); if (body != null) { return body.getExperiments(); } } catch (Exception e) { Log.e(TAG, e.getLocalizedMessage(), e); setState(ERROR, e); } finally { setState(DONE); } return Collections.emptyList(); }
From source file:com.difference.historybook.proxy.ProxyTest.java
@Test public void testSelector() { String body = "<html><head></head><body>Hello World!</body></html>"; stubFor(get(urlEqualTo("/some/page")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/html").withBody(body))); stubFor(get(urlEqualTo("/some/other/page")) .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "text/html").withBody(body))); Proxy proxy = getProxy().setPort(PROXY_PORT); ProxyFilter filter = mock(ProxyFilter.class); ProxyFilterFactory factory = mock(ProxyFilterFactory.class); when(factory.getInstance()).thenReturn(filter); proxy.setFilterFactory(factory);//from w w w. j av a2 s .c o m proxy.setResponseFilterSelector(t -> { return t.getStatus() == 200; }); try { proxy.start(); java.net.Proxy proxyServer = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", PROXY_PORT)); HttpURLConnection connection = (HttpURLConnection) new URL( "http://localhost:" + DUMMY_SERVER_PORT + "/some/page").openConnection(proxyServer); byte[] fetchedContent = IOUtils.toByteArray(connection.getInputStream()); assertArrayEquals(body.getBytes(Charsets.UTF_8), fetchedContent); verify(filter).processRequest(any()); verify(filter).processResponse(any()); verifyNoMoreInteractions(filter); connection = (HttpURLConnection) new URL("http://localhost:" + DUMMY_SERVER_PORT + "/some/other/page") .openConnection(proxyServer); fetchedContent = IOUtils.toByteArray(connection.getInputStream()); assertArrayEquals(body.getBytes(Charsets.UTF_8), fetchedContent); verify(filter, times(2)).processRequest(any()); verifyNoMoreInteractions(filter); proxy.stop(); } catch (Exception e) { fail(e.getLocalizedMessage()); } }
From source file:com.engineering.ses.spell.clientstubj.cmdclient.CommandClient.java
/*************************************************************************** * Interactive loop /*from w w w.java2 s. c o m*/ * @throws Exception **************************************************************************/ private void interactiveLoop() throws Exception { m_stdin = new BufferedReader(new InputStreamReader(System.in)); System.out.println(); while (true) { System.out.print("> "); try { String command = m_stdin.readLine(); if (command == null || command.trim().isEmpty()) continue; m_cmdProcessor.processCommand(command); System.out.println(); } catch (Exception ex) { if (ex.getLocalizedMessage().equals("exit")) break; System.err.println("ERROR: " + ex.getLocalizedMessage()); } } }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetSiteIdListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setSiteIdUI.getValues(); Vector<String> samples = this.setSiteIdUI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setSiteIdUI.displayMessage("Error: no subject to sample mapping file"); }//from w w w. jav a 2 s . com 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"); 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 site; if (samples.contains(sample)) { site = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + site + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setSiteIdUI.displayMessage("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.setSiteIdUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setSiteIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSiteIdUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:es.urjc.mctwp.bbeans.AbstractBean.java
/** * It runs a command safely and catching all error info. If commands fail, * it will redirect action to error page. * /*from w ww . ja v a2 s. c o m*/ * @param cmd * @return */ protected Command runCommand(Command cmd) { Command result = cmd; try { result = service.runCommand(cmd); if (result.getUserComment() != null) { setInfoMessage(result.getUserComment()); } } catch (Exception ce) { setErrorMessage(ce.getLocalizedMessage()); result = null; } return result; }
From source file:org.ameba.aop.IntegrationLayerAspect.java
/** * Called after an exception is thrown by classes of the integration layer. <p> Set log level to ERROR to log the root cause. </p> * * @param ex The root exception that is thrown * @return Returns the exception to be thrown */// ww w . ja v a2 s. com public Exception translateException(Exception ex) { if (EXC_LOGGER.isErrorEnabled()) { EXC_LOGGER.error(ex.getLocalizedMessage(), ex); } if (ex instanceof BusinessRuntimeException) { return ex; } Optional<Exception> handledException = doTranslateException(ex); if (handledException.isPresent()) { return handledException.get(); } if (ex instanceof DuplicateKeyException) { return new ResourceExistsException(); } if (ex instanceof IntegrationLayerException) { return ex; } return withRootCause ? new IntegrationLayerException(ex.getMessage(), ex) : new IntegrationLayerException(ex.getMessage()); }
From source file:com.yosanai.java.aws.console.AWSConsole.java
private void btnAccessActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnAccessActionPerformed if (null == config) { showConfig(false);/*from w w w . j a v a2 s.c o m*/ } if (StringUtils.isBlank(config.getString(AWSConnectionProvider.AWS_KEY))) { showConfig(true); } try { awsConnectionProvider.updateEC2Config(true, config); } catch (Exception e) { JOptionPane.showMessageDialog(this, "" + e.getLocalizedMessage(), "Failed to initialize connection to AWS", JOptionPane.ERROR_MESSAGE); } if (null == console && null != awsConnectionProvider.getConnection()) { console = new MainAWSPanel(); console.setParentFrame(this); console.setAwsConnectionProvider(awsConnectionProvider); getContentPane().add(console, BorderLayout.CENTER); invalidate(); validate(); console.init(); } }
From source file:com.wonders.bud.freshmommy.web.user.controller.BabyController.java
/** * <p>/*from w w w. j av a2s. co m*/ * Description:[?id??] * </p> * * Created by linqin [2014-11-20] * Midified by [] [] * @param request * @return */ @RequestMapping(value = "/babyList", method = RequestMethod.GET) @ResponseBody public RestMsg<List<BabyVO>> findBabiesByList(HttpServletRequest request) { RestMsg<List<BabyVO>> rm = new RestMsg<List<BabyVO>>(); String uId = request.getParameter("uId"); try { if (StringUtils.isBlank(uId)) { rm.errorMsg("?id"); return rm; } Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("uId", Integer.valueOf(uId)); List<BabyPO> list = new ArrayList<BabyPO>(); list = babyService.findBabiesByList(paramMap); List<BabyVO> babyList = new ArrayList<BabyVO>(); if (null != list && list.size() > 0) { for (BabyPO baby : list) { BabyVO vo = new BabyVO(); BeanUtils.copyProperties(vo, baby); babyList.add(vo); } } rm.setResult(babyList); rm.successMsg(); } catch (Exception e) { rm.errorMsg(e.getLocalizedMessage()); log.error(e.getLocalizedMessage()); } return rm; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute1Listener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setAttribute1UI.getValues(); Vector<String> samples = this.setAttribute1UI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setAttribute1UI.displayMessage("Error: no subject to sample mapping file"); }//from w ww . j av a2s .co m 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"); 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 attribute; if (samples.contains(sample)) { attribute = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + attribute + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { setAttribute1UI.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.setAttribute1UI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setAttribute1UI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setAttribute1UI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }