Code format - hawkbit-core (#1924)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,52 +9,52 @@
|
|||||||
SPDX-License-Identifier: EPL-2.0
|
SPDX-License-Identifier: EPL-2.0
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-core</artifactId>
|
<artifactId>hawkbit-core</artifactId>
|
||||||
<name>hawkBit :: Core</name>
|
<name>hawkBit :: Core</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot</artifactId>
|
<artifactId>spring-boot</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.validation</groupId>
|
<groupId>jakarta.validation</groupId>
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.classgraph</groupId>
|
<groupId>io.github.classgraph</groupId>
|
||||||
<artifactId>classgraph</artifactId>
|
<artifactId>classgraph</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.qameta.allure</groupId>
|
<groupId>io.qameta.allure</groupId>
|
||||||
<artifactId>allure-junit5</artifactId>
|
<artifactId>allure-junit5</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit;
|
package org.eclipse.hawkbit;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ContextAware} provides means for getting the current context (via {@link #getCurrentContext()}) and then
|
* {@link ContextAware} provides means for getting the current context (via {@link #getCurrentContext()}) and then
|
||||||
* to execute a {@link Runnable} or a {@link Function} in the same context using {@link #runInContext(String, Runnable)}
|
* to execute a {@link Runnable} or a {@link Function} in the same context using {@link #runInContext(String, Runnable)}
|
||||||
@@ -28,7 +28,7 @@ public interface ContextAware extends TenantAware {
|
|||||||
/**
|
/**
|
||||||
* Return the current context encoded as a {@link String}. Depending on the implementation it could,
|
* Return the current context encoded as a {@link String}. Depending on the implementation it could,
|
||||||
* for instance, be a serialized context or a reference to such.
|
* for instance, be a serialized context or a reference to such.
|
||||||
*
|
*
|
||||||
* @return could be empty if there is nothing to serialize or context aware is not supported.
|
* @return could be empty if there is nothing to serialize or context aware is not supported.
|
||||||
*/
|
*/
|
||||||
Optional<String> getCurrentContext();
|
Optional<String> getCurrentContext();
|
||||||
@@ -38,7 +38,6 @@ public interface ContextAware extends TenantAware {
|
|||||||
*
|
*
|
||||||
* @param <T> the type of the input to the function
|
* @param <T> the type of the input to the function
|
||||||
* @param <R> the type of the result of the function
|
* @param <R> the type of the result of the function
|
||||||
*
|
|
||||||
* @param serializedContext created by {@link #getCurrentContext()}. Must be non-<code>null</code>.
|
* @param serializedContext created by {@link #getCurrentContext()}. Must be non-<code>null</code>.
|
||||||
* @param function function to call in the reconstructed context. Must be non-<code>null</code>.
|
* @param function function to call in the reconstructed context. Must be non-<code>null</code>.
|
||||||
* @param t the argument that will be passed to the function
|
* @param t the argument that will be passed to the function
|
||||||
|
|||||||
@@ -12,19 +12,19 @@ package org.eclipse.hawkbit;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines global configuration for the controllers/clients on the provisioning
|
* Defines global configuration for the controllers/clients on the provisioning
|
||||||
* targets/devices.
|
* targets/devices.
|
||||||
*
|
*
|
||||||
* Note: many of the controller related properties can be overridden on tenant
|
* Note: many of the controller related properties can be overridden on tenant
|
||||||
* level.
|
* level.
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ConfigurationProperties(prefix = "hawkbit.controller")
|
@ConfigurationProperties(prefix = "hawkbit.controller")
|
||||||
public class ControllerPollProperties implements Serializable {
|
public class ControllerPollProperties implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
|
|||||||
setUseCodeAsDefaultMessage(true);
|
setUseCodeAsDefaultMessage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourceLoader(final ResourceLoader resourceLoader) {
|
||||||
|
this.resourceLoader = resourceLoader;
|
||||||
|
super.setResourceLoader(resourceLoader);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PropertiesHolder refreshProperties(final String filename, final PropertiesHolder propHolder) {
|
protected PropertiesHolder refreshProperties(final String filename, final PropertiesHolder propHolder) {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
@@ -66,10 +72,4 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
|
|||||||
}
|
}
|
||||||
return new PropertiesHolder(properties, lastModified);
|
return new PropertiesHolder(properties, lastModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setResourceLoader(final ResourceLoader resourceLoader) {
|
|
||||||
this.resourceLoader = resourceLoader;
|
|
||||||
super.setResourceLoader(resourceLoader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,25 +11,26 @@ package org.eclipse.hawkbit;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties for the server e.g. the server's URL which must be configured.
|
* Properties for the server e.g. the server's URL which must be configured.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@ConfigurationProperties("hawkbit.server")
|
@ConfigurationProperties("hawkbit.server")
|
||||||
public class HawkbitServerProperties {
|
public class HawkbitServerProperties {
|
||||||
|
|
||||||
|
private final Anonymous anonymous = new Anonymous();
|
||||||
|
private final Build build = new Build();
|
||||||
/**
|
/**
|
||||||
* Defines under which URI the update server can be reached. Used to
|
* Defines under which URI the update server can be reached. Used to
|
||||||
* calculate download URLs for DMF transmitted update actions.
|
* calculate download URLs for DMF transmitted update actions.
|
||||||
*/
|
*/
|
||||||
private String url = "http://localhost:8080";
|
private String url = "http://localhost:8080";
|
||||||
|
|
||||||
private final Anonymous anonymous = new Anonymous();
|
public void setUrl(final String url) {
|
||||||
|
this.url = url;
|
||||||
private final Build build = new Build();
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties for anonymous API access by Devices/Controllers.
|
* Properties for anonymous API access by Devices/Controllers.
|
||||||
@@ -42,7 +43,6 @@ public class HawkbitServerProperties {
|
|||||||
/**
|
/**
|
||||||
* Properties for artifact download under anonymous API access by
|
* Properties for artifact download under anonymous API access by
|
||||||
* Devices/Controllers.
|
* Devices/Controllers.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public static class Download {
|
public static class Download {
|
||||||
@@ -56,7 +56,6 @@ public class HawkbitServerProperties {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build information of the hawkBit instance. Influenced by maven.
|
* Build information of the hawkBit instance. Influenced by maven.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static class Build {
|
public static class Build {
|
||||||
|
|
||||||
@@ -74,8 +73,4 @@ public class HawkbitServerProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(final String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for a generated Artifact URL.
|
* Container for a generated Artifact URL.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ArtifactUrl {
|
public class ArtifactUrl {
|
||||||
@@ -24,13 +23,10 @@ public class ArtifactUrl {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param protocol
|
* @param protocol string, e.g. ftp, http, https
|
||||||
* string, e.g. ftp, http, https
|
* @param rel hypermedia value
|
||||||
* @param rel
|
* @param ref hypermedia value
|
||||||
* hypermedia value
|
|
||||||
* @param ref
|
|
||||||
* hypermedia value
|
|
||||||
*/
|
*/
|
||||||
public ArtifactUrl(final String protocol, final String rel, final String ref) {
|
public ArtifactUrl(final String protocol, final String rel, final String ref) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Interface declaration of the {@link ArtifactUrlHandler} which generates the
|
* Interface declaration of the {@link ArtifactUrlHandler} which generates the
|
||||||
* URLs to specific artifacts.
|
* URLs to specific artifacts.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ArtifactUrlHandler {
|
public interface ArtifactUrlHandler {
|
||||||
|
|
||||||
@@ -23,11 +22,8 @@ public interface ArtifactUrlHandler {
|
|||||||
* Returns a generated download URL for a given artifact parameters for a
|
* Returns a generated download URL for a given artifact parameters for a
|
||||||
* specific protocol.
|
* specific protocol.
|
||||||
*
|
*
|
||||||
* @param placeholder
|
* @param placeholder data for URL generation
|
||||||
* data for URL generation
|
* @param api given protocol that URL needs to support
|
||||||
* @param api
|
|
||||||
* given protocol that URL needs to support
|
|
||||||
*
|
|
||||||
* @return an URL for the given artifact parameters in a given protocol
|
* @return an URL for the given artifact parameters in a given protocol
|
||||||
*/
|
*/
|
||||||
List<ArtifactUrl> getUrls(URLPlaceholder placeholder, ApiType api);
|
List<ArtifactUrl> getUrls(URLPlaceholder placeholder, ApiType api);
|
||||||
@@ -36,14 +32,10 @@ public interface ArtifactUrlHandler {
|
|||||||
* Returns a generated download URL for a given artifact parameters for a
|
* Returns a generated download URL for a given artifact parameters for a
|
||||||
* specific protocol.
|
* specific protocol.
|
||||||
*
|
*
|
||||||
* @param placeholder
|
* @param placeholder data for URL generation
|
||||||
* data for URL generation
|
* @param api given protocol that URL needs to support
|
||||||
* @param api
|
* @param requestUri of the request that allows the handler to align the generated
|
||||||
* given protocol that URL needs to support
|
* URL to the original request.
|
||||||
* @param requestUri
|
|
||||||
* of the request that allows the handler to align the generated
|
|
||||||
* URL to the original request.
|
|
||||||
*
|
|
||||||
* @return an URL for the given artifact parameters in a given protocol
|
* @return an URL for the given artifact parameters in a given protocol
|
||||||
*/
|
*/
|
||||||
List<ArtifactUrl> getUrls(URLPlaceholder placeholder, ApiType api, URI requestUri);
|
List<ArtifactUrl> getUrls(URLPlaceholder placeholder, ApiType api, URI requestUri);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||||||
/**
|
/**
|
||||||
* Artifact handler properties class for holding all supported protocols with
|
* Artifact handler properties class for holding all supported protocols with
|
||||||
* host, ip, port and download pattern.
|
* host, ip, port and download pattern.
|
||||||
*
|
*
|
||||||
* @see PropertyBasedArtifactUrlHandler
|
* @see PropertyBasedArtifactUrlHandler
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ public final class Base62Util {
|
|||||||
private static final int BASE62_BASE = BASE62_ALPHABET.length();
|
private static final int BASE62_BASE = BASE62_ALPHABET.length();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param base10
|
* @param base10 number
|
||||||
* number
|
|
||||||
* @return converted number into Base62 ASCII string
|
* @return converted number into Base62 ASCII string
|
||||||
*/
|
*/
|
||||||
public static String fromBase10(final long base10) {
|
public static String fromBase10(final long base10) {
|
||||||
@@ -42,8 +41,7 @@ public final class Base62Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param base62
|
* @param base62 number
|
||||||
* number
|
|
||||||
* @return converted number into Base10
|
* @return converted number into Base10
|
||||||
*/
|
*/
|
||||||
public static Long toBase10(final String base62) {
|
public static Long toBase10(final String base62) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.net.URL;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve to reach the server url.
|
* Resolve to reach the server url.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface HostnameResolver {
|
public interface HostnameResolver {
|
||||||
|
|||||||
@@ -28,19 +28,18 @@ import org.springframework.util.StringUtils;
|
|||||||
/**
|
/**
|
||||||
* Implementation for ArtifactUrlHandler for creating urls to download resource
|
* Implementation for ArtifactUrlHandler for creating urls to download resource
|
||||||
* based on patterns configured by {@link ArtifactUrlHandlerProperties}.
|
* based on patterns configured by {@link ArtifactUrlHandlerProperties}.
|
||||||
*
|
*
|
||||||
* This mechanism can be used to generate links to arbitrary file hosting
|
* This mechanism can be used to generate links to arbitrary file hosting
|
||||||
* infrastructure. However, the hawkBit update server supports hosting files as
|
* infrastructure. However, the hawkBit update server supports hosting files as
|
||||||
* well in the following {@link UrlProtocol#getRef()} patterns:
|
* well in the following {@link UrlProtocol#getRef()} patterns:
|
||||||
*
|
*
|
||||||
* Default:
|
* Default:
|
||||||
* {protocol}://{hostname}:{port}{contextPath}/{tenant}/controller/v1/{controllerId}/
|
* {protocol}://{hostname}:{port}{contextPath}/{tenant}/controller/v1/{controllerId}/
|
||||||
* softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}
|
* softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}
|
||||||
*
|
*
|
||||||
* Default (MD5SUM files):
|
* Default (MD5SUM files):
|
||||||
* {protocol}://{hostname}:{port}{contextPath}/{tenant}/controller/v1/{controllerId}/
|
* {protocol}://{hostname}:{port}{contextPath}/{tenant}/controller/v1/{controllerId}/
|
||||||
* softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}.MD5SUM
|
* softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}.MD5SUM
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||||
|
|
||||||
@@ -64,16 +63,13 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
|||||||
private static final String TENANT_ID_BASE10_PLACEHOLDER = "tenantId";
|
private static final String TENANT_ID_BASE10_PLACEHOLDER = "tenantId";
|
||||||
private static final String TENANT_ID_BASE62_PLACEHOLDER = "tenantIdBase62";
|
private static final String TENANT_ID_BASE62_PLACEHOLDER = "tenantIdBase62";
|
||||||
private static final String SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER = "softwareModuleId";
|
private static final String SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER = "softwareModuleId";
|
||||||
private static final String SOFTWARE_MODULE_ID_BASE62_PLACEHOLDER = "softwareModuleIdBase62";
|
|
||||||
|
|
||||||
final static String DEFAULT_URL_PROTOCOL_REF = "{" + PROTOCOL_PLACEHOLDER + "}://{" + HOSTNAME_PLACEHOLDER + "}:{" + PORT_PLACEHOLDER + "}{" + CONTEXT_PATH + "}/{" + TENANT_PLACEHOLDER + "}/controller/v1/{" + CONTROLLER_ID_PLACEHOLDER + "}/softwaremodules/{" + SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER + "}/artifacts/{" + ARTIFACT_FILENAME_PLACEHOLDER + "}";
|
final static String DEFAULT_URL_PROTOCOL_REF = "{" + PROTOCOL_PLACEHOLDER + "}://{" + HOSTNAME_PLACEHOLDER + "}:{" + PORT_PLACEHOLDER + "}{" + CONTEXT_PATH + "}/{" + TENANT_PLACEHOLDER + "}/controller/v1/{" + CONTROLLER_ID_PLACEHOLDER + "}/softwaremodules/{" + SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER + "}/artifacts/{" + ARTIFACT_FILENAME_PLACEHOLDER + "}";
|
||||||
|
private static final String SOFTWARE_MODULE_ID_BASE62_PLACEHOLDER = "softwareModuleIdBase62";
|
||||||
private final ArtifactUrlHandlerProperties urlHandlerProperties;
|
private final ArtifactUrlHandlerProperties urlHandlerProperties;
|
||||||
private final String contextPath;
|
private final String contextPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param urlHandlerProperties
|
* @param urlHandlerProperties for URL generation configuration
|
||||||
* for URL generation configuration
|
|
||||||
*/
|
*/
|
||||||
public PropertyBasedArtifactUrlHandler(final ArtifactUrlHandlerProperties urlHandlerProperties, final String contextPath) {
|
public PropertyBasedArtifactUrlHandler(final ArtifactUrlHandlerProperties urlHandlerProperties, final String contextPath) {
|
||||||
this.urlHandlerProperties = urlHandlerProperties;
|
this.urlHandlerProperties = urlHandlerProperties;
|
||||||
@@ -95,64 +91,6 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateUrl(final UrlProtocol protocol, final URLPlaceholder placeholder,
|
|
||||||
final URI requestUri) {
|
|
||||||
final Set<Entry<String, String>> entrySet = getReplaceMap(protocol, placeholder, requestUri).entrySet();
|
|
||||||
|
|
||||||
String urlPattern = protocol.getRef();
|
|
||||||
|
|
||||||
for (final Entry<String, String> entry : entrySet) {
|
|
||||||
if (List.of(PORT_PLACEHOLDER,PORT_REQUEST_PLACEHOLDER).contains(entry.getKey())) {
|
|
||||||
urlPattern = urlPattern.replace(":{" + entry.getKey() + "}",
|
|
||||||
ObjectUtils.isEmpty(entry.getValue()) ? "" : (":" + entry.getValue()));
|
|
||||||
} else {
|
|
||||||
if(entry.getValue() != null) {
|
|
||||||
urlPattern = urlPattern.replace("{" + entry.getKey() + "}", entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return urlPattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> getReplaceMap(final UrlProtocol protocol, final URLPlaceholder placeholder,
|
|
||||||
final URI requestUri) {
|
|
||||||
final Map<String, String> replaceMap = new HashMap<>();
|
|
||||||
replaceMap.put(IP_PLACEHOLDER, protocol.getIp());
|
|
||||||
|
|
||||||
replaceMap.put(HOSTNAME_PLACEHOLDER, protocol.getHostname());
|
|
||||||
|
|
||||||
replaceMap.put(HOSTNAME_REQUEST_PLACEHOLDER, getRequestHost(protocol, requestUri));
|
|
||||||
replaceMap.put(PORT_REQUEST_PLACEHOLDER, getRequestPort(protocol, requestUri));
|
|
||||||
replaceMap.put(HOSTNAME_WITH_DOMAIN_REQUEST_PLACEHOLDER, computeHostWithRequestDomain(protocol, requestUri));
|
|
||||||
replaceMap.put(PROTOCOL_REQUEST_PLACEHOLDER, getRequestProtocol(protocol, requestUri));
|
|
||||||
|
|
||||||
replaceMap.put(CONTEXT_PATH, contextPath);
|
|
||||||
|
|
||||||
replaceMap.put(ARTIFACT_FILENAME_PLACEHOLDER,
|
|
||||||
URLEncoder.encode(placeholder.getSoftwareData().getFilename(), StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
replaceMap.put(ARTIFACT_SHA1_PLACEHOLDER, placeholder.getSoftwareData().getSha1Hash());
|
|
||||||
replaceMap.put(PROTOCOL_PLACEHOLDER, protocol.getProtocol());
|
|
||||||
replaceMap.put(PORT_PLACEHOLDER, getPort(protocol));
|
|
||||||
replaceMap.put(TENANT_PLACEHOLDER, placeholder.getTenant());
|
|
||||||
replaceMap.put(TENANT_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getTenantId()));
|
|
||||||
replaceMap.put(TENANT_ID_BASE62_PLACEHOLDER, Base62Util.fromBase10(placeholder.getTenantId()));
|
|
||||||
replaceMap.put(CONTROLLER_ID_PLACEHOLDER, placeholder.getControllerId());
|
|
||||||
replaceMap.put(TARGET_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getTargetId()));
|
|
||||||
if (placeholder.getTargetId() != null) {
|
|
||||||
replaceMap.put(TARGET_ID_BASE62_PLACEHOLDER, Base62Util.fromBase10(placeholder.getTargetId()));
|
|
||||||
}
|
|
||||||
replaceMap.put(ARTIFACT_ID_BASE62_PLACEHOLDER,
|
|
||||||
Base62Util.fromBase10(placeholder.getSoftwareData().getArtifactId()));
|
|
||||||
replaceMap.put(ARTIFACT_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getSoftwareData().getArtifactId()));
|
|
||||||
replaceMap.put(SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER,
|
|
||||||
String.valueOf(placeholder.getSoftwareData().getSoftwareModuleId()));
|
|
||||||
replaceMap.put(SOFTWARE_MODULE_ID_BASE62_PLACEHOLDER,
|
|
||||||
Base62Util.fromBase10(placeholder.getSoftwareData().getSoftwareModuleId()));
|
|
||||||
return replaceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getRequestPort(final UrlProtocol protocol, final URI requestUri) {
|
private static String getRequestPort(final UrlProtocol protocol, final URI requestUri) {
|
||||||
if (requestUri == null) {
|
if (requestUri == null) {
|
||||||
return getPort(protocol);
|
return getPort(protocol);
|
||||||
@@ -205,4 +143,62 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
|||||||
return host + "." + domain;
|
return host + "." + domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generateUrl(final UrlProtocol protocol, final URLPlaceholder placeholder,
|
||||||
|
final URI requestUri) {
|
||||||
|
final Set<Entry<String, String>> entrySet = getReplaceMap(protocol, placeholder, requestUri).entrySet();
|
||||||
|
|
||||||
|
String urlPattern = protocol.getRef();
|
||||||
|
|
||||||
|
for (final Entry<String, String> entry : entrySet) {
|
||||||
|
if (List.of(PORT_PLACEHOLDER, PORT_REQUEST_PLACEHOLDER).contains(entry.getKey())) {
|
||||||
|
urlPattern = urlPattern.replace(":{" + entry.getKey() + "}",
|
||||||
|
ObjectUtils.isEmpty(entry.getValue()) ? "" : (":" + entry.getValue()));
|
||||||
|
} else {
|
||||||
|
if (entry.getValue() != null) {
|
||||||
|
urlPattern = urlPattern.replace("{" + entry.getKey() + "}", entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return urlPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getReplaceMap(final UrlProtocol protocol, final URLPlaceholder placeholder,
|
||||||
|
final URI requestUri) {
|
||||||
|
final Map<String, String> replaceMap = new HashMap<>();
|
||||||
|
replaceMap.put(IP_PLACEHOLDER, protocol.getIp());
|
||||||
|
|
||||||
|
replaceMap.put(HOSTNAME_PLACEHOLDER, protocol.getHostname());
|
||||||
|
|
||||||
|
replaceMap.put(HOSTNAME_REQUEST_PLACEHOLDER, getRequestHost(protocol, requestUri));
|
||||||
|
replaceMap.put(PORT_REQUEST_PLACEHOLDER, getRequestPort(protocol, requestUri));
|
||||||
|
replaceMap.put(HOSTNAME_WITH_DOMAIN_REQUEST_PLACEHOLDER, computeHostWithRequestDomain(protocol, requestUri));
|
||||||
|
replaceMap.put(PROTOCOL_REQUEST_PLACEHOLDER, getRequestProtocol(protocol, requestUri));
|
||||||
|
|
||||||
|
replaceMap.put(CONTEXT_PATH, contextPath);
|
||||||
|
|
||||||
|
replaceMap.put(ARTIFACT_FILENAME_PLACEHOLDER,
|
||||||
|
URLEncoder.encode(placeholder.getSoftwareData().getFilename(), StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
replaceMap.put(ARTIFACT_SHA1_PLACEHOLDER, placeholder.getSoftwareData().getSha1Hash());
|
||||||
|
replaceMap.put(PROTOCOL_PLACEHOLDER, protocol.getProtocol());
|
||||||
|
replaceMap.put(PORT_PLACEHOLDER, getPort(protocol));
|
||||||
|
replaceMap.put(TENANT_PLACEHOLDER, placeholder.getTenant());
|
||||||
|
replaceMap.put(TENANT_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getTenantId()));
|
||||||
|
replaceMap.put(TENANT_ID_BASE62_PLACEHOLDER, Base62Util.fromBase10(placeholder.getTenantId()));
|
||||||
|
replaceMap.put(CONTROLLER_ID_PLACEHOLDER, placeholder.getControllerId());
|
||||||
|
replaceMap.put(TARGET_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getTargetId()));
|
||||||
|
if (placeholder.getTargetId() != null) {
|
||||||
|
replaceMap.put(TARGET_ID_BASE62_PLACEHOLDER, Base62Util.fromBase10(placeholder.getTargetId()));
|
||||||
|
}
|
||||||
|
replaceMap.put(ARTIFACT_ID_BASE62_PLACEHOLDER,
|
||||||
|
Base62Util.fromBase10(placeholder.getSoftwareData().getArtifactId()));
|
||||||
|
replaceMap.put(ARTIFACT_ID_BASE10_PLACEHOLDER, String.valueOf(placeholder.getSoftwareData().getArtifactId()));
|
||||||
|
replaceMap.put(SOFTWARE_MODULE_ID_BASE10_PLACEHOLDER,
|
||||||
|
String.valueOf(placeholder.getSoftwareData().getSoftwareModuleId()));
|
||||||
|
replaceMap.put(SOFTWARE_MODULE_ID_BASE62_PLACEHOLDER,
|
||||||
|
Base62Util.fromBase10(placeholder.getSoftwareData().getSoftwareModuleId()));
|
||||||
|
return replaceMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.api;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for variables available to the {@link ArtifactUrlHandler}.
|
* Container for variables available to the {@link ArtifactUrlHandler}.
|
||||||
*/
|
*/
|
||||||
@@ -27,18 +25,13 @@ public class URLPlaceholder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant of the client
|
||||||
* of the client
|
* @param tenantId of teh tenant
|
||||||
* @param tenantId
|
* @param controllerId of the target
|
||||||
* of teh tenant
|
* @param targetId of the target
|
||||||
* @param controllerId
|
* @param softwareData information about the artifact and software module that can be
|
||||||
* of the target
|
* accessed by the URL.
|
||||||
* @param targetId
|
|
||||||
* of the target
|
|
||||||
* @param softwareData
|
|
||||||
* information about the artifact and software module that can be
|
|
||||||
* accessed by the URL.
|
|
||||||
*/
|
*/
|
||||||
public URLPlaceholder(final String tenant, final Long tenantId, final String controllerId, final Long targetId,
|
public URLPlaceholder(final String tenant, final Long tenantId, final String controllerId, final Long targetId,
|
||||||
final SoftwareData softwareData) {
|
final SoftwareData softwareData) {
|
||||||
@@ -64,14 +57,10 @@ public class URLPlaceholder {
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param softwareModuleId
|
* @param softwareModuleId of the module the artifact belongs to
|
||||||
* of the module the artifact belongs to
|
* @param filename of the artifact
|
||||||
* @param filename
|
* @param artifactId of the artifact
|
||||||
* of the artifact
|
* @param sha1Hash of the artifact
|
||||||
* @param artifactId
|
|
||||||
* of the artifact
|
|
||||||
* @param sha1Hash
|
|
||||||
* of the artifact
|
|
||||||
*/
|
*/
|
||||||
public SoftwareData(final Long softwareModuleId, final String filename, final Long artifactId,
|
public SoftwareData(final Long softwareModuleId, final String filename, final Long artifactId,
|
||||||
final String sha1Hash) {
|
final String sha1Hash) {
|
||||||
|
|||||||
@@ -83,19 +83,8 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractDbArtifact addMissingHashes(final AbstractDbArtifact existing, final String calculatedSha1,
|
protected static String sanitizeTenant(final String tenant) {
|
||||||
final String calculatedMd5, final String calculatedSha256) {
|
return tenant.trim().toUpperCase();
|
||||||
|
|
||||||
final String sha1 = checkEmpty(existing.getHashes().getSha1(), calculatedSha1);
|
|
||||||
final String md5 = checkEmpty(existing.getHashes().getMd5(), calculatedMd5);
|
|
||||||
final String sha256 = checkEmpty(existing.getHashes().getSha256(), calculatedSha256);
|
|
||||||
|
|
||||||
existing.setHashes(new DbArtifactHash(sha1, md5, sha256));
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String checkEmpty(final String value, final String fallback) {
|
|
||||||
return StringUtils.isEmpty(value) ? fallback : value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteTempFile(final String tempFile) {
|
protected void deleteTempFile(final String tempFile) {
|
||||||
@@ -116,6 +105,9 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
|
|||||||
return file.getPath();
|
return file.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract AbstractDbArtifact store(final String tenant, final DbArtifactHash base16Hashes,
|
||||||
|
final String contentType, final String tempFile) throws IOException;
|
||||||
|
|
||||||
private static File createTempFile() {
|
private static File createTempFile() {
|
||||||
try {
|
try {
|
||||||
return Files.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX).toFile();
|
return Files.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX).toFile();
|
||||||
@@ -149,15 +141,23 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
|
|||||||
return providedHashValue != null && !hashValue.equals(providedHashValue);
|
return providedHashValue != null && !hashValue.equals(providedHashValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AbstractDbArtifact store(final String tenant, final DbArtifactHash base16Hashes,
|
|
||||||
final String contentType, final String tempFile) throws IOException;
|
|
||||||
|
|
||||||
private static DigestInputStream wrapInDigestInputStream(final InputStream input, final MessageDigest mdSHA1,
|
private static DigestInputStream wrapInDigestInputStream(final InputStream input, final MessageDigest mdSHA1,
|
||||||
final MessageDigest mdMD5, final MessageDigest mdSHA256) {
|
final MessageDigest mdMD5, final MessageDigest mdSHA256) {
|
||||||
return new DigestInputStream(new DigestInputStream(new DigestInputStream(input, mdSHA256), mdMD5), mdSHA1);
|
return new DigestInputStream(new DigestInputStream(new DigestInputStream(input, mdSHA256), mdMD5), mdSHA1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String sanitizeTenant(final String tenant) {
|
private AbstractDbArtifact addMissingHashes(final AbstractDbArtifact existing, final String calculatedSha1,
|
||||||
return tenant.trim().toUpperCase();
|
final String calculatedMd5, final String calculatedSha256) {
|
||||||
|
|
||||||
|
final String sha1 = checkEmpty(existing.getHashes().getSha1(), calculatedSha1);
|
||||||
|
final String md5 = checkEmpty(existing.getHashes().getMd5(), calculatedMd5);
|
||||||
|
final String sha256 = checkEmpty(existing.getHashes().getSha256(), calculatedSha256);
|
||||||
|
|
||||||
|
existing.setHashes(new DbArtifactHash(sha1, md5, sha256));
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String checkEmpty(final String value, final String fallback) {
|
||||||
|
return StringUtils.isEmpty(value) ? fallback : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,81 +19,58 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ArtifactRepository service interface.
|
* ArtifactRepository service interface.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ArtifactRepository {
|
public interface ArtifactRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores an artifact into the repository.
|
* Stores an artifact into the repository.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant to store the artifact
|
||||||
* the tenant to store the artifact
|
* @param content the content to store
|
||||||
* @param content
|
* @param filename the filename of the artifact
|
||||||
* the content to store
|
* @param contentType the content type of the artifact
|
||||||
* @param filename
|
* @param hash the hashes of the artifact to do hash-checks after storing the
|
||||||
* the filename of the artifact
|
* artifact, might be {@code null}
|
||||||
* @param contentType
|
|
||||||
* the content type of the artifact
|
|
||||||
* @param hash
|
|
||||||
* the hashes of the artifact to do hash-checks after storing the
|
|
||||||
* artifact, might be {@code null}
|
|
||||||
* @return the stored artifact
|
* @return the stored artifact
|
||||||
*
|
* @throws MethodNotSupportedException if implementation does not support the operation
|
||||||
* @throws MethodNotSupportedException
|
* @throws ArtifactStoreException in case storing of the artifact was not successful
|
||||||
* if implementation does not support the operation
|
* @throws HashNotMatchException in case {@code hash} is provided and not matching to the
|
||||||
* @throws ArtifactStoreException
|
* calculated hashes during storing
|
||||||
* in case storing of the artifact was not successful
|
|
||||||
* @throws HashNotMatchException
|
|
||||||
* in case {@code hash} is provided and not matching to the
|
|
||||||
* calculated hashes during storing
|
|
||||||
*/
|
*/
|
||||||
AbstractDbArtifact store(@NotEmpty String tenant, @NotNull InputStream content, @NotEmpty String filename,
|
AbstractDbArtifact store(@NotEmpty String tenant, @NotNull InputStream content, @NotEmpty String filename,
|
||||||
String contentType, DbArtifactHash hash);
|
String contentType, DbArtifactHash hash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an artifact by its SHA1 hash.
|
* Deletes an artifact by its SHA1 hash.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant to store the artifact
|
||||||
* the tenant to store the artifact
|
* @param sha1Hash the sha1-hash of the artifact to delete
|
||||||
* @param sha1Hash
|
* @throws MethodNotSupportedException if implementation does not support the operation
|
||||||
* the sha1-hash of the artifact to delete
|
|
||||||
*
|
|
||||||
* @throws MethodNotSupportedException
|
|
||||||
* if implementation does not support the operation
|
|
||||||
*/
|
*/
|
||||||
void deleteBySha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
void deleteBySha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a {@link AbstractDbArtifact} from the store by its SHA1 hash.
|
* Retrieves a {@link AbstractDbArtifact} from the store by its SHA1 hash.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant to store the artifact
|
||||||
* the tenant to store the artifact
|
* @param sha1Hash the sha1-hash of the file to lookup.
|
||||||
* @param sha1Hash
|
|
||||||
* the sha1-hash of the file to lookup.
|
|
||||||
* @return The artifact file object or {@code null} if no file exists.
|
* @return The artifact file object or {@code null} if no file exists.
|
||||||
*
|
* @throws MethodNotSupportedException if implementation does not support the operation
|
||||||
* @throws MethodNotSupportedException
|
|
||||||
* if implementation does not support the operation
|
|
||||||
*/
|
*/
|
||||||
AbstractDbArtifact getArtifactBySha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
AbstractDbArtifact getArtifactBySha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all artifacts of given tenant.
|
* Deletes all artifacts of given tenant.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant to erase
|
||||||
* to erase
|
|
||||||
*/
|
*/
|
||||||
void deleteByTenant(@NotEmpty String tenant);
|
void deleteByTenant(@NotEmpty String tenant);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an artifact exists for a given tenant by its sha1 hash
|
* Checks if an artifact exists for a given tenant by its sha1 hash
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant
|
||||||
* the tenant
|
* @param sha1Hash the sha1-hash of the file to lookup.
|
||||||
* @param sha1Hash
|
|
||||||
* the sha1-hash of the file to lookup.
|
|
||||||
*
|
|
||||||
* @return the boolean whether the artifact exists or not
|
* @return the boolean whether the artifact exists or not
|
||||||
*/
|
*/
|
||||||
boolean existsByTenantAndSha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
boolean existsByTenantAndSha1(@NotEmpty String tenant, @NotEmpty String sha1Hash);
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ public class ArtifactStoreException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ArtifactStoreException with message and cause.
|
* Constructs a ArtifactStoreException with message and cause.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message the message of the exception
|
||||||
* the message of the exception
|
* @param cause of the exception
|
||||||
* @param cause
|
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public ArtifactStoreException(final String message, final Throwable cause) {
|
public ArtifactStoreException(final String message, final Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
@@ -31,9 +29,8 @@ public class ArtifactStoreException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ArtifactStoreException with message.
|
* Constructs a ArtifactStoreException with message.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message the message of the exception
|
||||||
* the message of the exception
|
|
||||||
*/
|
*/
|
||||||
public ArtifactStoreException(final String message) {
|
public ArtifactStoreException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
@@ -41,9 +38,8 @@ public class ArtifactStoreException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ArtifactStoreException with cause.
|
* Constructs a ArtifactStoreException with cause.
|
||||||
*
|
*
|
||||||
* @param cause
|
* @param cause of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public ArtifactStoreException(final Throwable cause) {
|
public ArtifactStoreException(final Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
|
|||||||
@@ -12,29 +12,21 @@ package org.eclipse.hawkbit.artifact.repository;
|
|||||||
/**
|
/**
|
||||||
* Thrown when provided hashes and hashes caluclated during storing are not
|
* Thrown when provided hashes and hashes caluclated during storing are not
|
||||||
* matching.
|
* matching.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class HashNotMatchException extends RuntimeException {
|
public class HashNotMatchException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final String SHA1 = "SHA-1";
|
public static final String SHA1 = "SHA-1";
|
||||||
public static final String MD5 = "MD5";
|
public static final String MD5 = "MD5";
|
||||||
public static final String SHA256 = "SHA-256";
|
public static final String SHA256 = "SHA-256";
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private final String hashFunction;
|
private final String hashFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a HashNotMatchException with message and cause.
|
* Constructs a HashNotMatchException with message and cause.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message the message of the exception
|
||||||
* the message of the exception
|
* @param cause the cause of the exception
|
||||||
* @param cause
|
* @param hashFunction the hash function which caused this exception
|
||||||
* the cause of the exception
|
|
||||||
* @param hashFunction
|
|
||||||
* the hash function which caused this exception
|
|
||||||
*/
|
*/
|
||||||
public HashNotMatchException(final String message, final Throwable cause, final String hashFunction) {
|
public HashNotMatchException(final String message, final Throwable cause, final String hashFunction) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
@@ -43,11 +35,9 @@ public class HashNotMatchException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a HashNotMatchException with message.
|
* Constructs a HashNotMatchException with message.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message the message of the exception
|
||||||
* the message of the exception
|
* @param hashFunction the hash function which caused this exception
|
||||||
* @param hashFunction
|
|
||||||
* the hash function which caused this exception
|
|
||||||
*/
|
*/
|
||||||
public HashNotMatchException(final String message, final String hashFunction) {
|
public HashNotMatchException(final String message, final String hashFunction) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public interface DbArtifact {
|
|||||||
/**
|
/**
|
||||||
* Creates an {@link InputStream} on this artifact. Caller has to take care of
|
* Creates an {@link InputStream} on this artifact. Caller has to take care of
|
||||||
* closing the stream. Repeatable calls open a new {@link InputStream}.
|
* closing the stream. Repeatable calls open a new {@link InputStream}.
|
||||||
*
|
*
|
||||||
* @return {@link InputStream} to read from artifact.
|
* @return {@link InputStream} to read from artifact.
|
||||||
*/
|
*/
|
||||||
InputStream getFileInputStream();
|
InputStream getFileInputStream();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DbArtifactHash {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param sha1 the sha1 hash
|
* @param sha1 the sha1 hash
|
||||||
* @param md5 the md5 hash
|
* @param md5 the md5 hash
|
||||||
* @param sha256 the sha256 hash
|
* @param sha256 the sha256 hash
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ public interface TenancyCacheManager extends CacheManager {
|
|||||||
* tenant key. This is necessary e.g. for retrieving caches not for the
|
* tenant key. This is necessary e.g. for retrieving caches not for the
|
||||||
* current tenant.
|
* current tenant.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name the name of the cache to retrieve directly
|
||||||
* the name of the cache to retrieve directly
|
|
||||||
* @return the cache associated with the name without tenancy separation
|
* @return the cache associated with the name without tenancy separation
|
||||||
*/
|
*/
|
||||||
Cache getDirectCache(String name);
|
Cache getDirectCache(String name);
|
||||||
@@ -32,8 +31,7 @@ public interface TenancyCacheManager extends CacheManager {
|
|||||||
* Evicts all caches for a given tenant. All caches under a certain tenant
|
* Evicts all caches for a given tenant. All caches under a certain tenant
|
||||||
* gets evicted.
|
* gets evicted.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant to evict caches
|
||||||
* the tenant to evict caches
|
|
||||||
*/
|
*/
|
||||||
void evictCaches(final String tenant);
|
void evictCaches(final String tenant);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,8 @@ public class TenantAwareCacheManager implements TenancyCacheManager {
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param delegate
|
* @param delegate the {@link CacheManager} to delegate to.
|
||||||
* the {@link CacheManager} to delegate to.
|
* @param tenantAware the tenant aware to retrieve the current tenant
|
||||||
* @param tenantAware
|
|
||||||
* the tenant aware to retrieve the current tenant
|
|
||||||
*/
|
*/
|
||||||
public TenantAwareCacheManager(final CacheManager delegate, final TenantAware tenantAware) {
|
public TenantAwareCacheManager(final CacheManager delegate, final TenantAware tenantAware) {
|
||||||
this.tenantAware = tenantAware;
|
this.tenantAware = tenantAware;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.exception;
|
package org.eclipse.hawkbit.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Custom Exception to wrap the Runtime and checked exception
|
* Generic Custom Exception to wrap the Runtime and checked exception
|
||||||
*/
|
*/
|
||||||
@@ -30,7 +30,7 @@ public abstract class AbstractServerRtException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param error detail
|
* @param error detail
|
||||||
*/
|
*/
|
||||||
protected AbstractServerRtException(final SpServerError error) {
|
protected AbstractServerRtException(final SpServerError error) {
|
||||||
@@ -41,7 +41,7 @@ public abstract class AbstractServerRtException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message custom error message
|
* @param message custom error message
|
||||||
* @param error detail
|
* @param error detail
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +63,7 @@ public abstract class AbstractServerRtException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message custom error message
|
* @param message custom error message
|
||||||
* @param error detail
|
* @param error detail
|
||||||
* @param cause of the exception
|
* @param cause of the exception
|
||||||
@@ -76,7 +76,7 @@ public abstract class AbstractServerRtException extends RuntimeException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param error detail
|
* @param error detail
|
||||||
* @param cause of the exception
|
* @param cause of the exception
|
||||||
*/
|
*/
|
||||||
@@ -93,7 +93,8 @@ public abstract class AbstractServerRtException extends RuntimeException {
|
|||||||
* @param error detail
|
* @param error detail
|
||||||
* @param cause of the exception
|
* @param cause of the exception
|
||||||
*/
|
*/
|
||||||
protected AbstractServerRtException(final String message, final SpServerError error, final Throwable cause, final Map<String, Object> info) {
|
protected AbstractServerRtException(final String message, final SpServerError error, final Throwable cause,
|
||||||
|
final Map<String, Object> info) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ package org.eclipse.hawkbit.exception;
|
|||||||
* {@link GenericSpServerException} is thrown when a given entity in's actual
|
* {@link GenericSpServerException} is thrown when a given entity in's actual
|
||||||
* and cannot be stored within the current session. Reason could be that it has
|
* and cannot be stored within the current session. Reason could be that it has
|
||||||
* been changed within another session.
|
* been changed within another session.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GenericSpServerException extends AbstractServerRtException {
|
public class GenericSpServerException extends AbstractServerRtException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_GENERIC_ERROR;
|
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_GENERIC_ERROR;
|
||||||
|
|
||||||
@@ -30,9 +28,8 @@ public class GenericSpServerException extends AbstractServerRtException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param cause
|
* @param cause of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public GenericSpServerException(final Throwable cause) {
|
public GenericSpServerException(final Throwable cause) {
|
||||||
super(THIS_ERROR, cause);
|
super(THIS_ERROR, cause);
|
||||||
@@ -40,11 +37,9 @@ public class GenericSpServerException extends AbstractServerRtException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message custom error message
|
||||||
* custom error message
|
* @param cause of the exception
|
||||||
* @param cause
|
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public GenericSpServerException(final String message, final Throwable cause) {
|
public GenericSpServerException(final String message, final Throwable cause) {
|
||||||
super(message, THIS_ERROR, cause);
|
super(message, THIS_ERROR, cause);
|
||||||
@@ -52,9 +47,8 @@ public class GenericSpServerException extends AbstractServerRtException {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message custom error message
|
||||||
* custom error message
|
|
||||||
*/
|
*/
|
||||||
public GenericSpServerException(final String message) {
|
public GenericSpServerException(final String message) {
|
||||||
super(message, THIS_ERROR);
|
super(message, THIS_ERROR);
|
||||||
|
|||||||
@@ -15,14 +15,13 @@ package org.eclipse.hawkbit.exception;
|
|||||||
|
|
||||||
public enum SpServerError {
|
public enum SpServerError {
|
||||||
|
|
||||||
|
|
||||||
SP_REPO_GENERIC_ERROR("hawkbit.server.error.repo.genericError", "unknown error occurred"),
|
SP_REPO_GENERIC_ERROR("hawkbit.server.error.repo.genericError", "unknown error occurred"),
|
||||||
SP_REPO_ENTITY_ALREADY_EXISTS("hawkbit.server.error.repo.entitiyAlreayExists",
|
SP_REPO_ENTITY_ALREADY_EXISTS("hawkbit.server.error.repo.entitiyAlreayExists",
|
||||||
"The given entity already exists in database"),
|
"The given entity already exists in database"),
|
||||||
SP_REPO_AUTO_CONFIRMATION_ALREADY_ACTIVE("hawkbit.server.error.repo.autoConfAlreadyActive",
|
SP_REPO_AUTO_CONFIRMATION_ALREADY_ACTIVE("hawkbit.server.error.repo.autoConfAlreadyActive",
|
||||||
"Auto confirmation is already active"),
|
"Auto confirmation is already active"),
|
||||||
SP_CONFIRMATION_FEEDBACK_INVALID("hawkbit.server.confirmation.feedback.invalid",
|
SP_CONFIRMATION_FEEDBACK_INVALID("hawkbit.server.confirmation.feedback.invalid",
|
||||||
"Confirmation feedback is not valid"),
|
"Confirmation feedback is not valid"),
|
||||||
SP_REPO_CONSTRAINT_VIOLATION("hawkbit.server.error.repo.constraintViolation",
|
SP_REPO_CONSTRAINT_VIOLATION("hawkbit.server.error.repo.constraintViolation",
|
||||||
"The given entity cannot be saved due to Constraint Violation"),
|
"The given entity cannot be saved due to Constraint Violation"),
|
||||||
SP_REPO_INVALID_TARGET_ADDRESS("hawkbit.server.error.repo.invalidTargetAddress",
|
SP_REPO_INVALID_TARGET_ADDRESS("hawkbit.server.error.repo.invalidTargetAddress",
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort and search fields for actions.
|
* Sort and search fields for actions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.AbstractMap.SimpleImmutableEntry;
|
import java.util.AbstractMap.SimpleImmutableEntry;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the DistributionSet model which can be used in the
|
* Describing the fields of the DistributionSet model which can be used in the
|
||||||
* REST API e.g. for sorting etc.
|
* REST API e.g. for sorting etc.
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the Tag model which can be used in the REST API e.g.
|
* Describing the fields of the Tag model which can be used in the REST API e.g.
|
||||||
* for sorting etc.
|
* for sorting etc.
|
||||||
@@ -23,23 +23,23 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum DistributionSetTagFields implements RsqlQueryField {
|
public enum DistributionSetTagFields implements RsqlQueryField {
|
||||||
|
|
||||||
ID(TagFields.ID.getJpaEntityFieldName()),
|
ID(TagFields.ID.getJpaEntityFieldName()),
|
||||||
NAME(TagFields.NAME.getJpaEntityFieldName()),
|
NAME(TagFields.NAME.getJpaEntityFieldName()),
|
||||||
DESCRIPTION(TagFields.DESCRIPTION.getJpaEntityFieldName()),
|
DESCRIPTION(TagFields.DESCRIPTION.getJpaEntityFieldName()),
|
||||||
COLOUR(TagFields.COLOUR.getJpaEntityFieldName()),
|
COLOUR(TagFields.COLOUR.getJpaEntityFieldName()),
|
||||||
DISTRIBUTIONSET("assignedToDistributionSet",
|
DISTRIBUTIONSET("assignedToDistributionSet",
|
||||||
DistributionSetFields.ID.getJpaEntityFieldName(), DistributionSetFields.NAME.getJpaEntityFieldName());
|
DistributionSetFields.ID.getJpaEntityFieldName(), DistributionSetFields.NAME.getJpaEntityFieldName());
|
||||||
|
|
||||||
private final String jpaEntityFieldName;
|
private final String jpaEntityFieldName;
|
||||||
private final List<String> subEntityAttributes;
|
private final List<String> subEntityAttributes;
|
||||||
|
|
||||||
DistributionSetTagFields(final String jpaEntityFieldName) {
|
DistributionSetTagFields(final String jpaEntityFieldName) {
|
||||||
this.jpaEntityFieldName = jpaEntityFieldName;
|
this.jpaEntityFieldName = jpaEntityFieldName;
|
||||||
this.subEntityAttributes = Collections.emptyList();
|
this.subEntityAttributes = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
DistributionSetTagFields(final String jpaEntityFieldName, final String... subEntityAttributes) {
|
DistributionSetTagFields(final String jpaEntityFieldName, final String... subEntityAttributes) {
|
||||||
this.jpaEntityFieldName = jpaEntityFieldName;
|
this.jpaEntityFieldName = jpaEntityFieldName;
|
||||||
this.subEntityAttributes = List.of(subEntityAttributes);
|
this.subEntityAttributes = List.of(subEntityAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ public interface FieldValueConverter<T extends Enum<T>> {
|
|||||||
/**
|
/**
|
||||||
* Converts the given {@code value} into the representation to build a
|
* Converts the given {@code value} into the representation to build a
|
||||||
* generic query.
|
* generic query.
|
||||||
*
|
*
|
||||||
* @param e the enum to build the value for
|
* @param e the enum to build the value for
|
||||||
* @param value the value in string representation
|
* @param value the value in string representation
|
||||||
* @return the converted object or {@code null} if conversation fails, if
|
* @return the converted object or {@code null} if conversation fails, if
|
||||||
@@ -34,7 +34,7 @@ public interface FieldValueConverter<T extends Enum<T>> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the possible values associated with the given enum type.
|
* returns the possible values associated with the given enum type.
|
||||||
*
|
*
|
||||||
* @param e the enum type to retrieve the possible values
|
* @param e the enum type to retrieve the possible values
|
||||||
* @return the possible values for a specific enum or {@code null}
|
* @return the possible values for a specific enum or {@code null}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the Rollout model which can be used in the REST API e.g. for sorting etc.
|
* Describing the fields of the Rollout model which can be used in the REST API e.g. for sorting etc.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.util.Map.Entry;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An RSQL query field interface extended by all the fields that could be used in RSQL queries.
|
* An RSQL query field interface extended by all the fields that could be used in RSQL queries.
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.AbstractMap.SimpleImmutableEntry;
|
import java.util.AbstractMap.SimpleImmutableEntry;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the SoftwareModule model which can be used in the REST API e.g. for sorting etc.
|
* Describing the fields of the SoftwareModule model which can be used in the REST API e.g. for sorting etc.
|
||||||
*/
|
*/
|
||||||
@@ -41,6 +41,7 @@ public enum SoftwareModuleFields implements RsqlQueryField {
|
|||||||
SoftwareModuleFields(final String jpaEntityFieldName, final String... subEntityAttributes) {
|
SoftwareModuleFields(final String jpaEntityFieldName, final String... subEntityAttributes) {
|
||||||
this(jpaEntityFieldName, List.of(subEntityAttributes), null);
|
this(jpaEntityFieldName, List.of(subEntityAttributes), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftwareModuleFields(final String jpaEntityFieldName, final Entry<String, String> subEntityMapTuple) {
|
SoftwareModuleFields(final String jpaEntityFieldName, final Entry<String, String> subEntityMapTuple) {
|
||||||
this(jpaEntityFieldName, Collections.emptyList(), subEntityMapTuple);
|
this(jpaEntityFieldName, Collections.emptyList(), subEntityMapTuple);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.AbstractMap.SimpleImmutableEntry;
|
import java.util.AbstractMap.SimpleImmutableEntry;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the Target model which can be used in the REST API
|
* Describing the fields of the Target model which can be used in the REST API
|
||||||
* e.g. for sorting etc.
|
* e.g. for sorting etc.
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the Target model which can be used in the REST API e.g. for sorting etc.
|
* Describing the fields of the Target model which can be used in the REST API e.g. for sorting etc.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum TargetTagFields implements RsqlQueryField {
|
public enum TargetTagFields implements RsqlQueryField {
|
||||||
|
|
||||||
ID(TagFields.ID.getJpaEntityFieldName()),
|
ID(TagFields.ID.getJpaEntityFieldName()),
|
||||||
NAME(TagFields.NAME.getJpaEntityFieldName()),
|
NAME(TagFields.NAME.getJpaEntityFieldName()),
|
||||||
DESCRIPTION(TagFields.DESCRIPTION.getJpaEntityFieldName()),
|
DESCRIPTION(TagFields.DESCRIPTION.getJpaEntityFieldName()),
|
||||||
COLOUR(TagFields.COLOUR.getJpaEntityFieldName());
|
COLOUR(TagFields.COLOUR.getJpaEntityFieldName());
|
||||||
|
|
||||||
private final String jpaEntityFieldName;
|
private final String jpaEntityFieldName;
|
||||||
|
|
||||||
TargetTagFields(final String jpaEntityFieldName) {
|
TargetTagFields(final String jpaEntityFieldName) {
|
||||||
this.jpaEntityFieldName = jpaEntityFieldName;
|
this.jpaEntityFieldName = jpaEntityFieldName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,11 +34,9 @@ public interface TenantAware {
|
|||||||
* {@link TenantRunner} it must be ensured that the original tenant before
|
* {@link TenantRunner} it must be ensured that the original tenant before
|
||||||
* this invocation is reset.
|
* this invocation is reset.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant which the specific code should run
|
||||||
* the tenant which the specific code should run
|
* @param tenantRunner the runner which is implemented to run this specific code
|
||||||
* @param tenantRunner
|
* under the given tenant
|
||||||
* the runner which is implemented to run this specific code
|
|
||||||
* under the given tenant
|
|
||||||
* @return the return type of the {@link TenantRunner}
|
* @return the return type of the {@link TenantRunner}
|
||||||
*/
|
*/
|
||||||
<T> T runAsTenant(String tenant, TenantRunner<T> tenantRunner);
|
<T> T runAsTenant(String tenant, TenantRunner<T> tenantRunner);
|
||||||
@@ -50,13 +48,10 @@ public interface TenantAware {
|
|||||||
* {@link TenantRunner} it must be ensured that the original tenant before
|
* {@link TenantRunner} it must be ensured that the original tenant before
|
||||||
* this invocation is reset.
|
* this invocation is reset.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant the tenant which the specific code should run with
|
||||||
* the tenant which the specific code should run with
|
* @param username the username which the specific code should run with
|
||||||
* @param username
|
* @param tenantRunner the runner which is implemented to run this specific code
|
||||||
* the username which the specific code should run with
|
* under the given tenant
|
||||||
* @param tenantRunner
|
|
||||||
* the runner which is implemented to run this specific code
|
|
||||||
* under the given tenant
|
|
||||||
* @return the return type of the {@link TenantRunner}
|
* @return the return type of the {@link TenantRunner}
|
||||||
*/
|
*/
|
||||||
<T> T runAsTenantAsUser(String tenant, String username, TenantRunner<T> tenantRunner);
|
<T> T runAsTenantAsUser(String tenant, String username, TenantRunner<T> tenantRunner);
|
||||||
@@ -66,14 +61,11 @@ public interface TenantAware {
|
|||||||
* a given tenant by using the
|
* a given tenant by using the
|
||||||
* {@link TenantAware#runAsTenant(String, TenantRunner)}.
|
* {@link TenantAware#runAsTenant(String, TenantRunner)}.
|
||||||
*
|
*
|
||||||
*
|
* @param <T> the return type of the runner
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* the return type of the runner
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface TenantRunner<T> {
|
interface TenantRunner<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to run specific code and a given tenant.
|
* Called to run specific code and a given tenant.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ public interface UserAuthoritiesResolver {
|
|||||||
/**
|
/**
|
||||||
* User authorities/roles lookup based on the tenant and the username
|
* User authorities/roles lookup based on the tenant and the username
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant The tenant that this user belongs to
|
||||||
* The tenant that this user belongs to
|
* @param username The username of the user
|
||||||
* @param username
|
|
||||||
* The username of the user
|
|
||||||
* @return a {@link Collection} of authorities/roles for this user
|
* @return a {@link Collection} of authorities/roles for this user
|
||||||
*/
|
*/
|
||||||
Collection<String> getUserAuthorities(String tenant, String username);
|
Collection<String> getUserAuthorities(String tenant, String username);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.eclipse.hawkbit.exception.SpServerError;
|
|||||||
/**
|
/**
|
||||||
* The {@link #InvalidTenantConfigurationKeyException} is thrown when an invalid
|
* The {@link #InvalidTenantConfigurationKeyException} is thrown when an invalid
|
||||||
* configuration key is used.
|
* configuration key is used.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class InvalidTenantConfigurationKeyException extends AbstractServerRtException {
|
public class InvalidTenantConfigurationKeyException extends AbstractServerRtException {
|
||||||
|
|
||||||
@@ -31,9 +30,8 @@ public class InvalidTenantConfigurationKeyException extends AbstractServerRtExce
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param cause
|
* @param cause of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public InvalidTenantConfigurationKeyException(final Throwable cause) {
|
public InvalidTenantConfigurationKeyException(final Throwable cause) {
|
||||||
super(THIS_ERROR, cause);
|
super(THIS_ERROR, cause);
|
||||||
@@ -41,11 +39,9 @@ public class InvalidTenantConfigurationKeyException extends AbstractServerRtExce
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message of the exception
|
||||||
* of the exception
|
* @param cause of the exception
|
||||||
* @param cause
|
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public InvalidTenantConfigurationKeyException(final String message, final Throwable cause) {
|
public InvalidTenantConfigurationKeyException(final String message, final Throwable cause) {
|
||||||
super(message, THIS_ERROR, cause);
|
super(message, THIS_ERROR, cause);
|
||||||
@@ -53,9 +49,8 @@ public class InvalidTenantConfigurationKeyException extends AbstractServerRtExce
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public InvalidTenantConfigurationKeyException(final String message) {
|
public InvalidTenantConfigurationKeyException(final String message) {
|
||||||
super(message, THIS_ERROR);
|
super(message, THIS_ERROR);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.eclipse.hawkbit.exception.SpServerError;
|
|||||||
/**
|
/**
|
||||||
* Exception which is thrown, when the validation of the configuration value has
|
* Exception which is thrown, when the validation of the configuration value has
|
||||||
* not been successful.
|
* not been successful.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TenantConfigurationValidatorException extends AbstractServerRtException {
|
public class TenantConfigurationValidatorException extends AbstractServerRtException {
|
||||||
|
|
||||||
@@ -31,9 +30,8 @@ public class TenantConfigurationValidatorException extends AbstractServerRtExcep
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param cause
|
* @param cause of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public TenantConfigurationValidatorException(final Throwable cause) {
|
public TenantConfigurationValidatorException(final Throwable cause) {
|
||||||
super(THIS_ERROR, cause);
|
super(THIS_ERROR, cause);
|
||||||
@@ -41,11 +39,9 @@ public class TenantConfigurationValidatorException extends AbstractServerRtExcep
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message of the exception
|
||||||
* of the exception
|
* @param cause of the exception
|
||||||
* @param cause
|
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public TenantConfigurationValidatorException(final String message, final Throwable cause) {
|
public TenantConfigurationValidatorException(final String message, final Throwable cause) {
|
||||||
super(message, THIS_ERROR, cause);
|
super(message, THIS_ERROR, cause);
|
||||||
@@ -53,9 +49,8 @@ public class TenantConfigurationValidatorException extends AbstractServerRtExcep
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized constructor.
|
* Parameterized constructor.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message of the exception
|
||||||
* of the exception
|
|
||||||
*/
|
*/
|
||||||
public TenantConfigurationValidatorException(final String message) {
|
public TenantConfigurationValidatorException(final String message) {
|
||||||
super(message, THIS_ERROR);
|
super(message, THIS_ERROR);
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ package org.eclipse.hawkbit.api;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
import io.qameta.allure.Feature;
|
import io.qameta.allure.Feature;
|
||||||
import io.qameta.allure.Story;
|
import io.qameta.allure.Story;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@Feature("Unit Tests - Artifact URL Handler")
|
@Feature("Unit Tests - Artifact URL Handler")
|
||||||
@Story("Base62 Utility tests")
|
@Story("Base62 Utility tests")
|
||||||
|
|||||||
@@ -13,18 +13,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.qameta.allure.Description;
|
||||||
|
import io.qameta.allure.Feature;
|
||||||
|
import io.qameta.allure.Story;
|
||||||
import org.eclipse.hawkbit.api.ArtifactUrlHandlerProperties.UrlProtocol;
|
import org.eclipse.hawkbit.api.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||||
import org.eclipse.hawkbit.api.URLPlaceholder.SoftwareData;
|
import org.eclipse.hawkbit.api.URLPlaceholder.SoftwareData;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
|
||||||
import io.qameta.allure.Feature;
|
|
||||||
import io.qameta.allure.Story;
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,13 +49,10 @@ public class PropertyBasedArtifactUrlHandlerTest {
|
|||||||
private static final String TENANT = "TEST_TENANT";
|
private static final String TENANT = "TEST_TENANT";
|
||||||
|
|
||||||
private static final String HTTP_LOCALHOST = "http://localhost:8080/";
|
private static final String HTTP_LOCALHOST = "http://localhost:8080/";
|
||||||
|
|
||||||
private ArtifactUrlHandler urlHandlerUnderTest;
|
|
||||||
|
|
||||||
private ArtifactUrlHandlerProperties properties;
|
|
||||||
|
|
||||||
private static URLPlaceholder placeholder = new URLPlaceholder(TENANT, TENANT_ID, CONTROLLER_ID, TARGETID,
|
private static URLPlaceholder placeholder = new URLPlaceholder(TENANT, TENANT_ID, CONTROLLER_ID, TARGETID,
|
||||||
new SoftwareData(SOFTWAREMODULEID, FILENAME_DECODE, ARTIFACTID, SHA1HASH));
|
new SoftwareData(SOFTWAREMODULEID, FILENAME_DECODE, ARTIFACTID, SHA1HASH));
|
||||||
|
private ArtifactUrlHandler urlHandlerUnderTest;
|
||||||
|
private ArtifactUrlHandlerProperties properties;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@@ -142,6 +137,7 @@ public class PropertyBasedArtifactUrlHandlerTest {
|
|||||||
assertThat(urls).containsExactly(new ArtifactUrl(TEST_PROTO.toUpperCase(), TEST_REL, TEST_PROTO + "://"
|
assertThat(urls).containsExactly(new ArtifactUrl(TEST_PROTO.toUpperCase(), TEST_REL, TEST_PROTO + "://"
|
||||||
+ testHost + ":5683/fws/" + TENANT + "/" + TARGETID_BASE62 + "/" + ARTIFACTID_BASE62));
|
+ testHost + ":5683/fws/" + TENANT + "/" + TARGETID_BASE62 + "/" + ARTIFACTID_BASE62));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that the protocol of the statically defined hostname is replaced with the protocol of the request.")
|
@Description("Verfies that the protocol of the statically defined hostname is replaced with the protocol of the request.")
|
||||||
public void urlGenerationWithProtocolFromRequest() throws URISyntaxException {
|
public void urlGenerationWithProtocolFromRequest() throws URISyntaxException {
|
||||||
@@ -191,10 +187,10 @@ public class PropertyBasedArtifactUrlHandlerTest {
|
|||||||
proto.setProtocol(protocol);
|
proto.setProtocol(protocol);
|
||||||
properties.getProtocols().put("download-http", proto);
|
properties.getProtocols().put("download-http", proto);
|
||||||
|
|
||||||
URI uri = new URI(protocol+"://anotherHost.com");
|
URI uri = new URI(protocol + "://anotherHost.com");
|
||||||
final List<ArtifactUrl> urls = urlHandlerUnderTest.getUrls(placeholder, ApiType.DDI, uri);
|
final List<ArtifactUrl> urls = urlHandlerUnderTest.getUrls(placeholder, ApiType.DDI, uri);
|
||||||
assertThat(urls).containsExactly(new ArtifactUrl(protocol.toUpperCase(), "download-http",
|
assertThat(urls).containsExactly(new ArtifactUrl(protocol.toUpperCase(), "download-http",
|
||||||
uri +"/" + TENANT + "/controller/v1/" + CONTROLLER_ID + "/softwaremodules/"
|
uri + "/" + TENANT + "/controller/v1/" + CONTROLLER_ID + "/softwaremodules/"
|
||||||
+ SOFTWAREMODULEID + "/artifacts/" + FILENAME_ENCODE));
|
+ SOFTWAREMODULEID + "/artifacts/" + FILENAME_ENCODE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ package org.eclipse.hawkbit.api;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
import io.qameta.allure.Feature;
|
import io.qameta.allure.Feature;
|
||||||
import io.qameta.allure.Story;
|
import io.qameta.allure.Story;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@Feature("Unit Tests - Artifact URL Handler")
|
@Feature("Unit Tests - Artifact URL Handler")
|
||||||
@Story("URL placeholder tests")
|
@Story("URL placeholder tests")
|
||||||
|
|||||||
@@ -9,16 +9,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import io.github.classgraph.ClassGraph;
|
import io.github.classgraph.ClassGraph;
|
||||||
import io.github.classgraph.ClassInfo;
|
import io.github.classgraph.ClassInfo;
|
||||||
import io.github.classgraph.ScanResult;
|
import io.github.classgraph.ScanResult;
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
public class FileNameFieldsTest {
|
public class FileNameFieldsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user