@Test public void testMonitoringDisabled() { { notifier.notifyOnUpdatedAssets(event); verify(event, times(1)).getIndexEvents(); } }
public void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event) { if (!isUpdateNotifierEnabled()) { return; } event.getIndexEvents() .stream() .flatMap(evt -> { switch (evt.getKind()) { case Deleted: return Stream.of(((DeletedEvent) evt).getDeleted().getKey()); case NewlyIndexed: return Stream.of(((NewlyIndexedEvent) evt).getKObject().getKey()); case Renamed: return Stream.of(((RenamedEvent) evt).getTarget().getKey()); default: return Stream.empty(); } }) .map(path -> org.uberfire.java.nio.file.Paths.get(path)) .filter(path -> libraryIndexer.supportsPath(path)) .flatMap(path -> { try { WorkspaceProject project = projectService.resolveProject(Paths.convert(path)); return (project == null) ? Stream.empty() : Stream.of(project); } catch (Throwable t) { return Stream.empty(); } }) .map(project -> new ProjectAssetListUpdated(project)) .findFirst() .ifPresent(clientEvent -> { logger.info("Sending indexing notification for project [{}].", clientEvent.getProject().getRepository().getIdentifier()); assetListUpdateEvent.fire(clientEvent); }); }
LibraryAssetUpdateNotifier { public void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event) { if (!isUpdateNotifierEnabled()) { return; } event.getIndexEvents() .stream() .flatMap(evt -> { switch (evt.getKind()) { case Deleted: return Stream.of(((DeletedEvent) evt).getDeleted().getKey()); case NewlyIndexed: return Stream.of(((NewlyIndexedEvent) evt).getKObject().getKey()); case Renamed: return Stream.of(((RenamedEvent) evt).getTarget().getKey()); default: return Stream.empty(); } }) .map(path -> org.uberfire.java.nio.file.Paths.get(path)) .filter(path -> libraryIndexer.supportsPath(path)) .flatMap(path -> { try { WorkspaceProject project = projectService.resolveProject(Paths.convert(path)); return (project == null) ? Stream.empty() : Stream.of(project); } catch (Throwable t) { return Stream.empty(); } }) .map(project -> new ProjectAssetListUpdated(project)) .findFirst() .ifPresent(clientEvent -> { logger.info("Sending indexing notification for project [{}].", clientEvent.getProject().getRepository().getIdentifier()); assetListUpdateEvent.fire(clientEvent); }); } }
LibraryAssetUpdateNotifier { public void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event) { if (!isUpdateNotifierEnabled()) { return; } event.getIndexEvents() .stream() .flatMap(evt -> { switch (evt.getKind()) { case Deleted: return Stream.of(((DeletedEvent) evt).getDeleted().getKey()); case NewlyIndexed: return Stream.of(((NewlyIndexedEvent) evt).getKObject().getKey()); case Renamed: return Stream.of(((RenamedEvent) evt).getTarget().getKey()); default: return Stream.empty(); } }) .map(path -> org.uberfire.java.nio.file.Paths.get(path)) .filter(path -> libraryIndexer.supportsPath(path)) .flatMap(path -> { try { WorkspaceProject project = projectService.resolveProject(Paths.convert(path)); return (project == null) ? Stream.empty() : Stream.of(project); } catch (Throwable t) { return Stream.empty(); } }) .map(project -> new ProjectAssetListUpdated(project)) .findFirst() .ifPresent(clientEvent -> { logger.info("Sending indexing notification for project [{}].", clientEvent.getProject().getRepository().getIdentifier()); assetListUpdateEvent.fire(clientEvent); }); } LibraryAssetUpdateNotifier(); @Inject  LibraryAssetUpdateNotifier(final WorkspaceProjectService projectService,
                                      final LibraryIndexer libraryIndexer,
                                      final @Remote Event<ProjectAssetListUpdated> assetListUpdateEvent,
                                      final Logger logger); }
LibraryAssetUpdateNotifier { public void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event) { if (!isUpdateNotifierEnabled()) { return; } event.getIndexEvents() .stream() .flatMap(evt -> { switch (evt.getKind()) { case Deleted: return Stream.of(((DeletedEvent) evt).getDeleted().getKey()); case NewlyIndexed: return Stream.of(((NewlyIndexedEvent) evt).getKObject().getKey()); case Renamed: return Stream.of(((RenamedEvent) evt).getTarget().getKey()); default: return Stream.empty(); } }) .map(path -> org.uberfire.java.nio.file.Paths.get(path)) .filter(path -> libraryIndexer.supportsPath(path)) .flatMap(path -> { try { WorkspaceProject project = projectService.resolveProject(Paths.convert(path)); return (project == null) ? Stream.empty() : Stream.of(project); } catch (Throwable t) { return Stream.empty(); } }) .map(project -> new ProjectAssetListUpdated(project)) .findFirst() .ifPresent(clientEvent -> { logger.info("Sending indexing notification for project [{}].", clientEvent.getProject().getRepository().getIdentifier()); assetListUpdateEvent.fire(clientEvent); }); } LibraryAssetUpdateNotifier(); @Inject  LibraryAssetUpdateNotifier(final WorkspaceProjectService projectService,
                                      final LibraryIndexer libraryIndexer,
                                      final @Remote Event<ProjectAssetListUpdated> assetListUpdateEvent,
                                      final Logger logger); void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event); }
LibraryAssetUpdateNotifier { public void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event) { if (!isUpdateNotifierEnabled()) { return; } event.getIndexEvents() .stream() .flatMap(evt -> { switch (evt.getKind()) { case Deleted: return Stream.of(((DeletedEvent) evt).getDeleted().getKey()); case NewlyIndexed: return Stream.of(((NewlyIndexedEvent) evt).getKObject().getKey()); case Renamed: return Stream.of(((RenamedEvent) evt).getTarget().getKey()); default: return Stream.empty(); } }) .map(path -> org.uberfire.java.nio.file.Paths.get(path)) .filter(path -> libraryIndexer.supportsPath(path)) .flatMap(path -> { try { WorkspaceProject project = projectService.resolveProject(Paths.convert(path)); return (project == null) ? Stream.empty() : Stream.of(project); } catch (Throwable t) { return Stream.empty(); } }) .map(project -> new ProjectAssetListUpdated(project)) .findFirst() .ifPresent(clientEvent -> { logger.info("Sending indexing notification for project [{}].", clientEvent.getProject().getRepository().getIdentifier()); assetListUpdateEvent.fire(clientEvent); }); } LibraryAssetUpdateNotifier(); @Inject  LibraryAssetUpdateNotifier(final WorkspaceProjectService projectService,
                                      final LibraryIndexer libraryIndexer,
                                      final @Remote Event<ProjectAssetListUpdated> assetListUpdateEvent,
                                      final Logger logger); void notifyOnUpdatedAssets(@Observes @Named(Constants.INDEXER_ID) BatchIndexEvent event);  }