Merge branch 'master' into feature_rsql_parser_suggestion

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java


Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-09-21 09:14:04 +02:00
173 changed files with 993 additions and 762 deletions

View File

@@ -93,7 +93,7 @@ public class SimulationController {
gatewayToken)); gatewayToken));
} }
return ResponseEntity.ok("Updated " + amount + " DMF connected targets!"); return ResponseEntity.ok("Updated " + amount + " " + protocol + " connected targets!");
} }
private boolean isDmfDisabled() { private boolean isDmfDisabled() {

View File

@@ -32,7 +32,14 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-core</artifactId> <artifactId>spring-cloud-netflix-core</artifactId>
<version>1.0.7.RELEASE</version> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>

View File

@@ -10,12 +10,14 @@ package org.eclipse.hawkbit.feign.core.client;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.LinkedHashMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.feign.support.SpringMvcContract; import org.springframework.cloud.netflix.feign.support.SpringMvcContract;
import feign.MethodMetadata; import feign.MethodMetadata;
import feign.Param;
/** /**
* Own implementation of the {@link SpringMvcContract} which catches the * Own implementation of the {@link SpringMvcContract} which catches the
@@ -38,6 +40,10 @@ public class IgnoreMultipleConsumersProducersSpringMvcContract extends SpringMvc
// multiple consumers and produces, see // multiple consumers and produces, see
// https://github.com/spring-cloud/spring-cloud-netflix/issues/808 // https://github.com/spring-cloud/spring-cloud-netflix/issues/808
LOGGER.trace(e.getMessage(), e); LOGGER.trace(e.getMessage(), e);
// This line from super is mandatory to avoid that access to the
// expander causes a nullpointer.
data.indexToExpander(new LinkedHashMap<Integer, Param.Expander>());
} }
} }
} }

View File

@@ -20,18 +20,6 @@
<name>hawkBit-example :: DDI Feign Client</name> <name>hawkBit-example :: DDI Feign Client</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>1.0.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>

View File

@@ -9,13 +9,12 @@
package org.eclipse.hawkbit.ddi.client.resource; package org.eclipse.hawkbit.ddi.client.resource;
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi; import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi;
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the artifact store controller resource of the DDI-DL API. * Client binding for the artifact store controller resource of the DDI-DL API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiDlRestConstants.ARTIFACTS_V1_REQUEST_MAPPING) @FeignClient(name = "DdiDlArtifactStoreControllerClient", url = "${hawkbit.url:localhost:8080}")
public interface DdiDlArtifactStoreControllerResourceClient extends DdiDlArtifactStoreControllerRestApi { public interface DdiDlArtifactStoreControllerResourceClient extends DdiDlArtifactStoreControllerRestApi {
} }

View File

@@ -8,14 +8,13 @@
*/ */
package org.eclipse.hawkbit.ddi.client.resource; package org.eclipse.hawkbit.ddi.client.resource;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the Rootcontroller resource of the DDI API. * Client binding for the Rootcontroller resource of the DDI API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiRestConstants.BASE_V1_REQUEST_MAPPING) @FeignClient(name = "RootControllerClient", url = "${hawkbit.url:localhost:8080}")
public interface RootControllerResourceClient extends DdiRootControllerRestApi { public interface RootControllerResourceClient extends DdiRootControllerRestApi {
} }

View File

@@ -9,13 +9,12 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the DistributionSet resource of the management API. * Client binding for the DistributionSet resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtDistributionSetClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi { public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi {
} }

View File

@@ -9,12 +9,11 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the DistributionSetTag resource of the management API. * Client binding for the DistributionSetTag resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtDistributionSetTagClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi { public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi {
} }

View File

@@ -9,14 +9,13 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the DistributionSetType resource of the management API. * Client binding for the DistributionSetType resource of the management API.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtDistributionSetTypeClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi { public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi {
} }

View File

@@ -9,14 +9,13 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* A feign-client interface declaration which allows to build a feign-client * A feign-client interface declaration which allows to build a feign-client
* stub. * stub.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtDownloadArtifactClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi { public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi {
} }

View File

@@ -9,12 +9,11 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE) @FeignClient(name = "MgmtDownloadClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtDownloadClientResource extends MgmtDownloadRestApi { public interface MgmtDownloadClientResource extends MgmtDownloadRestApi {
} }

View File

