public static void writeProperties(final File file, final Properties properties) throws IOException { final OutputStream os = new FileOutputStream(file); try { final Writer writer = new OutputStreamWriter(os, StandardCharsets.UTF_8); properties.store(writer, "read only"); writer.close(); } finally { safeClose(os); } }
public static void writeProperties(final File file, final Properties properties) throws IOException { final OutputStream os = new FileOutputStream(file); try { final Writer writer = new OutputStreamWriter(os, StandardCharsets.UTF_8); properties.store(writer, "read only"); writer.close(); } finally { safeClose(os); } }
public static Properties loadProperties(final File file) throws IOException { if (! file.exists()) { return new Properties(); } Reader reader = null; try { reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); final Properties props = new Properties(); props.load(reader); return props; } finally { safeClose(reader); } }
public static String readRef(final File file) throws IOException { if(! file.exists()) { return Constants.BASE; } final InputStream is = new FileInputStream(file); try { return readRef(is); } finally { safeClose(is); } }
private PatchMetadataResolver parsePatchXml(final File patchXml) throws XMLStreamException, IOException { InputStream patchIS = null; try { patchIS = new FileInputStream(patchXml); return PatchXml.parse(patchIS); } finally { safeClose(patchIS); } }
private PatchConfig parsePatchConfig() throws FileNotFoundException, XMLStreamException { FileInputStream fis = null; try { fis = new FileInputStream(patchConfigFile); BufferedInputStream bis = new BufferedInputStream(fis); return PatchConfigXml.parse(bis); } finally { IoUtils.safeClose(fis); } }
public static List<String> readRefs(final File file) throws IOException { if(! file.exists()) { return Collections.emptyList(); } final InputStream is = new FileInputStream(file); try { return readRefs(is); } finally { safeClose(is); } }
public static Distribution parse(final File patchXml) throws IOException, XMLStreamException { final InputStream is = new FileInputStream(patchXml); try { return parse(is); } finally { safeClose(is); } }
private PatchMetadataResolver parsePatchXml(final File patchXml) throws XMLStreamException, IOException { InputStream patchIS = null; try { patchIS = new FileInputStream(patchXml); return PatchXml.parse(patchIS); } finally { safeClose(patchIS); } }
public static List<String> readRefs(final File file) throws IOException { if(! file.exists()) { return Collections.emptyList(); } final InputStream is = new FileInputStream(file); try { return readRefs(is); } finally { safeClose(is); } }
public static String readRef(final File file) throws IOException { if(! file.exists()) { return Constants.BASE; } final InputStream is = new FileInputStream(file); try { return readRef(is); } finally { safeClose(is); } }
public static void writeRefs(final File file, final List<String> refs, boolean append) throws IOException { mkdir(file.getParentFile()); final OutputStream os = new FileOutputStream(file, append); try { writeRefs(os, refs); os.flush(); os.close(); } finally { safeClose(os); } }
public static void writeRef(final File file, final String ref) throws IOException { mkdir(file.getParentFile()); final OutputStream os = new FileOutputStream(file); try { writeLine(os, ref); os.flush(); os.close(); } finally { safeClose(os); } }
public static void writeRef(final File file, final String ref) throws IOException { mkdir(file.getParentFile()); final OutputStream os = new FileOutputStream(file); try { writeLine(os, ref); os.flush(); os.close(); } finally { safeClose(os); } }
public static void writeRefs(final File file, final List<String> refs, boolean append) throws IOException { mkdir(file.getParentFile()); final OutputStream os = new FileOutputStream(file, append); try { writeRefs(os, refs); os.flush(); os.close(); } finally { safeClose(os); } }
public static Distribution parse(final InputStream stream) throws XMLStreamException { try { final XMLInputFactory inputFactory = INPUT_FACTORY; setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE); setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stream); // final Distribution root = new Distribution(); MAPPER.parseDocument(root, streamReader); return root; } finally { safeClose(stream); } }
public static BundledPatch parse(final InputStream stream) throws XMLStreamException { try { final XMLInputFactory inputFactory = INPUT_FACTORY; setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE); setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stream); // final PatchXml.Result<BundledPatch> result = new PatchXml.Result<BundledPatch>(); MAPPER.parseDocument(result, streamReader); return result.getResult(); } finally { safeClose(stream); } }
protected static void writePatch(final File patchRoot, final Patch patch) throws PatchingException { FileOutputStream os = null; try { os = new FileOutputStream(new File(patchRoot, PatchXml.PATCH_XML)); PatchXml.marshal(os, patch); } catch (Exception e) { throw new PatchingException(e); } finally { IoUtils.safeClose(os); } }
public static PatchConfig parse(final InputStream stream) throws XMLStreamException { try { final XMLInputFactory inputFactory = INPUT_FACTORY; setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE); setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stream); // final PatchConfigBuilder builder = new PatchConfigBuilder(); MAPPER.parseDocument(builder, streamReader); return builder.build(); } finally { safeClose(stream); } }
static void assertLoadable(final File jar) throws Exception { final URL[] urls = new URL[] { jar.toURI().toURL() }; final URLClassLoader cl = new URLClassLoader(urls); try { Assert.assertNotNull(cl.getResource("testResource")); final Class<?> clazz = cl.loadClass("org.jboss.as.patching.tests.TestClass"); final Constructor<?> constructor = clazz.getConstructor(String.class); final Object instance = constructor.newInstance("test"); Assert.assertNotNull(instance); } finally { IoUtils.safeClose(cl); } }