private void refreshView(final Path path) { final String pathUri = path.toURI(); for (Repository repository : repositories.values()) { final String repositoryUri = repository.getRoot().toURI(); if (pathUri.startsWith(repositoryUri)) { reset(); break; } } } }
/** * This can also return System Repository. * @param fs * @return */ public Repository getRepositoryByRepositoryFileSystem(final FileSystem fs) { if (fs == null) { return null; } if (convert(systemRepository.getRoot()).getFileSystem().equals(fs)) { return systemRepository; } for (final Repository repository : repositoriesByAlias.values()) { if (convert(repository.getRoot()).getFileSystem().equals(fs)) { return repository; } } return null; }
public void add(final Repository repository) { repositoriesByAlias.put(repository.getAlias(), repository); if (repository instanceof GitRepository && repository.getBranches() != null) { for (String branch : repository.getBranches()) { repositoriesByBranchRoot.put(repository.getBranchRoot(branch), repository); } } else { repositoriesByBranchRoot.put(repository.getRoot(), repository); } }
Path[] getAuthorizedRepositoryRoots() { //First get a collection of OU's to which the User has access final Collection<OrganizationalUnit> organizationalUnits = organizationalUnitService.getOrganizationalUnits(); final Collection<OrganizationalUnit> authorizedOrganizationalUnits = new ArrayList<OrganizationalUnit>(); for ( OrganizationalUnit ou : organizationalUnits ) { if ( authorizationManager.authorize( ou, identity ) ) { authorizedOrganizationalUnits.add( ou ); } } //Then check whether User has access to related Repositories final Set<Path> authorizedRoots = new HashSet<Path>(); for ( OrganizationalUnit ou : authorizedOrganizationalUnits ) { final Collection<Repository> repositories = ou.getRepositories(); for ( final Repository repository : repositories ) { if ( authorizationManager.authorize( repository, identity ) ) { authorizedRoots.add( Paths.convert( repository.getRoot() ) ); } } } return authorizedRoots.toArray( new Path[ authorizedRoots.size() ] ); }
private Set<Project> getProjects(final Repository repository) { final Set<Project> authorizedProjects = new HashSet<Project>(); if (repository == null) { return authorizedProjects; } final Path repositoryRoot = Paths.convert(repository.getRoot()); final DirectoryStream<Path> nioRepositoryPaths = ioService.newDirectoryStream(repositoryRoot); for (Path nioRepositoryPath : nioRepositoryPaths) { if (Files.isDirectory(nioRepositoryPath)) { final org.uberfire.backend.vfs.Path projectPath = Paths.convert(nioRepositoryPath); final Project project = projectService.get().resolveProject(projectPath); if (project != null) { authorizedProjects.add(project); } } } return authorizedProjects; } }
private Set<Project> getProjects(final Repository repository) { final Set<Project> authorizedProjects = new HashSet<Project>(); if (repository == null) { return authorizedProjects; } final Path repositoryRoot = Paths.convert(repository.getRoot()); final DirectoryStream<Path> nioRepositoryPaths = ioService.newDirectoryStream(repositoryRoot); for (Path nioRepositoryPath : nioRepositoryPaths) { if (Files.isDirectory(nioRepositoryPath)) { final org.uberfire.backend.vfs.Path projectPath = Paths.convert(nioRepositoryPath); final Project project = projectService.get().resolveProject(projectPath); if (project != null) { authorizedProjects.add(project); } } } return authorizedProjects; } }
@Override public List<FileDiff> diff(final PullRequest pullRequest) { final Repository repository = configuredRepositories.getRepositoryByRepositoryAlias(pullRequest.getTargetRepository()); this.createHiddenBranch(pullRequest); String diff = String.format("diff:%s,%s", pullRequest.getTargetBranch(), this.buildHiddenBranchName(pullRequest)); final List<FileDiff> diffs = (List<FileDiff>) this.ioService.readAttributes(convert(repository.getRoot()), diff); this.deleteHiddenBranch(pullRequest); return diffs; }
final VersionAttributeView versionAttributeView = ioService.getFileAttributeView(convert(repo.getRoot()), VersionAttributeView.class); final List<VersionRecord> records = versionAttributeView.readAttributes().history().records();
public RepositoryInfo getRepositoryInfo(final String alias) { final Repository repo = getRepository(alias); String ouName = null; for (final OrganizationalUnit ou : organizationalUnitService.getAllOrganizationalUnits()) { for (Repository repository : ou.getRepositories()) { if (repository.getAlias().equals(alias)) { ouName = ou.getName(); } } } return new RepositoryInfo(repo.getIdentifier(), alias, ouName, repo.getRoot(), repo.getPublicURIs(), getRepositoryHistory(alias, 0, HISTORY_PAGE_SIZE)); }
@Test public void testBranches() throws Exception { rootDirectories.add(createPath("default://origin@uf-playground")); rootDirectories.add(createPath("default://master@uf-playground")); rootDirectories.add(createPath("default://branch1@uf-playground")); ConfigGroup configGroup = getConfigGroup(); configGroup.setName("test"); Repository repository = helper.newRepository(configGroup); assertEquals(3, repository.getBranches().size()); assertTrue(repository.getRoot().toURI().contains("master")); }
if (repo != null) { repositoryRemovedEvent.fire(new RepositoryRemovedEvent(repo)); ioService.delete(convert(repo.getRoot()).getFileSystem().getPath(null));
@Test public void testNewBranch() throws Exception { final Path branchPath = mock(Path.class); final NewBranchEvent changedEvent = new NewBranchEvent("single", "mybranch", branchPath, System.currentTimeMillis()); configuredRepositories.onNewBranch(changedEvent); // Root for both is the default root assertEquals(configuredRepositories.getRepositoryByRepositoryAlias("single").getRoot(), configuredRepositories.getRepositoryByRootPath(branchPath).getRoot()); final Repository single = configuredRepositories.getRepositoryByRepositoryAlias("single"); assertEquals(2, single.getBranches().size()); assertEquals(branchPath, single.getBranchRoot("mybranch")); } }
@Override public Path initRepositoryStructure(final GAV gav, final Repository repo, final DeploymentMode mode) { final POM pom = new POM(repo.getAlias(), repo.getAlias(), gav, true); if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pom); } //Creating the parent pom final Path fsRoot = repo.getRoot(); final Path pathToPom = pomService.create(fsRoot, "", pom); //Deploying the parent pom artifact, // it needs to be deployed before the first child is created m2service.deployParentPom(gav); managedStatusUpdater.updateManagedStatus(repo, true); return pathToPom; }
@Override public Path initRepositoryStructure(final GAV gav, final Repository repo, final DeploymentMode mode) { final POM pom = new POM(repo.getAlias(), repo.getAlias(), gav, true); if (DeploymentMode.VALIDATED.equals(mode)) { checkRepositories(pom); } //Creating the parent pom final Path fsRoot = repo.getRoot(); final Path pathToPom = pomService.create(fsRoot, "", pom); //Deploying the parent pom artifact, // it needs to be deployed before the first child is created m2service.deployParentPom(gav); managedStatusUpdater.updateManagedStatus(repo, true); return pathToPom; }
final Path fsRoot = repository.getRoot(); final Path pathToPom = pomService.create(fsRoot, baseUrl,
final Path fsRoot = repository.getRoot(); final Path pathToPom = pomService.create(fsRoot, baseUrl,
@Test public void testRemoveSingle() throws Exception { final Path root = configuredRepositories.getRepositoryByRepositoryAlias("single").getRoot(); assertNotNull(configuredRepositories.getRepositoryByRootPath(root)); assertNotNull(configuredRepositories.remove("single")); assertFalse(configuredRepositories.containsAlias("single")); assertNull(configuredRepositories.getRepositoryByRootPath(root)); }