Fixed import and sonar issues

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-09-20 18:30:31 +02:00
parent ca23b6e1b8
commit 1000ca3d19
12 changed files with 56 additions and 43 deletions

View File

@@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
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

View File

@@ -8,8 +8,8 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.CollectionTable;
@@ -136,11 +136,10 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
@Override
public final void addMessage(final String message) {
if (messages == null) {
messages = new LinkedList<>();
}
if (message != null) {
if (messages == null) {
messages = new ArrayList<>((message.length() / 512) + 1);
}
Splitter.fixedLength(512).split(message).forEach(messages::add);
}
}

View File

@@ -119,7 +119,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
* Default constructor.
*/
public JpaDistributionSet() {
super();
// Default constructor for JPA
}
/**
@@ -252,15 +252,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
modules = new HashSet<>();
}
// 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();
}
checkTypeCompatability(softwareModule);
final Optional<SoftwareModule> found = modules.stream()
.filter(module -> module.getId().equals(softwareModule.getId())).findFirst();
@@ -286,6 +278,18 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
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
public boolean removeModule(final SoftwareModule softwareModule) {
if (modules == null) {

View File

@@ -130,18 +130,26 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
@Override
public boolean areModuleEntriesIdentical(final DistributionSetType dsType) {
if (!(dsType instanceof JpaDistributionSetType)) {
if (!(dsType instanceof JpaDistributionSetType) || isOneModuleListEmpty(dsType)) {
return false;
} else if (CollectionUtils.isEmpty(elements)
&& CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements)) {
} else if (areBothModuleListsEmpty(dsType)) {
return true;
} else if (CollectionUtils.isEmpty(elements)) {
return false;
}
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
public DistributionSetType addOptionalModuleType(final SoftwareModuleType smType) {
if (elements == null) {

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -90,7 +91,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
* Default constructor.
*/
public JpaSoftwareModule() {
// Default constructor for JPA
}
/**
@@ -121,7 +122,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Override
public void addArtifact(final LocalArtifact artifact) {
if (null == artifacts) {
artifacts = new LinkedList<>();
artifacts = new ArrayList<>(4);
artifacts.add(artifact);
return;
}

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -116,7 +115,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
@CascadeOnDelete
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST })
@JoinColumn(name = "target_Id", insertable = false, updatable = false)
private final List<RolloutTargetGroup> rolloutTargetGroup = new ArrayList<>();
private List<RolloutTargetGroup> rolloutTargetGroup;
/**
* Constructor.
@@ -166,6 +165,14 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
return tags;
}
public List<RolloutTargetGroup> getRolloutTargetGroup() {
if (rolloutTargetGroup == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(rolloutTargetGroup);
}
public boolean addTag(final TargetTag tag) {
if (tags == null) {
tags = new HashSet<>();
@@ -201,7 +208,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
public boolean addAction(final Action action) {
if (actions == null) {
actions = new LinkedList<>();
actions = new ArrayList<>(4);
}
return actions.add(action);

View File

@@ -15,7 +15,7 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
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.ViewScope;
import com.vaadin.ui.Component;

View File

@@ -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.ConfirmationTab;
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.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
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.Item;
import com.vaadin.data.util.IndexedContainer;

View File

@@ -24,11 +24,11 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
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.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
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.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.Item;
import com.vaadin.event.dd.DragAndDropEvent;

View File

@@ -27,13 +27,13 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon;
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
import org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout;
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.UIComponentIdProvider;
import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
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.ItemSetChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;

View File

@@ -30,8 +30,8 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.event.Transferable;

View File

@@ -240,11 +240,10 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
private void fowardBulkEvents(final List<org.eclipse.hawkbit.eventbus.event.Event> events,
final SecurityContext userContext) {
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
publishBulkEvent(events, userContext, filterBulkEvenTypes);
for (final Class<?> bulkType : filterBulkEvenTypes) {
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))
.collect(Collectors.toList());
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,
final SecurityContext userContext) {
events.stream()
.filter(event -> DelayedEventBusPushStrategy.this.eventSecurityCheck(userContext, event)
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
&& eventProvider.getSingleEvents().contains(event.getClass()))
.forEach(event -> eventBus.publish(vaadinUI, event));
}