use of org.uberfire.java.nio.fs.jgit.JGitPathImpl in project kie-wb-common by kiegroup.
the class LibraryFileUpdateNotifierTest method buildPathMockForBranch.
private org.uberfire.backend.vfs.Path buildPathMockForBranch(final String branchName, final String pathStr) {
JGitPathImpl jGitPath = mock(JGitPathImpl.class);
doReturn(jGitPath).when(libraryFileUpdateNotifier).getPath(pathStr);
doReturn(branchName).when(jGitPath).getRefTree();
org.uberfire.backend.vfs.Path vfsPath = mock(Path.class);
doReturn(vfsPath).when(libraryFileUpdateNotifier).convertPath(jGitPath);
return vfsPath;
}
use of org.uberfire.java.nio.fs.jgit.JGitPathImpl in project kie-wb-common by kiegroup.
the class LibraryFileUpdateNotifier method onBatchIndexEvent.
public void onBatchIndexEvent(@Observes final BatchIndexEvent event) {
event.getIndexEvents().stream().flatMap(evt -> {
switch(evt.getKind()) {
case Deleted:
return Stream.of(((IndexEvent.DeletedEvent) evt).getDeleted().getKey());
case NewlyIndexed:
return Stream.of(((IndexEvent.NewlyIndexedEvent) evt).getKObject().getKey());
case Renamed:
return Stream.of(((IndexEvent.RenamedEvent) evt).getTarget().getKey());
default:
return Stream.empty();
}
}).map(pathStr -> {
final Path path = getPath(pathStr);
final WorkspaceProject project = workspaceProjectService.resolveProject(convertPath(path));
final String repositoryId = project.getRepository().getIdentifier();
final String branchName = (path instanceof JGitPathImpl) ? ((JGitPathImpl) path).getRefTree() : null;
return new RepositoryFileListUpdatedEvent(repositoryId, branchName);
}).distinct().forEach(repositoryFileListUpdatedEvent::fire);
}
Aggregations