Fixed import and sonar issues
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
|
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
|
||||||
import org.springframework.retry.support.RetryTemplate;
|
import org.springframework.retry.support.RetryTemplate;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The spring AMQP configuration to use a AMQP for communication with SP update
|
* The spring AMQP configuration to use a AMQP for communication with SP update
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.model;
|
package org.eclipse.hawkbit.repository.jpa.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CollectionTable;
|
import javax.persistence.CollectionTable;
|
||||||
@@ -136,11 +136,10 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void addMessage(final String message) {
|
public final void addMessage(final String message) {
|
||||||
if (messages == null) {
|
|
||||||
messages = new LinkedList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
if (messages == null) {
|
||||||
|
messages = new ArrayList<>((message.length() / 512) + 1);
|
||||||
|
}
|
||||||
Splitter.fixedLength(512).split(message).forEach(messages::add);
|
Splitter.fixedLength(512).split(message).forEach(messages::add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public JpaDistributionSet() {
|
public JpaDistributionSet() {
|
||||||
super();
|
// Default constructor for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,15 +252,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
modules = new HashSet<>();
|
modules = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we cannot allow that modules are added without a type defined
|
checkTypeCompatability(softwareModule);
|
||||||
if (type == null) {
|
|
||||||
throw new DistributionSetTypeUndefinedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if it is allowed to such a module to this DS type
|
|
||||||
if (!type.containsModuleType(softwareModule.getType())) {
|
|
||||||
throw new UnsupportedSoftwareModuleForThisDistributionSetException();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Optional<SoftwareModule> found = modules.stream()
|
final Optional<SoftwareModule> found = modules.stream()
|
||||||
.filter(module -> module.getId().equals(softwareModule.getId())).findFirst();
|
.filter(module -> module.getId().equals(softwareModule.getId())).findFirst();
|
||||||
@@ -286,6 +278,18 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkTypeCompatability(final SoftwareModule softwareModule) {
|
||||||
|
// we cannot allow that modules are added without a type defined
|
||||||
|
if (type == null) {
|
||||||
|
throw new DistributionSetTypeUndefinedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if it is allowed to such a module to this DS type
|
||||||
|
if (!type.containsModuleType(softwareModule.getType())) {
|
||||||
|
throw new UnsupportedSoftwareModuleForThisDistributionSetException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeModule(final SoftwareModule softwareModule) {
|
public boolean removeModule(final SoftwareModule softwareModule) {
|
||||||
if (modules == null) {
|
if (modules == null) {
|
||||||
|
|||||||
@@ -130,18 +130,26 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areModuleEntriesIdentical(final DistributionSetType dsType) {
|
public boolean areModuleEntriesIdentical(final DistributionSetType dsType) {
|
||||||
if (!(dsType instanceof JpaDistributionSetType)) {
|
if (!(dsType instanceof JpaDistributionSetType) || isOneModuleListEmpty(dsType)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (CollectionUtils.isEmpty(elements)
|
} else if (areBothModuleListsEmpty(dsType)) {
|
||||||
&& CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements)) {
|
|
||||||
return true;
|
return true;
|
||||||
} else if (CollectionUtils.isEmpty(elements)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HashSet<DistributionSetTypeElement>(((JpaDistributionSetType) dsType).elements).equals(elements);
|
return new HashSet<DistributionSetTypeElement>(((JpaDistributionSetType) dsType).elements).equals(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isOneModuleListEmpty(final DistributionSetType dsType) {
|
||||||
|
return (!CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements)
|
||||||
|
&& CollectionUtils.isEmpty(elements))
|
||||||
|
|| (CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements)
|
||||||
|
&& !CollectionUtils.isEmpty(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean areBothModuleListsEmpty(final DistributionSetType dsType) {
|
||||||
|
return CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements) && CollectionUtils.isEmpty(elements);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DistributionSetType addOptionalModuleType(final SoftwareModuleType smType) {
|
public DistributionSetType addOptionalModuleType(final SoftwareModuleType smType) {
|
||||||
if (elements == null) {
|
if (elements == null) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.model;
|
package org.eclipse.hawkbit.repository.jpa.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -90,7 +91,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
|||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public JpaSoftwareModule() {
|
public JpaSoftwareModule() {
|
||||||
|
// Default constructor for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +122,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
|||||||
@Override
|
@Override
|
||||||
public void addArtifact(final LocalArtifact artifact) {
|
public void addArtifact(final LocalArtifact artifact) {
|
||||||
if (null == artifacts) {
|
if (null == artifacts) {
|
||||||
artifacts = new LinkedList<>();
|
artifacts = new ArrayList<>(4);
|
||||||
artifacts.add(artifact);
|
artifacts.add(artifact);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
|||||||
@CascadeOnDelete
|
@CascadeOnDelete
|
||||||
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST })
|
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST })
|
||||||
@JoinColumn(name = "target_Id", insertable = false, updatable = false)
|
@JoinColumn(name = "target_Id", insertable = false, updatable = false)
|
||||||
private final List<RolloutTargetGroup> rolloutTargetGroup = new ArrayList<>();
|
private List<RolloutTargetGroup> rolloutTargetGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -166,6 +165,14 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RolloutTargetGroup> getRolloutTargetGroup() {
|
||||||
|
if (rolloutTargetGroup == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.unmodifiableList(rolloutTargetGroup);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addTag(final TargetTag tag) {
|
public boolean addTag(final TargetTag tag) {
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
tags = new HashSet<>();
|
tags = new HashSet<>();
|
||||||
@@ -201,7 +208,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
|||||||
|
|
||||||
public boolean addAction(final Action action) {
|
public boolean addAction(final Action action) {
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
actions = new LinkedList<>();
|
actions = new ArrayList<>(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions.add(action);
|
return actions.add(action);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
|||||||
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
|||||||
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
|
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
|
||||||
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
|
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.data.util.IndexedContainer;
|
import com.vaadin.data.util.IndexedContainer;
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
|||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
|
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||||
@@ -36,7 +36,7 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
|||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon;
|
|||||||
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
|
||||||
import org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout;
|
import org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent;
|
import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Maps;
|
|
||||||
import com.vaadin.data.Container.ItemSetChangeEvent;
|
import com.vaadin.data.Container.ItemSetChangeEvent;
|
||||||
import com.vaadin.data.Container.ItemSetChangeListener;
|
import com.vaadin.data.Container.ItemSetChangeListener;
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.Transferable;
|
import com.vaadin.event.Transferable;
|
||||||
|
|||||||
@@ -240,11 +240,10 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
private void fowardBulkEvents(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 SecurityContext userContext) {
|
||||||
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
||||||
publishBulkEvent(events, userContext, filterBulkEvenTypes);
|
|
||||||
|
|
||||||
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
||||||
final List<org.eclipse.hawkbit.eventbus.event.Event> listBulkEvents = events.stream()
|
final List<org.eclipse.hawkbit.eventbus.event.Event> listBulkEvents = events.stream()
|
||||||
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
|
||||||
&& bulkType.isInstance(event))
|
&& bulkType.isInstance(event))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (!listBulkEvents.isEmpty()) {
|
if (!listBulkEvents.isEmpty()) {
|
||||||
@@ -253,15 +252,10 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publishBulkEvent(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
|
||||||
final SecurityContext userContext, final Set<Class<?>> filterBulkEvenTypes) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fowardSingleEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
private void fowardSingleEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
|
||||||
final SecurityContext userContext) {
|
final SecurityContext userContext) {
|
||||||
events.stream()
|
events.stream()
|
||||||
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
|
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
|
||||||
&& eventProvider.getSingleEvents().contains(event.getClass()))
|
&& eventProvider.getSingleEvents().contains(event.getClass()))
|
||||||
.forEach(event -> eventBus.publish(vaadinUI, event));
|
.forEach(event -> eventBus.publish(vaadinUI, event));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user