} else { is = patchZip.getInputStream(patchXmlEntry); final List<BundledPatchEntry> patches = PatchBundleXml.parse(is).getPatches(); displayPatchBundleXml(ctx, patches, patchZip);
metadata = PatchBundleXml.parse(is); } finally { IoUtils.safeClose(is);
} else { is = patchZip.getInputStream(patchXmlEntry); final List<BundledPatch.BundledPatchEntry> patches = PatchBundleXml.parse(is).getPatches(); displayPatchBundleXml(ctx, patches, patchZip);
} else { is = patchZip.getInputStream(patchXmlEntry); final List<BundledPatchEntry> patches = PatchBundleXml.parse(is).getPatches(); displayPatchBundleXml(ctx, patches, patchZip);
} else { is = patchZip.getInputStream(patchXmlEntry); final List<BundledPatch.BundledPatchEntry> patches = PatchBundleXml.parse(is).getPatches(); displayPatchBundleXml(ctx, patches, patchZip);
static void doMarshall(final String fileName) throws Exception { final String original = toString(fileName); try (final InputStream is = getResource(fileName)) { final BundledPatch patch = PatchBundleXml.parse(is); final StringWriter writer = new StringWriter(); PatchBundleXml.marshal(writer, patch); final String marshalled = writer.toString(); XMLUtils.compareXml(original, marshalled, false); } }
protected PatchingResult execute(final File workDir, final ContentVerificationPolicy contentPolicy) throws PatchingException, IOException, XMLStreamException { final File patchBundleXml = new File(workDir, PatchBundleXml.MULTI_PATCH_XML); if (patchBundleXml.exists()) { final InputStream patchIs = new FileInputStream(patchBundleXml); try { // Handle multi patch installs final BundledPatch bundledPatch = PatchBundleXml.parse(patchIs); return applyPatchBundle(workDir, bundledPatch, contentPolicy); } finally { safeClose(patchIs); } } else { // Parse the xml File patchXml = new File(workDir, PatchXml.PATCH_XML); PatchMetadataResolver patchResolver = parsePatchXml(patchXml); Patch patch = patchResolver.resolvePatch(null, null); final InstalledIdentity installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null); final String currentVersion = installedIdentity.getIdentity().getVersion(); if(!Constants.UNKNOWN.equals(currentVersion) && !patch.getIdentity().getVersion().equals(currentVersion)) { patchXml = new File(workDir, currentVersion + PatchMerger.PATCH_XML_SUFFIX); if(!patchXml.exists()) { throw new PatchingException("The patch does not contain metadata for currently installed " + patch.getIdentity().getName() + " version " + currentVersion); } patchResolver = parsePatchXml(patchXml); patch = patchResolver.resolvePatch(null, null); } return apply(patchResolver, PatchContentProvider.DefaultContentProvider.create(workDir), contentPolicy); } }
protected PatchingResult execute(final File workDir, final ContentVerificationPolicy contentPolicy) throws PatchingException, IOException, XMLStreamException { final File patchBundleXml = new File(workDir, PatchBundleXml.MULTI_PATCH_XML); if (patchBundleXml.exists()) { final InputStream patchIs = new FileInputStream(patchBundleXml); try { // Handle multi patch installs final BundledPatch bundledPatch = PatchBundleXml.parse(patchIs); return applyPatchBundle(workDir, bundledPatch, contentPolicy); } finally { safeClose(patchIs); } } else { // Parse the xml File patchXml = new File(workDir, PatchXml.PATCH_XML); PatchMetadataResolver patchResolver = parsePatchXml(patchXml); Patch patch = patchResolver.resolvePatch(null, null); final InstalledIdentity installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null); final String currentVersion = installedIdentity.getIdentity().getVersion(); if(!Constants.UNKNOWN.equals(currentVersion) && !patch.getIdentity().getVersion().equals(currentVersion)) { patchXml = new File(workDir, currentVersion + PatchMerger.PATCH_XML_SUFFIX); if(!patchXml.exists()) { throw new PatchingException("The patch does not contain metadata for currently installed " + patch.getIdentity().getName() + " version " + currentVersion); } patchResolver = parsePatchXml(patchXml); patch = patchResolver.resolvePatch(null, null); } return apply(patchResolver, PatchContentProvider.DefaultContentProvider.create(workDir), contentPolicy); } }
@Test public void testBasic() throws Exception { try (final InputStream is = getResource("multi-patch-01.xml")) { final BundledPatch bundledPatch = PatchBundleXml.parse(is); Assert.assertNotNull(bundledPatch); Assert.assertFalse(bundledPatch.getPatches().isEmpty()); } }