diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ArtifactUrlHandlerAutoConfiguration.java similarity index 63% rename from hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java rename to hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ArtifactUrlHandlerAutoConfiguration.java index 975a6c54a..2741aa4c5 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ArtifactUrlHandlerAutoConfiguration.java @@ -9,13 +9,9 @@ */ package org.eclipse.hawkbit.autoconfigure; -import java.net.MalformedURLException; -import java.net.URL; - import org.eclipse.hawkbit.HawkbitServerProperties; import org.eclipse.hawkbit.api.ArtifactUrlHandler; import org.eclipse.hawkbit.api.ArtifactUrlHandlerProperties; -import org.eclipse.hawkbit.api.HostnameResolver; import org.eclipse.hawkbit.api.PropertyBasedArtifactUrlHandler; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -25,30 +21,12 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; /** - * Auto configuration for {@link HostnameResolver} and - * {@link ArtifactUrlHandler} based on a properties. + * Auto-configuration for {@link ArtifactUrlHandler} based on a properties. */ @Configuration @EnableConfigurationProperties({ HawkbitServerProperties.class, ArtifactUrlHandlerProperties.class }) @PropertySource("classpath:/hawkbit-artifactdl-defaults.properties") -public class PropertyHostnameResolverAutoConfiguration { - - /** - * @param serverProperties to get the servers URL - * @return the default autoconfigure hostname resolver implementation which - * is property based specified by the property {@link #url} - */ - @Bean - @ConditionalOnMissingBean(value = HostnameResolver.class) - HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) { - return () -> { - try { - return new URL(serverProperties.getUrl()); - } catch (final MalformedURLException e) { - throw new IllegalArgumentException("URL not valid: " + serverProperties.getUrl(), e); - } - }; - } +public class ArtifactUrlHandlerAutoConfiguration { /** * @param urlHandlerProperties for bean configuration @@ -61,5 +39,4 @@ public class PropertyHostnameResolverAutoConfiguration { @Value("${server.servlet.context-path:}") final String contextPath) { return new PropertyBasedArtifactUrlHandler(urlHandlerProperties, contextPath); } - -} +} \ No newline at end of file diff --git a/hawkbit-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/hawkbit-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index a8083de17..9219c5312 100644 --- a/hawkbit-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/hawkbit-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -9,4 +9,4 @@ org.eclipse.hawkbit.autoconfigure.scheduling.AsyncConfigurerAutoConfiguration org.eclipse.hawkbit.autoconfigure.scheduling.ExecutorAutoConfiguration org.eclipse.hawkbit.autoconfigure.security.SecurityAutoConfiguration org.eclipse.hawkbit.autoconfigure.security.InMemoryUserManagementAutoConfiguration -org.eclipse.hawkbit.autoconfigure.PropertyHostnameResolverAutoConfiguration +org.eclipse.hawkbit.autoconfigure.ArtifactUrlHandlerAutoConfiguration diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/ArtifactUrlHandler.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/ArtifactUrlHandler.java index 8d55149fb..156a91e7d 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/ArtifactUrlHandler.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/ArtifactUrlHandler.java @@ -13,18 +13,16 @@ import java.net.URI; import java.util.List; /** - * Interface declaration of the {@link ArtifactUrlHandler} which generates the - * URLs to specific artifacts. + * Interface declaration of the {@link ArtifactUrlHandler} which generates the URLs to specific artifacts. */ public interface ArtifactUrlHandler { /** - * Returns a generated download URL for a given artifact parameters for a - * specific protocol. + * Returns a generated download URL for a given artifact parameters for a specific protocol. * * @param placeholder data for URL generation * @param api given protocol that URL needs to support - * @return an URL for the given artifact parameters in a given protocol + * @return a URL for the given artifact parameters in a given protocol */ List getUrls(URLPlaceholder placeholder, ApiType api); @@ -34,9 +32,8 @@ public interface ArtifactUrlHandler { * * @param placeholder data for URL generation * @param api given protocol that URL needs to support - * @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 + * @param requestUri of the request that allows the handler to align the generated URL to the original request. + * @return a URL for the given artifact parameters in a given protocol */ List getUrls(URLPlaceholder placeholder, ApiType api, URI requestUri); -} +} \ No newline at end of file diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/Base62Util.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/Base62Util.java index 7d7722bd4..4275ab9dd 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/Base62Util.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/Base62Util.java @@ -13,8 +13,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; /** - * Utility class for Base10 to Base62 conversion and vice versa. Base62 has the - * benefit of being shorter in ASCII representation than Base10. + * Utility class for Base10 to Base62 conversion and vice versa. Base62 has the benefit of being shorter in ASCII representation than Base10. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class Base62Util { @@ -23,15 +22,15 @@ public final class Base62Util { private static final int BASE62_BASE = BASE62_ALPHABET.length(); /** - * @param base10 number + * @param l number * @return converted number into Base62 ASCII string */ - public static String fromBase10(final long base10) { - if (base10 == 0) { + public static String fromBase10(final long l) { + if (l == 0) { return "0"; } - long temp = base10; + long temp = l; final StringBuilder sb = new StringBuilder(); while (temp > 0) { @@ -48,10 +47,10 @@ public final class Base62Util { return toBase10(new StringBuilder(base62).reverse().toString().toCharArray()); } - private static Long fromBase10(final long base10, final StringBuilder sb) { - final int rem = (int) (base10 % BASE62_BASE); + private static Long fromBase10(final long l, final StringBuilder sb) { + final int rem = (int) (l % BASE62_BASE); sb.append(BASE62_ALPHABET.charAt(rem)); - return base10 / BASE62_BASE; + return l / BASE62_BASE; } private static Long toBase10(final char[] chars) { diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java deleted file mode 100644 index bf4e63152..000000000 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.api; - -import java.net.URL; - -/** - * Resolve to reach the server url. - */ -@FunctionalInterface -public interface HostnameResolver { - - /** - * Resolved the hostname - * - * @return resolved hostname as URL - */ - URL resolveHostname(); -} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java index e5165b0c2..5a8a5f5d3 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java @@ -17,7 +17,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.eclipse.hawkbit.HawkbitServerProperties; -import org.eclipse.hawkbit.api.HostnameResolver; import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -71,18 +70,6 @@ public class AmqpTestConfiguration { return new ThreadPoolTaskScheduler(); } - @SuppressWarnings("java:S112") - @Bean - HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) { - return () -> { - try { - return new URL(serverProperties.getUrl()); - } catch (final MalformedURLException e) { - throw new RuntimeException(e); - } - }; - } - @Bean ConnectionFactory rabbitConnectionFactory(RabbitMqSetupService rabbitMqSetupService) { return rabbitMqSetupService.newVirtualHostWithConnectionFactory();