public static File getModulePath(File root, ModuleItem item) { return getModulePath(root, item.getName(), item.getSlot()); }
void reenableBaseModule(final ModuleItem item) throws IOException { if(modulesToReenable.isEmpty()) { modulesToReenable = new ArrayList<File>(); } final File modulePath = PatchContentLoader.getModulePath(getDirectoryStructure().getModuleRoot(), item.getName(), ((ModuleItem)item).getSlot()); final List<File> files = listFiles(modulePath); if (files != null && files.size() > 0) { for (final File file : files) { modulesToReenable.add(file); } } }
void disableBaseModule(final ModuleItem item) throws IOException { if(modulesToDisable.isEmpty()) { modulesToDisable = new ArrayList<File>(); } final File modulePath = PatchContentLoader.getModulePath(getDirectoryStructure().getModuleRoot(), item.getName(), ((ModuleItem)item).getSlot()); final List<File> files = listFiles(modulePath); if (files != null && files.size() > 0) { for (final File file : files) { modulesToDisable.add(file); } } }
void reenableBaseModule(final ModuleItem item) throws IOException { if(modulesToReenable.isEmpty()) { modulesToReenable = new ArrayList<File>(); } final File modulePath = PatchContentLoader.getModulePath(getDirectoryStructure().getModuleRoot(), item.getName(), ((ModuleItem)item).getSlot()); final List<File> files = listFiles(modulePath); if (files != null && files.size() > 0) { for (final File file : files) { modulesToReenable.add(file); } } }
public static File getModulePath(File root, ModuleItem item) { return getModulePath(root, item.getName(), item.getSlot()); }
void disableBaseModule(final ModuleItem item) throws IOException { if(modulesToDisable.isEmpty()) { modulesToDisable = new ArrayList<File>(); } final File modulePath = PatchContentLoader.getModulePath(getDirectoryStructure().getModuleRoot(), item.getName(), ((ModuleItem)item).getSlot()); final List<File> files = listFiles(modulePath); if (files != null && files.size() > 0) { for (final File file : files) { modulesToDisable.add(file); } } }
@Override File getSourceFile(ContentItem item) throws IOException { if (item.getContentType() == ContentType.BUNDLE) { final File root = new File(bundles, base); final File layer = new File(root, element.getProvider().getName()); return PatchContentLoader.getModulePath(layer, (ModuleItem) item); } else if (item.getContentType() == ContentType.MODULE) { final File root = new File(modules, base); final File layer = new File(root, element.getProvider().getName()); return PatchContentLoader.getModulePath(layer, (ModuleItem) item); } throw processingError("invalid content item for patch-element %s", item); }
static void assertDefinedAbsentBundle(File bundlesDir, String bundleName) throws Exception { final File bundlePath = PatchContentLoader.getModulePath(bundlesDir, bundleName, "main"); if(bundlePath.exists()) { final File[] children = bundlePath.listFiles(); if(children.length == 0) { return; } } fail("content found for " + bundleName + " in " + bundlesDir); }
static void assertDefinedAbsentBundle(File[] bundlesPath, String moduleName) throws Exception { for (File path : bundlesPath) { final File bundlePath = PatchContentLoader.getModulePath(path, moduleName, "main"); if(bundlePath.exists()) { final File[] children = bundlePath.listFiles(); if(children.length == 0) { return; } } } fail("content not found bundle for " + moduleName + " in " + asList(bundlesPath)); }
static void assertDefinedAbsentModule(File[] modulesPath, String moduleName) throws Exception { for (File path : modulesPath) { final File modulePath = PatchContentLoader.getModulePath(path, moduleName, "main"); final File moduleXml = new File(modulePath, "module.xml"); if (moduleXml.exists()) { assertDefinedModuleWithRootElement(moduleXml, moduleName, "<module-absent "); return; } } fail("count not found module for " + moduleName + " in " + asList(modulesPath)); }
public static void assertDefinedAbsentModule(File modulesDir, String moduleName) throws Exception { final File modulePath = PatchContentLoader.getModulePath(modulesDir, moduleName, "main"); final File moduleXml = new File(modulePath, "module.xml"); if (moduleXml.exists()) { assertDefinedModuleWithRootElement(moduleXml, moduleName, "<module-absent "); } else { fail("count not found module for " + moduleName + " in " + modulesDir); } }
static void assertModulePath(final File[] mp, final ModuleItem item, final File reference) { File resolved = null; for (final File root : mp) { final File moduleRoot = PatchContentLoader.getModulePath(root, item); final File moduleXml = new File(moduleRoot, "module.xml"); if (moduleXml.exists()) { resolved = moduleRoot; break; } } Assert.assertEquals(item.toString(), reference, resolved); }
@Override byte[] backup(PatchingTaskContext context) throws IOException { final File[] repoRoots = context.getTargetModulePath(); final String moduleName = contentItem.getName(); final String slot = contentItem.getSlot(); for(final File path : repoRoots) { // Find the first module and calculate the hash final File modulePath = PatchContentLoader.getModulePath(path, moduleName, slot); final File moduleXml = new File(modulePath, MODULE_XML); if(moduleXml.exists()) { PatchLogger.ROOT_LOGGER.debugf("found in path (%s)", moduleXml.getAbsolutePath()); context.invalidateRoot(modulePath); return HashUtils.hashFile(modulePath); } } return notFound(contentItem); }
@Override byte[] backup(PatchingTaskContext context) throws IOException { final File[] repoRoots = context.getTargetModulePath(); final String moduleName = contentItem.getName(); final String slot = contentItem.getSlot(); for(final File path : repoRoots) { // Find the first module and calculate the hash final File modulePath = PatchContentLoader.getModulePath(path, moduleName, slot); final File moduleXml = new File(modulePath, MODULE_XML); if(moduleXml.exists()) { PatchLogger.ROOT_LOGGER.debugf("found in path (%s)", moduleXml.getAbsolutePath()); context.invalidateRoot(modulePath); return HashUtils.hashFile(modulePath); } } return notFound(contentItem); }
static void assertDefinedBundle(File[] bundlesPath, String moduleName, byte[] expectedHash) throws Exception { for (File path : bundlesPath) { final File bundlePath = PatchContentLoader.getModulePath(path, moduleName, "main"); if(bundlePath.exists()) { if(expectedHash != null) { byte[] actualHash = hashFile(bundlePath); assertTrue("content of bundle differs", Arrays.equals(expectedHash, actualHash)); } return; } } fail("content not found bundle for " + moduleName + " in " + asList(bundlesPath)); }
static void assertDefinedBundle(File bundlesDir, String moduleName, byte[] expectedHash) throws Exception { final File bundlePath = PatchContentLoader.getModulePath(bundlesDir, moduleName, "main"); if(bundlePath.exists()) { if(expectedHash != null) { byte[] actualHash = hashFile(bundlePath); assertTrue("content of bundle differs", Arrays.equals(expectedHash, actualHash)); } } else { fail("content not found bundle for " + moduleName + " in " + bundlesDir); } }
@Override public File getTargetFile(ContentItem item) { if (item.getContentType() == ContentType.MISC) { return IdentityPatchContext.this.getTargetFile((MiscContentItem) item); } if (applyPatchId == null || state == State.ROLLBACK_ONLY) { throw new IllegalStateException("cannot process rollback tasks for modules/bundles"); // internal wrong usage, no i18n } final File root; final DirectoryStructure structure = delegate.getDirectoryStructure(); if (item.getContentType() == ContentType.BUNDLE) { root = structure.getBundlesPatchDirectory(applyPatchId); } else { root = structure.getModulePatchDirectory(applyPatchId); } return PatchContentLoader.getModulePath(root, (ModuleItem) item); }
public static void assertDefinedModule(File moduleRoot, String moduleName, byte[] expectedHash) throws Exception { final File modulePath = PatchContentLoader.getModulePath(moduleRoot, moduleName, "main"); final File moduleXml = new File(modulePath, "module.xml"); if (moduleXml.exists()) { assertDefinedModuleWithRootElement(moduleXml, moduleName, "<module"); if (expectedHash != null) { byte[] actualHash = hashFile(modulePath); assertTrue("content of module differs", Arrays.equals(expectedHash, actualHash)); } return; } fail("count not find module for " + moduleName + " in " + moduleRoot); }
public static void assertDefinedModule(File[] modulesPath, String moduleName, byte[] expectedHash) throws Exception { for (File path : modulesPath) { final File modulePath = PatchContentLoader.getModulePath(path, moduleName, "main"); final File moduleXml = new File(modulePath, "module.xml"); if (moduleXml.exists()) { assertDefinedModuleWithRootElement(moduleXml, moduleName, "<module"); if (expectedHash != null) { byte[] actualHash = hashFile(modulePath); assertTrue("content of module differs", Arrays.equals(expectedHash, actualHash)); } return; } } fail("count not find module for " + moduleName + " in " + asList(modulesPath)); }
static void assertModule(final String patchID, final PatchableTarget target, final ModuleItem item) { final File[] mp = TestUtils.getModuleRoot(target); final File currentPatch = target.getDirectoryStructure().getModulePatchDirectory(patchID); final File module = PatchContentLoader.getModulePath(currentPatch, item); assertModulePath(mp, item, module); }