Merge pull request #105 from bsinno/BUG/TARGET_TABLE_PERFOMANCE
merged. ok 👍
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.app;
|
package org.eclipse.hawkbit.app;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||||
|
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||||
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ public class MyUI extends HawkbitUI {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus) {
|
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus,
|
||||||
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus));
|
final UIEventProvider provider) {
|
||||||
|
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus, provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
package org.eclipse.hawkbit.autoconfigure.ui;
|
package org.eclipse.hawkbit.autoconfigure.ui;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.DistributedResourceBundleMessageSource;
|
import org.eclipse.hawkbit.DistributedResourceBundleMessageSource;
|
||||||
|
import org.eclipse.hawkbit.ui.HawkbitEventProvider;
|
||||||
|
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.vaadin.spring.annotation.EnableVaadinExtensions;
|
import org.vaadin.spring.annotation.EnableVaadinExtensions;
|
||||||
@@ -17,9 +20,6 @@ import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawkbit-ui autoconfiguration.
|
* The hawkbit-ui autoconfiguration.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableVaadinSecurity
|
@EnableVaadinSecurity
|
||||||
@@ -37,4 +37,15 @@ public class UIAutoConfiguration {
|
|||||||
return new DistributedResourceBundleMessageSource();
|
return new DistributedResourceBundleMessageSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A event provider bean which hold the supported events for the UI.
|
||||||
|
*
|
||||||
|
* @return the provider bean
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public UIEventProvider eventProvider() {
|
||||||
|
return new HawkbitEventProvider();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.ui;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default hawkbit event provider.
|
||||||
|
*/
|
||||||
|
public class HawkbitEventProvider implements UIEventProvider {
|
||||||
|
|
||||||
|
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(6);
|
||||||
|
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(3);
|
||||||
|
|
||||||
|
static {
|
||||||
|
SINGLE_EVENTS.add(TargetTagCreatedBulkEvent.class);
|
||||||
|
SINGLE_EVENTS.add(DistributionSetTagCreatedBulkEvent.class);
|
||||||
|
SINGLE_EVENTS.add(DistributionSetTagDeletedEvent.class);
|
||||||
|
SINGLE_EVENTS.add(DistributionSetTagUpdateEvent.class);
|
||||||
|
SINGLE_EVENTS.add(RolloutGroupChangeEvent.class);
|
||||||
|
SINGLE_EVENTS.add(RolloutChangeEvent.class);
|
||||||
|
|
||||||
|
BULK_EVENTS.add(TargetCreatedEvent.class);
|
||||||
|
BULK_EVENTS.add(TargetInfoUpdateEvent.class);
|
||||||
|
BULK_EVENTS.add(TargetDeletedEvent.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Class<? extends Event>> getSingleEvents() {
|
||||||
|
return SINGLE_EVENTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Class<? extends Event>> getBulkEvents() {
|
||||||
|
return BULK_EVENTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.ui;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The UI event provider hold all supported repository events which will
|
||||||
|
* delegated to the UI. A event type can delegated as single event or bulk
|
||||||
|
* event. Bulk event means, that all events from one type is collected by the
|
||||||
|
* provider. The delegater and delegated as a list of this events.
|
||||||
|
*/
|
||||||
|
public interface UIEventProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all supported repository single event types. All events which this
|
||||||
|
* type are delegated to the UI as single event.
|
||||||
|
*
|
||||||
|
* @return list of provided event types. Should not be null
|
||||||
|
*/
|
||||||
|
default Set<Class<? extends Event>> getSingleEvents() {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all supported repository bulk event types. All events which this
|
||||||
|
* type are delegated to the UI as a list. This list contains all collected
|
||||||
|
* events from one type.
|
||||||
|
*
|
||||||
|
* @return list of provided bulk event types. Should not be null
|
||||||
|
*/
|
||||||
|
default Set<Class<? extends Event>> getBulkEvents() {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all filtered bulk event types by the given events. The default
|
||||||
|
* maps the events by class.
|
||||||
|
*
|
||||||
|
* @param allEvents
|
||||||
|
* the events
|
||||||
|
* @return list of provided bulk event types which are filtered. Should not
|
||||||
|
* be null
|
||||||
|
*/
|
||||||
|
default Set<Class<?>> getFilteredBulkEventsType(final List<Event> allEvents) {
|
||||||
|
return allEvents.stream().map(Event::getClass).filter(getBulkEvents()::contains).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -104,12 +104,11 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
@ViewScope
|
@ViewScope
|
||||||
public class TargetTable extends AbstractTable implements Handler {
|
public class TargetTable extends AbstractTable implements Handler {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class);
|
||||||
private static final String TARGET_PINNED = "targetPinned";
|
private static final String TARGET_PINNED = "targetPinned";
|
||||||
|
|
||||||
private static final long serialVersionUID = -2300392868806614568L;
|
private static final long serialVersionUID = -2300392868806614568L;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class);
|
|
||||||
|
|
||||||
private static final int PROPERTY_DEPT = 3;
|
private static final int PROPERTY_DEPT = 3;
|
||||||
private static final String ITEMID = "itemId";
|
private static final String ITEMID = "itemId";
|
||||||
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
||||||
@@ -141,8 +140,6 @@ public class TargetTable extends AbstractTable implements Handler {
|
|||||||
private ShortcutAction actionSelectAll;
|
private ShortcutAction actionSelectAll;
|
||||||
private ShortcutAction actionUnSelectAll;
|
private ShortcutAction actionUnSelectAll;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected void init() {
|
protected void init() {
|
||||||
@@ -328,38 +325,20 @@ public class TargetTable extends AbstractTable implements Handler {
|
|||||||
(source, itemId, columnId) -> getTagetPollTime(itemId));
|
(source, itemId, columnId) -> getTagetPollTime(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable#
|
|
||||||
* isFirstRowSelectedOnLoad ()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFirstRowSelectedOnLoad() {
|
protected boolean isFirstRowSelectedOnLoad() {
|
||||||
return !managementUIState.getSelectedTargetIdName().isPresent()
|
return !managementUIState.getSelectedTargetIdName().isPresent()
|
||||||
|| managementUIState.getSelectedTargetIdName().get().isEmpty();
|
|| managementUIState.getSelectedTargetIdName().get().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see hawkbit.server.ui.common.table.AbstractTable#getItemIdToSelect()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Object getItemIdToSelect() {
|
protected Object getItemIdToSelect() {
|
||||||
if (managementUIState.getSelectedTargetIdName().isPresent()) {
|
if (managementUIState.getSelectedTargetIdName().isPresent()) {
|
||||||
setCurrentPageFirstItemId(managementUIState.getLastSelectedTargetIdName());
|
|
||||||
return managementUIState.getSelectedTargetIdName().get();
|
return managementUIState.getSelectedTargetIdName().get();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#onValueChange()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onValueChange() {
|
protected void onValueChange() {
|
||||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||||
@@ -379,23 +358,11 @@ public class TargetTable extends AbstractTable implements Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#isMaximized()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isMaximized() {
|
protected boolean isMaximized() {
|
||||||
return managementUIState.isTargetTableMaximized();
|
return managementUIState.isTargetTableMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see hawkbit.server.ui.common.table.AbstractTable#getTableVisibleColumns
|
|
||||||
* ()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TableColumn> getTableVisibleColumns() {
|
protected List<TableColumn> getTableVisibleColumns() {
|
||||||
final List<TableColumn> columnList = new ArrayList<>();
|
final List<TableColumn> columnList = new ArrayList<>();
|
||||||
@@ -452,13 +419,29 @@ public class TargetTable extends AbstractTable implements Handler {
|
|||||||
} else {
|
} else {
|
||||||
shouldRefreshTargets = true;
|
shouldRefreshTargets = true;
|
||||||
}
|
}
|
||||||
unselect(targetIdName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldRefreshTargets) {
|
if (shouldRefreshTargets) {
|
||||||
refreshOnDelete();
|
refreshOnDelete();
|
||||||
} else {
|
} else {
|
||||||
targetContainer.commit();
|
targetContainer.commit();
|
||||||
selectRow();
|
}
|
||||||
|
reSelectItemsAfterDeletionEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reSelectItemsAfterDeletionEvent() {
|
||||||
|
Set<Object> values = new HashSet<>();
|
||||||
|
if (isMultiSelect()) {
|
||||||
|
values = new HashSet<>((Set<?>) getValue());
|
||||||
|
} else {
|
||||||
|
values.add(getValue());
|
||||||
|
}
|
||||||
|
unSelectAll();
|
||||||
|
|
||||||
|
for (final Object value : values) {
|
||||||
|
if (getVisibleItemIds().contains(value)) {
|
||||||
|
select(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,9 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.EntityEvent;
|
import org.eclipse.hawkbit.eventbus.event.EntityEvent;
|
||||||
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
|
|
||||||
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
|
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
|
||||||
|
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
@@ -38,7 +30,6 @@ import org.springframework.security.web.context.HttpSessionSecurityContextReposi
|
|||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
import org.vaadin.spring.events.EventBus.SessionEventBus;
|
import org.vaadin.spring.events.EventBus.SessionEventBus;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.common.eventbus.AllowConcurrentEvents;
|
import com.google.common.eventbus.AllowConcurrentEvents;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.vaadin.server.VaadinSession;
|
import com.vaadin.server.VaadinSession;
|
||||||
@@ -73,12 +64,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
|
|
||||||
private ScheduledFuture<?> jobHandle;
|
private ScheduledFuture<?> jobHandle;
|
||||||
|
|
||||||
/**
|
private final UIEventProvider eventProvider;
|
||||||
* only events defined in the set are dispatched to the session event bus.
|
|
||||||
*/
|
|
||||||
private static final Set<Class<?>> UI_EVENTS = Sets.newHashSet(TargetInfoUpdateEvent.class,
|
|
||||||
TargetCreatedEvent.class, TargetDeletedEvent.class, RolloutChangeEvent.class, RolloutGroupChangeEvent.class,
|
|
||||||
TargetTagCreatedBulkEvent.class, DistributionSetTagCreatedBulkEvent.class,TargetTagDeletedEvent.class,DistributionSetTagDeletedEvent.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -90,9 +76,10 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
* back-end
|
* back-end
|
||||||
*/
|
*/
|
||||||
public DelayedEventBusPushStrategy(final SessionEventBus eventBus,
|
public DelayedEventBusPushStrategy(final SessionEventBus eventBus,
|
||||||
final com.google.common.eventbus.EventBus systemEventBus) {
|
final com.google.common.eventbus.EventBus systemEventBus, final UIEventProvider eventProvider) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.systemEventBus = systemEventBus;
|
this.systemEventBus = systemEventBus;
|
||||||
|
this.eventProvider = eventProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,12 +94,22 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
@AllowConcurrentEvents
|
@AllowConcurrentEvents
|
||||||
public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) {
|
public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) {
|
||||||
// to dispatch too many events which are not interested on the UI
|
// to dispatch too many events which are not interested on the UI
|
||||||
if (UI_EVENTS.contains(event.getClass()) && !queue.offer(event)) {
|
if (!isEventProvided(event)) {
|
||||||
|
LOG.trace("Event is not supported in the UI!!! Dropped event is {}", event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!queue.offer(event)) {
|
||||||
LOG.warn("Deque limit is reached, cannot add more events!!! Dropped event is {}", event);
|
LOG.warn("Deque limit is reached, cannot add more events!!! Dropped event is {}", event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEventProvided(final org.eclipse.hawkbit.eventbus.event.Event event) {
|
||||||
|
return eventProvider.getSingleEvents().contains(event.getClass())
|
||||||
|
|| eventProvider.getBulkEvents().contains(event.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final UI vaadinUI) {
|
public void init(final UI vaadinUI) {
|
||||||
LOG.debug("Initialize delayed event push strategy");
|
LOG.debug("Initialize delayed event push strategy");
|
||||||
@@ -208,37 +205,43 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
final SecurityContext oldContext = SecurityContextHolder.getContext();
|
final SecurityContext oldContext = SecurityContextHolder.getContext();
|
||||||
try {
|
try {
|
||||||
SecurityContextHolder.setContext(userContext);
|
SecurityContextHolder.setContext(userContext);
|
||||||
|
|
||||||
vaadinUI.access(() -> {
|
vaadinUI.access(() -> {
|
||||||
if (vaadinSession.getState() != State.OPEN) {
|
if (vaadinSession.getState() != State.OPEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fowardEvents(events, userContext);
|
fowardSingleEvents(events, userContext);
|
||||||
|
fowardBulkEvents(events, userContext);
|
||||||
// send a list of events, because ui performance issues
|
|
||||||
publishEventAsList(events, userContext, TargetInfoUpdateEvent.class);
|
|
||||||
publishEventAsList(events, userContext, TargetCreatedEvent.class);
|
|
||||||
publishEventAsList(events, userContext, TargetDeletedEvent.class);
|
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
SecurityContextHolder.setContext(oldContext);
|
SecurityContextHolder.setContext(oldContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publishEventAsList(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
private void fowardBulkEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||||
final SecurityContext userContext, final Class<?> eventType) {
|
final SecurityContext userContext) {
|
||||||
final List<org.eclipse.hawkbit.eventbus.event.Event> bulkEvents = events.stream()
|
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
||||||
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
publishBulkEvent(events, userContext, filterBulkEvenTypes);
|
||||||
&& eventType.isInstance(event))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (bulkEvents.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
eventBus.publish(vaadinUI, bulkEvents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fowardEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
private void publishBulkEvent(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||||
|
final SecurityContext userContext, final Set<Class<?>> filterBulkEvenTypes) {
|
||||||
|
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
||||||
|
final List<org.eclipse.hawkbit.eventbus.event.Event> listBulkEvents = events.stream()
|
||||||
|
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
||||||
|
&& bulkType.isInstance(event))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (!listBulkEvents.isEmpty()) {
|
||||||
|
eventBus.publish(vaadinUI, listBulkEvents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fowardSingleEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||||
final SecurityContext userContext) {
|
final SecurityContext userContext) {
|
||||||
events.stream().filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event))
|
events.stream()
|
||||||
|
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
||||||
|
&& eventProvider.getSingleEvents().contains(event.getClass()))
|
||||||
.forEach(event -> eventBus.publish(vaadinUI, event));
|
.forEach(event -> eventBus.publish(vaadinUI, event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user