List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:it.geosolutions.geoserver.jms.impl.handlers.catalog.JMSCatalogRemoveEventHandler.java
private static void remove(final Catalog catalog, CatalogInfo info, Properties options) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (info instanceof LayerGroupInfo) { final LayerGroupInfo deserObject = CatalogUtils.localizeLayerGroup((LayerGroupInfo) info, catalog); catalog.remove(deserObject);// w ww .ja v a 2 s . c o m // catalog.save(CatalogUtils.getProxy(deserObject)); // info=CatalogUtils.localizeLayerGroup((LayerGroupInfo) info, // catalog); } else if (info instanceof LayerInfo) { final LayerInfo layer = CatalogUtils.localizeLayer((LayerInfo) info, catalog); catalog.remove(layer); // catalog.save(CatalogUtils.getProxy(layer)); // info=CatalogUtils.localizeLayer((LayerInfo) info, catalog); } else if (info instanceof MapInfo) { final MapInfo localObject = CatalogUtils.localizeMapInfo((MapInfo) info, catalog); catalog.remove(localObject); // catalog.save(CatalogUtils.getProxy(localObject)); // info= CatalogUtils.localizeMapInfo((MapInfo) info,catalog); } else if (info instanceof NamespaceInfo) { final NamespaceInfo namespace = CatalogUtils.localizeNamespace((NamespaceInfo) info, catalog); catalog.remove(namespace); // catalog.save(CatalogUtils.getProxy(namespace)); // info =CatalogUtils.localizeNamespace((NamespaceInfo) info, // catalog); } else if (info instanceof StoreInfo) { StoreInfo store = CatalogUtils.localizeStore((StoreInfo) info, catalog); catalog.remove(store); // catalog.save(CatalogUtils.getProxy(store)); // info=CatalogUtils.localizeStore((StoreInfo)info,catalog); } else if (info instanceof ResourceInfo) { final ResourceInfo resource = CatalogUtils.localizeResource((ResourceInfo) info, catalog); catalog.remove(resource); // catalog.save(CatalogUtils.getProxy(resource)); // info =CatalogUtils.localizeResource((ResourceInfo)info,catalog); } else if (info instanceof StyleInfo) { final StyleInfo style = CatalogUtils.localizeStyle((StyleInfo) info, catalog); catalog.remove(style); // check options final String purge = (String) options.get("purge"); if (purge != null && Boolean.parseBoolean(purge)) { try { catalog.getResourcePool().deleteStyle(style, true); } catch (IOException e) { if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) { LOGGER.severe(e.getLocalizedMessage()); } } } // catalog.detach(CatalogUtils.getProxy(deserializedObject)); // info = CatalogUtils.localizeStyle((StyleInfo) info, catalog); } else if (info instanceof WorkspaceInfo) { final WorkspaceInfo workspace = CatalogUtils.localizeWorkspace((WorkspaceInfo) info, catalog); catalog.remove(workspace); // catalog.detach(workspace); // info = CatalogUtils.localizeWorkspace((WorkspaceInfo) info, // catalog); } else if (info instanceof CatalogInfo) { // TODO may we don't want to send this empty message! // TODO check the producer // DO NOTHING if (LOGGER.isLoggable(java.util.logging.Level.WARNING)) { LOGGER.warning("info - ID: " + info.getId() + " toString: " + info.toString()); } } else { throw new IllegalArgumentException("Bad incoming object: " + info.toString()); } }
From source file:jmupen.JMupenUpdater.java
public static void startWinUpdaterApplication() { final String javaBin; javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java.exe"; File updaterJar = new File(tmpDir.getAbsolutePath() + File.separator + "bin" + File.separator + "win" + File.separator + "JMupenWinupdater.jar"); File currentJarPathTxt = new File( tmpDir.getAbsolutePath() + File.separator + "bin" + File.separator + "currentjar.txt"); try {//from w w w . ja v a2s . c o m FileUtils.writeStringToFile(currentJarPathTxt, getJarFile().getAbsolutePath()); } catch (IOException e) { System.err.println("Error writing jar filepath " + e.getLocalizedMessage()); JMupenGUI.getInstance().showError("Error writing jar filepath to txt", e.getLocalizedMessage()); } catch (URISyntaxException ex) { System.err.println("Error writing jar filepath " + ex.getLocalizedMessage()); } if (!updaterJar.exists()) { JMupenGUI.getInstance().showError("WinUpdater not found", "in folder: " + updaterJar.getAbsolutePath()); return; } /* is it a jar file? */ if (!updaterJar.getName().endsWith(".jar")) { JMupenGUI.getInstance().showError("WinUpdater does not end with .jar????", updaterJar.getAbsolutePath()); return; } /* Build command: java -jar application.jar */ final ArrayList<String> command = new ArrayList<String>(); command.add(javaBin); command.add("-jar"); command.add(updaterJar.getPath()); final ProcessBuilder builder = new ProcessBuilder(command); try { builder.start(); } catch (IOException ex) { System.err.println("Error starting updater. " + ex.getLocalizedMessage()); JMupenGUI.getInstance().showError("Error starting updater", ex.getLocalizedMessage()); } System.gc(); System.exit(0); }
From source file:org.zenoss.zep.dao.impl.ConfigDaoImpl.java
private static String valueToString(FieldDescriptor field, Object value) throws ZepException { if (field.isRepeated()) { throw new ZepException("Repeated field not supported"); }// www. j a v a 2 s . c om switch (field.getJavaType()) { case BOOLEAN: return Boolean.toString((Boolean) value); case BYTE_STRING: return new String(Base64.encodeBase64(((ByteString) value).toByteArray()), Charset.forName("US-ASCII")); case DOUBLE: return Double.toString((Double) value); case ENUM: return Integer.toString(((EnumValueDescriptor) value).getNumber()); case FLOAT: return Float.toString((Float) value); case INT: return Integer.toString((Integer) value); case LONG: return Long.toString((Long) value); case MESSAGE: try { return JsonFormat.writeAsString((Message) value); } catch (IOException e) { throw new ZepException(e.getLocalizedMessage(), e); } case STRING: return (String) value; default: throw new ZepException("Unsupported type: " + field.getType()); } }
From source file:main.RankerOCR.java
/** * Write all the given text in a new line in a CSV file * <p>//from w ww. j a v a2 s . com * @param f CSV file to write * @param c Separator charter * @param s Values to write */ private static void writeOutpuDocCsv(File f, char c, String[] s) { FileWriter w = null; try { w = new FileWriter(f, true); for (String txt : s) { w.append(txt + c); } w.append("\n\r"); } catch (IOException ex) { printFormated(ex.getLocalizedMessage()); System.exit(-34); } finally { try { w.close(); } catch (IOException ex) { printFormated(ex.getLocalizedMessage()); System.exit(-34); } } }
From source file:main.RankerOCR.java
/** * Extract a file content as a string.//from w ww.ja v a 2s . c om * <p> * @param f Document file * @return Text of the document */ private static String readInputDocText(File f) { try (FileReader fr = new FileReader(f)) { StringBuilder s; try (BufferedReader b = new BufferedReader(fr)) { s = new StringBuilder(); while (true) { String line = b.readLine(); if (line == null) { break; } else { s.append(line); s.append("\n"); } } } return s.toString(); } catch (IOException ex) { printFormated(ex.getLocalizedMessage()); System.exit(-33); return null; } }
From source file:com.khepry.utilities.GenericUtilities.java
public static void displayOutFile(String outFilePath, Handler handler) { if (handler != null) { Logger.getLogger("").addHandler(handler); }/*from w ww . j av a 2s. c om*/ File outFile = new File(outFilePath); if (outFile.exists()) { try { Desktop.getDesktop().open(outFile); } catch (IOException ex) { Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } else { Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, outFilePath, new FileNotFoundException()); } }
From source file:main.RankerOCR.java
/** * Evaluate any output files parameters. * <p>//from w w w .j a va2 s . co m * @param s File path as a string * @param c Separator charter, require if must to create a new file * @return File if possible. Otherwise, stop the program and return an error * code */ private static File evalOutputFile(String s, char c) { File f = new File(s); if (!f.exists()) { try { f.createNewFile(); //Write CSV title String[] t = { "Difference %", "Ranker name", "Original name", "Comparative name", "Original path", "Comparative path", "Date & Time" }; writeOutpuDocCsv(f, c, t); } catch (IOException ex) { printFormated(ex.getLocalizedMessage()); System.exit(-35); } } if (!f.canWrite()) { printFormated("Can not write : " + s); System.exit(-34); } return f; }
From source file:fi.uta.infim.usaproxyreportgenerator.App.java
/** * Generates the actual HTML report file for a single session. * @param session the session to generate the report for * @param outputDir output directory for reports * @throws IOException if the report template cannot be read * @throws TemplateException if there is a problem processing the template *///www . j av a2 s . com private static void generateHTMLReport(UsaProxySession session, File outputDir) throws IOException, TemplateException { JSONObject httptraffic = new JSONObject(); for (UsaProxyHTTPTraffic t : session.getSortedHttpTrafficSessions()) { System.out.print("processing traffic id " + t.getSessionID() + "... "); httptraffic.accumulate(t.getSessionID().toString(), JSONObject.fromObject(t, config)); } JSONObject tf = new JSONObject(); tf.accumulate("DEFAULTELEMENTCOLOR", UsaProxyHTTPTrafficJSONProcessor.DEFAULTELEMENTCOLOR); tf.accumulate("DEFAULTVIEWPORTCOLOR", UsaProxyHTTPTrafficJSONProcessor.DEFAULTVIEWPORTCOLOR); tf.accumulate("httptraffics", httptraffic); Map<String, Object> sessionRoot = new HashMap<String, Object>(); sessionRoot.put("data", tf.toString()); sessionRoot.put("timestamp", session.getStart()); sessionRoot.put("id", session.getSessionID()); sessionRoot.put("ip", session.getAddress().getHostAddress()); sessionRoot.put("httpTraffics", session.getSortedHttpTrafficSessions()); Configuration cfg = new Configuration(); // Specify the data source where the template files come from. cfg.setClassForTemplateLoading(App.class, "/" + TEMPLATEDIR); cfg.setObjectWrapper(new DefaultObjectWrapper()); Template temp = cfg.getTemplate(REPORTTEMPLATE); Map<String, Object> root = new HashMap<String, Object>(); root.put("session", sessionRoot); root.put("httpTrafficListIdPrefix", HTTPTRAFFICLISTIDPREFIX); root.put("placeholderIdPrefix", PLACEHOLDERIDPREFIX); try { Writer out = new OutputStreamWriter(new FileOutputStream( new File(outputDir, "usaproxy-session-report-" + session.getSessionID() + ".html"))); temp.process(root, out); out.flush(); } catch (IOException e) { System.err.println("Error opening output file: " + e.getLocalizedMessage()); } }
From source file:com.hp.test.framework.htmparse.HtmlParse.java
public static void replaceMainTable(Boolean onlyMainTable, File f) { try {/*from ww w . j a va2 s.co m*/ String[] filename = f.getName().split("/."); String absolutePath = f.getAbsolutePath(); String filePath = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator)); BufferedReader in = new BufferedReader(new FileReader(f)); String Filepathof_newFile = filePath + "/" + filename[0] + "temp.html"; ReportingProperties reportingprop = new ReportingProperties(); String customizedText = reportingprop.getProperty("CustomizedText"); String CustomizedTitle = reportingprop.getProperty("CustomizedTitle"); reportingprop = null; BufferedWriter out = new BufferedWriter(new FileWriter(Filepathof_newFile)); // BufferedWriter out = new BufferedWriter(new FileWriter(filePath + "/" + filename[0] )); String str; while ((str = in.readLine()) != null) { if (str.contains( "<div class=\"chartStyle\" style=\"text-align: left;margin-left: 30px;float: left;width: 60%;\"> ")) { // out.write("</div> <div class=\"chartStyle\" style=\"text-align: left;margin-left: 30px;float: left;width: 30%;\"> "); out.write(str); out.write(in.readLine()); out.write(in.readLine()); out.write(in.readLine()); // out.write("\n"); out.write( "<div class=\"chartStyle\" style=\"text-align: left;margin-left: 5px;float: left;width: 95%;\">"); out.write("\n"); out.write("<div id=\"chartdiv\" style=\"width: 1300px; height: 350px;\"></div>"); out.write("\n"); out.write("</div>"); continue; } if (str.contains("No Video Recording Available")) continue; if (str.contains("Run Description")) { str = str.replace("Run Description", CustomizedTitle); str = str.replace("Here you can give description about the current Run", customizedText); out.write(str); out.write("\n"); continue; } // if(str.contains("Here you can give description about the current Run")) // { // str=str.replace("Here you can give description about the current Run", customizedText); // out.write(str); // out.write("\n"); // continue; // } if (!str.contains("Current Run Reports")) { out.write(str); out.write("\n"); } else { out.write(str); out.write("\n"); out.write(" <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">"); out.write("\n"); out.write("<script src=\"amcharts.js\" type=\"text/javascript\"></script>"); out.write("\n"); out.write("<script src=\"serial.js\" type=\"text/javascript\"></script>"); out.write("\n"); out.write("<script src=\"3dChart.js\" type=\"text/javascript\"></script>"); out.write("\n"); } } in.close(); out.close(); File renameFile = new File(Filepathof_newFile); FileUtils.copyFile(renameFile, f); System.out.println("Replacing Counts Feature wise is Completed"); } catch (IOException e) { System.out.println("Exception replacing Counts Feature wise" + e.getLocalizedMessage()); } }
From source file:com.khepry.utilities.GenericUtilities.java
public static void displayLogFile(String logFilePath, long logSleepMillis, String xsltFilePath, String xsldFilePath) {/*from w ww .j a v a 2s . c om*/ Logger.getLogger("").getHandlers()[0].close(); // only display the log file // if the logSleepMillis property // is greater than zero milliseconds if (logSleepMillis > 0) { try { Thread.sleep(logSleepMillis); File logFile = new File(logFilePath); File xsltFile = new File(xsltFilePath); File xsldFile = new File(xsldFilePath); File tmpFile = File.createTempFile("tmpLogFile", ".xhtml", logFile.getParentFile()); if (logFile.exists()) { if (xsltFile.exists() && xsldFile.exists()) { String xslFilePath; String xslFileName; String dtdFilePath; String dtdFileName; try { xslFileName = new File(logFilePath).getName().replace(".xhtml", ".xsl"); xslFilePath = logFile.getParentFile().toString().concat("/").concat(xslFileName); FileUtils.copyFile(new File(xsltFilePath), new File(xslFilePath)); dtdFileName = new File(logFilePath).getName().replace(".xhtml", ".dtd"); dtdFilePath = logFile.getParentFile().toString().concat("/").concat(dtdFileName); FileUtils.copyFile(new File(xsldFilePath), new File(dtdFilePath)); } catch (IOException ex) { String message = Level.SEVERE.toString().concat(": ").concat(ex.getLocalizedMessage()); Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, message, ex); GenericUtilities.outputToSystemErr(message, logSleepMillis > 0); return; } BufferedWriter bw = Files.newBufferedWriter(Paths.get(tmpFile.getAbsolutePath()), Charset.defaultCharset(), StandardOpenOption.CREATE); List<String> logLines = Files.readAllLines(Paths.get(logFilePath), Charset.defaultCharset()); for (String line : logLines) { if (line.startsWith("<!DOCTYPE log SYSTEM \"logger.dtd\">")) { bw.write("<!DOCTYPE log SYSTEM \"" + dtdFileName + "\">\n"); bw.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslFileName + "\"?>\n"); } else { bw.write(line.concat("\n")); } } bw.write("</log>\n"); bw.close(); } // the following statement is commented out because it's not quite ready for prime-time yet // Files.write(Paths.get(logFilePath), transformLogViaXSLT(logFilePath, xsltFilePath).getBytes(), StandardOpenOption.CREATE); Desktop.getDesktop().open(tmpFile); } else { Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, logFilePath, new FileNotFoundException()); } } catch (InterruptedException | IOException ex) { Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, null, ex); } } }