summaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr')
-rw-r--r--sdnr/wt/common-yang/utils/pom.xml5
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java30
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/TypeObjectSerializer.java37
-rw-r--r--sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestDataMappings.java99
-rw-r--r--sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangGenSalMapping.java273
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java71
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java3
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java2
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java14
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java2
-rwxr-xr-xsdnr/wt/helpserver/installer/pom.xml4
-rw-r--r--sdnr/wt/helpserver/provider/pom.xml3
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java29
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java8
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java2
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/GenericTransactionUtils.java12
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingAccessorImpl.java2
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java31
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java2
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java5
-rw-r--r--sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java3
-rw-r--r--sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/utils/AkkaConfig.java9
23 files changed, 552 insertions, 98 deletions
diff --git a/sdnr/wt/common-yang/utils/pom.xml b/sdnr/wt/common-yang/utils/pom.xml
index 4aa62fa8a..516895af0 100644
--- a/sdnr/wt/common-yang/utils/pom.xml
+++ b/sdnr/wt/common-yang/utils/pom.xml
@@ -79,6 +79,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
index f443fd615..d468e075c 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
@@ -278,6 +278,12 @@ public class YangToolsMapperHelper {
return notification instanceof DOMEvent;
}
+ /**
+ * Get time instant from notification if available or default
+ * @param notification
+ * @param defaultValue
+ * @return DateAndTime
+ */
public static DateAndTime getTime(Notification notification, Instant defaultValue) {
Instant time;
if (hasTime(notification)) { // If notification class extends/implements the EventInstantAware
@@ -290,6 +296,21 @@ public class YangToolsMapperHelper {
return DateAndTime.getDefaultInstance(ZonedDateTime.ofInstant(time, ZoneOffset.UTC).format(formatterOutput));
}
+ /**
+ * Get time instant from notification if available or actual time
+ * @param notification
+ * @return DateAndTime
+ */
+ public static DateAndTime getTime(Notification notification) {
+ return getTime(notification, Instant.now());
+ }
+
+ /**
+ * Get time instant from DOM notification if available or default
+ * @param DOM notification
+ * @param defaultValue
+ * @return DateAndTime
+ */
public static DateAndTime getTime(DOMNotification notification, Instant defaultValue) {
Instant time;
if (hasTime(notification)) { // If notification class extends/implements the EventInstantAware
@@ -301,4 +322,13 @@ public class YangToolsMapperHelper {
}
return DateAndTime.getDefaultInstance(ZonedDateTime.ofInstant(time, ZoneOffset.UTC).format(formatterOutput));
}
+
+ /**
+ * Get time instant from notification if available or actual time
+ * @param DOM notification
+ * @return DateAndTime
+ */
+ public static DateAndTime getTime(DOMNotification notification) {
+ return getTime(notification, Instant.now());
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/TypeObjectSerializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/TypeObjectSerializer.java
index b43e6c100..4fb39415e 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/TypeObjectSerializer.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/TypeObjectSerializer.java
@@ -31,22 +31,43 @@ import org.opendaylight.yangtools.yang.binding.TypeObject;
public class TypeObjectSerializer extends JsonSerializer<TypeObject> {
+ /**
+ * serialize typeobject values
+ * prefer stringValue() method over getValue() method
+ */
@Override
public void serialize(TypeObject value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- //stringValue
Method[] methods = value.getClass().getDeclaredMethods();
String name;
+ Method getValueMethod = null;
for (Method method : methods) {
name = method.getName();
- if (method.getParameterCount()==0 && (name.equals("stringValue") || name.equals("getValue"))) {
- try {
- gen.writeString((String)method.invoke(value));
- break;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | IOException e) {
- throw new IOException("No String getter method supported TypeObject for "+value.getClass(),e);
+ if (method.getParameterCount() == 0) {
+ if (name.equals("getValue")) {
+ getValueMethod = method;
+ } else if (name.equals("stringValue")) {
+ try {
+ gen.writeString((String) method.invoke(value));
+ break;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | IOException e) {
+ throw new IOException("No String getter method supported TypeObject for " + value.getClass(),
+ e);
+ }
}
}
}
+ if (getValueMethod != null) {
+ try {
+ if (String.class.equals(getValueMethod.getReturnType())) {
+ gen.writeString((String) getValueMethod.invoke(value));
+ } else {
+ gen.writeObject(getValueMethod.invoke(value));
+ }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IOException e) {
+ throw new IOException("No String getter method supported TypeObject for " + value.getClass(), e);
+ }
+
+ }
}
}
diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestDataMappings.java b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestDataMappings.java
new file mode 100644
index 000000000..584b4b044
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestDataMappings.java
@@ -0,0 +1,99 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.yang.mapper;
+
+import static org.junit.Assert.fail;
+import java.io.IOException;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data;
+
+public class TestDataMappings {
+
+ // @formatter:off
+ private static final String PMDATA15M_SERVERDB_JSON = "{\n"
+ + "\"node-name\": \"sim2\",\n"
+ + "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n"
+ + "\"layer-protocol-name\": \"MWPS\",\n"
+ + "\"radio-signal-id\": \"Test11\",\n"
+ + "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n"
+ + "\"granularity-period\": \"Period15Min\",\n"
+ + "\"scanner-id\": \"PM_RADIO_15M_9\",\n"
+ + "\"performance-data\": {\n"
+ + "\"es\": 0,\n"
+ + "\"rx-level-avg\": -41,\n"
+ + "\"time2-states\": -1,\n"
+ + "\"time4-states-s\": 0,\n"
+ + "\"time4-states\": 0,\n"
+ + "\"time8-states\": 0,\n"
+ + "\"time16-states-s\": -1,\n"
+ + "\"time16-states\": 0,\n"
+ + "\"time32-states\": 0,\n"
+ + "\"time64-states\": 0,\n"
+ + "\"time128-states\": 0,\n"
+ + "\"time256-states\": 900,\n"
+ + "\"time512-states\": -1,\n"
+ + "\"time512-states-l\": -1,\n"
+ + "\"time1024-states\": -1,\n"
+ + "\"time1024-states-l\": -1,\n"
+ + "\"time2048-states\": -1,\n"
+ + "\"time2048-states-l\": -1,\n"
+ + "\"time4096-states\": -1,\n"
+ + "\"time4096-states-l\": -1,\n"
+ + "\"time8192-states\": -1,\n"
+ + "\"time8192-states-l\": -1,\n"
+ + "\"snir-min\": -99,\n"
+ + "\"snir-max\": -99,\n"
+ + "\"snir-avg\": -99,\n"
+ + "\"xpd-min\": -99,\n"
+ + "\"xpd-max\": -99,\n"
+ + "\"xpd-avg\": -99,\n"
+ + "\"rf-temp-min\": -99,\n"
+ + "\"rf-temp-max\": -99,\n"
+ + "\"rf-temp-avg\": -99,\n"
+ + "\"defect-blocks-sum\": -1,\n"
+ + "\"time-period\": 900,\n"
+ + "\"tx-level-min\": 25,\n"
+ + "\"tx-level-max\": 25,\n"
+ + "\"tx-level-avg\": 25,\n"
+ + "\"rx-level-min\": -41,\n"
+ + "\"rx-level-max\": -41,\n"
+ + "\"unavailability\": 0,\n"
+ + "\"ses\": 0,\n"
+ + "\"cses\": 0\n"
+ + "},\n"
+ + "\"suspect-interval-flag\": false\n"
+ + "}";
+ // @formatter:on
+ @Test
+ public void testPmData15m() throws ClassNotFoundException {
+
+ YangToolsMapper2<Data> mapper = new YangToolsMapper2<Data>(Data.class, null);
+ try {
+ Data data = mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class);
+ System.out.println(data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Can not parse data");
+ }
+ }
+
+}
diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangGenSalMapping.java b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangGenSalMapping.java
new file mode 100644
index 000000000..40164d756
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangGenSalMapping.java
@@ -0,0 +1,273 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.yang.mapper;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.IdentifierDeserializer;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata15m.entity.PerformanceDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.DataBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestYangGenSalMapping {
+
+ // Create mapper for serialization and deserialization
+ DataProviderYangToolsMapper mapper = new DataProviderYangToolsMapper();
+
+ @Test
+ public void test1() throws IOException {
+
+ // Create test object
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+ netconfNodeBuilder.setConnectedMessage("ConnMessage");
+
+ LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
+ loginPasswordBuilder.setUsername("myTestUsername");
+ loginPasswordBuilder.setPassword("myTestPassword");
+ netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
+
+ OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder =
+ new OdlHelloMessageCapabilitiesBuilder();
+ List<Uri> uriList = new ArrayList<>();
+ uriList.add(new Uri("test.uri"));
+ odlHelloMessageCapabilitiesBuilder.setCapability(uriList);
+ netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build());
+
+ NetconfNode netconfNode = netconfNodeBuilder.build();
+ out(netconfNode.toString());
+
+ // Map Object to JSON String
+ String res = mapper.writeValueAsString(netconfNode);
+ JSONObject json = new JSONObject(res); // Convert text to object
+ out(json.toString(4)); // Print it with specified indentation
+
+ // Map to JSON String to Object
+ NetconfNode generatedNode = mapper.readValue(res.getBytes(), NetconfNode.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ // Compare result
+ //TODO - Guilin
+ //out("Equal? "+netconfNode.equals(generatedNode));
+ }
+
+ @Test
+ public void test3() throws IOException {
+
+ PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
+ performanceBuilder.setEs(99);
+ DataBuilder pmData15MinutesBuilder = new DataBuilder();
+ pmData15MinutesBuilder.setLayerProtocolName("fdsaf");
+ pmData15MinutesBuilder.setTimeStamp(new DateAndTime("2017-03-01T09:15:00.0Z"));
+ pmData15MinutesBuilder.setPerformanceData(performanceBuilder.build());
+
+ // Map Object to JSON String
+ String res = mapper.writeValueAsString(pmData15MinutesBuilder.build());
+ JSONObject json = new JSONObject(res); // Convert text to object
+ out(json.toString(4)); // Print it with specified indentation
+
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(res.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ }
+
+ @Test
+ public void test4() throws IOException {
+ // @formatter:off
+ String jsonString = "{\n"
+ + "\"node-name\": \"Sim2230\",\n"
+ + "\"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
+ + "\"layer-protocol-name\": \"MWPS\",\n"
+ + "\"radio-signal-id\": \"Test8\",\n"
+ + "\"time-stamp\": \"2017-03-01T09:15:00.0Z\",\n"
+ + "\"granularity-period\": \"Period15Min\",\n"
+ + "\"scanner-id\": \"PM_RADIO_15M_4\",\n"
+ + "\"performance-data\": {\n"
+ + "\"unavailability\": 0,\n"
+ + "\"tx-level-max\": 3,\n"
+ + "\"tx-level-avg\": 3,\n"
+ + "\"rx-level-min\": -44,\n"
+ + "\"rx-level-max\": -45,\n"
+ + "\"rx-level-avg\": -44,\n"
+ + "\"time2-states\": 0,\n"
+ + "\"time4-states-s\": 0,\n"
+ + "\"time4-states\": 0,\n"
+ + "\"time8-states\": -1,\n"
+ + "\"time16-states-s\": -1,\n"
+ + "\"time16-states\": 0,\n"
+ + "\"time32-states\": -1,\n"
+ + "\"time64-states\": 900,\n"
+ + "\"time128-states\": -1,\n"
+ + "\"time256-states\": -1,\n"
+ + "\"time512-states\": -1,\n"
+ + "\"time512-states-l\": -1,\n"
+ + "\"time1024-states\": -1,\n"
+ + "\"time1024-states-l\": -1,\n"
+ + "\"time8192-states-l\": -1,\n"
+ + "\"time8192-states\": -1,\n"
+ + "\"time2048-states\": -1,\n"
+ + "\"snir-min\": -99,\n"
+ + "\"snir-max\": -99,\n"
+ + "\"snir-avg\": -99,\n"
+ + "\"xpd-min\": -99,\n"
+ + "\"xpd-max\": -99,\n"
+ + "\"xpd-avg\": -99,\n"
+ + "\"rf-temp-min\": -99,\n"
+ + "\"rf-temp-max\": -99,\n"
+ + "\"rf-temp-avg\": -99,\n"
+ + "\"defect-blocks-sum\": -1,\n"
+ + "\"time-period\": 900,\n"
+ + "\"cses\": 0,\n"
+ + "\"time4096-states-l\": -1,\n"
+ + "\"tx-level-min\": 3,\n"
+ + "\"es\": 0,\n"
+ + "\"time2048-states-l\": -1,\n"
+ + "\"time4096-states\": -1,\n"
+ + "\"ses\": 0\n"
+ + "},\n"
+ + "\"suspect-interval-flag\": false\n"
+ + "}\n"
+ + "}";
+ // @formatter:on
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ }
+
+ @Test
+ public void test5() throws IOException {
+ // @formatter:off
+ String jsonString = "{\n"
+ + " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n"
+ + " \"node-name\": \"Sim2230\",\n"
+ + " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
+ + " \"scanner-id\": \"PM_RADIO_15M_14\",\n"
+ + " \"layer-protocol-name\": \"MWPS\",\n"
+ + " \"granularity-period\": \"Period15Min\",\n"
+ + " \"radio-signal-id\": \"Test8\",\n"
+ + " \"suspect-interval-flag\": false,\n"
+ + " \"performance-data\": {\n"
+ + " \"time4096-states-l\": -1,\n"
+ + " \"time16-states-s\": -1,\n"
+ + " \"tx-level-max\": 3,\n"
+ + " \"snir-max\": -99,\n"
+ + " \"time16-states\": 0,\n"
+ + " \"time64-states\": 900,\n"
+ + " \"unavailability\": 0,\n"
+ + " \"time8192-states-l\": -1,\n"
+ + " \"time512-states\": -1,\n"
+ + " \"xpd-min\": -99,\n"
+ + " \"xpd-avg\": -99,\n"
+ + " \"tx-level-avg\": 3,\n"
+ + " \"tx-level-min\": 3,\n"
+ + " \"rf-temp-min\": -99,\n"
+ + " \"rf-temp-avg\": -99,\n"
+ + " \"snir-avg\": -99,\n"
+ + " \"snir-min\": -99,\n"
+ + " \"time-period\": 900,\n"
+ + " \"time2-states\": 0,\n"
+ + " \"time4-states\": 0,\n"
+ + " \"time8-states\": -1,\n"
+ + " \"ses\": 0,\n"
+ + " \"time2048-states-l\": -1,\n"
+ + " \"time2048-states\": -1,\n"
+ + " \"xpd-max\": -99,\n"
+ + " \"rf-temp-max\": -99,\n"
+ + " \"time8192-states\": -1,\n"
+ + " \"time128-states\": -1,\n"
+ + " \"time256-states\": -1,\n"
+ + " \"rx-level-min\": -44,\n"
+ + " \"rx-level-avg\": -44,\n"
+ + " \"time1024-states-l\": -1,\n"
+ + " \"es\": 0,\n"
+ + " \"cses\": 0,\n"
+ + " \"time4-states-s\": 0,\n"
+ + " \"time1024-states\": -1,\n"
+ + " \"time512-states-l\": -1,\n"
+ + " \"time4096-states\": -1,\n"
+ + " \"rx-level-max\": -45,\n"
+ + " \"defect-blocks-sum\": -1,\n"
+ + " \"time32-states\": -1\n"
+ + " }\n"
+ + "}";
+ // @formatter:on
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ }
+
+ @Test
+ public void test8() throws IOException {
+ out(method());
+ String input;
+ input = "id-dd-dd";
+ System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input));
+ input = "idDdGg";
+ System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input));
+ input = "_idDdGg";
+ System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input));
+ input = "--ff--gfg";
+ System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input));
+ input = "";
+ System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input));
+ }
+
+ /* ---------------------------------
+ * Private
+ */
+ private static String method() {
+ String nameofCurrMethod = new Throwable().getStackTrace()[1].getMethodName();
+ return nameofCurrMethod;
+ }
+
+ private static void out(String text) {
+ System.out.println("----------------------");
+ System.out.println(text);
+ }
+
+ private static class DataProviderYangToolsMapper extends YangToolsMapper {
+
+ @SuppressWarnings("unused")
+ private final Logger LOG = LoggerFactory.getLogger(DataProviderYangToolsMapper.class);
+ private static final long serialVersionUID = 1L;
+
+ public DataProviderYangToolsMapper() {
+ super();
+ this.addDeserializer(Credentials.class, LoginPasswordBuilder.class.getName());
+ this.addKeyDeserializer(MeasurementKey.class, new IdentifierDeserializer());
+ }
+
+
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
index cc7fafb76..b73d3eadc 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
@@ -22,8 +22,12 @@
package org.onap.ccsdk.features.sdnr.wt.common.database.data;
import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
/**
* @author Michael Dürre
@@ -34,14 +38,6 @@ import java.util.regex.Pattern;
*/
public class IndicesEntry {
- private static final String regex =
- "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
- private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
- //for ES 2.2.0
- private static final String regexOld =
- "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
- private static final Pattern patternOld = Pattern.compile(regexOld, Pattern.MULTILINE);
-
private final String status;
private final String status2;
private final String name;
@@ -108,33 +104,42 @@ public class IndicesEntry {
}
public IndicesEntry(String line) throws ParseException {
- Matcher matcher = pattern.matcher(line.trim());
- if (!matcher.find() || matcher.groupCount() < 10) {
- matcher = patternOld.matcher(line.trim());
- if (!matcher.find() || matcher.groupCount() < 9) {
+ List<String> allElem = Arrays.stream(line.split(" ")).filter(e -> !e.isEmpty()).collect(Collectors.toList());
+ List<String> possibleStatus = List.of("yellow","red","green");
+ if (allElem.isEmpty() || !possibleStatus.contains(allElem.get(0))) {
+ throw new ParseException("unable to parse status:" + line, 0);
+ }
+ try {
+ if (allElem.size() == 10) {
+ // new format
+ this.status = allElem.get(0);
+ this.status2 = allElem.get(1);
+ this.name = allElem.get(2);
+ this.hash = allElem.get(3);
+ this.shards = Integer.parseInt(allElem.get(4));
+ this.replicas = Integer.parseInt(allElem.get(5));
+ this.c1 = Integer.parseInt(allElem.get(6));
+ this.c2 = Integer.parseInt(allElem.get(7));
+ this.size1 = allElem.get(8);
+ this.size2 = allElem.get(9);
+ } else if (allElem.size() == 9) {
+ // old format without hash
+ //for ES 2.2.0
+ this.status = allElem.get(0);
+ this.status2 = allElem.get(1);
+ this.name = allElem.get(2);
+ this.hash = "";
+ this.shards = Integer.parseInt(allElem.get(3));
+ this.replicas = Integer.parseInt(allElem.get(4));
+ this.c1 = Integer.parseInt(allElem.get(5));
+ this.c2 = Integer.parseInt(allElem.get(6));
+ this.size1 = allElem.get(7);
+ this.size2 = allElem.get(8);
+ } else {
throw new ParseException("unable to parse string:" + line, 0);
}
- this.status = matcher.group(1);
- this.status2 = matcher.group(2);
- this.name = matcher.group(3);
- this.hash = "";
- this.shards = Integer.parseInt(matcher.group(4));
- this.replicas = Integer.parseInt(matcher.group(5));
- this.c1 = Integer.parseInt(matcher.group(6));
- this.c2 = Integer.parseInt(matcher.group(7));
- this.size1 = matcher.group(8);
- this.size2 = matcher.group(9);
- } else {
- this.status = matcher.group(1);
- this.status2 = matcher.group(2);
- this.name = matcher.group(3);
- this.hash = matcher.group(4);
- this.shards = Integer.parseInt(matcher.group(5));
- this.replicas = Integer.parseInt(matcher.group(6));
- this.c1 = Integer.parseInt(matcher.group(7));
- this.c2 = Integer.parseInt(matcher.group(8));
- this.size1 = matcher.group(9);
- this.size2 = matcher.group(10);
+ } catch (NumberFormatException e) {
+ throw new ParseException("unable to parse int:" + line, 0);
}
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
index 2e0701257..3e823061b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -44,7 +45,8 @@ public class PomFile {
// documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// documentBuilderFactory.setFeature(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
// documentBuilderFactory.setFeature(XMLInputFactory.SUPPORT_DTD, false);
-
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
this.xmlDoc = documentBuilder.parse(is);
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
index de878a5d5..d149ae64c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
@@ -90,6 +90,9 @@ public class BaseHTTPClient {
}
public BaseHTTPClient(String base, boolean trustAllCerts, String certFilename, String passphrase, int sslCertType) {
+ if(base==null) {
+ throw new IllegalArgumentException("no baseUrl given");
+ }
if (!base.endsWith("/")) {
base += "/";
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
index 8b651cbe9..b207c3e00 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
@@ -170,7 +170,7 @@ public class JSONAssert {
};
public static void assertEquals(String def, String toTest, boolean strict) throws JSONException {
- assertEquals(null, def, toTest, strict);
+ assertEquals("", def, toTest, strict);
}
public static void assertEquals(String message, String def, String toTest, boolean strict) throws JSONException {
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
index c2471f58e..09ec5204c 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
@@ -68,9 +68,12 @@ public class TestEsData {
public void testIndices() {
IndicesEntryList list = new IndicesEntryList();
IndicesEntry entry = null;
+ IndicesEntry entryOld = null;
try {
entry = new IndicesEntry(
"yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 2 3 1.2kb 2.4kb");
+ entryOld = new IndicesEntry(
+ "yellow open inventoryequipment-v1 5 1 2 3 1.2kb 2.4kb");
list.add(entry);
list.add(new IndicesEntry(
"yellow open networkelement-connection-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
@@ -94,6 +97,17 @@ public class TestEsData {
assertEquals("1.2kb", entry.getSize1());
assertEquals("2.4kb", entry.getSize2());
+ assertNotNull(entryOld);
+ assertEquals("yellow", entryOld.getStatus());
+ assertEquals("open", entryOld.getStatus2());
+ assertEquals("inventoryequipment-v1", entryOld.getName());
+ assertEquals("", entryOld.getHash());
+ assertEquals(5, entryOld.getShards());
+ assertEquals(1, entryOld.getReplicas());
+ assertEquals(2, entryOld.getC1());
+ assertEquals(3, entryOld.getC2());
+ assertEquals("1.2kb", entryOld.getSize1());
+ assertEquals("2.4kb", entryOld.getSize2());
}
@Test
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
index 310444fd6..6eae55f04 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
@@ -184,7 +184,7 @@ public class AboutHttpServlet extends HttpServlet {
* collect dynamic data for about.md
*/
private void collectData(ContentType ctype) {
- LOG.info("collecting dynamic data");
+ LOG.info("collecting dynamic data with content-type {}", ctype);
try {
this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
this.data.put(PLACEHOLDER_DEVICEMANAGER_TABLE, this.getDevicemanagerBundles(ctype));
diff --git a/sdnr/wt/helpserver/installer/pom.xml b/sdnr/wt/helpserver/installer/pom.xml
index 498012d49..03296c830 100755
--- a/sdnr/wt/helpserver/installer/pom.xml
+++ b/sdnr/wt/helpserver/installer/pom.xml
@@ -47,7 +47,7 @@
<dependencies>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>${application.name}-feature</artifactId>
<version>${project.version}</version>
<type>xml</type>
@@ -60,7 +60,7 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>${application.name}-provider</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/sdnr/wt/helpserver/provider/pom.xml b/sdnr/wt/helpserver/provider/pom.xml
index 82205d553..f37c07e65 100644
--- a/sdnr/wt/helpserver/provider/pom.xml
+++ b/sdnr/wt/helpserver/provider/pom.xml
@@ -47,6 +47,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
@@ -68,7 +69,7 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
index 683311e8a..e9470ab09 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
@@ -41,8 +41,6 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
private static final String BASEURI = "/help";
- private static final boolean REDIRECT_LINKS = true;
-
private final Path basePath;
public HelpServlet() {
@@ -113,21 +111,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
return;
}
LOG.debug("delivering file");
- OutputStream out = resp.getOutputStream();
- // if (this.isTextFile(f) && REDIRECT_LINKS) {
- // String line;
- // try (BufferedReader br = new BufferedReader(new FileReader(f))) {
- // line = br.readLine();
- // while (line != null) {
- // out.write((line + "\n").getBytes());
- // line = br.readLine();
- // }
- // out.flush();
- // out.close();
- // br.close();
- // }
- // } else
- {
+ try (OutputStream out = resp.getOutputStream()) {
try (FileInputStream in = new FileInputStream(f)) {
byte[] buffer = new byte[1024];
@@ -139,6 +123,9 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
out.flush();
out.close();
}
+ } catch (IOException e) {
+ LOG.warn("Can not write meta file", e);
+ resp.setStatus(500);
}
} else {
LOG.debug("found not file for request");
@@ -148,15 +135,15 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
private boolean ispdf(File f) {
- return f != null ? this.ispdf(f.getName()) : false;
+ return f != null && this.ispdf(f.getName());
}
private boolean ispdf(String name) {
- return name != null ? name.toLowerCase().endsWith("pdf") : false;
+ return name != null && name.toLowerCase().endsWith("pdf");
}
private boolean isImageFile(File f) {
- return f != null ? this.isImageFile(f.getName()) : false;
+ return f != null && this.isImageFile(f.getName());
}
private boolean isImageFile(String name) {
@@ -169,7 +156,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
private boolean isTextFile(File f) {
- return f != null ? this.isTextFile(f.getName()) : false;
+ return f != null && this.isTextFile(f.getName());
}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
index f12c53a4d..133868fcf 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
@@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapability;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -210,7 +211,10 @@ public class Capabilities {
String namespace = qCapability.getNamespace().toString();
for (String capability : capabilities) {
if (capability.contains(namespace)) {
- return QName.create(capability).getRevision().get().toString();
+ Optional<Revision> revisionOpt = QName.create(capability).getRevision();
+ if (revisionOpt.isPresent()) {
+ return revisionOpt.get().toString();
+ }
}
}
return UNSUPPORTED;
@@ -223,7 +227,7 @@ public class Capabilities {
* @return true if namespace is supported.
*/
static public boolean isNamespaceSupported(String revision) {
- return revision != UNSUPPORTED;
+ return !UNSUPPORTED.equals(revision);
}
@Override
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
index a1a35401e..34073614e 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
@@ -63,7 +63,7 @@ public class NetconfAccessorImpl implements NetconfAccessor {
this.domContext = Objects.requireNonNull(domContext);
this.netconfNodeStateService = Objects.requireNonNull(netconfNodeStateService);
- ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null;
+ ConnectionStatus csts = netconfNode.getConnectionStatus();
if (csts == null) {
throw new IllegalStateException(String.format("connection status for %s is not connected", nodeId));
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/GenericTransactionUtils.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/GenericTransactionUtils.java
index 282048453..1aa3afe5c 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/GenericTransactionUtils.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/GenericTransactionUtils.java
@@ -115,14 +115,10 @@ public final class GenericTransactionUtils implements TransactionUtils {
if (od != null) {
statusIndicator.set("Unwrap checkFuture done");
Optional<T> optionalData = od.get();
- if (optionalData != null) {
- statusIndicator.set("Unwrap optional done");
- data = optionalData.orElse(null);
- statusIndicator.set("Read transaction done");
- noErrorIndication.set(true);
- } else {
- statusIndicator.set("optional Data is null");
- }
+ statusIndicator.set("Unwrap optional done");
+ data = optionalData.orElse(null);
+ statusIndicator.set("Read transaction done");
+ noErrorIndication.set(true);
} else {
statusIndicator.set("od feature is null");
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingAccessorImpl.java
index 6f3a592c8..b36e47621 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingAccessorImpl.java
@@ -111,7 +111,7 @@ public class NetconfBindingAccessorImpl extends NetconfAccessorImpl implements N
@Override
public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(
- @NonNull String streamName) {
+ String streamName) {
final CreateSubscriptionInputBuilder createSubscriptionInputBuilder = new CreateSubscriptionInputBuilder();
if (streamName != null) {
createSubscriptionInputBuilder.setStream(new StreamNameType(streamName));
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java
index b6843fb59..97d48d130 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java
@@ -127,16 +127,21 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco
YangInstanceIdentifier path) {
LOG.debug("Read to node datastore:{} path:{}", dataStoreType, path);
- try (DOMDataTreeReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) {
+ // Don't use try with resource because the implicit close of this construct is not handled
+ // correctly by underlying opendaylight NETCONF service
+ DOMDataTreeReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();
+ try {
FluentFuture<Optional<NormalizedNode<?, ?>>> foData = readOnlyTransaction.read(dataStoreType, path);
- // RAVI - Add a few debug here, like what ? Speak to Micha....
Optional<NormalizedNode<?, ?>> data = foData.get(120, TimeUnit.SECONDS);
- LOG.info("read is done - {} ", foData.isDone());
+ LOG.trace("read is done - {} ", foData.isDone());
return data;
-
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.info("Incomplete read to node transaction {} {}", dataStoreType, path, e);
+ } catch (InterruptedException e) {
+ LOG.debug("Incomplete read to node transaction {} {}", dataStoreType, path, e);
+ Thread.currentThread().interrupt();
+ return Optional.empty();
+ } catch (ExecutionException | TimeoutException e) {
+ LOG.debug("Incomplete read to node transaction {} {}", dataStoreType, path, e);
return Optional.empty();
}
}
@@ -217,9 +222,7 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco
replayIsSupported = Boolean.TRUE.equals(stream.isReplaySupport());
}
- if (filter.isPresent()) {
- inputBuilder.setFilter(filter.get());
- }
+ filter.ifPresent(inputBuilder::setFilter);
if (startTime.isPresent()) {
if (replayIsSupported) {
inputBuilder.setStartTime(getDateAndTime(startTime.get()));
@@ -253,8 +256,12 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco
if (!res.get().getErrors().isEmpty()) {
return res;
}
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("Exception during rpc call", e);
+ } catch (InterruptedException e) {
+ LOG.warn("InterruptedException during rpc call", e);
+ Thread.currentThread().interrupt();
+ return res;
+ } catch (ExecutionException e) {
+ LOG.warn("ExecutionException during rpc call", e);
return res;
}
}
@@ -265,7 +272,7 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco
@Override
public @NonNull Map<StreamKey, Stream> getNotificationStreamsAsMap() {
Optional<Streams> oStreams = readData(LogicalDatastoreType.OPERATIONAL, STREAMS_PATH, Streams.class);
- return oStreams.isPresent() ? oStreams.get().nonnullStream() : Collections.emptyMap();
+ return oStreams.map(Streams::nonnullStream).orElse(Collections.emptyMap());
}
@Override
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
index b27a7bd5c..ccce583ad 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
@@ -32,7 +32,7 @@ public class ClusterNodeInfo {
}
public ClusterNodeInfo(String s) throws Exception {
- final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
+ final String regex = "([a-z.]{0,10}):\\/\\/([a-zA-Z0-9-]{0,1024})@([a-zA-Z0-9.-]{0,1024}):([0-9]{0,10})";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
if (!matcher.find()) {
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
index 8f4446bb4..f11ce4011 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
@@ -25,7 +25,10 @@ public class ClusterRoleInfo {
private final int Index;
public ClusterRoleInfo(String s) throws Exception {
- final String regex = "([a-zA-Z]*)-([0-9]*)";
+ // role with minimum 1 character
+ // index with minimum 1 character or Integer.parseInt raise an exception
+ // index with maximum 10 because it's an integer
+ final String regex = "([a-zA-Z]{1,1024})-([0-9]{1,10})";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
if (!matcher.find()) {
diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
index 7cc6d7272..95715be39 100644
--- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
+++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
@@ -18,6 +18,7 @@
package org.onap.ccsdk.features.sdnr.wt.websocketmanager;
import com.fasterxml.jackson.core.JsonProcessingException;
+import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -59,7 +60,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
private static final String REGEX_SCOPEREGISTRATION = "\"data\"[\\s]*:[\\s]*\"scopes\"";
private static final Pattern PATTERN_SCOPEREGISTRATION =
Pattern.compile(REGEX_SCOPEREGISTRATION, Pattern.MULTILINE);
- private static final Random RND = new Random();
+ private static final SecureRandom RND = new SecureRandom();
private static final long SEND_MESSAGE_TIMEOUT_MILLIS = 1500;
private static final int QUEUE_SIZE = 100;
diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/utils/AkkaConfig.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/utils/AkkaConfig.java
index 794515bb2..7bbbfea6d 100644
--- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/utils/AkkaConfig.java
+++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/utils/AkkaConfig.java
@@ -49,7 +49,7 @@ public class AkkaConfig {
}
public ClusterNodeInfo(String s) throws Exception {
- final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
+ final String regex = "([a-z.]{0,10}):\\/\\/([a-zA-Z0-9-]{0,1024})@([a-zA-Z0-9.-]{0,1024}):([0-9]{0,10})";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
if (!matcher.find()) {
@@ -71,7 +71,10 @@ public class AkkaConfig {
private final int Index;
public ClusterRoleInfo(String s) throws Exception {
- final String regex = "([a-z]*)-([0-9]*)";
+ // role with minimum 1 character
+ // index with minimum 1 character or Integer.parseInt raise an exception
+ // index with maximum 10 because it's an integer
+ final String regex = "([a-z]{1,1024})-([0-9]{1,10})";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
if (!matcher.find()) {
@@ -177,7 +180,7 @@ public class AkkaConfig {
}
public boolean isCluster() {
- return this.cluserConfig != null ? this.cluserConfig.isCluster() : false;
+ return this.cluserConfig != null && this.cluserConfig.isCluster();
}
public static AkkaConfig load() throws Exception {