@@ -8,13 +8,12 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the Rollout resource of the management API. * Client binding for the Rollout resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtRolloutClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtRolloutClientResource extends MgmtRolloutRestApi { public interface MgmtRolloutClientResource extends MgmtRolloutRestApi {
} }

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -24,7 +23,7 @@ import feign.Param;
/** /**
* Client binding for the SoftwareModule resource of the management API. * Client binding for the SoftwareModule resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtSoftwareModuleClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi { public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi {
@Override @Override

View File

@@ -8,13 +8,12 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the SoftwareModuleType resource of the management API. * Client binding for the SoftwareModuleType resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtSoftwareModuleTypeClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi { public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi {
} }

View File

@@ -8,7 +8,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
@@ -16,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* Client binding for the {@link MgmtSystemRestApi}. * Client binding for the {@link MgmtSystemRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtSystemClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtSystemClientResource extends MgmtSystemRestApi { public interface MgmtSystemClientResource extends MgmtSystemRestApi {
} }

View File

@@ -8,7 +8,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemManagementRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemManagementRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
@@ -16,7 +15,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* Client binding for the {@link MgmtSystemManagementRestApi}. * Client binding for the {@link MgmtSystemManagementRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SYSTEM_ADMIN_MAPPING) @FeignClient(name = "MgmtSystemManagementClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtSystemManagementClientResource extends MgmtSystemManagementRestApi { public interface MgmtSystemManagementClientResource extends MgmtSystemManagementRestApi {
} }

View File

@@ -8,13 +8,12 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the Target resource of the management API. * Client binding for the Target resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtTargetClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtTargetClientResource extends MgmtTargetRestApi { public interface MgmtTargetClientResource extends MgmtTargetRestApi {
} }

View File

@@ -8,13 +8,12 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the TargetTag resource of the management API. * Client binding for the TargetTag resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) @FeignClient(name = "MgmtTargetTagClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi { public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi {
} }

View File

@@ -42,40 +42,12 @@
</plugins> </plugins>
</build> </build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>1.0.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-example-mgmt-feign-client</artifactId> <artifactId>hawkbit-example-mgmt-feign-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-core</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<artifactId>hibernate-validator</artifactId>
<groupId>org.hibernate</groupId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>

View File

@@ -17,9 +17,8 @@ import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetClientResource;
import org.eclipse.hawkbit.mgmt.client.scenarios.ConfigurableScenario; import org.eclipse.hawkbit.mgmt.client.scenarios.ConfigurableScenario;
import org.eclipse.hawkbit.mgmt.client.scenarios.CreateStartedRolloutExample; import org.eclipse.hawkbit.mgmt.client.scenarios.CreateStartedRolloutExample;
import org.eclipse.hawkbit.mgmt.client.scenarios.upload.FeignMultipartEncoder; import org.eclipse.hawkbit.mgmt.client.scenarios.upload.FeignMultipartEncoder;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.Banner.Mode;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -49,9 +48,6 @@ import feign.slf4j.Slf4jLogger;
@Import(FeignClientConfiguration.class) @Import(FeignClientConfiguration.class)
public class Application implements CommandLineRunner { public class Application implements CommandLineRunner {
@Autowired
private ClientConfigurationProperties configuration;
@Autowired @Autowired
private ConfigurableScenario configuredScenario; private ConfigurableScenario configuredScenario;
@@ -59,7 +55,7 @@ public class Application implements CommandLineRunner {
private CreateStartedRolloutExample gettingStartedRolloutScenario; private CreateStartedRolloutExample gettingStartedRolloutScenario;
public static void main(final String[] args) { public static void main(final String[] args) {
new SpringApplicationBuilder().showBanner(false).sources(Application.class).run(args); new SpringApplicationBuilder().bannerMode(Mode.OFF).sources(Application.class).run(args);
} }
@Override @Override
@@ -74,18 +70,18 @@ public class Application implements CommandLineRunner {
} }
@Bean @Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() { public BasicAuthRequestInterceptor basicAuthRequestInterceptor(final ClientConfigurationProperties configuration) {
return new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword()); return new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword());
} }
@Bean @Bean
public ConfigurableScenario configurableScenario(final MgmtDistributionSetClientResource distributionSetResource, public ConfigurableScenario configurableScenario(final MgmtDistributionSetClientResource distributionSetResource,
@Qualifier("mgmtSoftwareModuleClientResource") final MgmtSoftwareModuleClientResource softwareModuleResource, final MgmtSoftwareModuleClientResource softwareModuleResource,
@Qualifier("uploadSoftwareModule") final MgmtSoftwareModuleClientResource uploadSoftwareModule,
final MgmtTargetClientResource targetResource, final MgmtRolloutClientResource rolloutResource, final MgmtTargetClientResource targetResource, final MgmtRolloutClientResource rolloutResource,
final ClientConfigurationProperties clientConfigurationProperties) { final ClientConfigurationProperties clientConfigurationProperties) {
return new ConfigurableScenario(distributionSetResource, softwareModuleResource, uploadSoftwareModule, return new ConfigurableScenario(distributionSetResource, softwareModuleResource,
targetResource, rolloutResource, clientConfigurationProperties); uploadSoftwareModule(clientConfigurationProperties), targetResource, rolloutResource,
clientConfigurationProperties);
} }
@Bean @Bean
@@ -94,23 +90,21 @@ public class Application implements CommandLineRunner {
} }
@Bean @Bean
public Logger.Level feignLoggerLevel() { public MgmtSoftwareModuleClientResource uploadSoftwareModule(final ClientConfigurationProperties configuration) {
return Logger.Level.FULL;
}
@Bean
public MgmtSoftwareModuleClientResource uploadSoftwareModule() {
final ObjectMapper mapper = new ObjectMapper() final ObjectMapper mapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(new Jackson2HalModule()); .registerModule(new Jackson2HalModule());
return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()) return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
.requestInterceptor( .requestInterceptor(
new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword())) new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword()))
.logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder()) .logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder())
.decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))) .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper)))
.target(MgmtSoftwareModuleClientResource.class, .target(MgmtSoftwareModuleClientResource.class, configuration.getUrl());
configuration.getUrl() + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING); }
@Bean
public Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
} }
private static boolean containsArg(final String containsArg, final String... args) { private static boolean containsArg(final String containsArg, final String... args) {

View File

@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
/** /**
* *
@@ -50,18 +49,18 @@ public class ConfigurableScenario {
private final MgmtSoftwareModuleClientResource softwareModuleResource; private final MgmtSoftwareModuleClientResource softwareModuleResource;
private final MgmtSoftwareModuleClientResource uploadSoftwareModule;
private final MgmtTargetClientResource targetResource; private final MgmtTargetClientResource targetResource;
private final MgmtRolloutClientResource rolloutResource; private final MgmtRolloutClientResource rolloutResource;
private final ClientConfigurationProperties clientConfigurationProperties; private final ClientConfigurationProperties clientConfigurationProperties;
private final MgmtSoftwareModuleClientResource uploadSoftwareModule;
public ConfigurableScenario(final MgmtDistributionSetClientResource distributionSetResource, public ConfigurableScenario(final MgmtDistributionSetClientResource distributionSetResource,
@Qualifier("mgmtSoftwareModuleClientResource") final MgmtSoftwareModuleClientResource softwareModuleResource, final MgmtSoftwareModuleClientResource softwareModuleResource,
@Qualifier("uploadSoftwareModule") final MgmtSoftwareModuleClientResource uploadSoftwareModule, final MgmtSoftwareModuleClientResource uploadSoftwareModule, final MgmtTargetClientResource targetResource,
final MgmtTargetClientResource targetResource, final MgmtRolloutClientResource rolloutResource, final MgmtRolloutClientResource rolloutResource,
final ClientConfigurationProperties clientConfigurationProperties) { final ClientConfigurationProperties clientConfigurationProperties) {
this.distributionSetResource = distributionSetResource; this.distributionSetResource = distributionSetResource;
this.softwareModuleResource = softwareModuleResource; this.softwareModuleResource = softwareModuleResource;
@@ -191,7 +190,7 @@ public class ConfigurableScenario {
.type("application").buildAsList(scenario.getAppModulesPerDistributionSet())) .type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
.getBody()); .getBody());
for (int x = 0; x < scenario.getArtifactsPerSM(); x++) { for (int iArtifact = 0; iArtifact < scenario.getArtifactsPerSM(); iArtifact++) {
modules.forEach(module -> { modules.forEach(module -> {
final ArtifactFile file = new ArtifactFile("dummyfile.dummy", null, "multipart/form-data", artifact); final ArtifactFile file = new ArtifactFile("dummyfile.dummy", null, "multipart/form-data", artifact);
uploadSoftwareModule.uploadArtifact(module.getModuleId(), file, null, null, null); uploadSoftwareModule.uploadArtifact(module.getModuleId(), file, null, null, null);
@@ -201,21 +200,6 @@ public class ConfigurableScenario {
return modules; return modules;
} }
private static byte[] generateArtifact(final Scenario scenario) {
// Exception squid:S2245 - not used for cryptographic function
@SuppressWarnings("squid:S2245")
final Random random = new Random();
// create byte array
final byte[] nbyte = new byte[parseSize(scenario.getArtifactSize())];
// put the next byte in the array
random.nextBytes(nbyte);
return nbyte;
}
private void createTargets(final Scenario scenario) { private void createTargets(final Scenario scenario) {
LOGGER.info("Creating {} targets", scenario.getTargets()); LOGGER.info("Creating {} targets", scenario.getTargets());
@@ -239,4 +223,19 @@ public class ConfigurableScenario {
} }
return Integer.valueOf(size); return Integer.valueOf(size);
} }
private static byte[] generateArtifact(final Scenario scenario) {
// Exception squid:S2245 - not used for cryptographic function
@SuppressWarnings("squid:S2245")
final Random random = new Random();
// create byte array
final byte[] nbyte = new byte[parseSize(scenario.getArtifactSize())];
// put the next byte in the array
random.nextBytes(nbyte);
return nbyte;
}
} }

View File

@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
/** /**
* Example for creating and starting a Rollout. * Example for creating and starting a Rollout.
@@ -46,7 +45,6 @@ public class CreateStartedRolloutExample {
private MgmtDistributionSetClientResource distributionSetResource; private MgmtDistributionSetClientResource distributionSetResource;
@Autowired @Autowired
@Qualifier("mgmtSoftwareModuleClientResource")
private MgmtSoftwareModuleClientResource softwareModuleResource; private MgmtSoftwareModuleClientResource softwareModuleResource;
@Autowired @Autowired

View File

@@ -8,7 +8,8 @@
http://www.eclipse.org/legal/epl-v10.html http://www.eclipse.org/legal/epl-v10.html
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@@ -28,33 +29,21 @@
<module>hawkbit-example-ddi-feign-client</module> <module>hawkbit-example-ddi-feign-client</module>
<module>hawkbit-example-mgmt-feign-client</module> <module>hawkbit-example-mgmt-feign-client</module>
<module>hawkbit-example-mgmt-simulator</module> <module>hawkbit-example-mgmt-simulator</module>
</modules> </modules>
<properties>
<feign.version>8.14.2</feign.version>
</properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.netflix.feign</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>feign-core</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
<!-- need to overwrite for the interface inheritance feature of feign-core --> <version>Brixton.SR5</version>
<!-- <version>8.16.0</version> --> <type>pom</type>
<version>${feign.version}</version> <scope>import</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.netflix.feign</groupId> <groupId>com.netflix.feign</groupId>
<artifactId>feign-jackson</artifactId> <artifactId>feign-jackson</artifactId>
<!-- need to overwrite for the interface inheritance feature of feign-core --> <version>8.16.2</version>
<!-- <version>8.16.0</version> -->
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>${feign.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View File

@@ -23,6 +23,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.PatternTopic; import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.Topic; import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Service;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
@@ -32,6 +33,7 @@ import com.google.common.eventbus.Subscribe;
* *
*/ */
@EventSubscriber @EventSubscriber
@Service
public class EventDistributor { public class EventDistributor {
private static final Logger LOGGER = LoggerFactory.getLogger(EventDistributor.class); private static final Logger LOGGER = LoggerFactory.getLogger(EventDistributor.class);

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.eventbus;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.google.common.eventbus.DeadEvent; import com.google.common.eventbus.DeadEvent;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
@@ -22,6 +23,7 @@ import com.google.common.eventbus.Subscribe;
* *
*/ */
@EventSubscriber @EventSubscriber
@Service
public class DeadEventListener { public class DeadEventListener {
private static final Logger LOG = LoggerFactory.getLogger(DeadEventListener.class); private static final Logger LOG = LoggerFactory.getLogger(DeadEventListener.class);

View File

@@ -14,8 +14,6 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.stereotype.Service;
/** /**
* Marks an class as an event subscriber to listen on event on the event bus * Marks an class as an event subscriber to listen on event on the event bus
* without explicit register this class to the event bus. * without explicit register this class to the event bus.
@@ -36,7 +34,6 @@ import org.springframework.stereotype.Service;
*/ */
@Target({ TYPE }) @Target({ TYPE })
@Retention(RUNTIME) @Retention(RUNTIME)
@Service
public @interface EventSubscriber { public @interface EventSubscriber {
} }

View File

@@ -17,6 +17,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.stereotype.Service;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
@@ -56,6 +57,7 @@ public class EventBusSubscriberProcessorTest {
} }
@EventSubscriber @EventSubscriber
@Service
private class TestEventSubscriberClass { private class TestEventSubscriberClass {
@Subscribe @Subscribe
public void subscribe(final String s) { public void subscribe(final String s) {
@@ -64,6 +66,7 @@ public class EventBusSubscriberProcessorTest {
} }
@EventSubscriber @EventSubscriber
@Service
private class TestWrongEventSubscriberClass { private class TestWrongEventSubscriberClass {
public void methodWithoutAnnotation(final String s) { public void methodWithoutAnnotation(final String s) {

View File

@@ -25,7 +25,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -48,7 +47,7 @@ public interface DdiRootControllerRestApi {
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts", produces = { @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE }) "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts( ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
@PathVariable("targetid") final String targetid, @PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId); @PathVariable("softwareModuleId") final Long softwareModuleId);
/** /**
@@ -62,7 +61,8 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json", @RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid); ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid);
/** /**
* Handles GET {@link DdiArtifact} download request. This could be full or * Handles GET {@link DdiArtifact} download request. This could be full or
@@ -84,7 +84,8 @@ public interface DdiRootControllerRestApi {
* {@link HttpStatus#PARTIAL_CONTENT}. * {@link HttpStatus#PARTIAL_CONTENT}.
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}")
ResponseEntity<InputStream> downloadArtifact(@PathVariable("targetid") final String targetid, ResponseEntity<InputStream> downloadArtifact(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName); @PathVariable("fileName") final String fileName);
@@ -107,7 +108,8 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}"
+ DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE) + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid, ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName); @PathVariable("fileName") final String fileName);
@@ -129,7 +131,7 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION @RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction( ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid, @PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId, @PathVariable("actionId") @NotEmpty final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource); @RequestParam(value = "c", required = false, defaultValue = "-1") final int resource);
@@ -150,8 +152,9 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/" @RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/"
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, ResponseEntity<Void> postBasedeploymentActionFeedback(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId); @Valid final DdiActionFeedback feedback, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId);
/** /**
* This is the feedback channel for the config data action. * This is the feedback channel for the config data action.
@@ -167,8 +170,8 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(value = "/{targetid}/" @RequestMapping(value = "/{targetid}/"
+ DdiRestConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) + DdiRestConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData, ResponseEntity<Void> putConfigData(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid); @Valid final DdiConfigData configData, @PathVariable("targetid") final String targetid);
/** /**
* RequestMethod.GET method for the {@link DdiCancel} action. * RequestMethod.GET method for the {@link DdiCancel} action.
@@ -184,7 +187,8 @@ public interface DdiRootControllerRestApi {
*/ */
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION @RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid, ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId); @PathVariable("actionId") @NotEmpty final Long actionId);
/** /**
@@ -205,8 +209,8 @@ public interface DdiRootControllerRestApi {
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}/" @RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}/"
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, ResponseEntity<Void> postCancelActionFeedback(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid, @Valid final DdiActionFeedback feedback, @PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId); @PathVariable("actionId") @NotEmpty final Long actionId);
} }

View File

@@ -40,8 +40,8 @@ public interface DdiDlArtifactStoreControllerRestApi {
@RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME @RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
+ "/{fileName}") + "/{fileName}")
@ResponseBody @ResponseBody
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fileName") final String fileName, public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("tenant") final String tenant,
@AuthenticationPrincipal final String targetid); @PathVariable("fileName") final String fileName, @AuthenticationPrincipal final String targetid);
/** /**
* Handles GET MD5 checksum file download request. * Handles GET MD5 checksum file download request.
@@ -54,6 +54,7 @@ public interface DdiDlArtifactStoreControllerRestApi {
@RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME + "/{fileName}" @RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME + "/{fileName}"
+ DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX) + DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX)
@ResponseBody @ResponseBody
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName); public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName);
} }

View File

@@ -14,6 +14,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -29,7 +30,6 @@ import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
import org.eclipse.hawkbit.ddi.json.model.DdiPolling; import org.eclipse.hawkbit.ddi.json.model.DdiPolling;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
@@ -108,36 +108,34 @@ public final class DataConversionHelper {
return file; return file;
} }
static DdiControllerBase fromTarget(final Target target, final List<Action> actions, static DdiControllerBase fromTarget(final Target target, final Optional<Action> action,
final String defaultControllerPollTime, final TenantAware tenantAware) { final String defaultControllerPollTime, final TenantAware tenantAware) {
final DdiControllerBase result = new DdiControllerBase( final DdiControllerBase result = new DdiControllerBase(
new DdiConfig(new DdiPolling(defaultControllerPollTime))); new DdiConfig(new DdiPolling(defaultControllerPollTime)));
boolean addedUpdate = false; if (action.isPresent()) {
boolean addedCancel = false; if (action.get().isCancelingOrCanceled()) {
final long countCancelingActions = actions.stream().filter(a -> a.getStatus() == Status.CANCELING).count(); result.add(linkTo(
for (final Action action : actions) { methodOn(DdiRootController.class, tenantAware.getCurrentTenant()).getControllerCancelAction(
if (countCancelingActions <= 0 && !action.isCancelingOrCanceled() && !addedUpdate) { tenantAware.getCurrentTenant(), target.getControllerId(), action.get().getId()))
.withRel(DdiRestConstants.CANCEL_ACTION));
} else {
// we need to add the hashcode here of the actionWithStatus // we need to add the hashcode here of the actionWithStatus
// because the action might // because the action might
// have changed from 'soft' to 'forced' type and we need to // have changed from 'soft' to 'forced' type and we need to
// change the payload of the // change the payload of the
// response because of eTags. // response because of eTags.
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.getControllerBasedeploymentAction(target.getControllerId(), action.getId(), .getControllerBasedeploymentAction(tenantAware.getCurrentTenant(), target.getControllerId(),
calculateEtag(action))).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION)); action.get().getId(), calculateEtag(action.get())))
addedUpdate = true; .withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
} else if (action.isCancelingOrCanceled() && !addedCancel) {
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.getControllerCancelAction(target.getControllerId(), action.getId()))
.withRel(DdiRestConstants.CANCEL_ACTION));
addedCancel = true;
} }
} }
if (target.getTargetInfo().isRequestControllerAttributes()) { if (target.getTargetInfo().isRequestControllerAttributes()) {
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant()).putConfigData(null, result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
target.getControllerId())).withRel(DdiRestConstants.CONFIG_DATA_ACTION)); .putConfigData(tenantAware.getCurrentTenant(), null, target.getControllerId()))
.withRel(DdiRestConstants.CONFIG_DATA_ACTION));
} }
return result; return result;
} }

View File

@@ -69,8 +69,8 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
private EntityFactory entityFactory; private EntityFactory entityFactory;
@Override @Override
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fileName") final String fileName, public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("tenant") final String tenant,
@AuthenticationPrincipal final String targetid) { @PathVariable("fileName") final String fileName, @AuthenticationPrincipal final String targetid) {
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName); final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);
if (foundArtifacts.isEmpty()) { if (foundArtifacts.isEmpty()) {
@@ -110,7 +110,8 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
} }
@Override @Override
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName) { public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName) {
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName); final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);
if (foundArtifacts.isEmpty()) { if (foundArtifacts.isEmpty()) {

View File

@@ -99,7 +99,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
@Override @Override
public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts( public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
@PathVariable("targetid") final String targetid, @PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId) { @PathVariable("softwareModuleId") final Long softwareModuleId) {
LOG.debug("getSoftwareModulesArtifacts({})", targetid); LOG.debug("getSoftwareModulesArtifacts({})", targetid);
@@ -116,7 +116,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid) { public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid) {
LOG.debug("getControllerBase({})", targetid); LOG.debug("getControllerBase({})", targetid);
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(targetid, IpUtil final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(targetid, IpUtil
@@ -130,13 +131,14 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
return new ResponseEntity<>( return new ResponseEntity<>(
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target), DataConversionHelper.fromTarget(target, controllerManagement.findOldestActiveActionByTarget(target),
controllerManagement.getPollingTime(), tenantAware), controllerManagement.getPollingTime(), tenantAware),
HttpStatus.OK); HttpStatus.OK);
} }
@Override @Override
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("targetid") final String targetid, public ResponseEntity<InputStream> downloadArtifact(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName) { @PathVariable("fileName") final String fileName) {
ResponseEntity<InputStream> result; ResponseEntity<InputStream> result;
@@ -194,7 +196,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid, public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName) { @PathVariable("fileName") final String fileName) {
controllerManagement.updateLastTargetQuery(targetid, IpUtil controllerManagement.updateLastTargetQuery(targetid, IpUtil
@@ -220,7 +223,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
@Override @Override
public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction( public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
@PathVariable("targetid") final String targetid, @PathVariable("actionId") final Long actionId, @PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource) { @RequestParam(value = "c", required = false, defaultValue = "-1") final int resource) {
LOG.debug("getControllerBasedeploymentAction({},{})", targetid, resource); LOG.debug("getControllerBasedeploymentAction({},{})", targetid, resource);
@@ -254,8 +258,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, public ResponseEntity<Void> postBasedeploymentActionFeedback(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId) { @Valid @RequestBody final DdiActionFeedback feedback, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback); LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback);
final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil
@@ -349,8 +354,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData, public ResponseEntity<Void> putConfigData(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid) { @Valid @RequestBody final DdiConfigData configData, @PathVariable("targetid") final String targetid) {
controllerManagement.updateLastTargetQuery(targetid, IpUtil controllerManagement.updateLastTargetQuery(targetid, IpUtil
.getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties)); .getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties));
@@ -360,7 +365,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<DdiCancel> getControllerCancelAction( public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid, @PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) { @PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("getControllerCancelAction({})", targetid); LOG.debug("getControllerCancelAction({})", targetid);
@@ -390,7 +395,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, public ResponseEntity<Void> postCancelActionFeedback(@PathVariable("tenant") final String tenant,
@Valid @RequestBody final DdiActionFeedback feedback,
@PathVariable("targetid") @NotEmpty final String targetid, @PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) { @PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback); LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback);

View File

@@ -14,7 +14,13 @@ import java.util.Map;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.security.DdiSecurityProperties;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding;
@@ -33,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.amqp.RabbitProperties; import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -41,11 +48,12 @@ import org.springframework.retry.support.RetryTemplate;
import org.springframework.util.ErrorHandler; import org.springframework.util.ErrorHandler;
/** /**
* The spring AMQP configuration which is enabled by using the profile * Spring configuration for AMQP 0.9 based DMF communication for indirect device
* {@code amqp} to use a AMQP for communication with SP enabled devices. * integration.
* *
*/ */
@EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class }) @EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class })
@ConditionalOnProperty(prefix = "hawkbit.dmf.rabbitmq", name = "enabled", matchIfMissing = true)
public class AmqpConfiguration { public class AmqpConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(AmqpConfiguration.class); private static final Logger LOGGER = LoggerFactory.getLogger(AmqpConfiguration.class);
@@ -61,6 +69,7 @@ public class AmqpConfiguration {
@Configuration @Configuration
@ConditionalOnMissingBean(ConnectionFactory.class) @ConditionalOnMissingBean(ConnectionFactory.class)
@ConditionalOnProperty(prefix = "hawkbit.dmf.rabbitmq", name = "enabled", matchIfMissing = true)
protected static class RabbitConnectionFactoryCreator { protected static class RabbitConnectionFactoryCreator {
@Autowired @Autowired
@@ -280,6 +289,22 @@ public class AmqpConfiguration {
return new ConfigurableRabbitListenerContainerFactory(amqpProperties, rabbitConnectionFactory, errorHandler); return new ConfigurableRabbitListenerContainerFactory(amqpProperties, rabbitConnectionFactory, errorHandler);
} }
@Bean
@ConditionalOnMissingBean(AmqpControllerAuthentication.class)
public AmqpControllerAuthentication amqpControllerAuthentication(final ControllerManagement controllerManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
final DdiSecurityProperties ddiSecruityProperties, final SystemSecurityContext systemSecurityContext) {
return new AmqpControllerAuthentication(controllerManagement, tenantConfigurationManagement, tenantAware,
ddiSecruityProperties, systemSecurityContext);
}
@Bean
@ConditionalOnMissingBean(AmqpMessageDispatcherService.class)
public AmqpMessageDispatcherService amqpMessageDispatcherService(final RabbitTemplate rabbitTemplate,
final AmqpSenderService amqpSenderService, final ArtifactUrlHandler artifactUrlHandler) {
return new AmqpMessageDispatcherService(rabbitTemplate, amqpSenderService, artifactUrlHandler);
}
private static Map<String, Object> getTTLMaxArgsAuthenticationQueue() { private static Map<String, Object> getTTLMaxArgsAuthenticationQueue() {
final Map<String, Object> args = new HashMap<>(); final Map<String, Object> args = new HashMap<>();
args.put("x-message-ttl", Duration.ofSeconds(30).toMillis()); args.put("x-message-ttl", Duration.ofSeconds(30).toMillis());

View File

@@ -29,44 +29,51 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import org.springframework.stereotype.Component;
/** /**
* *
* A controller which handles the amqp authentfication. * A controller which handles the DMF AMQP authentication.
*/ */
@Component public class AmqpControllerAuthentication {
public class AmqpControllerAuthentfication {
private static final Logger LOGGER = LoggerFactory.getLogger(AmqpControllerAuthentfication.class); private static final Logger LOGGER = LoggerFactory.getLogger(AmqpControllerAuthentication.class);
private final PreAuthTokenSourceTrustAuthenticationProvider preAuthenticatedAuthenticationProvider; private final PreAuthTokenSourceTrustAuthenticationProvider preAuthenticatedAuthenticationProvider = new PreAuthTokenSourceTrustAuthenticationProvider();
private final List<PreAuthentificationFilter> filterChain = new ArrayList<>(); private final List<PreAuthentificationFilter> filterChain = new ArrayList<>();
@Autowired private final ControllerManagement controllerManagement;
private ControllerManagement controllerManagement;
@Autowired private final TenantConfigurationManagement tenantConfigurationManagement;
private TenantConfigurationManagement tenantConfigurationManagement;
@Autowired private final TenantAware tenantAware;
private TenantAware tenantAware;
@Autowired private final DdiSecurityProperties ddiSecruityProperties;
private DdiSecurityProperties ddiSecruityProperties;
@Autowired private final SystemSecurityContext systemSecurityContext;
private SystemSecurityContext systemSecurityContext;
/** /**
* Constructor. * Constructor.
*
* @param controllerManagement
* @param tenantConfigurationManagement
* @param tenantAware
* current tenant
* @param ddiSecruityProperties
* security configurations
* @param systemSecurityContext
* security context
*/ */
public AmqpControllerAuthentfication() { public AmqpControllerAuthentication(final ControllerManagement controllerManagement,
preAuthenticatedAuthenticationProvider = new PreAuthTokenSourceTrustAuthenticationProvider(); final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
final DdiSecurityProperties ddiSecruityProperties, final SystemSecurityContext systemSecurityContext) {
this.controllerManagement = controllerManagement;
this.tenantConfigurationManagement = tenantConfigurationManagement;
this.tenantAware = tenantAware;
this.ddiSecruityProperties = ddiSecruityProperties;
this.systemSecurityContext = systemSecurityContext;
} }
/** /**
@@ -139,23 +146,4 @@ public class AmqpControllerAuthentfication {
return new PreAuthenticatedAuthenticationToken(principal, credentials); return new PreAuthenticatedAuthenticationToken(principal, credentials);
} }
public void setControllerManagement(final ControllerManagement controllerManagement) {
this.controllerManagement = controllerManagement;
}
public void setSecruityProperties(final DdiSecurityProperties secruityProperties) {
this.ddiSecruityProperties = secruityProperties;
}
public void setTenantConfigurationManagement(final TenantConfigurationManagement tenantConfigurationManagement) {
this.tenantConfigurationManagement = tenantConfigurationManagement;
}
public void setTenantAware(final TenantAware tenantAware) {
this.tenantAware = tenantAware;
}
void setSystemSecurityContext(final SystemSecurityContext systemSecurityContext) {
this.systemSecurityContext = systemSecurityContext;
}
} }

View File

@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.util.IpUtil;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
@@ -46,21 +45,24 @@ import com.google.common.eventbus.Subscribe;
@EventSubscriber @EventSubscriber
public class AmqpMessageDispatcherService extends BaseAmqpService { public class AmqpMessageDispatcherService extends BaseAmqpService {
@Autowired private final ArtifactUrlHandler artifactUrlHandler;
private ArtifactUrlHandler artifactUrlHandler; private final AmqpSenderService amqpSenderService;
@Autowired
private AmqpSenderService amqpSenderService;
/** /**
* Constructor. * Constructor.
* *
* @param rabbitTemplate * @param rabbitTemplate
* the rabbitTemplate * the rabbitTemplate
* @param amqpSenderService
* to send AMQP message
* @param artifactUrlHandler
* for generating download URLs
*/ */
@Autowired public AmqpMessageDispatcherService(final RabbitTemplate rabbitTemplate, final AmqpSenderService amqpSenderService,
public AmqpMessageDispatcherService(final RabbitTemplate rabbitTemplate) { final ArtifactUrlHandler artifactUrlHandler) {
super(rabbitTemplate); super(rabbitTemplate);
this.artifactUrlHandler = artifactUrlHandler;
this.amqpSenderService = amqpSenderService;
} }
/** /**
@@ -178,12 +180,4 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
artifact.setSize(localArtifact.getSize()); artifact.setSize(localArtifact.getSize());
return artifact; return artifact;
} }
public void setArtifactUrlHandler(final ArtifactUrlHandler artifactUrlHandler) {
this.artifactUrlHandler = artifactUrlHandler;
}
public void setAmqpSenderService(final AmqpSenderService amqpSenderService) {
this.amqpSenderService = amqpSenderService;
}
} }

View File

@@ -13,6 +13,7 @@ import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@@ -32,6 +33,7 @@ import org.eclipse.hawkbit.dmf.json.model.ArtifactHash;
import org.eclipse.hawkbit.dmf.json.model.DownloadResponse; import org.eclipse.hawkbit.dmf.json.model.DownloadResponse;
import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken;
import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource;
import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ArtifactManagement;
@@ -41,7 +43,7 @@ import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.eventbus.event.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.eventbus.event.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.repository.exception.ToManyStatusEntriesException; import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionStatus;
@@ -90,7 +92,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
private ControllerManagement controllerManagement; private ControllerManagement controllerManagement;
@Autowired @Autowired
private AmqpControllerAuthentfication authenticationManager; private AmqpControllerAuthentication authenticationManager;
@Autowired @Autowired
private ArtifactManagement artifactManagement; private ArtifactManagement artifactManagement;
@@ -155,7 +157,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
return handleAuthentifiactionMessage(message); return handleAuthentifiactionMessage(message);
} catch (final IllegalArgumentException ex) { } catch (final IllegalArgumentException ex) {
throw new AmqpRejectAndDontRequeueException("Invalid message!", ex); throw new AmqpRejectAndDontRequeueException("Invalid message!", ex);
} catch (final TenantNotExistException | ToManyStatusEntriesException e) { } catch (final TenantNotExistException | TooManyStatusEntriesException e) {
throw new AmqpRejectAndDontRequeueException(e); throw new AmqpRejectAndDontRequeueException(e);
} finally { } finally {
SecurityContextHolder.setContext(oldContext); SecurityContextHolder.setContext(oldContext);
@@ -196,8 +198,8 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
} }
} catch (final IllegalArgumentException ex) { } catch (final IllegalArgumentException ex) {
throw new AmqpRejectAndDontRequeueException("Invalid message!", ex); throw new AmqpRejectAndDontRequeueException("Invalid message!", ex);
} catch (final TenantNotExistException teex) { } catch (final TenantNotExistException | TooManyStatusEntriesException e) {
throw new AmqpRejectAndDontRequeueException(teex); throw new AmqpRejectAndDontRequeueException(e);
} finally { } finally {
SecurityContextHolder.setContext(oldContext); SecurityContextHolder.setContext(oldContext);
} }
@@ -344,18 +346,24 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
} }
private void lookIfUpdateAvailable(final Target target) { private void lookIfUpdateAvailable(final Target target) {
final List<Action> actions = controllerManagement.findActionByTargetAndActive(target); final Optional<Action> action = controllerManagement.findOldestActiveActionByTarget(target);
if (actions.isEmpty()) { if (!action.isPresent()) {
return; return;
} }
// action are ordered by ASC
final Action action = actions.get(0); if (action.get().isCancelingOrCanceled()) {
final DistributionSet distributionSet = action.getDistributionSet(); amqpMessageDispatcherService.targetCancelAssignmentToDistributionSet(
new CancelTargetAssignmentEvent(target.getOptLockRevision(), target.getTenant(),
target.getControllerId(), action.get().getId(), target.getTargetInfo().getAddress()));
return;
}
final DistributionSet distributionSet = action.get().getDistributionSet();
final List<SoftwareModule> softwareModuleList = controllerManagement final List<SoftwareModule> softwareModuleList = controllerManagement
.findSoftwareModulesByDistributionSet(distributionSet); .findSoftwareModulesByDistributionSet(distributionSet);
final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> target.getSecurityToken()); final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> target.getSecurityToken());
amqpMessageDispatcherService.targetAssignDistributionSet(new TargetAssignDistributionSetEvent( amqpMessageDispatcherService.targetAssignDistributionSet(new TargetAssignDistributionSetEvent(
target.getOptLockRevision(), target.getTenant(), target.getControllerId(), action.getId(), target.getOptLockRevision(), target.getTenant(), target.getControllerId(), action.get().getId(),
softwareModuleList, target.getTargetInfo().getAddress(), targetSecurityToken)); softwareModuleList, target.getTargetInfo().getAddress(), targetSecurityToken));
} }
@@ -503,7 +511,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
this.hostnameResolver = hostnameResolver; this.hostnameResolver = hostnameResolver;
} }
void setAuthenticationManager(final AmqpControllerAuthentfication authenticationManager) { void setAuthenticationManager(final AmqpControllerAuthentication authenticationManager) {
this.authenticationManager = authenticationManager; this.authenticationManager = authenticationManager;
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.amqp;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
/** /**
@@ -20,6 +19,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*/ */
@ConfigurationProperties("hawkbit.dmf.rabbitmq") @ConfigurationProperties("hawkbit.dmf.rabbitmq")
public class AmqpProperties { public class AmqpProperties {
/**
* Enable DMF API based on AMQP 0.9
*/
private boolean enabled = true;
/** /**
* DMF API dead letter queue. * DMF API dead letter queue.
*/ */
@@ -76,17 +81,10 @@ public class AmqpProperties {
*/ */
private int declarationRetries = 50; private int declarationRetries = 50;
/**
* @return the declarationRetries
*/
public int getDeclarationRetries() { public int getDeclarationRetries() {
return declarationRetries; return declarationRetries;
} }
/**
* @param declarationRetries
* the declarationRetries to set
*/
public void setDeclarationRetries(final int declarationRetries) { public void setDeclarationRetries(final int declarationRetries) {
this.declarationRetries = declarationRetries; this.declarationRetries = declarationRetries;
} }
@@ -123,59 +121,26 @@ public class AmqpProperties {
this.maxConcurrentConsumers = maxConcurrentConsumers; this.maxConcurrentConsumers = maxConcurrentConsumers;
} }
/**
* Is missingQueuesFatal enabled
*
* @see SimpleMessageListenerContainer#setMissingQueuesFatal
* @return the missingQueuesFatal <true> enabled <false> disabled
*/
public boolean isMissingQueuesFatal() { public boolean isMissingQueuesFatal() {
return missingQueuesFatal; return missingQueuesFatal;
} }
/**
* @param missingQueuesFatal
* the missingQueuesFatal to set.
* @see SimpleMessageListenerContainer#setMissingQueuesFatal
*/
public void setMissingQueuesFatal(final boolean missingQueuesFatal) { public void setMissingQueuesFatal(final boolean missingQueuesFatal) {
this.missingQueuesFatal = missingQueuesFatal; this.missingQueuesFatal = missingQueuesFatal;
} }
/**
* Returns the dead letter exchange.
*
* @return dead letter exchange
*/
public String getDeadLetterExchange() { public String getDeadLetterExchange() {
return deadLetterExchange; return deadLetterExchange;
} }
/**
* Sets the dead letter exchange.
*
* @param deadLetterExchange
* the deadLetterExchange to be set
*/
public void setDeadLetterExchange(final String deadLetterExchange) { public void setDeadLetterExchange(final String deadLetterExchange) {
this.deadLetterExchange = deadLetterExchange; this.deadLetterExchange = deadLetterExchange;
} }
/**
* Returns the dead letter queue.
*
* @return the dead letter queue
*/
public String getDeadLetterQueue() { public String getDeadLetterQueue() {
return deadLetterQueue; return deadLetterQueue;
} }
/**
* Sets the dead letter queue.
*
* @param deadLetterQueue
* the deadLetterQueue ro be set
*/
public void setDeadLetterQueue(final String deadLetterQueue) { public void setDeadLetterQueue(final String deadLetterQueue) {
this.deadLetterQueue = deadLetterQueue; this.deadLetterQueue = deadLetterQueue;
} }
@@ -196,4 +161,11 @@ public class AmqpProperties {
this.receiverQueue = receiverQueue; this.receiverQueue = receiverQueue;
} }
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
} }

View File

@@ -61,7 +61,7 @@ public class AmqpControllerAuthenticationTest {
private AmqpMessageHandlerService amqpMessageHandlerService; private AmqpMessageHandlerService amqpMessageHandlerService;
private MessageConverter messageConverter; private MessageConverter messageConverter;
private TenantConfigurationManagement tenantConfigurationManagement; private TenantConfigurationManagement tenantConfigurationManagement;
private AmqpControllerAuthentfication authenticationManager; private AmqpControllerAuthentication authenticationManager;
private static final TenantConfigurationValue<Boolean> CONFIG_VALUE_FALSE = TenantConfigurationValue private static final TenantConfigurationValue<Boolean> CONFIG_VALUE_FALSE = TenantConfigurationValue
.<Boolean> builder().value(Boolean.FALSE).build(); .<Boolean> builder().value(Boolean.FALSE).build();
@@ -77,9 +77,6 @@ public class AmqpControllerAuthenticationTest {
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate,
mock(AmqpMessageDispatcherService.class)); mock(AmqpMessageDispatcherService.class));
authenticationManager = new AmqpControllerAuthentfication();
authenticationManager.setControllerManagement(mock(ControllerManagement.class));
final DdiSecurityProperties secruityProperties = mock(DdiSecurityProperties.class); final DdiSecurityProperties secruityProperties = mock(DdiSecurityProperties.class);
final Rp rp = mock(Rp.class); final Rp rp = mock(Rp.class);
final org.eclipse.hawkbit.security.DdiSecurityProperties.Authentication ddiAuthentication = mock( final org.eclipse.hawkbit.security.DdiSecurityProperties.Authentication ddiAuthentication = mock(
@@ -90,23 +87,22 @@ public class AmqpControllerAuthenticationTest {
when(secruityProperties.getAuthentication()).thenReturn(ddiAuthentication); when(secruityProperties.getAuthentication()).thenReturn(ddiAuthentication);
when(ddiAuthentication.getAnonymous()).thenReturn(anonymous); when(ddiAuthentication.getAnonymous()).thenReturn(anonymous);
when(anonymous.isEnabled()).thenReturn(false); when(anonymous.isEnabled()).thenReturn(false);
authenticationManager.setSecruityProperties(secruityProperties);
tenantConfigurationManagement = mock(TenantConfigurationManagement.class); tenantConfigurationManagement = mock(TenantConfigurationManagement.class);
authenticationManager.setTenantConfigurationManagement(tenantConfigurationManagement);
when(tenantConfigurationManagement.getConfigurationValue(any(), eq(Boolean.class))) when(tenantConfigurationManagement.getConfigurationValue(any(), eq(Boolean.class)))
.thenReturn(CONFIG_VALUE_FALSE); .thenReturn(CONFIG_VALUE_FALSE);
final ControllerManagement controllerManagement = mock(ControllerManagement.class); final ControllerManagement controllerManagement = mock(ControllerManagement.class);
when(controllerManagement.getSecurityTokenByControllerId(anyString())).thenReturn(CONTROLLLER_ID); when(controllerManagement.getSecurityTokenByControllerId(anyString())).thenReturn(CONTROLLLER_ID);
authenticationManager.setControllerManagement(controllerManagement);
amqpMessageHandlerService.setArtifactManagement(mock(ArtifactManagement.class)); amqpMessageHandlerService.setArtifactManagement(mock(ArtifactManagement.class));
final SecurityContextTenantAware tenantAware = new SecurityContextTenantAware(); final SecurityContextTenantAware tenantAware = new SecurityContextTenantAware();
authenticationManager.setTenantAware(tenantAware);
final SystemSecurityContext systemSecurityContext = new SystemSecurityContext(tenantAware); final SystemSecurityContext systemSecurityContext = new SystemSecurityContext(tenantAware);
authenticationManager.setSystemSecurityContext(systemSecurityContext);
authenticationManager = new AmqpControllerAuthentication(controllerManagement, tenantConfigurationManagement,
tenantAware, secruityProperties, systemSecurityContext);
authenticationManager.postConstruct(); authenticationManager.postConstruct();
amqpMessageHandlerService.setAuthenticationManager(authenticationManager); amqpMessageHandlerService.setAuthenticationManager(authenticationManager);
} }

View File

@@ -17,7 +17,6 @@ import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.net.URI; import java.net.URI;
@@ -79,18 +78,15 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
super.before(); super.before();
this.rabbitTemplate = Mockito.mock(RabbitTemplate.class); this.rabbitTemplate = Mockito.mock(RabbitTemplate.class);
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
amqpMessageDispatcherService = new AmqpMessageDispatcherService(rabbitTemplate);
amqpMessageDispatcherService = spy(amqpMessageDispatcherService);
senderService = Mockito.mock(DefaultAmqpSenderService.class); senderService = Mockito.mock(DefaultAmqpSenderService.class);
amqpMessageDispatcherService.setAmqpSenderService(senderService);
final ArtifactUrlHandler artifactUrlHandlerMock = Mockito.mock(ArtifactUrlHandler.class); final ArtifactUrlHandler artifactUrlHandlerMock = Mockito.mock(ArtifactUrlHandler.class);
when(artifactUrlHandlerMock.getUrl(anyString(), anyLong(), anyString(), anyString(), anyObject())) when(artifactUrlHandlerMock.getUrl(anyString(), anyLong(), anyString(), anyString(), anyObject()))
.thenReturn("http://mockurl"); .thenReturn("http://mockurl");
amqpMessageDispatcherService.setArtifactUrlHandler(artifactUrlHandlerMock); amqpMessageDispatcherService = new AmqpMessageDispatcherService(rabbitTemplate, senderService,
artifactUrlHandlerMock);
} }
@Test @Test

View File

@@ -23,6 +23,7 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.eclipse.hawkbit.api.HostnameResolver; import org.eclipse.hawkbit.api.HostnameResolver;
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository; import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
@@ -98,7 +99,7 @@ public class AmqpMessageHandlerServiceTest {
private ArtifactManagement artifactManagementMock; private ArtifactManagement artifactManagementMock;
@Mock @Mock
private AmqpControllerAuthentfication authenticationManagerMock; private AmqpControllerAuthentication authenticationManagerMock;
@Mock @Mock
private ArtifactRepository artifactRepositoryMock; private ArtifactRepository artifactRepositoryMock;
@@ -155,6 +156,7 @@ public class AmqpMessageHandlerServiceTest {
final ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class); final ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class);
when(controllerManagementMock.findOrRegisterTargetIfItDoesNotexist(targetIdCaptor.capture(), when(controllerManagementMock.findOrRegisterTargetIfItDoesNotexist(targetIdCaptor.capture(),
uriCaptor.capture())).thenReturn(null); uriCaptor.capture())).thenReturn(null);
when(controllerManagementMock.findOldestActiveActionByTarget(Matchers.any())).thenReturn(Optional.empty());
amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost"); amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
@@ -362,9 +364,8 @@ public class AmqpMessageHandlerServiceTest {
when(controllerManagementMock.addUpdateActionStatus(Matchers.any())).thenReturn(action); when(controllerManagementMock.addUpdateActionStatus(Matchers.any())).thenReturn(action);
when(entityFactoryMock.generateActionStatus()).thenReturn(new JpaActionStatus()); when(entityFactoryMock.generateActionStatus()).thenReturn(new JpaActionStatus());
// for the test the same action can be used // for the test the same action can be used
final List<Action> actionList = new ArrayList<>(); when(controllerManagementMock.findOldestActiveActionByTarget(Matchers.any()))
actionList.add(action); .thenReturn(Optional.of(action));
when(controllerManagementMock.findActionByTargetAndActive(Matchers.any())).thenReturn(actionList);
final List<SoftwareModule> softwareModuleList = createSoftwareModuleList(); final List<SoftwareModule> softwareModuleList = createSoftwareModuleList();
when(controllerManagementMock.findSoftwareModulesByDistributionSet(Matchers.any())) when(controllerManagementMock.findSoftwareModulesByDistributionSet(Matchers.any()))

View File

@@ -23,7 +23,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -88,7 +87,7 @@ public interface MgmtDistributionSetRestApi {
@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, @RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtDistributionSet>> createDistributionSets( ResponseEntity<List<MgmtDistributionSet>> createDistributionSets(
@RequestBody final List<MgmtDistributionSetRequestBodyPost> sets); final List<MgmtDistributionSetRequestBodyPost> sets);
/** /**
* Handles the DELETE request for a single DistributionSet . * Handles the DELETE request for a single DistributionSet .
@@ -116,7 +115,7 @@ public interface MgmtDistributionSetRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MgmtDistributionSet> updateDistributionSet( ResponseEntity<MgmtDistributionSet> updateDistributionSet(
@PathVariable("distributionSetId") final Long distributionSetId, @PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final MgmtDistributionSetRequestBodyPut toUpdate); final MgmtDistributionSetRequestBodyPut toUpdate);
/** /**
* Handles the GET request of retrieving assigned targets to a specific * Handles the GET request of retrieving assigned targets to a specific
@@ -198,7 +197,7 @@ public interface MgmtDistributionSetRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MgmtTargetAssignmentResponseBody> createAssignedTarget( ResponseEntity<MgmtTargetAssignmentResponseBody> createAssignedTarget(
@PathVariable("distributionSetId") final Long distributionSetId, @PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MgmtTargetAssignmentRequestBody> targetIds); final List<MgmtTargetAssignmentRequestBody> targetIds);
/** /**
* Gets a paged list of meta data for a distribution set. * Gets a paged list of meta data for a distribution set.
@@ -256,7 +255,7 @@ public interface MgmtDistributionSetRestApi {
@RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("distributionSetId") final Long distributionSetId, ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("distributionSetId") final Long distributionSetId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata); @PathVariable("metadataKey") final String metadataKey, final MgmtMetadata metadata);
/** /**
* Deletes a single meta data entry from the distribution set. * Deletes a single meta data entry from the distribution set.
@@ -285,7 +284,7 @@ public interface MgmtDistributionSetRestApi {
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("distributionSetId") final Long distributionSetId, ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MgmtMetadata> metadataRest); final List<MgmtMetadata> metadataRest);
/** /**
* Assigns a list of software modules to a distribution set. * Assigns a list of software modules to a distribution set.
@@ -301,7 +300,7 @@ public interface MgmtDistributionSetRestApi {
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId, ResponseEntity<Void> assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MgmtSoftwareModuleAssigment> softwareModuleIDs); final List<MgmtSoftwareModuleAssigment> softwareModuleIDs);
/** /**
* Deletes the assignment of the software module form the distribution set. * Deletes the assignment of the software module form the distribution set.

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -82,7 +81,7 @@ public interface MgmtDistributionSetTagRestApi {
*/ */
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTag>> createDistributionSetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags); ResponseEntity<List<MgmtTag>> createDistributionSetTags(final List<MgmtTagRequestBodyPut> tags);
/** /**
* *
@@ -99,7 +98,7 @@ public interface MgmtDistributionSetTagRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> updateDistributionSetTag( ResponseEntity<MgmtTag> updateDistributionSetTag(
@PathVariable("distributionsetTagId") final Long distributionsetTagId, @PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final MgmtTagRequestBodyPut restDSTagRest); final MgmtTagRequestBodyPut restDSTagRest);
/** /**
* Handles the DELETE request for a single distribution set tag. * Handles the DELETE request for a single distribution set tag.
@@ -142,7 +141,7 @@ public interface MgmtDistributionSetTagRestApi {
+ "/toggleTagAssignment") + "/toggleTagAssignment")
ResponseEntity<MgmtDistributionSetTagAssigmentResult> toggleTagAssignment( ResponseEntity<MgmtDistributionSetTagAssigmentResult> toggleTagAssignment(
@PathVariable("distributionsetTagId") final Long distributionsetTagId, @PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies); final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);
/** /**
* Handles the POST request to assign distribution sets to the given tag id. * Handles the POST request to assign distribution sets to the given tag id.
@@ -157,7 +156,7 @@ public interface MgmtDistributionSetTagRestApi {
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
ResponseEntity<List<MgmtDistributionSet>> assignDistributionSets( ResponseEntity<List<MgmtDistributionSet>> assignDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId, @PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies); final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);
/** /**
* Handles the DELETE request to unassign all distribution set from the * Handles the DELETE request to unassign all distribution set from the

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModule
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -99,7 +98,7 @@ public interface MgmtDistributionSetTypeRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtDistributionSetType> updateDistributionSetType( ResponseEntity<MgmtDistributionSetType> updateDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType);
/** /**
* Handles the POST request of creating new DistributionSetTypes. The * Handles the POST request of creating new DistributionSetTypes. The
@@ -115,7 +114,7 @@ public interface MgmtDistributionSetTypeRestApi {
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtDistributionSetType>> createDistributionSetTypes( ResponseEntity<List<MgmtDistributionSetType>> createDistributionSetTypes(
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes); final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes);
/** /**
* Handles the GET request of retrieving the list of mandatory software * Handles the GET request of retrieving the list of mandatory software
@@ -229,7 +228,7 @@ public interface MgmtDistributionSetTypeRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> addMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, ResponseEntity<Void> addMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtId smtId); final MgmtId smtId);
/** /**
* Handles the POST request for adding an optional software module type to a * Handles the POST request for adding an optional software module type to a
@@ -247,6 +246,6 @@ public interface MgmtDistributionSetTypeRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> addOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, ResponseEntity<Void> addOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtId smtId); final MgmtId smtId);
} }

View File

@@ -16,7 +16,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -77,7 +76,7 @@ public interface MgmtRolloutRestApi {
*/ */
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtRolloutResponseBody> create(@RequestBody final MgmtRolloutRestRequestBody rolloutRequestBody); ResponseEntity<MgmtRolloutResponseBody> create(final MgmtRolloutRestRequestBody rolloutRequestBody);
/** /**
* Handles the POST request for starting a rollout. * Handles the POST request for starting a rollout.

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequ
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -162,7 +161,7 @@ public interface MgmtSoftwareModuleRestApi {
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules( ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(
@RequestBody final List<MgmtSoftwareModuleRequestBodyPost> softwareModules); final List<MgmtSoftwareModuleRequestBodyPost> softwareModules);
/** /**
* Handles the PUT request of updating a software module. * Handles the PUT request of updating a software module.
@@ -177,7 +176,7 @@ public interface MgmtSoftwareModuleRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModule> updateSoftwareModule( ResponseEntity<MgmtSoftwareModule> updateSoftwareModule(
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule); final MgmtSoftwareModuleRequestBodyPut restSoftwareModule);
/** /**
* Handles the DELETE request for a single software module. * Handles the DELETE request for a single software module.
@@ -246,7 +245,7 @@ public interface MgmtSoftwareModuleRestApi {
@RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata); @PathVariable("metadataKey") final String metadataKey, final MgmtMetadata metadata);
/** /**
* Deletes a single meta data entry from the software module. * Deletes a single meta data entry from the software module.
@@ -275,6 +274,6 @@ public interface MgmtSoftwareModuleRestApi {
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final List<MgmtMetadata> metadataRest); final List<MgmtMetadata> metadataRest);
} }

View File

@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModule
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -94,7 +93,7 @@ public interface MgmtSoftwareModuleTypeRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModuleType> updateSoftwareModuleType( ResponseEntity<MgmtSoftwareModuleType> updateSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId,
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType);
/** /**
* Handles the POST request of creating new SoftwareModuleTypes. The request * Handles the POST request of creating new SoftwareModuleTypes. The request
@@ -110,6 +109,6 @@ public interface MgmtSoftwareModuleTypeRestApi {
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes( ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes); final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes);
} }

View File

@@ -16,7 +16,6 @@ import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@@ -83,6 +82,6 @@ public interface MgmtSystemRestApi {
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue( ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(
@PathVariable("keyName") final String keyName, @PathVariable("keyName") final String keyName,
@RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest); final MgmtSystemTenantConfigurationValueRequest configurationValueRest);
} }

View File

@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -84,7 +83,7 @@ public interface MgmtTargetRestApi {
*/ */
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets); ResponseEntity<List<MgmtTarget>> createTargets(final List<MgmtTargetRequestBody> targets);
/** /**
* Handles the PUT request of updating a target. The ID is within the URL * Handles the PUT request of updating a target. The ID is within the URL
@@ -103,7 +102,7 @@ public interface MgmtTargetRestApi {
@RequestMapping(method = RequestMethod.PUT, value = "/{controllerId}", consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.PUT, value = "/{controllerId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTarget> updateTarget(@PathVariable("controllerId") final String controllerId, ResponseEntity<MgmtTarget> updateTarget(@PathVariable("controllerId") final String controllerId,
@RequestBody final MgmtTargetRequestBody targetRest); final MgmtTargetRequestBody targetRest);
/** /**
* Handles the DELETE request of deleting a target. * Handles the DELETE request of deleting a target.
@@ -247,7 +246,7 @@ public interface MgmtTargetRestApi {
"application/hal+json", "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> postAssignedDistributionSet(@PathVariable("controllerId") final String controllerId, ResponseEntity<Void> postAssignedDistributionSet(@PathVariable("controllerId") final String controllerId,
@RequestBody final MgmtDistributionSetAssigment dsId); final MgmtDistributionSetAssigment dsId);
/** /**
* Handles the GET request of retrieving the installed distribution set of * Handles the GET request of retrieving the installed distribution set of

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -81,7 +80,7 @@ public interface MgmtTargetTagRestApi {
*/ */
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags); ResponseEntity<List<MgmtTag>> createTargetTags(final List<MgmtTagRequestBodyPut> tags);
/** /**
* *
@@ -96,7 +95,7 @@ public interface MgmtTargetTagRestApi {
@RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> updateTagretTag(@PathVariable("targetTagId") final Long targetTagId, ResponseEntity<MgmtTag> updateTagretTag(@PathVariable("targetTagId") final Long targetTagId,
@RequestBody final MgmtTagRequestBodyPut restTargetTagRest); final MgmtTagRequestBodyPut restTargetTagRest);
/** /**
* Handles the DELETE request for a single target tag. * Handles the DELETE request for a single target tag.
@@ -136,7 +135,7 @@ public interface MgmtTargetTagRestApi {
+ "/toggleTagAssignment") + "/toggleTagAssignment")
ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignment( ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignment(
@PathVariable("targetTagId") final Long targetTagId, @PathVariable("targetTagId") final Long targetTagId,
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);
/** /**
* Handles the POST request to assign targets to the given tag id. * Handles the POST request to assign targets to the given tag id.
@@ -150,7 +149,7 @@ public interface MgmtTargetTagRestApi {
*/ */
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId, ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);
/** /**
* Handles the DELETE request to unassign all targets from the given tag id. * Handles the DELETE request to unassign all targets from the given tag id.

View File

@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.springframework.util.CollectionUtils;
/** /**
* A mapper which maps repository model to RESTful model representation and * A mapper which maps repository model to RESTful model representation and
@@ -53,31 +54,42 @@ final class MgmtDistributionSetTypeMapper {
final DistributionSetType result = entityFactory.generateDistributionSetType(smsRest.getKey(), final DistributionSetType result = entityFactory.generateDistributionSetType(smsRest.getKey(),
smsRest.getName(), smsRest.getDescription()); smsRest.getName(), smsRest.getDescription());
// Add mandatory addMandatoryModules(softwareManagement, smsRest, result);
smsRest.getMandatorymodules().stream().map(mand -> { addOptionalModules(softwareManagement, smsRest, result);
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(mand.getId());
if (smType == null) {
throw new EntityNotFoundException("SoftwareModuleType with ID " + mand.getId() + " not found");
}
return smType;
}).forEach(result::addMandatoryModuleType);
// Add optional
smsRest.getOptionalmodules().stream().map(opt -> {
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(opt.getId());
if (smType == null) {
throw new EntityNotFoundException("SoftwareModuleType with ID " + opt.getId() + " not found");
}
return smType;
}).forEach(result::addOptionalModuleType);
return result; return result;
} }
private static void addOptionalModules(final SoftwareManagement softwareManagement,
final MgmtDistributionSetTypeRequestBodyPost smsRest, final DistributionSetType result) {
if (!CollectionUtils.isEmpty(smsRest.getOptionalmodules())) {
smsRest.getOptionalmodules().stream().map(opt -> {
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(opt.getId());
if (smType == null) {
throw new EntityNotFoundException("SoftwareModuleType with ID " + opt.getId() + " not found");
}
return smType;
}).forEach(result::addOptionalModuleType);
}
}
private static void addMandatoryModules(final SoftwareManagement softwareManagement,
final MgmtDistributionSetTypeRequestBodyPost smsRest, final DistributionSetType result) {
if (!CollectionUtils.isEmpty(smsRest.getMandatorymodules())) {
smsRest.getMandatorymodules().stream().map(mand -> {
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeById(mand.getId());
if (smType == null) {
throw new EntityNotFoundException("SoftwareModuleType with ID " + mand.getId() + " not found");
}
return smType;
}).forEach(result::addMandatoryModuleType);
}
}
static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) { static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) {
final List<MgmtDistributionSetType> response = new ArrayList<>(); final List<MgmtDistributionSetType> response = new ArrayList<>();
for (final DistributionSetType dsType : types) { for (final DistributionSetType dsType : types) {

View File

@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.LocalArtifact;
@@ -43,6 +44,9 @@ public final class MgmtSoftwareModuleMapper {
private static SoftwareModuleType getSoftwareModuleTypeFromKeyString(final String type, private static SoftwareModuleType getSoftwareModuleTypeFromKeyString(final String type,
final SoftwareManagement softwareManagement) { final SoftwareManagement softwareManagement) {
if (type == null) {
throw new ConstraintViolationException("type cannot be null");
}
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeByKey(type.trim()); final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeByKey(type.trim());

View File

@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -633,6 +634,19 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
final DistributionSet missingName = testdataFactory.generateDistributionSet("missingName");
missingName.setName(null);
mvc.perform(
post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
final DistributionSet toLongName = testdataFactory.generateDistributionSet(RandomStringUtils.randomAscii(80));
mvc.perform(
post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
// unsupported media type // unsupported media type
mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets)) mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets))
.contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print())

View File

@@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -553,6 +554,19 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
final DistributionSetType missingName = entityFactory.generateDistributionSetType("test123", null, "Desc123");
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final DistributionSetType toLongName = entityFactory.generateDistributionSetType("test123",
RandomStringUtils.randomAscii(80), "Desc123");
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
// not allowed methods // not allowed methods
mvc.perform(put("/rest/v1/distributionsettypes")).andDo(MockMvcResultPrinter.print()) mvc.perform(put("/rest/v1/distributionsettypes")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isMethodNotAllowed()); .andExpect(status().isMethodNotAllowed());

View File

@@ -58,6 +58,7 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Description;
@@ -456,6 +457,19 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
final SoftwareModule missingName = entityFactory.generateSoftwareModule(osType, null, "version 1", null, null);
mvc.perform(
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
final SoftwareModule toLongName = entityFactory.generateSoftwareModule(osType,
RandomStringUtils.randomAscii(80), "version 1", null, null);
mvc.perform(
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
// unsupported media type // unsupported media type
mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(modules)) mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(modules))
.contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print())

View File

@@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -37,6 +38,7 @@ import org.junit.Test;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Description;
@@ -335,6 +337,19 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
final SoftwareModuleType missingName = entityFactory.generateSoftwareModuleType("test123", null, "Desc123", 5);
mvc.perform(post("/rest/v1/softwaremoduletypes")
.content(JsonBuilder.softwareModuleTypes(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final SoftwareModuleType toLongName = entityFactory.generateSoftwareModuleType("test123",
RandomStringUtils.randomAscii(80), "Desc123", 5);
mvc.perform(post("/rest/v1/softwaremoduletypes")
.content(JsonBuilder.softwareModuleTypes(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
// unsupported media type // unsupported media type
mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types)) mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types))
.contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print())

View File

@@ -32,10 +32,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo; import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
@@ -669,6 +671,48 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_REST_BODY_NOT_READABLE.getKey()); assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_REST_BODY_NOT_READABLE.getKey());
} }
@Test
@Description("Verfies that a mandatory properties of new targets are validated as not null.")
public void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception {
final Target test1 = entityFactory.generateTarget("id1", "token");
test1.setName(null);
final MvcResult mvcResult = mvc
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
.content(JsonBuilder.targets(Lists.newArrayList(test1), true))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
.convertException(mvcResult.getResponse().getContentAsString());
assertThat(exceptionInfo.getExceptionClass()).isEqualTo(ConstraintViolationException.class.getName());
assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_REPO_CONSTRAINT_VIOLATION.getKey());
}
@Test
@Description("Verfies that a properties of new targets are validated as in allowed size range.")
public void createTargetWithInvalidPropertyBadRequest() throws Exception {
final Target test1 = entityFactory.generateTarget("id1", "token");
test1.setName(RandomStringUtils.randomAscii(80));
final MvcResult mvcResult = mvc
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
.content(JsonBuilder.targets(Lists.newArrayList(test1), true))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
.convertException(mvcResult.getResponse().getContentAsString());
assertThat(exceptionInfo.getExceptionClass()).isEqualTo(ConstraintViolationException.class.getName());
assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_REPO_CONSTRAINT_VIOLATION.getKey());
}
@Test @Test
public void createTargetsListReturnsSuccessful() throws Exception { public void createTargetsListReturnsSuccessful() throws Exception {
final Target test1 = entityFactory.generateTarget("id1", "token"); final Target test1 = entityFactory.generateTarget("id1", "token");

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@@ -19,7 +20,7 @@ import org.eclipse.hawkbit.repository.eventbus.event.DownloadProgressEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException; import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
import org.eclipse.hawkbit.repository.exception.ToManyStatusEntriesException; import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionStatus;
@@ -95,7 +96,7 @@ public interface ControllerManagement {
* *
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
* @throws ToManyStatusEntriesException * @throws TooManyStatusEntriesException
* if more than the allowed number of status entries are * if more than the allowed number of status entries are
* inserted * inserted
*/ */
@@ -111,7 +112,18 @@ public interface ControllerManagement {
* @return a list of actions assigned to given target which are active * @return a list of actions assigned to given target which are active
*/ */
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
List<Action> findActionByTargetAndActive(@NotNull Target target); List<Action> findActiveActionByTarget(@NotNull Target target);
/**
* Retrieves oldest {@link Action} that is active and assigned to a
* {@link Target}.
*
* @param target
* the target to retrieve the actions from
* @return a list of actions assigned to given target which are active
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Optional<Action> findOldestActiveActionByTarget(@NotNull Target target);
/** /**
* Get the {@link Action} entity for given actionId with all lazy * Get the {@link Action} entity for given actionId with all lazy

View File

@@ -131,7 +131,7 @@ public interface SoftwareManagement {
* @return created {@link Entity} * @return created {@link Entity}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types); List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleType> types);
/** /**
* Creates new {@link SoftwareModuleType}. * Creates new {@link SoftwareModuleType}.
@@ -483,21 +483,20 @@ public interface SoftwareManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm); SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm);
/** /**
* Finds all meta data by the given software module id. * Finds all meta data by the given software module id.
* *
* @param softwareModuleId * @param softwareModuleId
* the software module id to retrieve the meta data from * the software module id to retrieve the meta data from
*
* *
* @throws RSQLParameterUnsupportedFieldException * @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the * if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException * @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong * if the RSQL syntax is wrong
* @return result of all meta data entries for a given software * @return result of all meta data entries for a given software module id.
* module id.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
List<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(Long softwareModuleId); List<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(Long softwareModuleId);

View File

@@ -31,7 +31,18 @@ public class ConstraintViolationException extends AbstractServerRtException {
* thrown * thrown
*/ */
public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) { public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) {
super(getExceptionMessage(ex), SpServerError.SP_REPO_CONSTRAINT_VIOLATION); this(getExceptionMessage(ex));
}
/**
* Creates a new {@link ConstraintViolationException} with the error code
* {@link SpServerError#SP_REPO_CONSTRAINT_VIOLATION}.
*
* @param msgText
* the message text for this exception
*/
public ConstraintViolationException(final String msgText) {
super(msgText, SpServerError.SP_REPO_CONSTRAINT_VIOLATION);
} }
/** /**

View File

@@ -18,7 +18,7 @@ import org.eclipse.hawkbit.exception.AbstractServerRtException;
* *
* *
*/ */
public final class ToManyStatusEntriesException extends AbstractServerRtException { public final class TooManyStatusEntriesException extends AbstractServerRtException {
/** /**
* *
*/ */
@@ -28,7 +28,7 @@ public final class ToManyStatusEntriesException extends AbstractServerRtExceptio
* Creates a new FileUploadFailedException with * Creates a new FileUploadFailedException with
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. * {@link SpServerError#SP_REST_BODY_NOT_READABLE} error.
*/ */
public ToManyStatusEntriesException() { public TooManyStatusEntriesException() {
super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES); super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES);
} }
@@ -36,7 +36,7 @@ public final class ToManyStatusEntriesException extends AbstractServerRtExceptio
* @param cause * @param cause
* for the exception * for the exception
*/ */
public ToManyStatusEntriesException(final Throwable cause) { public TooManyStatusEntriesException(final Throwable cause) {
super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES, cause); super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES, cause);
} }
@@ -44,7 +44,7 @@ public final class ToManyStatusEntriesException extends AbstractServerRtExceptio
* @param message * @param message
* of the error * of the error
*/ */
public ToManyStatusEntriesException(final String message) { public TooManyStatusEntriesException(final String message) {
super(message, SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES); super(message, SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES);
} }
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
@@ -79,21 +80,31 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
Slice<Action> findByTarget(Pageable pageable, JpaTarget target); Slice<Action> findByTarget(Pageable pageable, JpaTarget target);
/** /**
* Retrieves all {@link Action}s which are active and referring the given * Retrieves all {@link Action}s which are active and referring to the given
* {@link Target} in a specified order. Loads also the lazy * {@link Target} order by ID ascending.
* {@link Action#getDistributionSet()} field.
* *
* @param pageable
* page parameters
* @param target * @param target
* the target to find assigned actions * the target to find assigned actions
* @param active * @param active
* the action active flag * the action active flag
* @return the found {@link Action}s * @return the found {@link Action}s
*/ */
@EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD)
List<Action> findByTargetAndActiveOrderByIdAsc(final JpaTarget target, boolean active); List<Action> findByTargetAndActiveOrderByIdAsc(final JpaTarget target, boolean active);
/**
* Retrieves the oldest {@link Action} that is active and referring to the
* given {@link Target}.
*
* @param target
* the target to find assigned actions
* @param active
* the action active flag
*
* @return the found {@link Action}
*/
@EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD)
Optional<Action> findFirstByTargetAndActiveOrderByIdAsc(final JpaTarget target, boolean active);
/** /**
* Retrieves latest {@link UpdateAction} for given target and * Retrieves latest {@link UpdateAction} for given target and
* {@link SoftwareModule}. * {@link SoftwareModule}.

View File

@@ -12,6 +12,7 @@ import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
@@ -26,7 +27,7 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException; import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
import org.eclipse.hawkbit.repository.exception.ToManyStatusEntriesException; import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.eclipse.hawkbit.repository.jpa.cache.CacheWriteNotify; import org.eclipse.hawkbit.repository.jpa.cache.CacheWriteNotify;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus; import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
@@ -156,10 +157,15 @@ public class JpaControllerManagement implements ControllerManagement {
} }
@Override @Override
public List<Action> findActionByTargetAndActive(final Target target) { public List<Action> findActiveActionByTarget(final Target target) {
return actionRepository.findByTargetAndActiveOrderByIdAsc((JpaTarget) target, true); return actionRepository.findByTargetAndActiveOrderByIdAsc((JpaTarget) target, true);
} }
@Override
public Optional<Action> findOldestActiveActionByTarget(final Target target) {
return actionRepository.findFirstByTargetAndActiveOrderByIdAsc((JpaTarget) target, true);
}
@Override @Override
public List<SoftwareModule> findSoftwareModulesByDistributionSet(final DistributionSet distributionSet) { public List<SoftwareModule> findSoftwareModulesByDistributionSet(final DistributionSet distributionSet) {
return new ArrayList<>(softwareModuleRepository.findByAssignedTo((JpaDistributionSet) distributionSet)); return new ArrayList<>(softwareModuleRepository.findByAssignedTo((JpaDistributionSet) distributionSet));
@@ -326,7 +332,7 @@ public class JpaControllerManagement implements ControllerManagement {
LOG_DOS.error( LOG_DOS.error(
"Potential denial of service (DOS) attack identfied. More status entries in the system than permitted ({})!", "Potential denial of service (DOS) attack identfied. More status entries in the system than permitted ({})!",
securityProperties.getDos().getMaxStatusEntriesPerAction()); securityProperties.getDos().getMaxStatusEntriesPerAction());
throw new ToManyStatusEntriesException( throw new TooManyStatusEntriesException(
String.valueOf(securityProperties.getDos().getMaxStatusEntriesPerAction())); String.valueOf(securityProperties.getDos().getMaxStatusEntriesPerAction()));
} }
} }

View File

@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.google.common.eventbus.AllowConcurrentEvents; import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
@@ -40,6 +41,7 @@ import com.google.common.eventbus.Subscribe;
* *
*/ */
@EventSubscriber @EventSubscriber
@Service
public class EventMerger { public class EventMerger {
private static final Set<RolloutEventKey> rolloutEvents = ConcurrentHashMap.newKeySet(); private static final Set<RolloutEventKey> rolloutEvents = ConcurrentHashMap.newKeySet();

View File

@@ -12,6 +12,8 @@ import javax.persistence.Basic;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.MetaData;
@@ -25,9 +27,12 @@ public abstract class AbstractJpaMetaData implements MetaData {
@Id @Id
@Column(name = "meta_key", length = 128) @Column(name = "meta_key", length = 128)
@Size(min = 1, max = 128)
@NotNull
private String key; private String key;
@Column(name = "meta_value", length = 4000) @Column(name = "meta_value", length = 4000)
@Size(max = 4000)
@Basic @Basic
private String value; private String value;

View File

@@ -10,6 +10,8 @@ package org.eclipse.hawkbit.repository.jpa.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
@@ -26,9 +28,12 @@ public abstract class AbstractJpaNamedEntity extends AbstractJpaTenantAwareBaseE
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "name", nullable = false, length = 64) @Column(name = "name", nullable = false, length = 64)
@Size(max = 64)
@NotNull
private String name; private String name;
@Column(name = "description", nullable = true, length = 512) @Column(name = "description", nullable = true, length = 512)
@Size(max = 512)
private String description; private String description;
/** /**

View File

@@ -10,6 +10,8 @@ package org.eclipse.hawkbit.repository.jpa.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
@@ -26,6 +28,8 @@ public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEn
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "version", nullable = false, length = 64) @Column(name = "version", nullable = false, length = 64)
@Size(max = 64)
@NotNull
private String version; private String version;
/** /**

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Tag;
@@ -26,6 +27,7 @@ public abstract class AbstractJpaTag extends AbstractJpaNamedEntity implements T
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = 16)
@Size(max = 16)
private String colour; private String colour;
protected AbstractJpaTag() { protected AbstractJpaTag() {

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemManagementHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.SystemManagementHolder;
@@ -31,6 +32,7 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40) @Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
@Size(max = 40)
private String tenant; private String tenant;
/** /**

View File

@@ -27,6 +27,7 @@ import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedSubgraph; import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.eventbus.event.ActionCreatedEvent; import org.eclipse.hawkbit.repository.eventbus.event.ActionCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.ActionPropertyChangeEvent; import org.eclipse.hawkbit.repository.eventbus.event.ActionPropertyChangeEvent;
@@ -63,13 +64,15 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target")) @JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target"))
@NotNull
private JpaTarget target; private JpaTarget target;
@Column(name = "active") @Column(name = "active")
private boolean active; private boolean active;
@Column(name = "action_type", nullable = false) @Column(name = "action_type", nullable = false, length = 16)
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@NotNull
private ActionType actionType; private ActionType actionType;
@Column(name = "forced_time") @Column(name = "forced_time")

View File

@@ -25,6 +25,7 @@ import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph; import javax.persistence.NamedEntityGraph;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.jpa.cache.CacheField; import org.eclipse.hawkbit.repository.jpa.cache.CacheField;
import org.eclipse.hawkbit.repository.jpa.cache.CacheKeys; import org.eclipse.hawkbit.repository.jpa.cache.CacheKeys;
@@ -54,9 +55,11 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "action", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action")) @JoinColumn(name = "action", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action"))
@NotNull
private JpaAction action; private JpaAction action;
@Column(name = "status") @Column(name = "status")
@NotNull
private Status status; private Status status;
@CascadeOnDelete @CascadeOnDelete

View File

@@ -33,6 +33,7 @@ import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent.PropertyChange; import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent.PropertyChange;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent; import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
@@ -109,6 +110,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
@ManyToOne(fetch = FetchType.LAZY, targetEntity = JpaDistributionSetType.class) @ManyToOne(fetch = FetchType.LAZY, targetEntity = JpaDistributionSetType.class)
@JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds")) @JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
@NotNull
private DistributionSetType type; private DistributionSetType type;
@Column(name = "complete") @Column(name = "complete")

View File

@@ -22,6 +22,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -50,9 +51,11 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
private final Set<DistributionSetTypeElement> elements = new HashSet<>(); private final Set<DistributionSetTypeElement> elements = new HashSet<>();
@Column(name = "type_key", nullable = false, length = 64) @Column(name = "type_key", nullable = false, length = 64)
@Size(max = 64)
private String key; private String key;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = 16)
@Size(max = 16)
private String colour; private String colour;
@Column(name = "deleted") @Column(name = "deleted")

View File

@@ -20,6 +20,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.ExternalArtifact; import org.eclipse.hawkbit.repository.model.ExternalArtifact;
import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider; import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider;
@@ -44,6 +45,7 @@ public class JpaExternalArtifact extends AbstractJpaArtifact implements External
private JpaExternalArtifactProvider externalArtifactProvider; private JpaExternalArtifactProvider externalArtifactProvider;
@Column(name = "url_suffix", length = 512) @Column(name = "url_suffix", length = 512)
@Size(max = 512)
private String urlSuffix; private String urlSuffix;
// CascadeType.PERSIST as we register ourself at the BSM // CascadeType.PERSIST as we register ourself at the BSM

View File

@@ -12,6 +12,7 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Index; import javax.persistence.Index;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.ExternalArtifact; import org.eclipse.hawkbit.repository.model.ExternalArtifact;
import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider; import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider;
@@ -30,9 +31,11 @@ public class JpaExternalArtifactProvider extends AbstractJpaNamedEntity implemen
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "base_url", length = 512, nullable = false) @Column(name = "base_url", length = 512, nullable = false)
@Size(max = 512)
private String basePath; private String basePath;
@Column(name = "default_url_suffix", length = 512, nullable = true) @Column(name = "default_url_suffix", length = 512, nullable = true)
@Size(max = 512)
private String defaultSuffix; private String defaultSuffix;
/** /**

View File

@@ -18,6 +18,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -40,10 +41,12 @@ public class JpaLocalArtifact extends AbstractJpaArtifact implements LocalArtifa
@NotNull @NotNull
@Column(name = "gridfs_file_name", length = 40) @Column(name = "gridfs_file_name", length = 40)
@Size(max = 40)
private String gridFsFileName; private String gridFsFileName;
@NotNull @NotNull
@Column(name = "provided_file_name", length = 256) @Column(name = "provided_file_name", length = 256)
@Size(max = 256)
private String filename; private String filename;
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST }) @ManyToOne(optional = false, cascade = { CascadeType.PERSIST })

View File

@@ -24,6 +24,8 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutPropertyChangeEvent; import org.eclipse.hawkbit.repository.eventbus.event.RolloutPropertyChangeEvent;
import org.eclipse.hawkbit.repository.jpa.cache.CacheField; import org.eclipse.hawkbit.repository.jpa.cache.CacheField;
@@ -57,10 +59,13 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
private List<RolloutGroup> rolloutGroups; private List<RolloutGroup> rolloutGroups;
@Column(name = "target_filter", length = 1024, nullable = false) @Column(name = "target_filter", length = 1024, nullable = false)
@Size(max = 1024)
@NotNull
private String targetFilterQuery; private String targetFilterQuery;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds")) @JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
@NotNull
private JpaDistributionSet distributionSet; private JpaDistributionSet distributionSet;
@Column(name = "status") @Column(name = "status")
@@ -69,8 +74,9 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
@Column(name = "last_check") @Column(name = "last_check")
private long lastCheck; private long lastCheck;
@Column(name = "action_type", nullable = false) @Column(name = "action_type", nullable = false, length = 16)
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@NotNull
private ActionType actionType = ActionType.FORCED; private ActionType actionType = ActionType.FORCED;
@Column(name = "forced_time") @Column(name = "forced_time")

View File

@@ -24,6 +24,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupPropertyChangeEvent; import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupPropertyChangeEvent;
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper; import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
@@ -66,24 +67,28 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD; private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD;
@Column(name = "success_condition_exp", length = 512, nullable = false) @Column(name = "success_condition_exp", length = 512, nullable = false)
@Size(max = 512)
private String successConditionExp; private String successConditionExp;
@Column(name = "success_action", nullable = false) @Column(name = "success_action", nullable = false)
private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP; private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP;
@Column(name = "success_action_exp", length = 512, nullable = false) @Column(name = "success_action_exp", length = 512, nullable = false)
@Size(max = 512)
private String successActionExp; private String successActionExp;
@Column(name = "error_condition") @Column(name = "error_condition")
private RolloutGroupErrorCondition errorCondition; private RolloutGroupErrorCondition errorCondition;
@Column(name = "error_condition_exp", length = 512) @Column(name = "error_condition_exp", length = 512)
@Size(max = 512)
private String errorConditionExp; private String errorConditionExp;
@Column(name = "error_action") @Column(name = "error_action")
private RolloutGroupErrorAction errorAction; private RolloutGroupErrorAction errorAction;
@Column(name = "error_action_exp", length = 512) @Column(name = "error_action_exp", length = 512)
@Size(max = 512)
private String errorActionExp; private String errorActionExp;
@Column(name = "total_targets") @Column(name = "total_targets")

View File

@@ -28,6 +28,8 @@ import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -58,6 +60,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@ManyToOne @ManyToOne
@JoinColumn(name = "module_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type")) @JoinColumn(name = "module_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type"))
@NotNull
private JpaSoftwareModuleType type; private JpaSoftwareModuleType type;
@ManyToMany(mappedBy = "modules", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY) @ManyToMany(mappedBy = "modules", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY)
@@ -67,6 +70,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
private boolean deleted; private boolean deleted;
@Column(name = "vendor", nullable = true, length = 256) @Column(name = "vendor", nullable = true, length = 256)
@Size(max = 256)
private String vendor; private String vendor;
@OneToMany(mappedBy = "softwareModule", cascade = { CascadeType.ALL }, targetEntity = JpaLocalArtifact.class) @OneToMany(mappedBy = "softwareModule", cascade = { CascadeType.ALL }, targetEntity = JpaLocalArtifact.class)

View File

@@ -14,6 +14,8 @@ import javax.persistence.Index;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -34,6 +36,8 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "type_key", nullable = false, length = 64) @Column(name = "type_key", nullable = false, length = 64)
@Size(max = 64)
@NotNull
private String key; private String key;
@Column(name = "max_ds_assignments", nullable = false) @Column(name = "max_ds_assignments", nullable = false)
@@ -41,6 +45,7 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
private int maxAssignments; private int maxAssignments;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = 16)
@Size(max = 16)
private String colour; private String colour;
@Column(name = "deleted") @Column(name = "deleted")

View File

@@ -74,7 +74,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "controller_id", length = 64) @Column(name = "controller_id", length = 64)
@Size(min = 1) @Size(min = 1, max = 64)
@NotNull @NotNull
private String controllerId; private String controllerId;
@@ -107,6 +107,8 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
* with this security token. * with this security token.
*/ */
@Column(name = "sec_token", insertable = true, updatable = true, nullable = false, length = 128) @Column(name = "sec_token", insertable = true, updatable = true, nullable = false, length = 128)
@Size(max = 64)
@NotNull
private String securityToken; private String securityToken;
@CascadeOnDelete @CascadeOnDelete

View File

@@ -13,6 +13,8 @@ import javax.persistence.Entity;
import javax.persistence.Index; import javax.persistence.Index;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@@ -30,10 +32,14 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery { public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery {
private static final long serialVersionUID = 7493966984413479089L; private static final long serialVersionUID = 7493966984413479089L;
@Column(name = "name", length = 64) @Column(name = "name", length = 64, nullable = false)
@Size(max = 64)
@NotNull
private String name; private String name;
@Column(name = "query", length = 1024) @Column(name = "query", length = 1024, nullable = false)
@Size(max = 1024)
@NotNull
private String query; private String query;
public JpaTargetFilterQuery() { public JpaTargetFilterQuery() {

View File

@@ -37,6 +37,8 @@ import javax.persistence.MapsId;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException; import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
@@ -88,6 +90,7 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
private JpaTarget target; private JpaTarget target;
@Column(name = "address", length = 512) @Column(name = "address", length = 512)
@Size(max = 512)
private String address; private String address;
@Column(name = "last_target_query") @Column(name = "last_target_query")
@@ -96,8 +99,9 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
@Column(name = "install_date") @Column(name = "install_date")
private Long installationDate; private Long installationDate;
@Column(name = "update_status", nullable = false, length = 255) @Column(name = "update_status", nullable = false, length = 16)
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@NotNull
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)

View File

@@ -13,6 +13,8 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.repository.model.TenantConfiguration;
@@ -29,11 +31,15 @@ import org.eclipse.hawkbit.repository.model.TenantConfiguration;
public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration { public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "conf_key", length = 128) @Column(name = "conf_key", length = 128, nullable = false)
@Size(max = 128)
@NotNull
private String key; private String key;
@Column(name = "conf_value", length = 512) @Column(name = "conf_value", length = 512, nullable = false)
@Basic @Basic
@Size(max = 512)
@NotNull
private String value; private String value;
/** /**

View File

@@ -19,6 +19,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
@@ -43,6 +44,7 @@ public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMe
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "tenant", nullable = false, length = 40) @Column(name = "tenant", nullable = false, length = 40)
@Size(max = 40)
private String tenant; private String tenant;
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)

View File

@@ -0,0 +1,5 @@
ALTER TABLE sp_target_info MODIFY update_status VARCHAR(16) not null;
ALTER TABLE sp_action MODIFY action_type VARCHAR(16) not null;
ALTER TABLE sp_rollout MODIFY action_type VARCHAR(16) not null;
ALTER TABLE sp_tenant_configuration MODIFY conf_key VARCHAR(128) not null;
ALTER TABLE sp_tenant_configuration MODIFY conf_value VARCHAR(512) not null;

View File

@@ -0,0 +1,5 @@
ALTER TABLE sp_target_info MODIFY update_status VARCHAR(16) not null;
ALTER TABLE sp_action MODIFY action_type VARCHAR(16) not null;
ALTER TABLE sp_rollout MODIFY action_type VARCHAR(16) not null;
ALTER TABLE sp_tenant_configuration MODIFY conf_key VARCHAR(128) not null;
ALTER TABLE sp_tenant_configuration MODIFY conf_value VARCHAR(512) not null;

View File

@@ -506,6 +506,21 @@ public class TestdataFactory {
return distributionSet; return distributionSet;
} }
/**
* builder method for generating a {@link DistributionSet}.
*
* @param name
* {@link DistributionSet#getName()}
*
* @return the generated {@link DistributionSet}
*/
public DistributionSet generateDistributionSet(final String name) {
final DistributionSet distributionSet = entityFactory.generateDistributionSet(name, DEFAULT_VERSION, null,
findOrCreateDefaultTestDsType(), null);
distributionSet.setDescription(LOREM.words(10));
return distributionSet;
}
/** /**
* Creates {@link DistributionSetTag}s in repository. * Creates {@link DistributionSetTag}s in repository.
* *

View File

@@ -32,7 +32,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
@@ -261,7 +261,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
final String fileName = (String) table.getContainerDataSource().getItem(itemId) final String fileName = (String) table.getContainerDataSource().getItem(itemId)
.getItemProperty(PROVIDED_FILE_NAME).getValue(); .getItemProperty(PROVIDED_FILE_NAME).getValue();
final Button deleteIcon = SPUIComponentProvider.getButton( final Button deleteIcon = SPUIComponentProvider.getButton(
fileName + "-" + SPUIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "", fileName + "-" + UIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true, SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true,
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class); FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId); deleteIcon.setData(itemId);
@@ -345,7 +345,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
detailsTable.setImmediate(true); detailsTable.setImmediate(true);
detailsTable.setSizeFull(); detailsTable.setSizeFull();
detailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE); detailsTable.setId(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
detailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); detailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
detailsTable.addStyleName(ValoTheme.TABLE_SMALL); detailsTable.addStyleName(ValoTheme.TABLE_SMALL);
return detailsTable; return detailsTable;
@@ -386,7 +386,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
*/ */
public void createMaxArtifactDetailsTable() { public void createMaxArtifactDetailsTable() {
maxArtifactDetailsTable = createArtifactDetailsTable(); maxArtifactDetailsTable = createArtifactDetailsTable();
maxArtifactDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX); maxArtifactDetailsTable.setId(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource()); maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource());
addGeneratedColumn(maxArtifactDetailsTable); addGeneratedColumn(maxArtifactDetailsTable);
if (!readOnly) { if (!readOnly) {

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria; import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.ViewScope;
@@ -37,8 +37,8 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
@Override @Override
protected String getComponentId(final Component component) { protected String getComponentId(final Component component) {
String id = component.getId(); String id = component.getId();
if (id != null && id.startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { if (id != null && id.startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
id = SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX; id = UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
} }
return id; return id;
} }
@@ -56,16 +56,16 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static Map<String, List<String>> createDropConfigurations() { private static Map<String, List<String>> createDropConfigurations() {
final Map<String, List<String>> config = new HashMap<>(); final Map<String, List<String>> config = new HashMap<>();
// Delete drop area droppable components // Delete drop area droppable components
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList( config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)); UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
return config; return config;
} }
private static Map<String, Object> createDropHintConfigurations() { private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = new HashMap<>(); final Map<String, Object> config = new HashMap<>();
config.put(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START); config.put(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START); config.put(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
return config; return config;
} }
} }

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable; import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
@@ -114,7 +114,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override @Override
protected String getDeleteAreaId() { protected String getDeleteAreaId() {
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID; return UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
} }
@Override @Override
@@ -130,10 +130,10 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
addToDeleteList(sourceTable, (TableTransferable) event.getTransferable()); addToDeleteList(sourceTable, (TableTransferable) event.getTransferable());
updateSWActionCount(); updateSWActionCount();
} }
if (sourceComponent.getId().startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { if (sourceComponent.getId().startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
final String swModuleTypeName = sourceComponent.getId() final String swModuleTypeName = sourceComponent.getId()
.replace(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); .replace(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() && artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) { .equalsIgnoreCase(swModuleTypeName)) {

View File

@@ -21,7 +21,7 @@ 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.SPUIComponentIdProvider; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -77,7 +77,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private ConfirmationTab createSMDeleteConfirmationTab() { private ConfirmationTab createSMDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab(); final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponentIdProvider.SW_DELETE_ALL); tab.getConfirmAll().setId(UIComponentIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab)); tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
@@ -181,7 +181,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private ConfirmationTab createSMtypeDeleteConfirmationTab() { private ConfirmationTab createSMtypeDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab(); final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE); tab.getConfirmAll().setId(UIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab)); tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));

View File

@@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
@@ -140,20 +140,20 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private void createRequiredComponents() { private void createRequiredComponents() {
nameTextField = createTextField("textfield.name", SPUIComponentIdProvider.SOFT_MODULE_NAME); nameTextField = createTextField("textfield.name", UIComponentIdProvider.SOFT_MODULE_NAME);
versionTextField = createTextField("textfield.version", SPUIComponentIdProvider.SOFT_MODULE_VERSION); versionTextField = createTextField("textfield.version", UIComponentIdProvider.SOFT_MODULE_VERSION);
vendorTextField = createTextField("textfield.vendor", SPUIComponentIdProvider.SOFT_MODULE_VENDOR); vendorTextField = createTextField("textfield.vendor", UIComponentIdProvider.SOFT_MODULE_VENDOR);
vendorTextField.setRequired(false); vendorTextField.setRequired(false);
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style") descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
.prompt(i18n.get("textfield.description")).id(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION) .prompt(i18n.get("textfield.description")).id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION)
.buildTextComponent(); .buildTextComponent();
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", null, null, true, null, typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", null, null, true, null,
i18n.get("upload.swmodule.type")); i18n.get("upload.swmodule.type"));
typeComboBox.setId(SPUIComponentIdProvider.SW_MODULE_TYPE); typeComboBox.setId(UIComponentIdProvider.SW_MODULE_TYPE);
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY); typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
typeComboBox.setNewItemsAllowed(Boolean.FALSE); typeComboBox.setNewItemsAllowed(Boolean.FALSE);
typeComboBox.setImmediate(Boolean.TRUE); typeComboBox.setImmediate(Boolean.TRUE);

View File

@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
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.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -91,7 +91,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override @Override
protected String getEditButtonId() { protected String getEditButtonId() {
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON; return UIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
} }
@Override @Override
@@ -137,19 +137,19 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"), final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor); HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponentIdProvider.DETAILS_VENDOR_LABEL_ID); vendorLabel.setId(UIComponentIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel); detailsTabLayout.addComponent(vendorLabel);
if (type != null) { if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"), final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type); type);
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID); typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel); detailsTabLayout.addComponent(typeLabel);
} }
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"), final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign); HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponentIdProvider.SWM_DTLS_MAX_ASSIGN); assignLabel.setId(UIComponentIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel); detailsTabLayout.addComponent(assignLabel);
} }
@@ -186,7 +186,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override @Override
protected String getDetailsHeaderCaptionId() { protected String getDetailsHeaderCaptionId() {
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID; return UIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
} }
@Override @Override

