@Override public KieModule resolveModule(Path resource, boolean loadPOM) { return (KieModule) resourceResolver.resolveModule(resource, loadPOM); }
@Override public T resolveModule(final Path resource) { return resolveModule(resource, true); }
@Override public T resolveModule(final Path resource) { return resolveModule(resource, true); }
@Override public KieModule resolveModule(final Path resource) { return (KieModule) resourceResolver.resolveModule(resource); }
@Test public void testReImport() throws Exception { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://project1/pom.xml"); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); abstractProjectService.reImport(path); verify(invalidateDMOCache).fire(any(InvalidateDMOModuleCacheEvent.class)); }
@Override public void reImport(final Path pathToPomXML) { try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Path path = Paths.convert(projectDirectory); final Module module = resourceResolver.resolveModule(path); invalidateDMOCache.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } catch (final Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Test public void testReImport() throws Exception { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://project1/pom.xml"); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); abstractProjectService.reImport(path); verify(invalidateDMOCache).fire(any(InvalidateDMOModuleCacheEvent.class)); }
@Override public void reImport(final Path pathToPomXML) { try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Path path = Paths.convert(projectDirectory); final Module module = resourceResolver.resolveModule(path); invalidateDMOCache.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } catch (final Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Override public org.guvnor.common.services.project.model.Package resolvePackage(final Path resource) { try { //Null resource paths cannot resolve to a Module if (resource == null) { return null; } //If Path is not within a Module we cannot resolve a package final Module module = resolveModule(resource); if (module == null) { return null; } //pom.xml is not inside a package if (isPom(resource)) { return null; } return makePackage(module, resource); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public org.guvnor.common.services.project.model.Package resolvePackage(final Path resource) { try { //Null resource paths cannot resolve to a Module if (resource == null) { return null; } //If Path is not within a Module we cannot resolve a package final Module module = resolveModule(resource); if (module == null) { return null; } //pom.xml is not inside a package if (isPom(resource)) { return null; } return makePackage(module, resource); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Test public void testUseRepoServiceToDeleteRootModule() { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file:///space/project1/pom.xml"); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); when(pomService.load(any())).thenReturn(mock(POM.class)); Repository repo = mock(Repository.class); when(repoService.getRepository(eq(org.uberfire.backend.server.util.Paths.convert(Paths.get("file:///space/project1"))))).thenReturn(repo); String alias = "repo-alias"; when(repo.getAlias()).thenReturn(alias); Space space = new Space("space"); when(repo.getSpace()).thenReturn(space); abstractProjectService.delete(path, ""); verify(repoService).removeRepository(eq(space), eq(alias)); verify(ioService, times(0)).delete(any(), any()); }
@Test public void testUseRepoServiceToDeleteRootModule() { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file:///space/project1/pom.xml"); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); when(pomService.load(any())).thenReturn(mock(POM.class)); Repository repo = mock(Repository.class); when(repoService.getRepository(eq(org.uberfire.backend.server.util.Paths.convert(Paths.get("file:///space/project1"))))).thenReturn(repo); String alias = "repo-alias"; when(repo.getAlias()).thenReturn(alias); Space space = new Space("space"); when(repo.getSpace()).thenReturn(space); abstractProjectService.delete(path, ""); verify(repoService).removeRepository(eq(space), eq(alias)); verify(ioService, times(0)).delete(any(), any()); }
@Test public void testUseIOServiceToDeleteSubModule() { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://space/project1/subproject/pom.xml"); when(ioService.exists(any())).thenReturn(true); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); when(pomService.load(any())).thenReturn(mock(POM.class)); Repository repo = mock(Repository.class); when(repoService.getRepository(path)).thenReturn(repo); String alias = "repo-alias"; when(repo.getAlias()).thenReturn(alias); Space space = new Space("space"); when(repo.getSpace()).thenReturn(space); abstractProjectService.delete(path, ""); verify(repoService, times(0)).removeRepository(any(), any()); verify(ioService).delete(eq(Paths.get("file://space/project1/subproject")), anyVararg()); } }
@Test public void testUseIOServiceToDeleteSubModule() { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://space/project1/subproject/pom.xml"); when(ioService.exists(any())).thenReturn(true); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); when(pomService.load(any())).thenReturn(mock(POM.class)); Repository repo = mock(Repository.class); when(repoService.getRepository(path)).thenReturn(repo); String alias = "repo-alias"; when(repo.getAlias()).thenReturn(alias); Space space = new Space("space"); when(repo.getSpace()).thenReturn(space); abstractProjectService.delete(path, ""); verify(repoService, times(0)).removeRepository(any(), any()); verify(ioService).delete(eq(Paths.get("file://space/project1/subproject")), anyVararg()); } }
private void findModule(final org.uberfire.java.nio.file.Path folderPath, final boolean checkModulesFromFolders) { final org.uberfire.java.nio.file.Path pomPath = folderPath.resolve(POM_PATH); if (Files.exists(pomPath)) { final Module module = resourceResolver.resolveModule(Paths.convert(pomPath)); if (module != null) { addModule(module); } else if (checkModulesFromFolders) { lookForModulesFromFolders(folderPath); } } else if (checkModulesFromFolders) { lookForModulesFromFolders(folderPath); } }
private void findModule(final org.uberfire.java.nio.file.Path folderPath, final boolean checkModulesFromFolders) { final org.uberfire.java.nio.file.Path pomPath = folderPath.resolve(POM_PATH); if (Files.exists(pomPath)) { final Module module = resourceResolver.resolveModule(Paths.convert(pomPath)); if (module != null) { addModule(module); } else if (checkModulesFromFolders) { lookForModulesFromFolders(folderPath); } } else if (checkModulesFromFolders) { lookForModulesFromFolders(folderPath); } }
try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Module module2Delete = resourceResolver.resolveModule(Paths.convert(projectDirectory));
try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Module module2Delete = resourceResolver.resolveModule(Paths.convert(projectDirectory));
@Override public boolean isPom(final Path resource) { try { //Null resource paths cannot resolve to a Module if (resource == null) { return false; } //Check if path equals pom.xml final Module module = resolveModule(resource); //It's possible that the Incremental Build attempts to act on a Module file before the module has been fully created. //This should be a short-term issue that will be resolved when saving a module batches pom.xml, kmodule.xml and project.imports //etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests. if (module == null) { return false; } final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize(); final org.uberfire.java.nio.file.Path pomFilePath = Paths.convert(module.getPomXMLPath()); return path.startsWith(pomFilePath); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public boolean isPom(final Path resource) { try { //Null resource paths cannot resolve to a Module if (resource == null) { return false; } //Check if path equals pom.xml final Module module = resolveModule(resource); //It's possible that the Incremental Build attempts to act on a Module file before the module has been fully created. //This should be a short-term issue that will be resolved when saving a module batches pom.xml, kmodule.xml and project.imports //etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests. if (module == null) { return false; } final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize(); final org.uberfire.java.nio.file.Path pomFilePath = Paths.convert(module.getPomXMLPath()); return path.startsWith(pomFilePath); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }