diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2020-09-03 10:58:59 +0200 |
---|---|---|
committer | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2020-09-03 10:59:11 +0200 |
commit | a452cd75ddae953c881e507ee9223961387e9355 (patch) | |
tree | c386204f67a14642e75d3caa3060bf1c1892b7d8 /sdnr/wt/common/src/main | |
parent | 4756715c82c0d71f934d47620031893bc92a1344 (diff) |
update common
fixed unit tests and clean up some code
Issue-ID: CCSDK-2725
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I3624b3c69bbfb17ea6e28f26d96e2f77107721d4
Diffstat (limited to 'sdnr/wt/common/src/main')
6 files changed, 32 insertions, 9 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java index fe43837e2..96bfa070b 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java @@ -29,7 +29,6 @@ import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; import java.util.Optional; - import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.ConfigFileObserver; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section; @@ -71,6 +70,8 @@ public class ConfigurationFileRepresentation implements IConfigChangedListener { if (!this.mFile.createNewFile()) { LOG.error("Can not create file {}", f.getAbsolutePath()); } + this.mFile.setReadable(true, false); + this.mFile.setWritable(true, false); } reLoad(); diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java index 7fb58a165..c6b121ae3 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java @@ -29,7 +29,6 @@ import java.util.Objects; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; - import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConversionException; import org.slf4j.Logger; @@ -51,7 +50,8 @@ public class Section { // constants private static final Logger LOG = LoggerFactory.getLogger(Section.class); private static final String DELIMITER = "="; - private static final String COMMENTCHARS[] = {"#", ";"}; + private static final String DEFAULT_COMMENTCHAR = "#"; + private static final String COMMENTCHARS[] = {DEFAULT_COMMENTCHAR, ";"}; private static final String ENVVARIABLE = "${"; private static final String REGEXENVVARIABLE = "(\\$\\{[A-Z0-9_-]+\\})"; // end of constants @@ -132,6 +132,20 @@ public class Section { return value; } + public boolean addComment(String key,String comment) { + if (this.values.containsKey(key)) { + this.values.get(key).addComment(DEFAULT_COMMENTCHAR+comment); + } + return false; + } + + public boolean removeComment(String key,String comment) { + if (this.values.containsKey(key)) { + this.values.get(key).removeComment(DEFAULT_COMMENTCHAR+comment); + } + return false; + } + public void setProperty(String key, String value) { boolean isuncommented = this.isCommentLine(key); if (isuncommented) { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java index a4758f1b5..f513e011c 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; /** - * + * * @author Michael Dürre, Herbert Eiselt * */ @@ -35,7 +35,7 @@ class SectionValue { private String value; private final List<String> comments; private boolean isUncommented; - // end of variables + // end of variables // constructors public SectionValue(String value, List<String> commentsForValue, boolean isuncommented) { @@ -72,6 +72,16 @@ class SectionValue { return this; } + public void addComment(String comment) { + this.comments.add(comment); + this.isUncommented = false; + } + + public void removeComment(String comment) { + this.comments.remove(comment); + this.isUncommented = this.comments.size()==0; + } + public List<String> getComments() { return comments; } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java index 836c0fae7..f8734d5a6 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java @@ -91,7 +91,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.UpdateByQueryResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.UpdateResponse; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; -import org.osgi.framework.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java index 475178b4c..8b43eb157 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. * All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +18,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ccsdk.features.sdnr.wt.common.database; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.SocketChannel; - import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; public class Portstatus { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java index 7956b2bfc..c73af27fa 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.responses; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; import org.elasticsearch.client.Response; |