View File

@@ -25,7 +25,7 @@ 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.SPUIComponentIdProvider; 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;
@@ -83,7 +83,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Override @Override
protected String getTableId() { protected String getTableId() {
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE; return UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
} }
@Override @Override
@@ -230,7 +230,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
private Button createManageMetadataButton(final String nameVersionStr) { private Button createManageMetadataButton(final String nameVersionStr) {
final Button manageMetadataBtn = SPUIComponentProvider.getButton( final Button manageMetadataBtn = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false, UIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class); FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
manageMetadataBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON); manageMetadataBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON);
manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon")); manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon"));

View File

@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader; import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -58,17 +58,17 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override @Override
protected String getSearchBoxId() { protected String getSearchBoxId() {
return SPUIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD; return UIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
} }
@Override @Override
protected String getSearchRestIconId() { protected String getSearchRestIconId() {
return SPUIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON; return UIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON;
} }
@Override @Override
protected String getAddIconId() { protected String getAddIconId() {
return SPUIComponentIdProvider.SW_MODULE_ADD_BUTTON; return UIComponentIdProvider.SW_MODULE_ADD_BUTTON;
} }
@Override @Override
@@ -124,7 +124,7 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override @Override
protected String getMaxMinIconId() { protected String getMaxMinIconId() {
return SPUIComponentIdProvider.SW_MAX_MIN_TABLE_ICON; return UIComponentIdProvider.SW_MAX_MIN_TABLE_ICON;
} }
@Override @Override

