public static void exportWithProperties(String propFile, String outFile) throws IOException { Properties props = new Properties(); try { props.load(new FileInputStream(propFile)); } catch (FileNotFoundException e) { System.err.println("Property file not found: " + propFile); System.exit(2); } catch (IOException e) { System.err.println("Unable to read properties: " + propFile); System.exit(2); } OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(outFile)); WikiEngine engine = new WikiEngine(props); Exporter x = new Exporter(out, true); x.export(engine); } catch (WikiException e) { // TODO Auto-generated catch block e.printStackTrace(System.err); System.exit(3); } catch (IOException e) { e.printStackTrace(System.err); System.exit(3); } finally { if (out != null) out.close(); // Make sure JSPWiki dies too System.exit(0); } }
/** * This is a special version of the routine which knows the FileSystemProvider default format. * * @param dir * @param outFile * @throws IOException */ public static void exportWithDir(String dir, String outFile) throws IOException { FileOutputStream out = new FileOutputStream(new File(outFile)); Exporter x = new Exporter(out, true); x.export(dir); out.close(); }
/** * Removes the given exporter from the list of exporters. * * @param aExporter the exporter to remove, cannot be <code>null</code>. */ public void removeExporter(final Exporter aExporter) { if (this.mainFrame != null) { this.mainFrame.removeExportMenuItem(aExporter.getName()); } updateActions(); }
/** * Returns the names of all current available exporters. * * @return an array of exporter names, never <code>null</code>, but can be empty. */ public String[] getExporterNames() { try { final ServiceReference[] serviceRefs = this.bundleContext.getAllServiceReferences(Exporter.class.getName(), null); final int count = serviceRefs == null ? 0 : serviceRefs.length; final String[] result = new String[count]; for (int i = 0; i < count; i++) { final Exporter exporter = (Exporter) this.bundleContext.getService(serviceRefs[i]); result[i] = exporter.getName(); this.bundleContext.ungetService(serviceRefs[i]); } return result; } catch (InvalidSyntaxException exception) { throw new RuntimeException("getAllExporterNames failed!", exception); } }
/** * Returns the exporter with the given name. * * @param aName the name of the exporter to return, cannot be <code>null</code>. * @return the exporter with the given name, can be <code>null</code> if no such exporter is * found. * @throws IllegalArgumentException in case the given name was <code>null</code> or empty. */ public Exporter getExporter(final String aName) throws IllegalArgumentException { if ((aName == null) || aName.trim().isEmpty()) { throw new IllegalArgumentException("Name cannot be null or empty!"); } try { final ServiceReference[] serviceRefs = this.bundleContext.getAllServiceReferences(Exporter.class.getName(), null); final int count = (serviceRefs == null) ? 0 : serviceRefs.length; for (int i = 0; i < count; i++) { final Exporter exporter = (Exporter) this.bundleContext.getService(serviceRefs[i]); if (aName.equals(exporter.getName())) { return exporter; } } return null; } catch (InvalidSyntaxException exception) { throw new RuntimeException("getExporter failed!", exception); } }
/** * Exports the current diagram to the given exporter. * * @param aExporter the exporter to export to, cannot be <code>null</code>. * @param aOutputStream the output stream to write the export to, cannot be <code>null</code>. * @throws IOException in case of I/O problems. */ public void exportTo(final Exporter aExporter, final OutputStream aOutputStream) throws IOException { if (this.mainFrame != null) { aExporter.export(this.dataContainer, this.mainFrame.getDiagramScrollPane(), aOutputStream); } }