Remove unused org.eclipse.hawkbit.api.HostnameResolver (#1978)
_release_notes_ Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<ArtifactUrl> 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<ArtifactUrl> getUrls(URLPlaceholder placeholder, ApiType api, URI requestUri);
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user