View File

@@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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;
@@ -65,7 +65,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override @Override
protected String getButtonsTableId() { protected String getButtonsTableId() {
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID; return UIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
} }
@Override @Override
@@ -82,7 +82,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override @Override
protected String createButtonId(final String name) { protected String createButtonId(final String name) {
return SPUIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name; return UIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name;
} }
@Override @Override
@@ -104,7 +104,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override @Override
protected String getButttonWrapperIdPrefix() { protected String getButttonWrapperIdPrefix() {
return SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX; return UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
} }
@Override @Override

View File

@@ -13,7 +13,7 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -86,7 +86,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
@Override @Override
protected String getHideButtonId() { protected String getHideButtonId() {
return SPUIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID; return UIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID;
} }
@Override @Override

View File

@@ -32,7 +32,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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;
@@ -155,10 +155,10 @@ public class UploadConfirmationWindow implements Button.ClickListener {
} }
private void createRequiredComponents() { private void createRequiredComponents() {
uploadBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT, uploadBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT,
SPUILabelDefinitions.SUBMIT, ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class); SPUILabelDefinitions.SUBMIT, ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
uploadBtn.addClickListener(this); uploadBtn.addClickListener(this);
cancelBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON, cancelBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON,
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
SPUIButtonStyleTiny.class); SPUIButtonStyleTiny.class);
cancelBtn.addClickListener(this); cancelBtn.addClickListener(this);
@@ -166,7 +166,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
uploadDetailsTable = new Table(); uploadDetailsTable = new Table();
uploadDetailsTable.addStyleName("artifact-table"); uploadDetailsTable.addStyleName("artifact-table");
uploadDetailsTable.setSizeFull(); uploadDetailsTable.setSizeFull();
uploadDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE); uploadDetailsTable.setId(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_BORDERLESS); uploadDetailsTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); uploadDetailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_SMALL); uploadDetailsTable.addStyleName(ValoTheme.TABLE_SMALL);
@@ -242,7 +242,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
newItem.getItemProperty(SW_MODULE_NAME).setValue(HawkbitCommonUtil.getFormatedLabel(swNameVersion)); newItem.getItemProperty(SW_MODULE_NAME).setValue(HawkbitCommonUtil.getFormatedLabel(swNameVersion));
newItem.getItemProperty(SIZE).setValue(customFile.getFileSize()); newItem.getItemProperty(SIZE).setValue(customFile.getFileSize());
final Button deleteIcon = SPUIComponentProvider.getButton( final Button deleteIcon = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD, UIComponentIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O, ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O,
SPUIButtonStyleSmallNoBorder.class); SPUIButtonStyleSmallNoBorder.class);
deleteIcon.addClickListener(this); deleteIcon.addClickListener(this);
@@ -537,14 +537,14 @@ public class UploadConfirmationWindow implements Button.ClickListener {
@Override @Override
public void buttonClick(final ClickEvent event) { public void buttonClick(final ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) { if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) {
uploadConfrimationWindow.close(); uploadConfrimationWindow.close();
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) { } else if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) {
uploadLayout.clearUploadedFileDetails(); uploadLayout.clearUploadedFileDetails();
uploadConfrimationWindow.close(); uploadConfrimationWindow.close();
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_BUTTON)) { } else if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_BUTTON)) {
processArtifactUpload(); processArtifactUpload();
} else if (event.getComponent().getId().startsWith(SPUIComponentIdProvider.UPLOAD_DELETE_ICON)) { } else if (event.getComponent().getId().startsWith(UIComponentIdProvider.UPLOAD_DELETE_ICON)) {
final String itemId = ((Button) event.getComponent()).getData().toString(); final String itemId = ((Button) event.getComponent()).getData().toString();
final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData()); final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData());
final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue(); final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();

