@Override protected RollbackPatch resolveMetaData(PatchMetadataResolver resolver) throws PatchingException { return (RollbackPatch) resolver.resolvePatch(null, null); } };
@Override protected Patch resolveMetaData(PatchMetadataResolver resolver) throws PatchingException { return resolver.resolvePatch(null, null); } };
@Override protected RollbackPatch resolveMetaData(PatchMetadataResolver resolver) throws PatchingException { return (RollbackPatch) resolver.resolvePatch(null, null); } };
@Override protected Patch resolveMetaData(PatchMetadataResolver resolver) throws PatchingException { return resolver.resolvePatch(null, null); } };
static RollbackPatch loadRollbackInformation(final String patchId, final InstalledImage installedImage) throws PatchingException, IOException, XMLStreamException { final File historyDir = installedImage.getPatchHistoryDir(patchId); final File patchXml = new File(historyDir, Constants.ROLLBACK_XML); return (RollbackPatch) PatchXml.parse(patchXml).resolvePatch(null, null); }
static RollbackPatch loadRollbackInformation(final String patchId, final InstalledImage installedImage) throws PatchingException, IOException, XMLStreamException { final File historyDir = installedImage.getPatchHistoryDir(patchId); final File patchXml = new File(historyDir, Constants.ROLLBACK_XML); return (RollbackPatch) PatchXml.parse(patchXml).resolvePatch(null, null); }
private static Patch parsePatchXml(final File patch1Dir, File patch1) throws PatchingException { final File patch1Xml = new File(patch1Dir, PatchXml.PATCH_XML); if (!patch1Xml.exists()) { throw new PatchingException("Failed to locate " + PatchXml.PATCH_XML + " in " + patch1.getAbsolutePath()); } try { return PatchXml.parse(patch1Xml).resolvePatch(null, null); } catch (Exception e) { throw new PatchingException("Failed to parse " + PatchXml.PATCH_XML + " from " + patch1.getAbsolutePath(), e); } }
static Patch loadPatchInformation(final String patchId, final InstalledImage installedImage) throws PatchingException, IOException, XMLStreamException { final File patchDir = installedImage.getPatchHistoryDir(patchId); final File patchXml = new File(patchDir, PatchXml.PATCH_XML); return PatchXml.parse(patchXml).resolvePatch(null, null); }
static Patch loadPatchInformation(final String patchId, final InstalledImage installedImage) throws PatchingException, IOException, XMLStreamException { final File patchDir = installedImage.getPatchHistoryDir(patchId); final File patchXml = new File(patchDir, PatchXml.PATCH_XML); return PatchXml.parse(patchXml).resolvePatch(null, null); }
private static Patch parsePatchXml(final File patch1Dir, File patch1) throws PatchingException { final File patch1Xml = new File(patch1Dir, PatchXml.PATCH_XML); if (!patch1Xml.exists()) { throw new PatchingException("Failed to locate " + PatchXml.PATCH_XML + " in " + patch1.getAbsolutePath()); } try { return PatchXml.parse(patch1Xml).resolvePatch(null, null); } catch (Exception e) { throw new PatchingException("Failed to parse " + PatchXml.PATCH_XML + " from " + patch1.getAbsolutePath(), e); } }
private static void assertExistsOnDisk(IteratorImpl i, String id) throws NoSuchElementException { final File historyDir = i.mgr.getInstalledImage().getPatchHistoryDir(id); if(!historyDir.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.noPatchHistory(historyDir.getAbsolutePath())); } // TODO parsed xml can be cached final File rollbackXml = new File(historyDir, "rollback.xml"); if(!rollbackXml.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.patchIsMissingFile(rollbackXml.getAbsolutePath())); } try { PatchXml.parse(rollbackXml); } catch (Exception e) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.fileIsNotReadable(rollbackXml.getAbsolutePath() + ": " + e.getLocalizedMessage())); } final File patchXml = new File(historyDir, "patch.xml"); if(!patchXml.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.patchIsMissingFile(patchXml.getAbsolutePath())); } final Patch patchMetaData; try { patchMetaData = PatchXml.parse(patchXml).resolvePatch(i.mgr.getIdentity().getName(), i.mgr.getIdentity().getVersion()); } catch (Exception e) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.fileIsNotReadable(patchXml.getAbsolutePath() + ": " + e.getLocalizedMessage())); } if(i.excludeAgedOut && isAgedOut(i.mgr, patchMetaData)) { throw new NoSuchElementException("Patch " + patchMetaData.getPatchId() + " was aged out"); } }
private static void assertExistsOnDisk(IteratorImpl i, String id) throws NoSuchElementException { final File historyDir = i.mgr.getInstalledImage().getPatchHistoryDir(id); if(!historyDir.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.noPatchHistory(historyDir.getAbsolutePath())); } // TODO parsed xml can be cached final File rollbackXml = new File(historyDir, "rollback.xml"); if(!rollbackXml.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.patchIsMissingFile(rollbackXml.getAbsolutePath())); } try { PatchXml.parse(rollbackXml); } catch (Exception e) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.fileIsNotReadable(rollbackXml.getAbsolutePath() + ": " + e.getLocalizedMessage())); } final File patchXml = new File(historyDir, "patch.xml"); if(!patchXml.exists()) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.patchIsMissingFile(patchXml.getAbsolutePath())); } final Patch patchMetaData; try { patchMetaData = PatchXml.parse(patchXml).resolvePatch(i.mgr.getIdentity().getName(), i.mgr.getIdentity().getVersion()); } catch (Exception e) { throw new NoSuchElementException(PatchLogger.ROOT_LOGGER.fileIsNotReadable(patchXml.getAbsolutePath() + ": " + e.getLocalizedMessage())); } if(i.excludeAgedOut && isAgedOut(i.mgr, patchMetaData)) { throw new NoSuchElementException("Patch " + patchMetaData.getPatchId() + " was aged out"); } }
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); } }
protected PatchingResult apply(final PatchMetadataResolver patchResolver, final PatchContentProvider contentProvider, final ContentVerificationPolicy contentPolicy) throws PatchingException { // Apply the patch final org.jboss.as.patching.metadata.Identity identity = patchResolver.resolvePatch(null, null).getIdentity(); final InstallationManager.InstallationModification modification = ((InstallationManagerImpl)manager). getInstalledIdentity(identity.getName(), identity.getVersion()).modifyInstallation(callback); try { return runner.applyPatch(patchResolver, contentProvider, contentPolicy, modification); } catch (Exception e) { modification.cancel(); throw rethrowException(e); } }
PatchXml.parse(new StringReader(buf.toString())).resolvePatch(null, null); fail("duplicate element patch-id error expected"); } catch(XMLStreamException e) {
private void doMarshall(String fileName) throws Exception { final String original = toString(fileName); try (final InputStream is = getResource(fileName)) { final Patch patch = PatchXml.parse(is).resolvePatch(null, null); final StringWriter writer = new StringWriter(); PatchXml.marshal(writer, patch); final String marshalled = writer.toString(); XMLUtils.compareXml(original, marshalled, false); } }
protected PatchingResult apply(final PatchMetadataResolver patchResolver, final PatchContentProvider contentProvider, final ContentVerificationPolicy contentPolicy) throws PatchingException { // Apply the patch final org.jboss.as.patching.metadata.Identity identity = patchResolver.resolvePatch(null, null).getIdentity(); final InstallationManager.InstallationModification modification = ((InstallationManagerImpl)manager). getInstalledIdentity(identity.getName(), identity.getVersion()).modifyInstallation(callback); try { return runner.applyPatch(patchResolver, contentProvider, contentPolicy, modification); } catch (Exception e) { modification.cancel(); throw rethrowException(e); } }
@Test public void testParseOneOff() throws Exception { final InputStream is = getResource("patch-02-ONE-OFF.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // One-off Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertNotNull(patch.getIdentity().getVersion()); }
@Test public void testParseCP() throws Exception { final InputStream is = getResource("patch-01-CP.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // Cumulative Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertEquals(Patch.PatchType.CUMULATIVE, identity.getPatchType()); assertNotNull(identity.forType(Patch.PatchType.CUMULATIVE, Identity.IdentityUpgrade.class).getResultingVersion()); assertNotNull(identity.getVersion()); }