Skip to content

Commit

Permalink
Split repository API for module and DS management. Refactor utility u…
Browse files Browse the repository at this point in the history
…sage (eclipse-hawkbit#524)

* Split DS management and reduce util usage.

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

* Split sw module and type management.

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

* Sonar issues.

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

* Make sonar listen to the exception!

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

* Register both beans.

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

* Split JPA implementations.

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

* Revert user details change.

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

* Fix compilation errors.

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

* Fix bean queries. Fix image path.

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

* Document preferred utility usage.

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

* Fix exmaples and revert unintended checkin.

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

* Code cleanup.

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

* Typos, readibility.

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

* Remove unused reference.

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

* Rollouts cache delete aware.

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

* Fix rolloutgroup delete event.

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

* Add new RolloutGroupDeletedEvent event

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
  • Loading branch information
kaizimmerm authored Jun 1, 2017
1 parent f9af7fe commit d23fa00
Show file tree
Hide file tree
Showing 203 changed files with 2,738 additions and 2,320 deletions.
1 change: 1 addition & 0 deletions 3rd-dependencies/Release_0_2_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

| Group ID | Artifact ID | Version | CQ |
|---|---|---|---|
|com.github.ben-manes.caffeine|caffeine|2.3.5| [CQ13563](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13563) |
|aopalliance|aopalliance|1.0| [CQ10346](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10346) |
|ch.qos.logback|logback-classic|1.1.3| [CQ10347](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10347) |
|ch.qos.logback|logback-core|1.1.3| [CQ12925](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12925) |
Expand Down
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ Please read this if you intend to contribute to the project.
* Sonarqube:
* Our rule set can be found [here](https://sonar.ops.bosch-iot-rollouts.com/projects) with navigating to the tab "Quality Profiles", selecting "hawkBit", and then selecting "Actions" - "Back up"

### Utility library usage

hawkBit has currently both [guava](https://github.com/google/guava) and [Apache commons lang](https://commons.apache.org/proper/commons-lang/) on the classpath in several of its modules. However, we see introducing too many utility libraries problematic as we force these as transitive dependencies on hawkBit users. We in fact are looking into reducing them in future not adding new ones.

So we kindly ask contributors:

* not introduce extra utility library dependencies
* keep them out of the core modules (e.g. hawkbit-core, hawkbit-rest-core, hawkbit-http-security) to avoid that all modules have them as transitive dependency
* use utility functions in general based in the following priority:
* use utility functions from JDK if feasible
* use Spring utility classes if feasible
* use [guava](https://github.com/google/guava) if feasible
* use [Apache commons lang](https://commons.apache.org/proper/commons-lang/) if feasible

Note that the guava project for instance often documents where they think that JDK is having a similar functionality (e.g. their thoughts on [Throwables.propagate](https://github.com/google/guava/wiki/Why-we-deprecated-Throwables.propagate)).

Examples:

* Prefer `Arrays.asList(...)` from JDK over guava's `Lists.newArrayList(...)`
* Prefer `StringUtils` from Spring over guava's `Strings` Apache's `StringUtils`

### Test documentation

Please documented the test cases that you contribute by means of [Allure](http://allure.qatools.ru) annotations and proper test method naming.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.simulator.amqp;

import java.util.Arrays;
import java.util.Map;

import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
Expand All @@ -27,8 +28,6 @@
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import com.google.common.collect.Lists;

/**
* Handle all incoming Messages from hawkBit update server.
*
Expand Down Expand Up @@ -133,7 +132,7 @@ private void handleCancelDownloadAction(final Message message, final String thin
final Long actionId = convertMessage(message, Long.class);

final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
spSenderService.finishUpdateProcess(update, Lists.newArrayList("Simulation canceled"));
spSenderService.finishUpdateProcess(update, Arrays.asList("Simulation canceled"));
}

private void handleUpdateProcess(final Message message, final String thingId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.simulator.ui;

import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;

Expand All @@ -23,7 +24,6 @@
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
import org.springframework.beans.factory.annotation.Autowired;

import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.vaadin.data.util.BeanContainer;
Expand Down Expand Up @@ -93,7 +93,7 @@ public class SimulatorView extends VerticalLayout implements View {
private final HorizontalLayout toolbar = new HorizontalLayout();
private final Grid grid = new Grid();
private final ComboBox responseComboBox = new ComboBox("",
Lists.newArrayList(ResponseStatus.SUCCESSFUL, ResponseStatus.ERROR));
Arrays.asList(ResponseStatus.SUCCESSFUL, ResponseStatus.ERROR));

private BeanContainer<String, AbstractSimulatedDevice> beanContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment;

import com.google.common.collect.Lists;

/**
* Builder pattern for building {@link MgmtDistributionSetRequestBodyPost}.
*/
Expand Down Expand Up @@ -84,7 +83,7 @@ public DistributionSetBuilder description(final String description) {
* @return a single entry list of {@link MgmtDistributionSetRequestBodyPost}
*/
public List<MgmtDistributionSetRequestBodyPost> build() {
return Lists.newArrayList(doBuild(""));
return Arrays.asList(doBuild(""));
}

/**
Expand Down Expand Up @@ -114,7 +113,7 @@ public List<MgmtDistributionSetRequestBodyPost> buildAsList(final int count) {
* @return a list of {@link MgmtDistributionSetRequestBodyPost}
*/
public List<MgmtDistributionSetRequestBodyPost> buildAsList(final int offset, final int count) {
final ArrayList<MgmtDistributionSetRequestBodyPost> bodyList = Lists.newArrayList();
final List<MgmtDistributionSetRequestBodyPost> bodyList = new ArrayList<>();
for (int index = offset; index < count + offset; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment;

import com.google.common.collect.Lists;

/**
*
* Builder pattern for building {@link MgmtDistributionSetTypeRequestBodyPost}.
Expand All @@ -28,8 +27,8 @@ public class DistributionSetTypeBuilder {
private String key;
private String name;
private String description;
private final List<MgmtSoftwareModuleTypeAssigment> mandatorymodules = Lists.newArrayList();
private final List<MgmtSoftwareModuleTypeAssigment> optionalmodules = Lists.newArrayList();
private final List<MgmtSoftwareModuleTypeAssigment> mandatorymodules = new ArrayList<>();
private final List<MgmtSoftwareModuleTypeAssigment> optionalmodules = new ArrayList<>();

/**
* @param key
Expand Down Expand Up @@ -101,7 +100,7 @@ public DistributionSetTypeBuilder optionalmodules(final Long... softwareModuleTy
* {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtDistributionSetTypeRequestBodyPost> build() {
return Lists.newArrayList(doBuild(""));
return Arrays.asList(doBuild(""));
}

/**
Expand All @@ -116,7 +115,7 @@ public List<MgmtDistributionSetTypeRequestBodyPost> build() {
* @return a list of {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtDistributionSetTypeRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtDistributionSetTypeRequestBodyPost> bodyList = Lists.newArrayList();
final List<MgmtDistributionSetTypeRequestBodyPost> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;

import com.google.common.collect.Lists;

/**
*
* Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}.
Expand Down Expand Up @@ -90,7 +89,7 @@ public SoftwareModuleBuilder description(final String description) {
* @return a single entry list of {@link MgmtSoftwareModuleRequestBodyPost}
*/
public List<MgmtSoftwareModuleRequestBodyPost> build() {
return Lists.newArrayList(doBuild(""));
return Arrays.asList(doBuild(""));
}

/**
Expand All @@ -104,7 +103,7 @@ public List<MgmtSoftwareModuleRequestBodyPost> build() {
* @return a list of {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtSoftwareModuleRequestBodyPost> bodyList = Lists.newArrayList();
final List<MgmtSoftwareModuleRequestBodyPost> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;

import com.google.common.collect.Lists;

/**
*
* Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}.
Expand Down Expand Up @@ -79,7 +78,7 @@ public SoftwareModuleTypeBuilder maxAssignments(final int maxAssignments) {
* {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleTypeRequestBodyPost> build() {
return Lists.newArrayList(doBuild(""));
return Arrays.asList(doBuild(""));
}

/**
Expand All @@ -93,7 +92,7 @@ public List<MgmtSoftwareModuleTypeRequestBodyPost> build() {
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleTypeRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtSoftwareModuleTypeRequestBodyPost> bodyList = Lists.newArrayList();
final List<MgmtSoftwareModuleTypeRequestBodyPost> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;

import com.google.common.collect.Lists;

/**
* Builder pattern for building {@link MgmtTagRequestBodyPut}.
*
Expand Down Expand Up @@ -64,7 +63,7 @@ public TagBuilder color(final String color) {
* @return a single entry list of {@link MgmtTagRequestBodyPut}
*/
public List<MgmtTagRequestBodyPut> build() {
return Lists.newArrayList(doBuild(name));
return Arrays.asList(doBuild(name));
}

/**
Expand All @@ -77,7 +76,7 @@ public List<MgmtTagRequestBodyPut> build() {
* @return a list of {@link MgmtTagRequestBodyPut}
*/
public List<MgmtTagRequestBodyPut> buildAsList(final int count) {
final ArrayList<MgmtTagRequestBodyPut> bodyList = Lists.newArrayList();
final List<MgmtTagRequestBodyPut> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(name + index));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*/
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;

import com.google.common.collect.Lists;

/**
*
* Builder pattern for building {@link MgmtTargetRequestBody}.
Expand Down Expand Up @@ -76,7 +76,7 @@ public TargetBuilder description(final String description) {
* @return a single entry list of {@link MgmtTargetRequestBody}
*/
public List<MgmtTargetRequestBody> build() {
return Lists.newArrayList(doBuild(""));
return Arrays.asList(doBuild(""));
}

/**
Expand Down Expand Up @@ -106,7 +106,7 @@ public List<MgmtTargetRequestBody> buildAsList(final int count) {
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtTargetRequestBody> buildAsList(final int offset, final int count) {
final List<MgmtTargetRequestBody> bodyList = Lists.newArrayList();
final List<MgmtTargetRequestBody> bodyList = new ArrayList<>();
for (int index = offset; index < count + offset; index++) {
bodyList.add(doBuild(String.format("%06d", index)));
}
Expand Down
4 changes: 4 additions & 0 deletions extensions/hawkbit-extension-uaa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions hawkbit-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.protostuff</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,11 @@ public CacheManager directCacheManager() {
*/
public class TenantCacheResolver extends SimpleCacheResolver {

/*
* (non-Javadoc)
*
* @see org.springframework.cache.interceptor.AbstractCacheResolver#
* resolveCaches(org.springframework
* .cache.interceptor.CacheOperationInvocationContext)
*/
@Override
public Collection<Cache> resolveCaches(final CacheOperationInvocationContext<?> context) {
return super.resolveCaches(context).stream().map(TenantCacheWrapper::new).collect(Collectors.toList());
}

/*
* (non-Javadoc)
*
* @see org.springframework.cache.interceptor.SimpleCacheResolver#
* getCacheNames(org.springframework
* .cache.interceptor.CacheOperationInvocationContext)
*/
@Override
protected Collection<String> getCacheNames(final CacheOperationInvocationContext<?> context) {
return super.getCacheNames(context).stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@
import org.vaadin.spring.security.web.authentication.VaadinAuthenticationSuccessHandler;
import org.vaadin.spring.security.web.authentication.VaadinUrlAuthenticationSuccessHandler;

import com.google.common.collect.Lists;

/**
* All configurations related to HawkBit's authentication and authorization
* layer.
Expand Down Expand Up @@ -223,7 +221,7 @@ protected void configure(final HttpSecurity http) throws Exception {

final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
"controllerAnonymousFilter", "anonymous",
Lists.newArrayList(new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS),
Arrays.asList(new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS),
new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_DOWNLOAD_ROLE)));
anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and()
Expand Down
5 changes: 1 addition & 4 deletions hawkbit-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
*/
package org.eclipse.hawkbit.api;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.google.common.collect.Lists;

/**
* Artifact handler properties class for holding all supported protocols with
* host, ip, port and download pattern.
Expand Down Expand Up @@ -85,7 +84,7 @@ public static class UrlProtocol {
/**
* Support for the following hawkBit API.
*/
private List<ApiType> supports = Lists.newArrayList(ApiType.DDI, ApiType.DMF);
private List<ApiType> supports = Arrays.asList(ApiType.DDI, ApiType.DMF);

public boolean isEnabled() {
return enabled;
Expand Down
Loading

0 comments on commit d23fa00

Please sign in to comment.