Remove and Rename modules

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-05-18 13:48:04 +02:00
parent e30748dd53
commit 5bb24c78ad
423 changed files with 124 additions and 782 deletions

View File

@@ -66,7 +66,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-ui</artifactId> <artifactId>hawkbit-ui</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -67,11 +67,6 @@
<artifactId>hawkbit-mgmt-resource</artifactId> <artifactId>hawkbit-mgmt-resource</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-system-resource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-ddi-resource</artifactId> <artifactId>hawkbit-ddi-resource</artifactId>
@@ -84,7 +79,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-ui</artifactId> <artifactId>hawkbit-ui</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -12,7 +12,6 @@ import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration; import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
import org.eclipse.hawkbit.ddi.EnableDdiApi; import org.eclipse.hawkbit.ddi.EnableDdiApi;
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi; import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@@ -27,7 +26,6 @@ import org.springframework.context.annotation.Import;
@EnableHawkbitManagedSecurityConfiguration @EnableHawkbitManagedSecurityConfiguration
@EnableMgmtApi @EnableMgmtApi
@EnableDdiApi @EnableDdiApi
@EnableSystemApi
// Exception squid:S1118 - Spring boot standard behavior // Exception squid:S1118 - Spring boot standard behavior
@SuppressWarnings({ "squid:S1118" }) @SuppressWarnings({ "squid:S1118" })
public class Start { public class Start {

View File

@@ -17,7 +17,7 @@
<version>0.2.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>hawkbit-example-feign-core-client</artifactId> <artifactId>hawkbit-example-core-feign-client</artifactId>
<name>hawkBit-example :: Feign Core Client</name> <name>hawkBit-example :: Feign Core Client</name>
<dependencies> <dependencies>

View File

@@ -16,7 +16,7 @@
<artifactId>hawkbit-examples-parent</artifactId> <artifactId>hawkbit-examples-parent</artifactId>
<version>0.2.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>hawkbit-example-ddi-client</artifactId> <artifactId>hawkbit-example-ddi-feign-client</artifactId>
<name>hawkBit-example :: DDI Feign Client</name> <name>hawkBit-example :: DDI Feign Client</name>
@@ -35,7 +35,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-example-feign-core-client</artifactId> <artifactId>hawkbit-example-core-feign-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -17,13 +17,13 @@
<version>0.2.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
</parent> </parent>
<packaging>jar</packaging> <packaging>jar</packaging>
<artifactId>hawkbit-example-mgmt-client</artifactId> <artifactId>hawkbit-example-mgmt-feign-client</artifactId>
<name>hawkBit-example :: Management client API</name> <name>hawkBit-example :: Management client API</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-example-feign-core-client</artifactId> <artifactId>hawkbit-example-core-feign-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -31,11 +31,6 @@
<artifactId>hawkbit-mgmt-api</artifactId> <artifactId>hawkbit-mgmt-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-system-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>

View File

@@ -8,14 +8,14 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.system.rest.api.SystemRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the {@link SystemRestApi}. * Client binding for the {@link MgmtSystemRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + SystemClientResource.PATH) @FeignClient(url = "${hawkbit.url:localhost:8080}/" + SystemClientResource.PATH)
public interface SystemClientResource extends SystemRestApi { public interface SystemClientResource extends MgmtSystemRestApi {
static String PATH = "rest/v1/system"; static String PATH = "rest/v1/system";
} }

View File

@@ -8,15 +8,15 @@
*/ */
package org.eclipse.hawkbit.mgmt.client.resource; package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.system.rest.api.SystemManagementRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemManagementRestApi;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the {@link SystemManagementRestApi}. * Client binding for the {@link MgmtSystemManagementRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + SystemManagementClientResource.PATH) @FeignClient(url = "${hawkbit.url:localhost:8080}/" + SystemManagementClientResource.PATH)
public interface SystemManagementClientResource extends SystemManagementRestApi { public interface SystemManagementClientResource extends MgmtSystemManagementRestApi {
static String PATH = "system/admin"; static String PATH = "system/admin";
} }

View File

@@ -17,7 +17,7 @@
<version>0.2.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
</parent> </parent>
<packaging>jar</packaging> <packaging>jar</packaging>
<artifactId>hawkbit-example-mgmt-spring-client</artifactId> <artifactId>hawkbit-example-mgmt-simulator</artifactId>
<name>hawkBit-example :: Management Feign Client</name> <name>hawkBit-example :: Management Feign Client</name>
<build> <build>
@@ -57,7 +57,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-example-mgmt-client</artifactId> <artifactId>hawkbit-example-mgmt-feign-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -22,12 +22,12 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>hawkbit-example-feign-core-client</module>
<module>hawkbit-device-simulator</module> <module>hawkbit-device-simulator</module>
<module>hawkbit-example-app</module> <module>hawkbit-example-app</module>
<module>hawkbit-example-mgmt-client</module> <module>hawkbit-example-core-feign-client</module>
<module>hawkbit-example-mgmt-spring-client</module> <module>hawkbit-example-ddi-feign-client</module>
<module>hawkbit-example-ddi-client</module> <module>hawkbit-example-mgmt-feign-client</module>
<module>hawkbit-example-mgmt-simulator</module>
</modules> </modules>

View File

@@ -40,7 +40,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-ui</artifactId> <artifactId>hawkbit-ui</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
@@ -68,12 +68,6 @@
<version>${project.version}</version> <version>${project.version}</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-system-resource</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-resource</artifactId> <artifactId>hawkbit-mgmt-resource</artifactId>

View File

@@ -26,6 +26,7 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken; import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken;
import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter; import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
@@ -40,7 +41,6 @@ import org.eclipse.hawkbit.security.HttpControllerPreAuthenticatedSecurityHeader
import org.eclipse.hawkbit.security.HttpDownloadAuthenticationFilter; import org.eclipse.hawkbit.security.HttpDownloadAuthenticationFilter;
import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider; import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.system.rest.api.SystemRestConstant;
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;
@@ -292,9 +292,9 @@ public class SecurityManagedConfiguration {
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement), new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
RequestHeaderAuthenticationFilter.class) RequestHeaderAuthenticationFilter.class)
.authorizeRequests().anyRequest().authenticated() .authorizeRequests().anyRequest().authenticated()
.antMatchers(SystemRestConstant.BASE_SYSTEM_MAPPING + "/admin/**") .antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN) .hasAnyAuthority(SpPermission.SYSTEM_ADMIN)
.antMatchers(SystemRestConstant.BASE_SYSTEM_MAPPING + "/**") .antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/**")
.hasAnyAuthority(SpPermission.SYSTEM_DIAG); .hasAnyAuthority(SpPermission.SYSTEM_DIAG);
} }
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.autoconfigure.web;
import org.eclipse.hawkbit.ddi.EnableDdiApi; import org.eclipse.hawkbit.ddi.EnableDdiApi;
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi; import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@@ -20,8 +19,8 @@ import org.springframework.context.annotation.Import;
* *
*/ */
@Configuration @Configuration
@ConditionalOnClass({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class }) @ConditionalOnClass({ EnableDdiApi.class, EnableMgmtApi.class })
@Import({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class }) @Import({ EnableDdiApi.class, EnableMgmtApi.class })
public class ResourceControllerAutoConfiguration { public class ResourceControllerAutoConfiguration {
} }

