/** * 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; }
/** * 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; }
@Override byte[] apply(PatchingTaskContext context, PatchContentLoader loader) throws IOException { if (context.getCurrentMode() == PatchingTaskContext.Mode.ROLLBACK) { return getContentItem().getContentHash(); } // Copy the new bundle resources to the patching directory final File targetDir = context.getTargetFile(contentItem); final File sourceDir = loader.getFile(contentItem); final File[] moduleResources = sourceDir.listFiles(); if(! targetDir.mkdirs() && ! targetDir.exists()) { throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(targetDir.getAbsolutePath()); } if(moduleResources == null || moduleResources.length == 0) { return NO_CONTENT; } for(final File file : moduleResources) { final File target = new File(targetDir, file.getName()); IoUtils.copy(file, target); } return contentItem.getContentHash(); }
@Override byte[] apply(PatchingTaskContext context, PatchContentLoader loader) throws IOException { if (context.getCurrentMode() == PatchingTaskContext.Mode.ROLLBACK) { return getContentItem().getContentHash(); } // Copy the new bundle resources to the patching directory final File targetDir = context.getTargetFile(contentItem); final File sourceDir = loader.getFile(contentItem); final File[] moduleResources = sourceDir.listFiles(); if(! targetDir.mkdirs() && ! targetDir.exists()) { throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(targetDir.getAbsolutePath()); } if(moduleResources == null || moduleResources.length == 0) { return NO_CONTENT; } for(final File file : moduleResources) { final File target = new File(targetDir, file.getName()); IoUtils.copy(file, target); } return contentItem.getContentHash(); }