View File

@@ -34,7 +34,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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;
@@ -333,7 +333,7 @@ public class UploadLayout extends VerticalLayout {
} }
private void createProcessButton() { private void createProcessButton() {
processBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON, processBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_PROCESS_BUTTON,
SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null, SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null,
SPUIButtonStyleSmall.class); SPUIButtonStyleSmall.class);
processBtn.setIcon(FontAwesome.BELL); processBtn.setIcon(FontAwesome.BELL);
@@ -344,7 +344,7 @@ public class UploadLayout extends VerticalLayout {
} }
private void createDiscardBtn() { private void createDiscardBtn() {
discardBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_BUTTON, discardBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_DISCARD_BUTTON,
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
SPUIButtonStyleSmall.class); SPUIButtonStyleSmall.class);
discardBtn.setIcon(FontAwesome.TRASH_O); discardBtn.setIcon(FontAwesome.TRASH_O);
@@ -635,7 +635,7 @@ public class UploadLayout extends VerticalLayout {
} }
private void displayConfirmWindow(final Button.ClickEvent event) { private void displayConfirmWindow(final Button.ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON)) { if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_PROCESS_BUTTON)) {
if (artifactUploadState.getFileSelected().isEmpty()) { if (artifactUploadState.getFileSelected().isEmpty()) {
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
} else { } else {
@@ -802,7 +802,7 @@ public class UploadLayout extends VerticalLayout {
} }
private void createUploadStatusButton() { private void createUploadStatusButton() {
uploadStatusButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_STATUS_BUTTON, "", "", "", uploadStatusButton = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_STATUS_BUTTON, "", "", "",
false, null, SPUIButtonStyleSmall.class); false, null, SPUIButtonStyleSmall.class);
uploadStatusButton.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON); uploadStatusButton.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE); uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; 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;
@@ -87,7 +87,7 @@ public class UploadResultWindow implements Button.ClickListener {
} }
private void createComponents() { private void createComponents() {
closeBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE, closeBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE,
SPUILabelDefinitions.CLOSE, SPUILabelDefinitions.CLOSE, ValoTheme.BUTTON_PRIMARY, false, null, SPUILabelDefinitions.CLOSE, SPUILabelDefinitions.CLOSE, ValoTheme.BUTTON_PRIMARY, false, null,
SPUIButtonStyleTiny.class); SPUIButtonStyleTiny.class);
closeBtn.addClickListener(this); closeBtn.addClickListener(this);
@@ -96,7 +96,7 @@ public class UploadResultWindow implements Button.ClickListener {
uploadResultTable.addStyleName("artifact-table"); uploadResultTable.addStyleName("artifact-table");
uploadResultTable.setSizeFull(); uploadResultTable.setSizeFull();
uploadResultTable.setImmediate(true); uploadResultTable.setImmediate(true);
uploadResultTable.setId(SPUIComponentIdProvider.UPLOAD_RESULT_TABLE); uploadResultTable.setId(UIComponentIdProvider.UPLOAD_RESULT_TABLE);
uploadResultTable.addStyleName(ValoTheme.TABLE_BORDERLESS); uploadResultTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
uploadResultTable.addStyleName(ValoTheme.TABLE_SMALL); uploadResultTable.addStyleName(ValoTheme.TABLE_SMALL);
uploadResultTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); uploadResultTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
@@ -128,7 +128,7 @@ public class UploadResultWindow implements Button.ClickListener {
reasonLabel = HawkbitCommonUtil.getFormatedLabel(uploadResult.getReason()); reasonLabel = HawkbitCommonUtil.getFormatedLabel(uploadResult.getReason());
reasonLabel.setDescription(uploadResult.getReason()); reasonLabel.setDescription(uploadResult.getReason());
final String idStr = SPUIComponentIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/" final String idStr = UIComponentIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/"
+ uploadResult.getFileName(); + uploadResult.getFileName();
reasonLabel.setId(idStr); reasonLabel.setId(idStr);
newItem.getItemProperty(REASON).setValue(reasonLabel); newItem.getItemProperty(REASON).setValue(reasonLabel);
@@ -187,8 +187,8 @@ public class UploadResultWindow implements Button.ClickListener {
@Override @Override
public void buttonClick(final ClickEvent event) { public void buttonClick(final ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE) if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|| event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) { || event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
uploadResultsWindow.close(); uploadResultsWindow.close();
//close upload status popup if open //close upload status popup if open
eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED); eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED);

Some files were not shown because too many files have changed in this diff Show More