View File

@@ -48,7 +48,7 @@ import org.springframework.web.context.WebApplicationContext;
* for legacy controllers that can not be fed with a download URI at runtime. * for legacy controllers that can not be fed with a download URI at runtime.
*/ */
@RestController @RestController
@Scope(value = WebApplicationContext.SCOPE_REQUEST) @Scope(WebApplicationContext.SCOPE_REQUEST)
public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerRestApi { public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerRestApi {
private static final Logger LOG = LoggerFactory.getLogger(DdiArtifactStoreController.class); private static final Logger LOG = LoggerFactory.getLogger(DdiArtifactStoreController.class);

View File

@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.json.model.system; package org.eclipse.hawkbit.mgmt.json.model.system;
import org.springframework.hateoas.ResourceSupport; import org.springframework.hateoas.ResourceSupport;
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantConfigurationValue extends ResourceSupport { public class MgmtSystemTenantConfigurationValue extends ResourceSupport {
@JsonInclude(Include.ALWAYS) @JsonInclude(Include.ALWAYS)
private Object value; private Object value;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.json.model.system; package org.eclipse.hawkbit.mgmt.json.model.system;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
@@ -18,21 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantConfigurationValueRequest { public class MgmtSystemTenantConfigurationValueRequest {
@JsonProperty(required = true) @JsonProperty(required = true)
private Object value; private Object value;
/** /**
* *
* @return the value of the SystemTenantConfigurationValueRequest * @return the value of the MgmtSystemTenantConfigurationValueRequest
*/ */
public Object getValue() { public Object getValue() {
return value; return value;
} }
/** /**
* Sets the SystemTenantConfigurationValueRequest * Sets the MgmtSystemTenantConfigurationValueRequest
* *
* @param value * @param value
*/ */

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.json.model.systemmanagement; package org.eclipse.hawkbit.mgmt.json.model.systemmanagement;
import java.util.Collection; import java.util.Collection;
@@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class SystemCache { public class MgmtSystemCache {
private final String name; private final String name;
private final Collection<String> keys; private final Collection<String> keys;
@@ -31,7 +31,7 @@ public class SystemCache {
* @param cacheKeys * @param cacheKeys
* the keys which contains in the cache * the keys which contains in the cache
*/ */
public SystemCache(final String name, final Collection<String> cacheKeys) { public MgmtSystemCache(final String name, final Collection<String> cacheKeys) {
this.name = name; this.name = name;
this.keys = cacheKeys; this.keys = cacheKeys;
} }
@@ -57,6 +57,6 @@ public class SystemCache {
*/ */
@Override @Override
public String toString() { public String toString() {
return "SystemCache [name=" + name + ", keys=" + keys + "]"; return "MgmtSystemCache [name=" + name + ", keys=" + keys + "]";
} }
} }

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.json.model.systemmanagement; package org.eclipse.hawkbit.mgmt.json.model.systemmanagement;
import java.util.List; import java.util.List;
@@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class SystemStatisticsRest { public class MgmtSystemStatisticsRest {
private long overallTargets; private long overallTargets;
private long overallArtifacts; private long overallArtifacts;
@@ -28,13 +28,13 @@ public class SystemStatisticsRest {
private long overallActions; private long overallActions;
private long overallTenants; private long overallTenants;
private List<SystemTenantServiceUsage> tenantStats; private List<MgmtSystemTenantServiceUsage> tenantStats;
public long getOverallTargets() { public long getOverallTargets() {
return overallTargets; return overallTargets;
} }
public SystemStatisticsRest setOverallTargets(final long overallTargets) { public MgmtSystemStatisticsRest setOverallTargets(final long overallTargets) {
this.overallTargets = overallTargets; this.overallTargets = overallTargets;
return this; return this;
} }
@@ -43,7 +43,7 @@ public class SystemStatisticsRest {
return overallArtifacts; return overallArtifacts;
} }
public SystemStatisticsRest setOverallArtifacts(final long overallArtifacts) { public MgmtSystemStatisticsRest setOverallArtifacts(final long overallArtifacts) {
this.overallArtifacts = overallArtifacts; this.overallArtifacts = overallArtifacts;
return this; return this;
} }
@@ -52,7 +52,7 @@ public class SystemStatisticsRest {
return overallArtifactVolumeInBytes; return overallArtifactVolumeInBytes;
} }
public SystemStatisticsRest setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) { public MgmtSystemStatisticsRest setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) {
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes; this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
return this; return this;
} }
@@ -61,7 +61,7 @@ public class SystemStatisticsRest {
return overallActions; return overallActions;
} }
public SystemStatisticsRest setOverallActions(final long overallActions) { public MgmtSystemStatisticsRest setOverallActions(final long overallActions) {
this.overallActions = overallActions; this.overallActions = overallActions;
return this; return this;
} }
@@ -70,16 +70,16 @@ public class SystemStatisticsRest {
return overallTenants; return overallTenants;
} }
public SystemStatisticsRest setOverallTenants(final long overallTenants) { public MgmtSystemStatisticsRest setOverallTenants(final long overallTenants) {
this.overallTenants = overallTenants; this.overallTenants = overallTenants;
return this; return this;
} }
public void setTenantStats(final List<SystemTenantServiceUsage> tenantStats) { public void setTenantStats(final List<MgmtSystemTenantServiceUsage> tenantStats) {
this.tenantStats = tenantStats; this.tenantStats = tenantStats;
} }
public List<SystemTenantServiceUsage> getTenantStats() { public List<MgmtSystemTenantServiceUsage> getTenantStats() {
return tenantStats; return tenantStats;
} }

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.json.model.systemmanagement; package org.eclipse.hawkbit.mgmt.json.model.systemmanagement;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
@@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantServiceUsage { public class MgmtSystemTenantServiceUsage {
private final String tenantName; private final String tenantName;
private long targets; private long targets;
@@ -31,7 +31,7 @@ public class SystemTenantServiceUsage {
* *
* @param tenantName * @param tenantName
*/ */
public SystemTenantServiceUsage(final String tenantName) { public MgmtSystemTenantServiceUsage(final String tenantName) {
super(); super();
this.tenantName = tenantName; this.tenantName = tenantName;
} }

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.mgmt.rest.api;
/** /**
* Constants for RESTful API. * Constants for RESTful API.
* *
*
*
*/ */
public final class MgmtRestConstants { public final class MgmtRestConstants {
@@ -46,8 +44,21 @@ public final class MgmtRestConstants {
public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules"; public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules";
public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE = "/api/" + API_VERSION + "/downloadserver/"; public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE = "/api/" + API_VERSION + "/downloadserver/";
public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING = "downloadId/{downloadId}"; public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING = "downloadId/{downloadId}";
/**
* The base URL mapping for the spring acuator management context path.
*/
public static final String BASE_SYSTEM_MAPPING = "/system";
/**
* URL mapping for system admin operations.
*/
public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin";
public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + BASE_SYSTEM_MAPPING;
/** /**
* The target URL mapping, href link for assigned distribution set. * The target URL mapping, href link for assigned distribution set.
*/ */

View File

@@ -6,12 +6,12 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.rest.api; package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.Collection; import java.util.Collection;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemCache; import org.eclipse.hawkbit.mgmt.json.model.systemmanagement.MgmtSystemCache;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemStatisticsRest; import org.eclipse.hawkbit.mgmt.json.model.systemmanagement.MgmtSystemStatisticsRest;
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;
@@ -22,8 +22,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
* {@link SystemManagement} capabilities by REST. * {@link SystemManagement} capabilities by REST.
* *
*/ */
@RequestMapping(SystemRestConstant.SYSTEM_ADMIN_MAPPING) @RequestMapping(MgmtRestConstants.SYSTEM_ADMIN_MAPPING)
public interface SystemManagementRestApi { public interface MgmtSystemManagementRestApi {
/** /**
* Deletes the tenant data of a given tenant. USE WITH CARE! * Deletes the tenant data of a given tenant. USE WITH CARE!
@@ -43,7 +43,7 @@ public interface SystemManagementRestApi {
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json", @RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<SystemStatisticsRest> getSystemUsageStats(); ResponseEntity<MgmtSystemStatisticsRest> getSystemUsageStats();
/** /**
* Returns a list of all caches. * Returns a list of all caches.
@@ -51,7 +51,7 @@ public interface SystemManagementRestApi {
* @return a list of caches for all tenants * @return a list of caches for all tenants
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/caches") @RequestMapping(method = RequestMethod.GET, value = "/caches")
ResponseEntity<Collection<SystemCache>> getCaches(); ResponseEntity<Collection<MgmtSystemCache>> getCaches();
/** /**
* Invalidates all caches for all tenants. * Invalidates all caches for all tenants.

View File

@@ -6,12 +6,12 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.rest.api; package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValueRequest; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.springframework.hateoas.ResourceSupport; 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;
@@ -25,8 +25,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
* *
* *
*/ */
@RequestMapping(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING) @RequestMapping(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING)
public interface SystemRestApi { public interface MgmtSystemRestApi {
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<ResourceSupport> getSystem(); ResponseEntity<ResourceSupport> getSystem();
@@ -36,7 +36,7 @@ public interface SystemRestApi {
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { "application/hal+json", @RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Map<String, SystemTenantConfigurationValue>> getSystemConfiguration(); ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getSystemConfiguration();
/** /**
* Handles the DELETE request of deleting a tenant specific configuration * Handles the DELETE request of deleting a tenant specific configuration
@@ -64,7 +64,8 @@ public interface SystemRestApi {
*/ */
@RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { "application/hal+json", @RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }) MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<SystemTenantConfigurationValue> getConfigurationValue(@PathVariable("keyName") final String keyName); ResponseEntity<MgmtSystemTenantConfigurationValue> getConfigurationValue(
@PathVariable("keyName") final String keyName);
/** /**
* Handles the GET request of deleting a tenant specific configuration value * Handles the GET request of deleting a tenant specific configuration value
@@ -80,8 +81,8 @@ public interface SystemRestApi {
*/ */
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { "application/hal+json", @RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", 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<SystemTenantConfigurationValue> updateConfigurationValue( ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(
@PathVariable("keyName") final String keyName, @PathVariable("keyName") final String keyName,
@RequestBody final SystemTenantConfigurationValueRequest configurationValueRest); @RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest);
} }

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.rest.resource; package org.eclipse.hawkbit.mgmt.rest.resource;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -14,13 +14,13 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.mgmt.json.model.systemmanagement.MgmtSystemCache;
import org.eclipse.hawkbit.mgmt.json.model.systemmanagement.MgmtSystemStatisticsRest;
import org.eclipse.hawkbit.mgmt.json.model.systemmanagement.MgmtSystemTenantServiceUsage;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemManagementRestApi;
import org.eclipse.hawkbit.report.model.SystemUsageReport; import org.eclipse.hawkbit.report.model.SystemUsageReport;
import org.eclipse.hawkbit.report.model.TenantUsage; import org.eclipse.hawkbit.report.model.TenantUsage;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemCache;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemStatisticsRest;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemTenantServiceUsage;
import org.eclipse.hawkbit.system.rest.api.SystemManagementRestApi;
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.beans.factory.annotation.Autowired;
@@ -37,9 +37,9 @@ import org.springframework.web.bind.annotation.RestController;
* *
*/ */
@RestController @RestController
public class SystemManagementResource implements SystemManagementRestApi { public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi {
private static final Logger LOGGER = LoggerFactory.getLogger(SystemManagementResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(MgmtSystemManagementResource.class);
@Autowired @Autowired
private SystemManagement systemManagement; private SystemManagement systemManagement;
@@ -67,22 +67,22 @@ public class SystemManagementResource implements SystemManagementRestApi {
* @return system usage statistics * @return system usage statistics
*/ */
@Override @Override
public ResponseEntity<SystemStatisticsRest> getSystemUsageStats() { public ResponseEntity<MgmtSystemStatisticsRest> getSystemUsageStats() {
final SystemUsageReport report = systemManagement.getSystemUsageStatistics(); final SystemUsageReport report = systemManagement.getSystemUsageStatistics();
final SystemStatisticsRest result = new SystemStatisticsRest().setOverallActions(report.getOverallActions()) final MgmtSystemStatisticsRest result = new MgmtSystemStatisticsRest()
.setOverallArtifacts(report.getOverallArtifacts()) .setOverallActions(report.getOverallActions()).setOverallArtifacts(report.getOverallArtifacts())
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes()) .setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size()); .setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
result.setTenantStats( result.setTenantStats(report.getTenants().stream().map(MgmtSystemManagementResource::convertTenant)
report.getTenants().stream().map(SystemManagementResource::convertTenant).collect(Collectors.toList())); .collect(Collectors.toList()));
return ResponseEntity.ok(result); return ResponseEntity.ok(result);
} }
private static SystemTenantServiceUsage convertTenant(final TenantUsage tenant) { private static MgmtSystemTenantServiceUsage convertTenant(final TenantUsage tenant) {
final SystemTenantServiceUsage result = new SystemTenantServiceUsage(tenant.getTenantName()); final MgmtSystemTenantServiceUsage result = new MgmtSystemTenantServiceUsage(tenant.getTenantName());
result.setActions(tenant.getActions()); result.setActions(tenant.getActions());
result.setArtifacts(tenant.getArtifacts()); result.setArtifacts(tenant.getArtifacts());
result.setOverallArtifactVolumeInBytes(tenant.getOverallArtifactVolumeInBytes()); result.setOverallArtifactVolumeInBytes(tenant.getOverallArtifactVolumeInBytes());
@@ -98,7 +98,7 @@ public class SystemManagementResource implements SystemManagementRestApi {
*/ */
@Override @Override
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
public ResponseEntity<Collection<SystemCache>> getCaches() { public ResponseEntity<Collection<MgmtSystemCache>> getCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames(); final Collection<String> cacheNames = cacheManager.getCacheNames();
return ResponseEntity return ResponseEntity
.ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList())); .ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList()));
@@ -118,20 +118,20 @@ public class SystemManagementResource implements SystemManagementRestApi {
return ResponseEntity.ok(cacheNames); return ResponseEntity.ok(cacheNames);
} }
private SystemCache cacheRest(final Cache cache) { private MgmtSystemCache cacheRest(final Cache cache) {
final Object nativeCache = cache.getNativeCache(); final Object nativeCache = cache.getNativeCache();
if (nativeCache instanceof com.google.common.cache.Cache) { if (nativeCache instanceof com.google.common.cache.Cache) {
return guavaCache(cache, nativeCache); return guavaCache(cache, nativeCache);
} else { } else {
return new SystemCache(cache.getName(), Collections.emptyList()); return new MgmtSystemCache(cache.getName(), Collections.emptyList());
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private SystemCache guavaCache(final Cache cache, final Object nativeCache) { private MgmtSystemCache guavaCache(final Cache cache, final Object nativeCache) {
final com.google.common.cache.Cache<Object, Object> guavaCache = (com.google.common.cache.Cache<Object, Object>) nativeCache; final com.google.common.cache.Cache<Object, Object> guavaCache = (com.google.common.cache.Cache<Object, Object>) nativeCache;
final List<String> keys = guavaCache.asMap().keySet().stream().map(key -> key.toString()) final List<String> keys = guavaCache.asMap().keySet().stream().map(key -> key.toString())
.collect(Collectors.toList()); .collect(Collectors.toList());
return new SystemCache(cache.getName(), keys); return new MgmtSystemCache(cache.getName(), keys);
} }
} }

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.rest.resource; package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
@@ -14,18 +14,18 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
/** /**
* A mapper which maps repository model to RESTful model representation and * A mapper which maps repository model to RESTful model representation and
* back. * back.
*/ */
public class SystemMapper { public class MgmtSystemMapper {
private SystemMapper() { private MgmtSystemMapper() {
// Utility class // Utility class
} }
@@ -34,10 +34,10 @@ public class SystemMapper {
* instance of TenantConfigurationManagement * instance of TenantConfigurationManagement
* @return a map of all existing configuration values * @return a map of all existing configuration values
*/ */
public static Map<String, SystemTenantConfigurationValue> toResponse( public static Map<String, MgmtSystemTenantConfigurationValue> toResponse(
final TenantConfigurationManagement tenantConfigurationManagement) { final TenantConfigurationManagement tenantConfigurationManagement) {
final Map<String, SystemTenantConfigurationValue> configurationMap = new HashMap<>(); final Map<String, MgmtSystemTenantConfigurationValue> configurationMap = new HashMap<>();
for (final TenantConfigurationKey key : TenantConfigurationKey.values()) { for (final TenantConfigurationKey key : TenantConfigurationKey.values()) {
configurationMap.put(key.getKeyName(), configurationMap.put(key.getKeyName(),
@@ -49,15 +49,15 @@ public class SystemMapper {
/** /**
* maps a TenantConfigurationValue from the repository model to a * maps a TenantConfigurationValue from the repository model to a
* SystemTenantConfigurationValue, the RESTful model. * MgmtSystemTenantConfigurationValue, the RESTful model.
* *
* @param repoConfValue * @param repoConfValue
* configuration value as repository model * configuration value as repository model
* @return configuration value as RESTful model * @return configuration value as RESTful model
*/ */
public static SystemTenantConfigurationValue toResponse(final String key, public static MgmtSystemTenantConfigurationValue toResponse(final String key,
final TenantConfigurationValue<?> repoConfValue) { final TenantConfigurationValue<?> repoConfValue) {
final SystemTenantConfigurationValue restConfValue = new SystemTenantConfigurationValue(); final MgmtSystemTenantConfigurationValue restConfValue = new MgmtSystemTenantConfigurationValue();
restConfValue.setValue(repoConfValue.getValue()); restConfValue.setValue(repoConfValue.getValue());
restConfValue.setGlobal(repoConfValue.isGlobal()); restConfValue.setGlobal(repoConfValue.isGlobal());
@@ -66,7 +66,7 @@ public class SystemMapper {
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt()); restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy()); restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy());
restConfValue.add(linkTo(methodOn(SystemResource.class).getConfigurationValue(key)).withRel("self")); restConfValue.add(linkTo(methodOn(MgmtSystemResource.class).getConfigurationValue(key)).withRel("self"));
return restConfValue; return restConfValue;
} }

View File

@@ -6,18 +6,18 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.system.rest.resource; package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValueRequest;
import org.eclipse.hawkbit.system.rest.api.SystemRestApi;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -31,15 +31,11 @@ import org.springframework.web.bind.annotation.RestController;
/** /**
* REST Resource handling tenant specific configuration operations. * REST Resource handling tenant specific configuration operations.
*
*
*
*
*/ */
@RestController @RestController
public class SystemResource implements SystemRestApi { public class MgmtSystemResource implements MgmtSystemRestApi {
private static final Logger LOG = LoggerFactory.getLogger(SystemResource.class); private static final Logger LOG = LoggerFactory.getLogger(MgmtSystemResource.class);
@Autowired @Autowired
private TenantConfigurationManagement tenantConfigurationManagement; private TenantConfigurationManagement tenantConfigurationManagement;
@@ -47,7 +43,7 @@ public class SystemResource implements SystemRestApi {
@Override @Override
public ResponseEntity<ResourceSupport> getSystem() { public ResponseEntity<ResourceSupport> getSystem() {
final ResourceSupport resourceSupport = new ResourceSupport(); final ResourceSupport resourceSupport = new ResourceSupport();
resourceSupport.add(linkTo(methodOn(SystemResource.class).getSystemConfiguration()).withRel("configs")); resourceSupport.add(linkTo(methodOn(MgmtSystemResource.class).getSystemConfiguration()).withRel("configs"));
return ResponseEntity.ok(resourceSupport); return ResponseEntity.ok(resourceSupport);
} }
@@ -55,8 +51,8 @@ public class SystemResource implements SystemRestApi {
* @return a Map of all configuration values. * @return a Map of all configuration values.
*/ */
@Override @Override
public ResponseEntity<Map<String, SystemTenantConfigurationValue>> getSystemConfiguration() { public ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getSystemConfiguration() {
return new ResponseEntity<>(SystemMapper.toResponse(tenantConfigurationManagement), HttpStatus.OK); return new ResponseEntity<>(MgmtSystemMapper.toResponse(tenantConfigurationManagement), HttpStatus.OK);
} }
/** /**
@@ -91,13 +87,13 @@ public class SystemResource implements SystemRestApi {
* response. * response.
*/ */
@Override @Override
public ResponseEntity<SystemTenantConfigurationValue> getConfigurationValue( public ResponseEntity<MgmtSystemTenantConfigurationValue> getConfigurationValue(
@PathVariable("keyName") final String keyName) { @PathVariable("keyName") final String keyName) {
final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName); final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName);
LOG.debug("{} config value getted, return status {}", keyName, HttpStatus.OK); LOG.debug("{} config value getted, return status {}", keyName, HttpStatus.OK);
return new ResponseEntity<>(SystemMapper.toResponse(configKey.getKeyName(), return new ResponseEntity<>(MgmtSystemMapper.toResponse(configKey.getKeyName(),
tenantConfigurationManagement.getConfigurationValue(configKey)), HttpStatus.OK); tenantConfigurationManagement.getConfigurationValue(configKey)), HttpStatus.OK);
} }
@@ -114,16 +110,16 @@ public class SystemResource implements SystemRestApi {
* response. * response.
*/ */
@Override @Override
public ResponseEntity<SystemTenantConfigurationValue> updateConfigurationValue( public ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(
@PathVariable("keyName") final String keyName, @PathVariable("keyName") final String keyName,
@RequestBody final SystemTenantConfigurationValueRequest configurationValueRest) { @RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest) {
final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName); final TenantConfigurationKey configKey = TenantConfigurationKey.fromKeyName(keyName);
final TenantConfigurationValue<Object> updatedValue = tenantConfigurationManagement final TenantConfigurationValue<Object> updatedValue = tenantConfigurationManagement
.addOrUpdateConfiguration(configKey, configurationValueRest.getValue()); .addOrUpdateConfiguration(configKey, configurationValueRest.getValue());
return new ResponseEntity<>(SystemMapper.toResponse(keyName, updatedValue), HttpStatus.OK); return new ResponseEntity<>(MgmtSystemMapper.toResponse(keyName, updatedValue), HttpStatus.OK);
} }
} }

View File

@@ -1,14 +0,0 @@
# Eclipse.IoT hawkBit - System API
The System API is used to configurate the hawkBit Update Server. This includes tenants specific operations as well as system wide operations.
# Compile
#### Build hawkbit-system-api
```
$ cd hawkbit/hawkbit-system-api
$ mvn clean install
```

View File

@@ -1,33 +0,0 @@
<!--
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-parent</artifactId>
<version>0.2.0-SNAPSHOT</version>
</parent>
<artifactId>hawkbit-system-api</artifactId>
<name>hawkBit :: System REST API</name>
<dependencies>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -1,41 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.api;
/**
*
*/
public final class SystemRestConstant {
/**
* API version definition. We are using only major versions.
*/
public static final String API_VERSION = "v1";
/**
* The base URL mapping for the spring acuator management context path.
*/
public static final String BASE_SYSTEM_MAPPING = "/system";
/**
* The base URL mapping of the SP rest resources.
*/
public static final String BASE_V1_REQUEST_MAPPING = "/rest/" + API_VERSION;
/**
* URL mapping for system admin operations.
*/
public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin";
public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + BASE_SYSTEM_MAPPING;
private SystemRestConstant() {
}
}

View File

@@ -1,13 +0,0 @@
# Eclipse.IoT hawkBit - System Resource
This is the server-side implementation of the hawkBit System API that is used to configurate the hawkBit Update Server
# Compile
#### Build hawkbit-system-resource
```
$ cd hawkbit/hawkbit-system-resource
$ mvn clean install
```

View File

@@ -1,157 +0,0 @@
<!--
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-parent</artifactId>
<version>0.2.0-SNAPSHOT</version>
</parent>
<artifactId>hawkbit-system-resource</artifactId>
<name>hawkBit :: System REST Resources</name>
<dependencies>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-system-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-rest-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-rest-core</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-http-security</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-junit-adaptor</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,33 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Controller;
/**
* Annotation to enable {@link ComponentScan} in the resource package to setup
* all {@link Controller} annotated classes and setup the System API.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Configuration
@ComponentScan
@Import(RestConfiguration.class)
public @interface EnableSystemApi {
}

View File

@@ -1,32 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.resource;
import java.io.IOException;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Utility additions for the REST API tests.
*
*
*/
public final class ResourceUtility {
private static final ObjectMapper mapper = new ObjectMapper();
static ExceptionInfo convertException(final String jsonExceptionResponse)
throws JsonParseException, JsonMappingException, IOException {
return mapper.readValue(jsonExceptionResponse, ExceptionInfo.class);
}
}

View File

@@ -1,175 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.resource;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Random;
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
import org.eclipse.hawkbit.TestDataUtil;
import org.eclipse.hawkbit.WithSpringAuthorityRule;
import org.eclipse.hawkbit.WithUser;
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Test;
import org.springframework.http.MediaType;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
/**
*
*
*/
@Features("Component Tests - System API")
@Stories("System Management Resource")
public class SystemManagementResourceTest extends AbstractIntegrationTestWithMongoDB {
@Test
@WithUser(tenantId = "mytenant", authorities = { SpPermission.SYSTEM_ADMIN })
@Description("Tests that the system is able to collect statistics for the entire system.")
public void collectSystemStatistics() throws Exception {
createTestTenantsForSystemStatistics(2, 2000, 100, 2);
mvc.perform(get("/system/admin/usage").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].targets", equalTo(100)))
.andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].overallArtifactVolumeInBytes",
equalTo(2000)))
.andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].artifacts", equalTo(1)))
.andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].actions", equalTo(200)))
.andExpect(jsonPath("$overallTargets", equalTo(200)))
.andExpect(jsonPath("$overallArtifacts", equalTo(2)))
.andExpect(jsonPath("$overallArtifactVolumeInBytes", equalTo(4000)))
.andExpect(jsonPath("$overallActions", equalTo(400)))
.andExpect(jsonPath("$overallTenants", equalTo(4)));
}
@Test
@WithUser(tenantId = "mytenant", authorities = { SpPermission.DELETE_TARGET, SpPermission.DELETE_REPOSITORY,
SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY })
@Description("Tests that the system is not able to collect statistics for the entire system if the .")
public void collectSystemStatisticsWithMissingPermissionFails() throws Exception {
mvc.perform(get("/system/admin/usage").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isForbidden());
}
@Test
@WithUser(tenantId = "mytenant", allSpPermissions = true)
@Description("Tests that a tenant can be deletd by API.")
public void deleteTenant() throws Exception {
final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotNull();
mvc.perform(delete("/system/admin/tenants/mytenant")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNull();
}
@Test
@WithUser(tenantId = "mytenant", authorities = { SpPermission.DELETE_TARGET, SpPermission.DELETE_REPOSITORY,
SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY })
@Description("Tenant deletion is only possible for SYSTEM_ADMINs. Repository or target delete is not sufficient.")
public void deleteTenantFailsMissingPermission() throws Exception {
final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotNull();
mvc.perform(delete("/system/admin/tenants/mytenant")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isForbidden());
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotNull();
}
@Test
public void getCachesReturnStatus200() throws Exception {
mvc.perform(get("/system/admin/caches")).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
}
@Test
public void invalidateCachesReturnStatus200() throws Exception {
mvc.perform(delete("/system/admin/caches")).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
}
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
final int updates) throws Exception {
final Random randomgen = new Random();
final byte random[] = new byte[artifactSize];
randomgen.nextBytes(random);
for (int i = 0; i < tenants; i++) {
final String tenantname = "tenant" + i;
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("bumlux", tenantname), () -> {
systemManagement.getTenantMetadata(tenantname);
if (artifactSize > 0) {
createTestArtifact(random);
createDeletedTestArtifact(random);
}
if (targets > 0) {
final List<Target> createdTargets = createTestTargets(targets);
if (updates > 0) {
for (int x = 0; x < updates; x++) {
final DistributionSet ds = TestDataUtil.generateDistributionSet("to be deployed" + x,
softwareManagement, distributionSetManagement, true);
deploymentManagement.assignDistributionSet(ds, createdTargets);
}
}
}
return null;
});
}
return random;
}
private List<Target> createTestTargets(final int targets) {
return targetManagement
.createTargets(TestDataUtil.buildTargetFixtures(targets, "testTargetOfTenant", "testTargetOfTenant"));
}
private void createTestArtifact(final byte[] random) {
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
"version 1", null, null);
sm = softwareModuleRepository.save(sm);
artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
}
private void createDeletedTestArtifact(final byte[] random) {
final DistributionSet ds = TestDataUtil.generateDistributionSet("deleted garbage", softwareManagement,
distributionSetManagement, true);
ds.getModules().stream().forEach(module -> {
artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), module.getId(), "file1", false);
softwareManagement.deleteSoftwareModule(module);
});
}
}

View File

@@ -1,147 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.resource;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.Matchers.hasSize;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.system.rest.api.SystemRestConstant;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Component Tests - System RESTful API")
@Stories("ConfigurationResource")
public class SystemResourceTest extends AbstractIntegrationTest {
private static String BASE_JSON_REQUEST_STRING = "{\"value\":\"%s\"}";
@Test
@Description("perform a GET request on all existing configurations.")
public void getConfigurationValues() throws Exception {
final ResultActions resultActions = mvc.perform(get(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("$.*", hasSize(TenantConfigurationKey.values().length)));
for (final TenantConfigurationKey key : TenantConfigurationKey.values()) {
final TenantConfigurationValue<?> confValue = tenantConfigurationManagement.getConfigurationValue(key);
resultActions.andExpect(jsonPath("$.['" + key.getKeyName() + "'].value", equalTo(confValue.getValue())))
.andExpect(jsonPath("$.['" + key.getKeyName() + "'].global", equalTo(confValue.isGlobal())));
}
}
@Test
@Description("perform a GET request on a existing configuration key.")
public void getConfigurationValue() throws Exception {
final TenantConfigurationKey key = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME;
final String notGlobalValue = "notTheGlobalHeaderAuthoryName";
tenantConfigurationManagement.addOrUpdateConfiguration(key, notGlobalValue);
mvc.perform(get(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", key.getKeyName()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("value", equalTo(notGlobalValue))).andExpect(jsonPath("global", equalTo(false)))
.andExpect(jsonPath("createdAt", notNullValue())).andExpect(jsonPath("createdBy", notNullValue()));
}
@Test
@Description("perform a PUT request on a existing configuration key with a valid value.")
public void putConfigurationValue() throws Exception {
final TenantConfigurationKey key = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME;
final String testValue = "12:12:12";
mvc.perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", key.getKeyName())
.content(String.format(BASE_JSON_REQUEST_STRING, testValue)).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).getValue())
.isEqualTo(testValue);
}
@Test
@Description("perform a DELETE request on a existing configuration key.")
public void deleteConfigurationValue() throws Exception {
final TenantConfigurationKey key = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME;
final String notGlobalValue = "notTheGlobalHeaderAuthoryName";
tenantConfigurationManagement.addOrUpdateConfiguration(key, notGlobalValue);
assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).isGlobal()).isEqualTo(false);
assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).getValue())
.isEqualTo(notGlobalValue);
mvc.perform(delete(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", key.getKeyName()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNoContent());
assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).isGlobal()).isEqualTo(true);
assertThat(tenantConfigurationManagement.getConfigurationValue(key, String.class).getValue())
.isNotEqualTo(notGlobalValue);
}
@Test
@Description("perform a (put) request on a not existing configuration key.")
public void putInvalidConfigurationKey() throws Exception {
final String notExistingKey = "notExistingKey";
final String testValue = "12:12:12";
final MvcResult mvcResult = mvc
.perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", notExistingKey)
.content(String.format(BASE_JSON_REQUEST_STRING, testValue))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
.convertException(mvcResult.getResponse().getContentAsString());
assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_CONFIGURATION_KEY_INVALID.getKey());
}
@Test
@Description("perform a put request with a not matching configuration value.")
public void putInvalidConfigurationValue() throws Exception {
final TenantConfigurationKey key = TenantConfigurationKey.POLLING_TIME_INTERVAL;
final String testValue = "invalidFormattedDuration";
final MvcResult mvcResult = mvc
.perform(put(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", key.getKeyName())
.content(String.format(BASE_JSON_REQUEST_STRING, testValue))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
.convertException(mvcResult.getResponse().getContentAsString());
assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_CONFIGURATION_VALUE_INVALID.getKey());
}
}

View File

@@ -16,7 +16,7 @@
<artifactId>hawkbit-parent</artifactId> <artifactId>hawkbit-parent</artifactId>
<version>0.2.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>hawkbit-mgmt-ui</artifactId> <artifactId>hawkbit-ui</artifactId>
<name>hawkBit :: UI</name> <name>hawkBit :: UI</name>
<description>Bosch IoT Software Provisioning server web application</description> <description>Bosch IoT Software Provisioning server web application</description>
<build> <build>

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