Refactoring/Improving source: core (#1598)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -12,8 +12,7 @@ package org.eclipse.hawkbit;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
import org.springframework.core.io.Resource;
|
||||
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
|
||||
* same name. All properties files will be merged.
|
||||
*/
|
||||
@Slf4j
|
||||
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 ResourceLoader resourceLoader;
|
||||
|
||||
@@ -47,7 +44,7 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
|
||||
final Properties properties = new Properties();
|
||||
long lastModified = -1;
|
||||
if (!(resourceLoader instanceof ResourcePatternResolver)) {
|
||||
LOGGER.warn(
|
||||
log.warn(
|
||||
"Resource Loader {} doesn't support getting multiple resources. Default properties mechanism will used",
|
||||
resourceLoader.getClass().getName());
|
||||
return super.refreshProperties(filename, propHolder);
|
||||
@@ -65,7 +62,7 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
@@ -75,5 +72,4 @@ public class DistributedResourceBundleMessageSource extends ReloadableResourceBu
|
||||
this.resourceLoader = resourceLoader;
|
||||
super.setResourceLoader(resourceLoader);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.api;
|
||||
|
||||
/**
|
||||
* hawkBit API type.
|
||||
*
|
||||
*/
|
||||
public enum ApiType {
|
||||
|
||||
@@ -29,4 +28,4 @@ public enum ApiType {
|
||||
* Support for Management API.
|
||||
*/
|
||||
MGMT
|
||||
}
|
||||
}
|
||||
@@ -88,4 +88,4 @@ public class ArtifactUrlHandlerProperties {
|
||||
this.supports = Collections.unmodifiableList(supports);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,18 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.api;
|
||||
|
||||
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.
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public final class Base62Util {
|
||||
|
||||
private static final String BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private static final int BASE62_BASE = BASE62_ALPHABET.length();
|
||||
|
||||
private Base62Util() {
|
||||
// Utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* @param base10
|
||||
* number
|
||||
@@ -66,4 +66,4 @@ public final class Base62Util {
|
||||
private static int toBase10(final int n, final int pow) {
|
||||
return n * (int) Math.pow(BASE62_BASE, pow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,9 @@ import java.net.URL;
|
||||
public interface HostnameResolver {
|
||||
|
||||
/**
|
||||
* Resolved the hostname
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* @return resolved hostname as URL
|
||||
*/
|
||||
URL resolveHostname();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ package org.eclipse.hawkbit.api;
|
||||
* pattern.
|
||||
*/
|
||||
public interface ProtocolProperties {
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
boolean isEnabled();
|
||||
}
|
||||
}
|
||||
@@ -81,4 +81,4 @@ public class URLPlaceholder {
|
||||
this.sha1Hash = sha1Hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,4 +33,4 @@ public class DbArtifactHash {
|
||||
this.md5 = md5;
|
||||
this.sha256 = sha256;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,4 +124,4 @@ class DefaultDownloadIdCacheTest {
|
||||
assertThat(cacheManagerKeyCaptor.getValue()).isEqualTo(knownKey);
|
||||
assertThat(cacheManagerValueCaptor.getValue()).isEqualTo(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user