throw PatchLogger.ROOT_LOGGER.noSuchLayer(layerName); entry = new PatchEntry(target, element); map.put(layerName, entry); entry.updateElement(element); return entry;
if(rollbackEntry.get(new Location(module)) != null) { continue; continue; final File modulePath = PatchContentLoader.getModulePath(rollbackEntry.getDirectoryStructure().getModulePatchDirectory(oneOff.getId()), module); rollbackEntry.invalidateRoot(modulePath); if(reenabledModules.isEmpty()) { reenabledModules = new HashSet<ModuleItem>(); rollbackEntry.disableBaseModule(module); } else { if(cpElementModules == null) { rollbackEntry.disableBaseModule(module);
static PatchingTask create(final PatchingTaskDescription description, final IdentityPatchContext.PatchEntry context) { final ContentItem item = description.getContentItem(); switch (item.getContentType()) { case BUNDLE: return createBundleTask(description); case MISC: return createMiscTask(description, (MiscContentItem) item, context); case MODULE: return createModuleTask(description, context.getCurrentMode() == Mode.ROLLBACK || description.isRolledback()); default: throw new IllegalStateException(); } }
final IdentityRollbackCallback callback = new IdentityRollbackCallback(patchId, patches, resetConfiguration, identity.getDirectoryStructure()); try { return executeTasks(context, callback);
if(rollbackEntry.get(new Location(module)) != null) { continue; continue; final File modulePath = PatchContentLoader.getModulePath(rollbackEntry.getDirectoryStructure().getModulePatchDirectory(oneOff.getId()), module); rollbackEntry.invalidateRoot(modulePath); if(reenabledModules.isEmpty()) { reenabledModules = new HashSet<ModuleItem>(); rollbackEntry.disableBaseModule(module); } else { if(cpElementModules == null) { rollbackEntry.disableBaseModule(module);
final IdentityRollbackCallback callback = new IdentityRollbackCallback(patchId, patches, resetConfiguration, identity.getDirectoryStructure()); try { return executeTasks(context, callback);
final String elementPatchId = element.getId(); if (target.isApplied(elementPatchId)) { target.apply(elementPatchId, elementPatchType); identityEntry.apply(patchId, patchType); identityEntry.setResultingVersion(upgrade.getResultingVersion()); final IdentityApplyCallback callback = new IdentityApplyCallback(patch, identityEntry.getDirectoryStructure()); try { return executeTasks(context, callback);
final String elementPatchId = element.getId(); if (target.isApplied(elementPatchId)) { target.apply(elementPatchId, elementPatchType); identityEntry.apply(patchId, patchType); identityEntry.setResultingVersion(upgrade.getResultingVersion()); final IdentityApplyCallback callback = new IdentityApplyCallback(patch, identityEntry.getDirectoryStructure()); try { return executeTasks(context, callback);
final String cumulativePatchID = target.getCumulativePatchID(); if (Constants.BASE.equals(cumulativePatchID)) { reenableRolledBackInBase(target); final DirectoryStructure structure = target.getDirectoryStructure(); final File modulesRoot = structure.getModulePatchDirectory(patchId); final File bundlesRoot = structure.getBundlesPatchDirectory(patchId);
final String cumulativePatchID = target.getCumulativePatchID(); if (Constants.BASE.equals(cumulativePatchID)) { reenableRolledBackInBase(target); final DirectoryStructure structure = target.getDirectoryStructure(); final File modulesRoot = structure.getModulePatchDirectory(patchId); final File bundlesRoot = structure.getBundlesPatchDirectory(patchId);
/** * Prepare all tasks. * * @param entry the patch entry * @param context the patch context * @param tasks a list for prepared tasks * @param conflicts a list for conflicting content items * @throws PatchingException */ static void prepareTasks(final IdentityPatchContext.PatchEntry entry, final IdentityPatchContext context, final List<PreparedTask> tasks, final List<ContentItem> conflicts) throws PatchingException { for (final PatchingTasks.ContentTaskDefinition definition : entry.getTaskDefinitions()) { final PatchingTask task = createTask(definition, context, entry); if(!task.isRelevant(entry)) { continue; } try { // backup and validate content if (!task.prepare(entry) || definition.hasConflicts()) { // Unless it a content item was manually ignored (or excluded) final ContentItem item = task.getContentItem(); if (!context.isIgnored(item)) { conflicts.add(item); } } tasks.add(new PreparedTask(task, entry)); } catch (IOException e) { throw new PatchingException(e); } } }
/** * Prepare all tasks. * * @param entry the patch entry * @param context the patch context * @param tasks a list for prepared tasks * @param conflicts a list for conflicting content items * @throws PatchingException */ static void prepareTasks(final IdentityPatchContext.PatchEntry entry, final IdentityPatchContext context, final List<PreparedTask> tasks, final List<ContentItem> conflicts) throws PatchingException { for (final PatchingTasks.ContentTaskDefinition definition : entry.getTaskDefinitions()) { final PatchingTask task = createTask(definition, context, entry); if(!task.isRelevant(entry)) { continue; } try { // backup and validate content if (!task.prepare(entry) || definition.hasConflicts()) { // Unless it a content item was manually ignored (or excluded) final ContentItem item = task.getContentItem(); if (!context.isIgnored(item)) { conflicts.add(item); } } tasks.add(new PreparedTask(task, entry)); } catch (IOException e) { throw new PatchingException(e); } } }
throw PatchLogger.ROOT_LOGGER.noSuchLayer(layerName); entry = new PatchEntry(target, element); map.put(layerName, entry); entry.updateElement(element); return entry;
/** * Apply modifications to a content task definition. * * @param patchId the patch id * @param modifications the modifications * @param definitions the task definitions * @param filter the content item filter */ static void apply(final String patchId, final Collection<ContentModification> modifications, final PatchEntry patchEntry, final ContentItemFilter filter) { for (final ContentModification modification : modifications) { final ContentItem item = modification.getItem(); // Check if we accept the item if (!filter.accepts(item)) { continue; } final Location location = new Location(item); final ContentEntry contentEntry = new ContentEntry(patchId, modification); ContentTaskDefinition definition = patchEntry.get(location); if (definition == null) { definition = new ContentTaskDefinition(location, contentEntry, false); patchEntry.put(location, definition); } else { definition.setTarget(contentEntry); } } }
/** * Apply modifications to a content task definition. * * @param patchId the patch id * @param modifications the modifications * @param definitions the task definitions * @param filter the content item filter */ static void apply(final String patchId, final Collection<ContentModification> modifications, final PatchEntry patchEntry, final ContentItemFilter filter) { for (final ContentModification modification : modifications) { final ContentItem item = modification.getItem(); // Check if we accept the item if (!filter.accepts(item)) { continue; } final Location location = new Location(item); final ContentEntry contentEntry = new ContentEntry(patchId, modification); ContentTaskDefinition definition = patchEntry.get(location); if (definition == null) { definition = new ContentTaskDefinition(location, contentEntry, false); patchEntry.put(location, definition); } else { definition.setTarget(contentEntry); } } }
static void addMissingModifications(IdentityPatchContext.PatchEntry target, Collection<ContentModification> modifications, final ContentItemFilter filter) throws IOException { final String cpId = target.getCumulativePatchID(); for (final ContentModification modification : modifications) { final ContentItem item = modification.getItem(); // Check if we accept the item if (!filter.accepts(item)) { continue; } final Location location = new Location(item); final ContentTaskDefinition definition = target.get(location); if (definition == null) { target.put(location, new ContentTaskDefinition(location, new ContentEntry(cpId, modification), false)); } else if(definition.isRollback()) { target.prepareForPortForward(item, cpId); definition.setTarget(new ContentEntry(cpId, modification)); } } }
/** * Create a patch element for the rollback patch. * * @param entry the entry * @return the new patch element */ protected static PatchElement createRollbackElement(final PatchEntry entry) { final PatchElement patchElement = entry.element; final String patchId; final Patch.PatchType patchType = patchElement.getProvider().getPatchType(); if (patchType == Patch.PatchType.CUMULATIVE) { patchId = entry.getCumulativePatchID(); } else { patchId = patchElement.getId(); } return createPatchElement(entry, patchId, entry.rollbackActions); }
static void addMissingModifications(IdentityPatchContext.PatchEntry target, Collection<ContentModification> modifications, final ContentItemFilter filter) throws IOException { final String cpId = target.getCumulativePatchID(); for (final ContentModification modification : modifications) { final ContentItem item = modification.getItem(); // Check if we accept the item if (!filter.accepts(item)) { continue; } final Location location = new Location(item); final ContentTaskDefinition definition = target.get(location); if (definition == null) { target.put(location, new ContentTaskDefinition(location, new ContentEntry(cpId, modification), false)); } else if(definition.isRollback()) { target.prepareForPortForward(item, cpId); definition.setTarget(new ContentEntry(cpId, modification)); } } }
/** * Create a patch element for the rollback patch. * * @param entry the entry * @return the new patch element */ protected static PatchElement createRollbackElement(final PatchEntry entry) { final PatchElement patchElement = entry.element; final String patchId; final Patch.PatchType patchType = patchElement.getProvider().getPatchType(); if (patchType == Patch.PatchType.CUMULATIVE) { patchId = entry.getCumulativePatchID(); } else { patchId = patchElement.getId(); } return createPatchElement(entry, patchId, entry.rollbackActions); }
@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())); } }