Split repository API for module and DS management. Refactor utility usage (#524)
* Split DS management and reduce util usage. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Split sw module and type management. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Sonar issues. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Make sonar listen to the exception! Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Register both beans. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Split JPA implementations. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Revert user details change. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix compilation errors. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix bean queries. Fix image path. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Document preferred utility usage. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix exmaples and revert unintended checkin. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code cleanup. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Typos, readibility. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove unused reference. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Rollouts cache delete aware. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix rolloutgroup delete event. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add new RolloutGroupDeletedEvent event Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -15,8 +16,6 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Artifact handler properties class for holding all supported protocols with
|
||||
* host, ip, port and download pattern.
|
||||
@@ -85,7 +84,7 @@ public class ArtifactUrlHandlerProperties {
|
||||
/**
|
||||
* Support for the following hawkBit API.
|
||||
*/
|
||||
private List<ApiType> supports = Lists.newArrayList(ApiType.DDI, ApiType.DMF);
|
||||
private List<ApiType> supports = Arrays.asList(ApiType.DDI, ApiType.DMF);
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.api;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -17,12 +22,9 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.api.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.net.UrlEscapers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Implementation for ArtifactUrlHandler for creating urls to download resource
|
||||
@@ -43,6 +45,8 @@ import com.google.common.net.UrlEscapers;
|
||||
*/
|
||||
public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PropertyBasedArtifactUrlHandler.class);
|
||||
|
||||
private static final String PROTOCOL_PLACEHOLDER = "protocol";
|
||||
private static final String CONTROLLER_ID_PLACEHOLDER = "controllerId";
|
||||
private static final String TARGET_ID_BASE10_PLACEHOLDER = "targetId";
|
||||
@@ -99,7 +103,7 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
for (final Entry<String, String> entry : entrySet) {
|
||||
if (entry.getKey().equals(PORT_PLACEHOLDER)) {
|
||||
urlPattern = urlPattern.replace(":{" + entry.getKey() + "}",
|
||||
Strings.isNullOrEmpty(entry.getValue()) ? "" : (":" + entry.getValue()));
|
||||
StringUtils.isEmpty(entry.getValue()) ? "" : (":" + entry.getValue()));
|
||||
} else {
|
||||
urlPattern = urlPattern.replace("{" + entry.getKey() + "}", entry.getValue());
|
||||
}
|
||||
@@ -109,7 +113,7 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
|
||||
private static Map<String, String> getReplaceMap(final UrlProtocol protocol, final URLPlaceholder placeholder,
|
||||
final URI requestUri) {
|
||||
final Map<String, String> replaceMap = Maps.newHashMapWithExpectedSize(19);
|
||||
final Map<String, String> replaceMap = new HashMap<>();
|
||||
replaceMap.put(IP_PLACEHOLDER, protocol.getIp());
|
||||
replaceMap.put(HOSTNAME_PLACEHOLDER, protocol.getHostname());
|
||||
|
||||
@@ -117,8 +121,13 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
replaceMap.put(PORT_REQUEST_PLACEHOLDER, getRequestPort(protocol, requestUri));
|
||||
replaceMap.put(HOSTNAME_WITH_DOMAIN_REQUEST_PLACEHOLDER, computeHostWithRequestDomain(protocol, requestUri));
|
||||
|
||||
replaceMap.put(ARTIFACT_FILENAME_PLACEHOLDER,
|
||||
UrlEscapers.urlFragmentEscaper().escape(placeholder.getSoftwareData().getFilename()));
|
||||
try {
|
||||
replaceMap.put(ARTIFACT_FILENAME_PLACEHOLDER,
|
||||
URLEncoder.encode(placeholder.getSoftwareData().getFilename(), StandardCharsets.UTF_8.toString()));
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
LOG.error("Could not encode {}", placeholder.getSoftwareData().getFilename(), e);
|
||||
}
|
||||
|
||||
replaceMap.put(ARTIFACT_SHA1_PLACEHOLDER, placeholder.getSoftwareData().getSha1Hash());
|
||||
replaceMap.put(PROTOCOL_PLACEHOLDER, protocol.getProtocol());
|
||||
replaceMap.put(PORT_PLACEHOLDER, getPort(protocol));
|
||||
@@ -168,14 +177,14 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
return protocol.getHostname();
|
||||
}
|
||||
|
||||
final String host = Splitter.on('.').trimResults().omitEmptyStrings().splitToList(protocol.getHostname())
|
||||
.get(0);
|
||||
final String host = StringUtils.delimitedListToStringArray(protocol.getHostname(), ".")[0].trim();
|
||||
|
||||
final List<String> domainElements = Splitter.on('.').trimResults().omitEmptyStrings()
|
||||
.splitToList(requestUri.getHost());
|
||||
final String domain = Joiner.on(".").join(domainElements.subList(1, domainElements.size()));
|
||||
final List<String> domainElements = Arrays
|
||||
.asList(StringUtils.delimitedListToStringArray(requestUri.getHost(), "."));
|
||||
final String domain = StringUtils.collectionToDelimitedString(domainElements.subList(1, domainElements.size()),
|
||||
".");
|
||||
|
||||
if (Strings.isNullOrEmpty(domain)) {
|
||||
if (StringUtils.isEmpty(domain)) {
|
||||
return protocol.getHostname();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.tenancy.configuration;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* The {@link #InvalidTenantConfigurationKeyException} is thrown when an invalid
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.tenancy.configuration.validator;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* Exception which is thrown, when the validation of the configuration value has
|
||||
|
||||
Reference in New Issue
Block a user