static PatchingTask createModuleTask(final PatchingTaskDescription description, boolean rollback) { if (rollback) { return new ModuleRollbackTask(description); } else { final ModificationType type = description.getModificationType(); if(type == ModificationType.REMOVE) { return new ModuleRemoveTask(description); } else { return new ModuleUpdateTask(description); } } }
/** * Create the patching task based on the definition. * * @param definition the task description * @param provider the content provider * @param context the task context * @return the created task */ static PatchingTask createTask(final PatchingTasks.ContentTaskDefinition definition, final PatchContentProvider provider, final IdentityPatchContext.PatchEntry context) { final PatchContentLoader contentLoader = provider.getLoader(definition.getTarget().getPatchId()); final PatchingTaskDescription description = PatchingTaskDescription.create(definition, contentLoader); return PatchingTask.Factory.create(description, context); }
/** * Cancel the current patch and undo the changes. * * @param callback the finalize callback */ protected void cancel(final FinalizeCallback callback) { try { undoChanges(); } finally { callback.operationCancelled(this); } }
protected void reenableRolledBackInBase(final IdentityPatchContext.PatchEntry target) throws IOException { for(ContentTaskDefinition def : target.getTaskDefinitions()) { if(def.isRollback()) { final ContentItem item = def.getTarget().getItem(); if(item.getContentType() == ContentType.MODULE) { target.reenableBaseModule((ModuleItem)item); } } } }
/** * Get a misc file. * * @param root the root * @param item the misc content item * @return the misc file */ static File getTargetFile(final File root, final MiscContentItem item) { return PatchContentLoader.getMiscPath(root, item); }
@Override File getTargetFile(ContentItem item) throws IOException { return elementLoader.getFile(item); } };
@Override public void cleanup() { // If cleanup gets called before finalizePatch, something went wrong if (state != State.PREPARED) { undoChanges(); } }
FileRemoveTask(PatchingTaskDescription description, File target, File backup) { this.target = target; this.backup = backup; this.description = description; this.item = description.getContentItem(MiscContentItem.class); }
@Override public PatchingResult rollback(final String patchId, final ContentVerificationPolicy contentPolicy, final boolean rollbackTo, final boolean resetConfiguration) throws PatchingException { return rollback(null, patchId, contentPolicy, rollbackTo, resetConfiguration); }
static void cleanupEntry(final Collection<IdentityPatchContext.PatchEntry> entries) { for (final IdentityPatchContext.PatchEntry entry : entries) { entry.cleanupRollbackPatchHistory(); } }
/** * Fail if the copied content is different from the one specified in the metadata. This should be true in most of the * cases. Only removing a module does not really match this, since we are creating a removed-module rather than * removing the contents. * * @param context the task context * @return */ protected boolean failOnContentMismatch(PatchingTaskContext context) { return context.getCurrentMode() != PatchingTaskContext.Mode.UNDO; }
static void writeRefs(final OutputStream os, final List<String> refs) throws IOException { for(final String ref : refs) { writeLine(os, ref); } }
/** * Get the original modification. Tasks like module remove can override this and fix the hashes based on the created content. * * @param targetHash the new target hash code (current content) * @param itemHash the new content item hash (backup content) * @return the original modification */ protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { return description.getModification(); }
protected void reenableRolledBackInBase(final IdentityPatchContext.PatchEntry target) throws IOException { for(ContentTaskDefinition def : target.getTaskDefinitions()) { if(def.isRollback()) { final ContentItem item = def.getTarget().getItem(); if(item.getContentType() == ContentType.MODULE) { target.reenableBaseModule((ModuleItem)item); } } } }
/** * Create the patching task based on the definition. * * @param definition the task description * @param provider the content provider * @param context the task context * @return the created task */ static PatchingTask createTask(final PatchingTasks.ContentTaskDefinition definition, final PatchContentProvider provider, final IdentityPatchContext.PatchEntry context) { final PatchContentLoader contentLoader = provider.getLoader(definition.getTarget().getPatchId()); final PatchingTaskDescription description = PatchingTaskDescription.create(definition, contentLoader); return PatchingTask.Factory.create(description, context); }
static PatchingTask createModuleTask(final PatchingTaskDescription description, boolean rollback) { if (rollback) { return new ModuleRollbackTask(description); } else { final ModificationType type = description.getModificationType(); if(type == ModificationType.REMOVE) { return new ModuleRemoveTask(description); } else { return new ModuleUpdateTask(description); } } }
/** * Cancel the current patch and undo the changes. * * @param callback the finalize callback */ protected void cancel(final FinalizeCallback callback) { try { undoChanges(); } finally { callback.operationCancelled(this); } }
@Override File getTargetFile(ContentItem item) throws IOException { return targetLoader.getFile(item); } };
@Override public void cleanup() { // If cleanup gets called before finalizePatch, something went wrong if (state != State.PREPARED) { undoChanges(); } }
FileRemoveTask(PatchingTaskDescription description, File target, File backup) { this.target = target; this.backup = backup; this.description = description; this.item = description.getContentItem(MiscContentItem.class); }