Fix rollouts status cache eviction and NPE in UI (#530)

* Fix nullpointer in UI and rollout cache invalidation prob.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Sonar issue and util usage.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Evict cache on tenant delete.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-06-01 20:08:47 +02:00
committed by GitHub
parent 67a4677ef6
commit 672d4270d7
17 changed files with 86 additions and 60 deletions

View File

@@ -19,7 +19,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.util.StringUtils;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon;
@@ -28,6 +27,8 @@ import org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent;
import com.google.common.base.Strings;
@@ -359,7 +360,7 @@ public class CommonDialogWindow extends Window {
}
private static Object emptyToNull(final Collection<?> c) {
return (c == null || c.isEmpty()) ? null : c;
return CollectionUtils.isEmpty(c) ? null : c;
}
private boolean hasNullValidator(final Component component) {

View File

@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item;
@@ -156,10 +157,10 @@ public class SoftwareModuleDetailsTable extends Table {
final Set<SoftwareModuleType> swModuleMandatoryTypes = distributionSet.getType().getMandatoryModuleTypes();
final Set<SoftwareModuleType> swModuleOptionalTypes = distributionSet.getType().getOptionalModuleTypes();
if (swModuleMandatoryTypes != null && !swModuleMandatoryTypes.isEmpty()) {
if (!CollectionUtils.isEmpty(swModuleMandatoryTypes)) {
swModuleMandatoryTypes.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet));
}
if (swModuleOptionalTypes != null && !swModuleOptionalTypes.isEmpty()) {
if (!CollectionUtils.isEmpty(swModuleOptionalTypes)) {
swModuleOptionalTypes.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet));
}
}

View File

@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.springframework.util.CollectionUtils;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
@@ -99,7 +100,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId,
new PageRequest(0, MAX_METADATA_QUERY))
.getContent();
if (null != swMetadataList && !swMetadataList.isEmpty()) {
if (!CollectionUtils.isEmpty(swMetadataList)) {
swMetadataList.forEach(this::setSWMetadataProperties);
}
}

View File

@@ -606,11 +606,14 @@ public abstract class AbstractGrid<T extends Indexed> extends Grid implements Re
@Override
public String getStyle(final CellReference cellReference) {
if (Arrays.stream(center).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
if (center != null
&& Arrays.stream(center).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
return "centeralign";
} else if (Arrays.stream(right).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
} else if (right != null
&& Arrays.stream(right).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
return "rightalign";
} else if (Arrays.stream(left).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
} else if (left != null
&& Arrays.stream(left).anyMatch(o -> Objects.equals(o, cellReference.getPropertyId()))) {
return "leftalign";
}
return null;

View File

@@ -38,6 +38,7 @@ import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.springframework.util.CollectionUtils;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -388,7 +389,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
if (null != typeNameValue && null != typeKeyValue && null != itemIds && !itemIds.isEmpty()) {
if (null != typeNameValue && null != typeKeyValue && !CollectionUtils.isEmpty(itemIds)) {
final List<Long> mandatory = itemIds.stream()
.filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
@@ -429,8 +430,8 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final DistributionSetTypeUpdate update = entityFactory.distributionSetType().update(existingType.getId())
.description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
if (distributionSetTypeManagement.countDistributionSetsByType(existingType.getId()) <= 0 && null != itemIds
&& !itemIds.isEmpty()) {
if (distributionSetTypeManagement.countDistributionSetsByType(existingType.getId()) <= 0
&& !CollectionUtils.isEmpty(itemIds)) {
update.mandatory(itemIds.stream().filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
.collect(Collectors.toList()))

View File

@@ -38,6 +38,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -324,8 +325,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) {
if (null != manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
if (!CollectionUtils.isEmpty(manageDistUIState.getSelectedDeleteSWModuleTypes())
&& manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
}
@@ -420,8 +420,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final DistributionSetIdName distId = (DistributionSetIdName) ((Button) event.getComponent()).getData();
if (null != manageDistUIState.getDeletedDistributionList()
&& !manageDistUIState.getDeletedDistributionList().isEmpty()
if (!CollectionUtils.isEmpty(manageDistUIState.getDeletedDistributionList())
&& manageDistUIState.getDeletedDistributionList().contains(distId)) {
manageDistUIState.getDeletedDistributionList().remove(distId);
}
@@ -509,8 +508,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistTypeDelete(final String discardDSType, final Object itemId, final ConfirmationTab tab) {
if (null != manageDistUIState.getSelectedDeleteDistSetTypes()
&& !manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
if (!CollectionUtils.isEmpty(manageDistUIState.getSelectedDeleteDistSetTypes())
&& manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
}