Refactoring/Improving source: core (#1598)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-03 16:47:57 +02:00
committed by GitHub
parent 24c4cde84e
commit e4c70f3f34
10 changed files with 20 additions and 27 deletions

View File

@@ -12,8 +12,7 @@ package org.eclipse.hawkbit;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.slf4j.Logger; import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
@@ -24,11 +23,9 @@ import org.springframework.core.io.support.ResourcePatternResolver;
* MessageSource implementation supports more than 1 properties file with the * MessageSource implementation supports more than 1 properties file with the
* same name. All properties files will be merged. * same name. All properties files will be merged.
*/ */
@Slf4j
public class DistributedResourceBundleMessageSource extends ReloadableResourceBundleMessageSource { public class DistributedResourceBundleMessageSource extends ReloadableResourceBundleMessageSource {
// Exception squid:S2387 - Follows our upper case convention
@SuppressWarnings({ "squid:S2387" })
private static final Logger LOGGER = LoggerFactory.getLogger(DistributedResourceBundleMessageSource.class);
private static final String PROPERTIES_SUFFIX = ".properties"; private static final String PROPERTIES_SUFFIX = ".properties";
private ResourceLoader resourceLoader; private ResourceLoader resourceLoader;
@@ -47,7 +44,7 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
final Properties properties = new Properties(); final Properties properties = new Properties();
long lastModified = -1; long lastModified = -1;
if (!(resourceLoader instanceof ResourcePatternResolver)) { if (!(resourceLoader instanceof ResourcePatternResolver)) {
LOGGER.warn( log.warn(
"Resource Loader {} doesn't support getting multiple resources. Default properties mechanism will used", "Resource Loader {} doesn't support getting multiple resources. Default properties mechanism will used",
resourceLoader.getClass().getName()); resourceLoader.getClass().getName());
return super.refreshProperties(filename, propHolder); return super.refreshProperties(filename, propHolder);
@@ -65,7 +62,7 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
} }
} }
} catch (final IOException ignored) { } catch (final IOException ignored) {
LOGGER.warn("Resource with filename " + filename + " couldn't load", ignored); log.warn("Resource with filename " + filename + " couldn't load", ignored);
} }
return new PropertiesHolder(properties, lastModified); return new PropertiesHolder(properties, lastModified);
} }
@@ -75,5 +72,4 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
this.resourceLoader = resourceLoader; this.resourceLoader = resourceLoader;
super.setResourceLoader(resourceLoader); super.setResourceLoader(resourceLoader);
} }
}
}

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.api;
/** /**
* hawkBit API type. * hawkBit API type.
*
*/ */
public enum ApiType { public enum ApiType {
@@ -29,4 +28,4 @@ public enum ApiType {
* Support for Management API. * Support for Management API.
*/ */
MGMT MGMT
} }

View File

@@ -88,4 +88,4 @@ public class ArtifactUrlHandlerProperties {
this.supports = Collections.unmodifiableList(supports); this.supports = Collections.unmodifiableList(supports);
} }
} }
} }

View File

@@ -9,18 +9,18 @@
*/ */
package org.eclipse.hawkbit.api; package org.eclipse.hawkbit.api;
import lombok.NoArgsConstructor;
/** /**
* Utility class for Base10 to Base62 conversion and vice versa. Base62 has the * Utility class for Base10 to Base62 conversion and vice versa. Base62 has the
* benefit of being shorter in ASCII representation than Base10. * benefit of being shorter in ASCII representation than Base10.
*/ */
@NoArgsConstructor
public final class Base62Util { public final class Base62Util {
private static final String BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final int BASE62_BASE = BASE62_ALPHABET.length(); private static final int BASE62_BASE = BASE62_ALPHABET.length();
private Base62Util() {
// Utility class
}
/** /**
* @param base10 * @param base10
* number * number
@@ -66,4 +66,4 @@ public final class Base62Util {
private static int toBase10(final int n, final int pow) { private static int toBase10(final int n, final int pow) {
return n * (int) Math.pow(BASE62_BASE, pow); return n * (int) Math.pow(BASE62_BASE, pow);
} }
} }

View File

@@ -19,10 +19,9 @@ import java.net.URL;
public interface HostnameResolver { public interface HostnameResolver {
/** /**
* Resolved the hostname
* *
* * @return resolved hostname as URL
* @return
*/ */
URL resolveHostname(); URL resolveHostname();
}
}

View File

@@ -14,6 +14,7 @@ package org.eclipse.hawkbit.api;
* pattern. * pattern.
*/ */
public interface ProtocolProperties { public interface ProtocolProperties {
/** /**
* @return the hostname value to resolve in the pattern. * @return the hostname value to resolve in the pattern.
*/ */
@@ -38,4 +39,4 @@ public interface ProtocolProperties {
* @return <code>true</code> if the {@link ProtocolProperties} is enabled. * @return <code>true</code> if the {@link ProtocolProperties} is enabled.
*/ */
boolean isEnabled(); boolean isEnabled();
} }

View File

@@ -81,4 +81,4 @@ public class URLPlaceholder {
this.sha1Hash = sha1Hash; this.sha1Hash = sha1Hash;
} }
} }
} }

View File

@@ -25,8 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**

View File

@@ -33,4 +33,4 @@ public class DbArtifactHash {
this.md5 = md5; this.md5 = md5;
this.sha256 = sha256; this.sha256 = sha256;
} }
} }

View File

@@ -124,4 +124,4 @@ class DefaultDownloadIdCacheTest {
assertThat(cacheManagerKeyCaptor.getValue()).isEqualTo(knownKey); assertThat(cacheManagerKeyCaptor.getValue()).isEqualTo(knownKey);
assertThat(cacheManagerValueCaptor.getValue()).isEqualTo(value); assertThat(cacheManagerValueCaptor.getValue()).isEqualTo(value);
} }
} }