private Map<String,String> loadLayerPatches(boolean addons) { Map<String,String> result = Collections.emptyMap(); final Patch patch = getMetadata(); if(patch != null) { result = new HashMap<String, String>(); for (PatchElement e : patch.getElements()) { if (e.getProvider().isAddOn() == addons) { result.put(e.getProvider().getName(), e.getId()); } } } return result; }
private Map<String,String> loadLayerPatches(boolean addons) { Map<String,String> result = Collections.emptyMap(); final Patch patch = getMetadata(); if(patch != null) { result = new HashMap<String, String>(); for (PatchElement e : patch.getElements()) { if (e.getProvider().isAddOn() == addons) { result.put(e.getProvider().getName(), e.getId()); } } } return result; }
final ModelNode element = new ModelNode(); element.get(Constants.PATCH_ID).set(e.getId()); element.get(Constants.TYPE).set(e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER); element.get(Constants.NAME).set(e.getProvider().getName()); element.get(Constants.DESCRIPTION).set(e.getDescription());
final ModelNode element = new ModelNode(); element.get(Constants.PATCH_ID).set(e.getId()); element.get(Constants.TYPE).set(e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER); element.get(Constants.NAME).set(e.getProvider().getName()); element.get(Constants.DESCRIPTION).set(e.getDescription());
element.get(Constants.PATCH_ID).set(e.getId()); element.get(Constants.NAME).set(e.getProvider().getName()); element.get(Constants.TYPE).set(e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER); element.get(Constants.DESCRIPTION).set(e.getDescription()); elements.add(element);
element.get(Constants.PATCH_ID).set(e.getId()); element.get(Constants.NAME).set(e.getProvider().getName()); element.get(Constants.TYPE).set(e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER); element.get(Constants.DESCRIPTION).set(e.getDescription()); elements.add(element);
final String base = element.getProvider().isAddOn() ? Constants.DEFAULT_ADD_ONS_PATH : Constants.DEFAULT_LAYERS_PATH;
private static boolean isAgedOut(InstalledIdentity installedIdentity, final Patch metadata) { for (PatchElement pe : metadata.getElements()) { final PatchElementProvider peProvider = pe.getProvider(); final PatchableTarget layer = peProvider.isAddOn() ? installedIdentity.getAddOn(peProvider.getName()) : installedIdentity.getLayer(peProvider.getName()); if (layer == null) { // if an identity is missing a layer that means either it was re-configured and the layer // was removed // or the layer in the patch is optional and may be missing on the disk // we haven't had this case yet, not sure how critical this is to terminate the process of // cleaning up throw new IllegalStateException(PatchLogger.ROOT_LOGGER.layerNotFound(peProvider.getName())); } final File patchDir = layer.getDirectoryStructure().getModulePatchDirectory(pe.getId()); if (!patchDir.exists()) { return true; } } return false; }
private static boolean isAgedOut(InstalledIdentity installedIdentity, final Patch metadata) { for (PatchElement pe : metadata.getElements()) { final PatchElementProvider peProvider = pe.getProvider(); final PatchableTarget layer = peProvider.isAddOn() ? installedIdentity.getAddOn(peProvider.getName()) : installedIdentity.getLayer(peProvider.getName()); if (layer == null) { // if an identity is missing a layer that means either it was re-configured and the layer // was removed // or the layer in the patch is optional and may be missing on the disk // we haven't had this case yet, not sure how critical this is to terminate the process of // cleaning up throw new IllegalStateException(PatchLogger.ROOT_LOGGER.layerNotFound(peProvider.getName())); } final File patchDir = layer.getDirectoryStructure().getModulePatchDirectory(pe.getId()); if (!patchDir.exists()) { return true; } } return false; }
final boolean addOn = provider.isAddOn(); for (final PatchElement originalElement : original.getElements()) { if (name.equals(originalElement.getProvider().getName()) && addOn == originalElement.getProvider().isAddOn()) { PatchingTasks.addMissingModifications(target, originalElement.getModifications(), ContentItemFilter.ALL_BUT_MISC);
final PatchElementProvider provider = element.getProvider(); final String layerName = provider.getName(); final PatchableTarget target = provider.isAddOn() ? identity.getAddOn(layerName) : identity.getLayer(layerName); boolean modules = false; boolean bundles = false;
final PatchElementProvider provider = element.getProvider(); final String layerName = provider.getName(); final PatchableTarget target = provider.isAddOn() ? identity.getAddOn(layerName) : identity.getLayer(layerName); boolean modules = false; boolean bundles = false;
@Override public void operationCancelled(IdentityPatchContext context) { // Cleanup history, bundles and module patch directories final InstalledImage image = structure.getInstalledImage(); IoUtils.recursiveDelete(image.getPatchHistoryDir(patchId)); IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(patchId)); IoUtils.recursiveDelete(structure.getModulePatchDirectory(patchId)); for (final PatchElement element : original.getElements()) { boolean addOn = element.getProvider().isAddOn(); final IdentityPatchContext.PatchEntry entry = context.getEntry(element.getProvider().getName(), addOn); final DirectoryStructure structure = entry.getDirectoryStructure(); IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(element.getId())); IoUtils.recursiveDelete(structure.getModulePatchDirectory(element.getId())); } }
@Override public void operationCancelled(IdentityPatchContext context) { // Cleanup history, bundles and module patch directories final InstalledImage image = structure.getInstalledImage(); IoUtils.recursiveDelete(image.getPatchHistoryDir(patchId)); IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(patchId)); IoUtils.recursiveDelete(structure.getModulePatchDirectory(patchId)); for (final PatchElement element : original.getElements()) { boolean addOn = element.getProvider().isAddOn(); final IdentityPatchContext.PatchEntry entry = context.getEntry(element.getProvider().getName(), addOn); final DirectoryStructure structure = entry.getDirectoryStructure(); IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(element.getId())); IoUtils.recursiveDelete(structure.getModulePatchDirectory(element.getId())); } }
private void displayPatchXml(CommandContext ctx, Patch patch) throws CommandException { final Identity identity = patch.getIdentity(); SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", patch.getPatchId()}); table.addLine(new String[]{"Type:", identity.getPatchType().getName()}); table.addLine(new String[]{"Identity name:", identity.getName()}); table.addLine(new String[]{"Identity version:", identity.getVersion()}); table.addLine(new String[]{"Description:", patch.getDescription() == null ? "n/a" : patch.getDescription()}); if (patch.getLink() != null) { table.addLine(new String[]{"Link:", patch.getLink()}); } ctx.printLine(table.toString(false)); if (verbose) { ctx.printLine(""); ctx.printLine("ELEMENTS"); for (PatchElement e : patch.getElements()) { table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", e.getId()}); table.addLine(new String[]{"Name:", e.getProvider().getName()}); table.addLine(new String[]{"Type:", e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER}); table.addLine(new String[]{"Description:", e.getDescription()}); ctx.printLine(""); ctx.printLine(table.toString(false)); } } } }
private void displayPatchXml(CommandContext ctx, Patch patch) throws CommandException { final Identity identity = patch.getIdentity(); SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", patch.getPatchId()}); table.addLine(new String[]{"Type:", identity.getPatchType().getName()}); table.addLine(new String[]{"Identity name:", identity.getName()}); table.addLine(new String[]{"Identity version:", identity.getVersion()}); table.addLine(new String[]{"Description:", patch.getDescription() == null ? "n/a" : patch.getDescription()}); if (patch.getLink() != null) { table.addLine(new String[]{"Link:", patch.getLink()}); } ctx.printLine(table.toString(false)); if (verbose) { ctx.printLine(""); ctx.printLine("ELEMENTS"); for (PatchElement e : patch.getElements()) { table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", e.getId()}); table.addLine(new String[]{"Name:", e.getProvider().getName()}); table.addLine(new String[]{"Type:", e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER}); table.addLine(new String[]{"Description:", e.getDescription()}); ctx.printLine(""); ctx.printLine(table.toString(false)); } } } }
private void displayPatchXml(CommandContext ctx, Patch patch) throws CommandLineException { final Identity identity = patch.getIdentity(); SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", patch.getPatchId()}); table.addLine(new String[]{"Type:", identity.getPatchType().getName()}); table.addLine(new String[]{"Identity name:", identity.getName()}); table.addLine(new String[]{"Identity version:", identity.getVersion()}); table.addLine(new String[]{"Description:", patch.getDescription() == null ? "n/a" : patch.getDescription()}); if (patch.getLink() != null) { table.addLine(new String[]{"Link:", patch.getLink()}); } ctx.printLine(table.toString(false)); if(verbose.isPresent(ctx.getParsedCommandLine())) { ctx.printLine(""); ctx.printLine("ELEMENTS"); for(PatchElement e : patch.getElements()) { table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", e.getId()}); table.addLine(new String[]{"Name:", e.getProvider().getName()}); table.addLine(new String[]{"Type:", e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER}); table.addLine(new String[]{"Description:", e.getDescription()}); ctx.printLine(""); ctx.printLine(table.toString(false)); } } }
private void displayPatchXml(CommandContext ctx, Patch patch) throws CommandLineException { final Identity identity = patch.getIdentity(); SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", patch.getPatchId()}); table.addLine(new String[]{"Type:", identity.getPatchType().getName()}); table.addLine(new String[]{"Identity name:", identity.getName()}); table.addLine(new String[]{"Identity version:", identity.getVersion()}); table.addLine(new String[]{"Description:", patch.getDescription() == null ? "n/a" : patch.getDescription()}); if (patch.getLink() != null) { table.addLine(new String[]{"Link:", patch.getLink()}); } ctx.printLine(table.toString(false)); if(verbose.isPresent(ctx.getParsedCommandLine())) { ctx.printLine(""); ctx.printLine("ELEMENTS"); for(PatchElement e : patch.getElements()) { table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{"Patch ID:", e.getId()}); table.addLine(new String[]{"Name:", e.getProvider().getName()}); table.addLine(new String[]{"Type:", e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER}); table.addLine(new String[]{"Description:", e.getDescription()}); ctx.printLine(""); ctx.printLine(table.toString(false)); } } }
static void assertNotApplied(final Patch patch, InstallationManager manager) throws IOException { InstalledIdentity installedIdentity = null; try { installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), patch.getIdentity().getVersion()); } catch (PatchingException e) { Assert.fail(e.getLocalizedMessage()); } final PatchableTarget.TargetInfo identity = installedIdentity.getIdentity().loadTargetInfo(); assertNotApplied(patch.getIdentity().getPatchType(), patch.getPatchId(), identity); assertDoesNotExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patch.getPatchId())); for (final PatchElement element : patch.getElements()) { final PatchElementProvider provider = element.getProvider(); final PatchableTarget target = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName()); Assert.assertNotNull(target); assertNotApplied(provider.getPatchType(), element.getId(), target.loadTargetInfo()); } }
static void assertApplied(final Patch patch, InstallationManager manager) throws IOException { final String patchID = patch.getPatchId(); InstalledIdentity installedIdentity = null; try { installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null); } catch (PatchingException e) { Assert.fail(e.getLocalizedMessage()); } final PatchableTarget target = installedIdentity.getIdentity(); final PatchableTarget.TargetInfo identity = target.loadTargetInfo(); assertIsApplied(patch.getIdentity().getPatchType(), patchID, identity); assertExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patchID)); assertContentItems(patchID, target, patch.getModifications()); for (final PatchElement element : patch.getElements()) { final PatchElementProvider provider = element.getProvider(); final PatchableTarget targetElement = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName()); assertIsApplied(provider.getPatchType(), element.getId(), targetElement.loadTargetInfo()); assertContentItems(element.getId(), targetElement, element.getModifications()); } }