Search in sources :

Example 1 with DashboardDeletedEvent

use of org.graylog2.dashboards.events.DashboardDeletedEvent in project graylog2-server by Graylog2.

the class StartPageCleanupListener method removeStartpageReferencesIfDashboardDeleted.

@Subscribe
@SuppressWarnings("unused")
public void removeStartpageReferencesIfDashboardDeleted(DashboardDeletedEvent dashboardDeletedEvent) {
    final Startpage deletedStartpage = Startpage.create("dashboard", dashboardDeletedEvent.dashboardId());
    resetReferencesToStartpage(deletedStartpage);
}
Also used : Startpage(org.graylog2.rest.models.users.requests.Startpage) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with DashboardDeletedEvent

use of org.graylog2.dashboards.events.DashboardDeletedEvent in project graylog2-server by Graylog2.

the class ViewsResourceTest method deletingDashboardTriggersEvent.

@Test
public void deletingDashboardTriggersEvent() {
    final String viewId = "foobar";
    when(searchUser.canDeleteView(view)).thenReturn(true);
    when(view.type()).thenReturn(ViewDTO.Type.DASHBOARD);
    when(view.id()).thenReturn(viewId);
    when(viewService.get(viewId)).thenReturn(Optional.of(view));
    when(userService.loadAll()).thenReturn(Collections.emptyList());
    this.viewsResource.delete(viewId, searchUser);
    final ArgumentCaptor<DashboardDeletedEvent> eventCaptor = ArgumentCaptor.forClass(DashboardDeletedEvent.class);
    verify(clusterEventBus, times(1)).post(eventCaptor.capture());
    final DashboardDeletedEvent dashboardDeletedEvent = eventCaptor.getValue();
    assertThat(dashboardDeletedEvent.dashboardId()).isEqualTo("foobar");
}
Also used : DashboardDeletedEvent(org.graylog2.dashboards.events.DashboardDeletedEvent) Test(org.junit.Test)

Example 3 with DashboardDeletedEvent

use of org.graylog2.dashboards.events.DashboardDeletedEvent in project graylog2-server by Graylog2.

the class ViewsResource method triggerDeletedEvent.

private void triggerDeletedEvent(ViewDTO dto) {
    if (dto != null && dto.type() != null && dto.type().equals(ViewDTO.Type.DASHBOARD)) {
        final DashboardDeletedEvent dashboardDeletedEvent = DashboardDeletedEvent.create(dto.id());
        // noinspection UnstableApiUsage
        clusterEventBus.post(dashboardDeletedEvent);
    }
}
Also used : DashboardDeletedEvent(org.graylog2.dashboards.events.DashboardDeletedEvent)

Aggregations

DashboardDeletedEvent (org.graylog2.dashboards.events.DashboardDeletedEvent)2 Subscribe (com.google.common.eventbus.Subscribe)1 Startpage (org.graylog2.rest.models.users.requests.Startpage)1 Test (org.junit.Test)1