List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetTissueTypeListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setTissueTypeUI.getValues(); Vector<String> samples = this.setTissueTypeUI.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.setTissueTypeUI.displayMessage("Error: no subject to sample mapping file"); }/*from w w w. j a v a 2 s. c o 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 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" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setTissueTypeUI.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.setTissueTypeUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setTissueTypeUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setTissueTypeUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:org.kitodo.sruimport.SRUImport.java
private SearchResult performQuery(String queryURL) { try {/*from w ww. j av a2s .c o m*/ HttpResponse response = sruClient.execute(new HttpGet(queryURL)); if (Objects.equals(response.getStatusLine().getStatusCode(), SC_OK)) { return ResponseHandler.getSearchResult(response); } } catch (IOException e) { logger.error(e.getLocalizedMessage()); } return new SearchResult(); }
From source file:net.osten.watermap.convert.SanMateoWildernessReport.java
/** * Returns water reports from text file. * Text file format: name, description, state, last report, reported by, lat, lon. * * @return set of water reports/*from w ww .j a va2s .c o m*/ */ public Set<WaterReport> convert() { Set<WaterReport> results = new HashSet<WaterReport>(); int lineNumber = 1; try { log.info("opening filePath=" + filePath); ImmutableList<String> lines = filePath != null ? Files.asCharSource(new File(filePath), Charsets.UTF_8).readLines() : Resources.asCharSource(fileURL, Charsets.UTF_8).readLines(); log.fine("found " + lines.size() + " lines"); for (String line : lines) { // find start of data line section WaterReport wr = null; log.fine("parsing line[" + lineNumber + "]=" + line); wr = parseDataLine(line); if (wr != null && wr.getName() != null) { log.fine("adding wr=" + wr); boolean added = results.add(wr); if (!added) { results.remove(wr); results.add(wr); } } else { log.finer("did not add wr for line " + lineNumber); } lineNumber++; } } catch (IOException e) { log.severe(e.getLocalizedMessage()); } return results; }
From source file:org.sonews.daemon.sync.SynchronousNNTPDaemon.java
@Override public void shutdownNow() { if (this.serverSocket != null) { try {//from w w w.j av a2 s . c om this.serverSocket.close(); } catch (IOException ex) { Log.get().log(Level.WARNING, ex.getLocalizedMessage(), ex); } } }
From source file:com.ning.metrics.goodwill.access.GoodwillAccessor.java
protected final void closeStream(final InputStream in) { if (in != null) { try {//from w ww . j a v a 2s.co m in.close(); } catch (IOException e) { log.warn("Failed to close http-client - provided InputStream: {}", e.getLocalizedMessage()); } } }
From source file:com.kylinolap.job.flow.JobFlowNode.java
protected JobInstance updateJobStep(String jobInstanceUuid, int jobInstanceStepSeqId, KylinConfig config, JobStepStatusEnum newStatus, Long execStartTime, Long execEndTime, String output) throws IOException { // set step status to running JobInstance jobInstance = JobDAO.getInstance(config).getJob(jobInstanceUuid); JobStep currentStep = null;// w ww . j ava 2 s . co m try { currentStep = jobInstance.getSteps().get(jobInstanceStepSeqId); JobStepStatusEnum currentStatus = currentStep.getStatus(); boolean hasChange = false; if (null != execStartTime) { hasChange = true; currentStep.setExecStartTime(execStartTime); } if (null != execEndTime) { hasChange = true; currentStep.setExecEndTime(execEndTime); } if (null != output) { hasChange = true; // currentStep.setCmdOutput(output); JobDAO.getInstance(config).saveJobOutput(currentStep, output); } if (JobStepStatusEnum.WAITING == currentStatus && (JobStepStatusEnum.RUNNING == newStatus || JobStepStatusEnum.FINISHED == newStatus)) { hasChange = true; currentStep.setExecWaitTime((System.currentTimeMillis() - currentStep.getExecStartTime()) / 1000); } if (null != newStatus) { hasChange = true; currentStep.setStatus(newStatus); } if (hasChange) { JobDAO.getInstance(config).updateJobInstance(jobInstance); } } catch (IOException e) { log.error(e.getLocalizedMessage(), e); } if (null != execEndTime) { JobEngine.JOB_DURATION.put( JobInstance.getStepIdentity(jobInstance, currentStep) + " - " + String.valueOf(currentStep.getExecStartTime()), (double) (currentStep.getExecEndTime() - currentStep.getExecStartTime()) / 1000); } return jobInstance; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectOtherIdentifiersListener.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 {//from w w w.ja va 2 s . co m 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(); Vector<String> siteIds = this.setOtherIdsUI.getSiteIds(); Vector<String> visitNames = this.setOtherIdsUI.getVisitNames(); for (int i = 0; i < rawFiles.size(); i++) { //site identifier if (siteIds.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), siteIds.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSITE_ID\t\t\n"); } } //visit name if (visitNames.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), visitNames.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tVISIT_NAME\t\t\n"); } } } 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("SITE_ID") != 0 && s[3].compareTo("VISIT_NAME") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setOtherIdsUI.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.setOtherIdsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setOtherIdsUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:org.openbaton.vnfm.generic.utils.LogDispatcher.java
@Override public String sendLogs(String request) { String vnfrName = this.gson.fromJson(request, JsonObject.class).get("vnfrName").getAsString(); String hostname = this.gson.fromJson(request, JsonObject.class).get("hostname").getAsString(); Map<String, List<String>> logs = new HashMap<>(); try {// ww w.j ava2s . c om logs.put("output", readFile(this.logPath + vnfrName + '/' + hostname + ".log", Charset.defaultCharset())); logs.put("error", readFile(this.logPath + vnfrName + '/' + hostname + "-error.log", Charset.defaultCharset())); } catch (IOException exception) { exception.printStackTrace(); this.log.error("Unable to retrieve logs: " + exception.getLocalizedMessage()); return "{ \"answer\": \"" + "Unable to retrieve logs: " + exception.getLocalizedMessage() + "\"}"; } return "{ \"answer\": " + this.gson.toJson(logs) + '}'; }
From source file:org.kitodo.sruimport.SRUImport.java
private Document performQueryToDocument(String queryURL) { try {/*from www . j a va 2 s . co m*/ HttpResponse response = sruClient.execute(new HttpGet(queryURL)); if (Objects.equals(response.getStatusLine().getStatusCode(), SC_OK)) { return ResponseHandler.transformResponseToDocument(response); } throw new ConfigException("SRU Request Failed"); } catch (IOException e) { throw new ConfigException(e.getLocalizedMessage()); } }
From source file:com.norconex.jefmon.instance.action.impl.LogViewerActionPanel.java
private Component createLogLines() { String text;/*from w w w. j a v a 2 s . c o m*/ try { text = StringUtils.join(getLinesReader().readLines(), "\n"); } catch (IOException e) { text = "Could not read log. Error is: " + e.getLocalizedMessage(); } Label lines = new Label("logLines", text); return lines; }