diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-08-31 08:46:55 +0200 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2022-08-31 21:04:07 +0000 |
commit | 34f89faa64f815d5cf33d0905046eaf392017b39 (patch) | |
tree | 7bd6295609feb87b3fa187602985b58e34965fe4 | |
parent | 63d92319b01b54d72bde494f923f80eb6c242cfe (diff) |
add fixes for wt sulfur
fix devmgrs and db access
Issue-ID: CCSDK-3749
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I41018d2daa55b200a9ba89e784f8adf4200d32c3
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
33 files changed, 458 insertions, 845 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java index f507eec13..c6bd16484 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback<T> { private static final Logger LOG = LoggerFactory.getLogger(KeyBasedThreadpool.class); - private final Queue<Entry<T, S>> queue; + private final ConcurrentLinkedQueue<Entry<T, S>> queue; private final List<T> runningKeys; private final int keyPoolSize; private final GenericRunnableFactory<T, S> factory; @@ -65,7 +65,7 @@ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback< LOG.info("starting key-based threadpool with keysize={} and size={}", keyPoolSize, poolSize); } - public void execute(T key, S arg) { + public synchronized void execute(T key, S arg) { if (this.isKeyPoolSizeReached(key)) { LOG.debug("pool size for key {} reached. add to queue", key); queue.add(new SimpleEntry<>(key, arg)); @@ -97,6 +97,9 @@ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback< private boolean isKeyPoolSizeReached(T key) { LOG.trace("running keys size={}", this.runningKeys.size()); + if (this.keyPoolSize == 1) { + return this.runningKeys.contains(key); + } return this.runningKeys.stream().filter(e -> e == key).count() >= this.keyPoolSize; } @@ -107,7 +110,7 @@ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback< this.executeNext(); } - public void join() { + public synchronized void join() { LOG.debug("wait for all executors to finish"); while (this.runningKeys.size() > 0 && this.queue.size() > 0) { try { diff --git a/sdnr/wt/data-provider/dblib/pom.xml b/sdnr/wt/data-provider/dblib/pom.xml index 5c7294c50..9ea692c27 100644 --- a/sdnr/wt/data-provider/dblib/pom.xml +++ b/sdnr/wt/data-provider/dblib/pom.xml @@ -102,6 +102,10 @@ <scope>provided</scope> </dependency> <!-- MariaDB start --> + <dependency> + <groupId>com.zaxxer</groupId> + <artifactId>HikariCP</artifactId> + </dependency> <dependency> <!-- Not part of ODL karaf standard delivery --> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java index 1ed0b5f17..b93145cbb 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java @@ -30,6 +30,9 @@ import java.sql.Statement; import java.text.ParseException; import java.util.regex.Matcher; import java.util.regex.Pattern; + +import com.zaxxer.hikari.HikariDataSource; +import org.mariadb.jdbc.MariaDbPoolDataSource; import org.onap.ccsdk.features.sdnr.wt.common.database.Portstatus; import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry; import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntryList; @@ -42,6 +45,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.sql.ConnectionPoolDataSource; + public class SqlDBClient { private static final Logger LOG = LoggerFactory.getLogger(SqlDBClient.class); @@ -58,11 +63,13 @@ public class SqlDBClient { private static final String SELECT_VERSION_QUERY = "SELECT @@version as version"; private static final String DBNAME_DEFAULT = "sdnrdb"; + private static final int DEFAULT_POOLSIZE = 50; private final String dbConnectionString; private final String dbName; private final String dbHost; private final int dbPort; + private final HikariDataSource connectionPool; /** * * @param dbUrl e.g. jdbc:mysql://sdnrdb:3306/sdnrdb @@ -78,6 +85,10 @@ public class SqlDBClient { this.dbHost = matcher.group(2); this.dbPort = Integer.parseInt(matcher.group(3)); this.dbName = matcher.group(4); + this.connectionPool = new HikariDataSource(); + this.connectionPool.setJdbcUrl(this.dbConnectionString); + this.connectionPool.setUsername(username); + this.connectionPool.setPassword(password); } public AliasesEntryList readViews() { diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java index 56e965c9f..56a986e55 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java @@ -185,8 +185,9 @@ public class SqlDBReaderWriter<T extends DataObject> { } String insertedId = null; PreparedStatement stmt = null; + Connection connection = null; try { - Connection connection = this.dbService.getConnection(); + connection = this.dbService.getConnection(); stmt = connection.prepareStatement(query.toSql()); stmt.execute(); @@ -208,6 +209,13 @@ public class SqlDBReaderWriter<T extends DataObject> { LOG.warn("problem closing sql statement: ", e); } } + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + LOG.warn("problem closing sql connection: ", e); + } + } } return insertedId; @@ -221,8 +229,9 @@ public class SqlDBReaderWriter<T extends DataObject> { LOG.trace("query={}", query.toSql()); } PreparedStatement stmt = null; + Connection connection = null; try { - Connection connection = this.dbService.getConnection(); + connection = this.dbService.getConnection(); stmt = connection.prepareStatement(query.toSql()); stmt.execute(); @@ -241,6 +250,13 @@ public class SqlDBReaderWriter<T extends DataObject> { LOG.warn("problem closing sql statement: ", e); } } + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + LOG.warn("problem closing sql connection: ", e); + } + } } return insertedId; } @@ -262,8 +278,9 @@ public class SqlDBReaderWriter<T extends DataObject> { } int affectedRows = 0; PreparedStatement stmt = null; + Connection connection = null; try { - Connection connection = this.dbService.getConnection(); + connection = this.dbService.getConnection(); stmt = connection.prepareStatement(query.toSql()); stmt.execute(); affectedRows = stmt.getUpdateCount(); @@ -278,6 +295,13 @@ public class SqlDBReaderWriter<T extends DataObject> { LOG.warn("problem closing sql statement: ", e); } } + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + LOG.warn("problem closing sql connection: ", e); + } + } } return affectedRows; } diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java index 75d8c9ad2..d98d36d7c 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java @@ -61,6 +61,9 @@ public class SqlDBStatusReader { long minorCount = 0; long warningCount = 0; ResultSet data; + if(LOG.isTraceEnabled()){ + LOG.trace("query={}", selectQuery); + } try { data = this.dbClient.read(selectQuery); String severity; @@ -92,6 +95,9 @@ public class SqlDBStatusReader { long connectedCount = 0, connectingCount = 0, disconnectedCount = 0, mountedCount = 0, unableToConnectCount = 0, undefinedCount = 0, unmountedCount = 0; long cnt; + if(LOG.isTraceEnabled()){ + LOG.trace("query={}", selectQuery); + } try { data = this.dbClient.read(selectQuery); while (data.next()) { diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java index 65e0c54e4..bc888df50 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java @@ -30,7 +30,7 @@ public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFil @Override public String getFilterExpression() { - return String.format("`%s` RLIKE '%s'", this.getKey(), this.getValue()); + return String.format("`%s` RLIKE '^%s$'", this.getKey(), this.getValue()); } @Override diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java index 34c4d6fe8..33703042e 100644 --- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java +++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java @@ -125,6 +125,7 @@ public class TestMariaDataProvider { private static final String NODEID1 = "node1"; private static final String NODEID2 = "node2"; + private static final String NODEID22 = "node22"; private static final String NODEID3 = "node3"; private static final String NODEID4 = "node4"; private static final String NODEID5 = "node5"; @@ -140,6 +141,7 @@ public class TestMariaDataProvider { private static final String USERNAME = "admin"; private static MariaDBTestBase testBase; private static SqlDBDataProvider dbProvider; + private static SqlDBDataProvider dbProviderOverall; private static SqlDBClient dbClient; private static String CONTROLLERID; @@ -153,6 +155,7 @@ public class TestMariaDataProvider { MariaDBTestBase.testCreateTableStructure(dbClient); dbProvider.setControllerId(); CONTROLLERID = dbProvider.getControllerId(); + dbProviderOverall = testBase.getOverallDbProvider(); } @@ -533,19 +536,23 @@ public class TestMariaDataProvider { NetworkElementConnectionEntity ne2 = new NetworkElementConnectionBuilder().setNodeId(NODEID2) .setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user") .setPassword("passwd").setStatus(ConnectionLogStatus.Connecting).build(); + NetworkElementConnectionEntity ne22 = new NetworkElementConnectionBuilder().setNodeId(NODEID22) + .setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user") + .setPassword("passwd").setStatus(ConnectionLogStatus.Connected).build(); NetworkElementConnectionEntity ne3 = new NetworkElementConnectionBuilder().setNodeId(NODEID3) .setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user") .setPassword("passwd").setStatus(ConnectionLogStatus.Connecting).build(); try { dbProvider.createNetworkElementConnection(ne1); dbProvider.createNetworkElementConnection(ne2); + dbProvider.createNetworkElementConnection(ne22); dbProvider.updateNetworkConnection22(ne3, NODEID3); } catch (IOException e) { e.printStackTrace(); fail("problem creating neconnection"); } data = dbProvider.readNetworkElementConnectionList(createInput(1, 20)); - assertEquals(3, data.getData().size()); + assertEquals(4, data.getData().size()); NetworkElementConnectionEntity update1 = new NetworkElementConnectionBuilder() .setStatus(ConnectionLogStatus.Connected).setDeviceType(NetworkElementDeviceType.ORAN).build(); dbProvider.updateNetworkConnectionDeviceType(update1, NODEID1); @@ -574,15 +581,41 @@ public class TestMariaDataProvider { e.printStackTrace(); fail("failed to read status"); } - assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnected().intValue()); + assertEquals(2, status.getData().get(0).getNetworkElementConnections().getConnected().intValue()); assertEquals(2, status.getData().get(0).getNetworkElementConnections().getConnecting().intValue()); assertEquals(0, status.getData().get(0).getNetworkElementConnections().getDisconnected().intValue()); assertEquals(0, status.getData().get(0).getNetworkElementConnections().getMounted().intValue()); - assertEquals(3, status.getData().get(0).getNetworkElementConnections().getTotal().intValue()); + assertEquals(4, status.getData().get(0).getNetworkElementConnections().getTotal().intValue()); assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnableToConnect().intValue()); assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUndefined().intValue()); assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnmounted().intValue()); + ReadStatusOutputBuilder status2=null; + try { + EntityInput input=createInput("node-id","node2*", 1, 20); + status = dbProvider.readStatus(input); + status2 = dbProviderOverall.readStatus(input); + } catch (IOException e) { + e.printStackTrace(); + fail("failed to read status"); + } + assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnected().intValue()); + assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnecting().intValue()); + assertEquals(0, status.getData().get(0).getNetworkElementConnections().getDisconnected().intValue()); + assertEquals(0, status.getData().get(0).getNetworkElementConnections().getMounted().intValue()); + assertEquals(2, status.getData().get(0).getNetworkElementConnections().getTotal().intValue()); + assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnableToConnect().intValue()); + assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUndefined().intValue()); + assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnmounted().intValue()); + + assertEquals(1, status2.getData().get(0).getNetworkElementConnections().getConnected().intValue()); + assertEquals(1, status2.getData().get(0).getNetworkElementConnections().getConnecting().intValue()); + assertEquals(0, status2.getData().get(0).getNetworkElementConnections().getDisconnected().intValue()); + assertEquals(0, status2.getData().get(0).getNetworkElementConnections().getMounted().intValue()); + assertEquals(2, status2.getData().get(0).getNetworkElementConnections().getTotal().intValue()); + assertEquals(0, status2.getData().get(0).getNetworkElementConnections().getUnableToConnect().intValue()); + assertEquals(0, status2.getData().get(0).getNetworkElementConnections().getUndefined().intValue()); + assertEquals(0, status2.getData().get(0).getNetworkElementConnections().getUnmounted().intValue()); DeleteNetworkElementConnectionInput delete1 = new DeleteNetworkElementConnectionInputBuilder().setId(NODEID1).build(); @@ -595,7 +628,7 @@ public class TestMariaDataProvider { data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20)); assertEquals(0, data.getData().size()); data = dbProvider.readNetworkElementConnectionList(createInput(1, 20)); - assertEquals(2, data.getData().size()); + assertEquals(3, data.getData().size()); } diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java index 7dd2464f9..30c68a01d 100644 --- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java +++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java @@ -225,6 +225,20 @@ public class TestQuerySyntax { } @Test + public void testSelectForFilterValues6() { + EntityInput input = new ReadGuiCutThroughEntryInputBuilder() + .setFilter(YangToolsMapperHelper.toMap(Arrays.asList( + new FilterBuilder().setProperty("id").setFiltervalue("*ran*").build()))) + .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build()) + .build(); + SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID); + System.out.println(query.toSql()); + assertTrue(query.toSql().contains("RLIKE")); + assertTrue(query.toSql().contains(".*")); + + } + + @Test public void testCount() { CountQuery query = new CountQuery(Entity.Eventlog, TestMariaDataProvider.createInput(1, 20)); String sQuery = query.toSql(); diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java index aebd3328e..3123d25a6 100644 --- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java +++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java @@ -57,6 +57,7 @@ import ch.vorburger.mariadb4j.DBConfigurationBuilder; public class MariaDBTestBase { private final SqlDBDataProvider dbProvider; + private final SqlDBDataProvider dbProviderOverall; private final DB db; private SqlDBConfig config; private static final Map<String, String> envDefaultValues = initEnvDefaultValues(); @@ -96,6 +97,11 @@ public class MariaDBTestBase { this.config.setControllerId("test123"); this.db = null; this.dbProvider = new SqlDBDataProvider(config, false); + + SqlDBConfig config2 = new SqlDBConfig(new ConfigurationFileRepresentation("test2.properties")); + config2.setDbSuffix(""); + config2.setControllerId(null); + this.dbProviderOverall = new SqlDBDataProvider(config2, false); } public MariaDBTestBase(int port) throws ManagedProcessException { @@ -111,6 +117,10 @@ public class MariaDBTestBase { this.db = startDatabase(port); //create db with name sdnrdb this.dbProvider = new SqlDBDataProvider(config, false); + SqlDBConfig config2 = new SqlDBConfig(new ConfigurationFileRepresentation("test2.properties")); + config2.setDbSuffix(""); + config2.setControllerId(null); + this.dbProviderOverall = new SqlDBDataProvider(config2, false); } public void close() throws ManagedProcessException { @@ -126,6 +136,9 @@ public class MariaDBTestBase { public SqlDBDataProvider getDbProvider() { return dbProvider; } + public SqlDBDataProvider getOverallDbProvider() { + return dbProviderOverall; + } public DB getDb() { return db; diff --git a/sdnr/wt/data-provider/installer/pom.xml b/sdnr/wt/data-provider/installer/pom.xml index 123493c2e..a6ec2f0c2 100755 --- a/sdnr/wt/data-provider/installer/pom.xml +++ b/sdnr/wt/data-provider/installer/pom.xml @@ -72,6 +72,10 @@ <groupId>com.highstreet-technologies.opendaylight</groupId> <artifactId>odl-ready</artifactId> </dependency> + <dependency> + <groupId>com.zaxxer</groupId> + <artifactId>HikariCP</artifactId> + </dependency> </dependencies> <build> diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java index 6ddc092d5..868bf7ec6 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java @@ -32,6 +32,9 @@ public class ODLVersionLUT { if (onapCCSDKVersion == null) { return def; } + if (onapCCSDKVersion.startsWith("2.5.")) { + return "ONAP London"; + } if (onapCCSDKVersion.startsWith("2.4.")) { return "ONAP Kohn"; } @@ -69,6 +72,7 @@ public class ODLVersionLUT { } if(odlMdsalVersionLUT==null) { odlMdsalVersionLUT = new HashMap<>(); + odlMdsalVersionLUT.put("9.0.4","sulfur-SR1 (0.16.1)"); odlMdsalVersionLUT.put("9.0.2","sulfur-SR0 (0.16.0)"); odlMdsalVersionLUT.put("8.0.11","phosphorus-SR2 (0.15.2)"); odlMdsalVersionLUT.put("8.0.7","phosphorus-SR1 (0.15.1)"); diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java index 4bad25ce7..e4c2b4547 100644 --- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java +++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java @@ -50,7 +50,7 @@ public class TestDcae { private static final String ENABLEDDCAE_TESTCONFIG_FILENAME = "test2.properties"; private static final File ENABLEDDCAE_TESTCONFIG_FILE = new File(ENABLEDDCAE_TESTCONFIG_FILENAME); - private static final int DCAE_SERVER_PORT = 45451; + private static final int DCAE_SERVER_PORT = 45452; private static final String URI = "/abc"; private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=http://localhost:" + DCAE_SERVER_PORT + URI + "\n" + "dcaeHeartbeatPeriodSeconds=120\n" diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java index e3113db3c..b2c669819 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java @@ -34,6 +34,7 @@ import javax.xml.stream.XMLStreamReader; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util.TestYangParserUtil; import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; @@ -79,7 +80,7 @@ public class TestORanDOMToInternalDataModel { @BeforeClass public static void setup() throws IOException { - schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); + schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); hwContainerSchema = Inference.ofDataTreePath(schemaContext, HW_CONTAINER); systemSchema = Inference.ofDataTreePath(schemaContext, IETF_CONTAINER); } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java deleted file mode 100644 index 80c18aef2..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import com.google.common.annotations.Beta; -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.stream.Collectors; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.parser.api.YangParser; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.api.YangParserException; -import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; -import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Utility class which provides convenience methods for producing effective schema context based on the supplied - * yang/yin sources or paths to these sources. - */ -@Beta -public final class YangParserTestUtils { - - private static final FileFilter YANG_FILE_FILTER = file -> { - // Locale keeps SpotBugs happy. It should not matter that much anyway. - final String name = file.getName().toLowerCase(Locale.ENGLISH); - return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); - }; - - private static final @NonNull YangParserFactory PARSER_FACTORY; - - static { - final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); - if (!it.hasNext()) { - throw new IllegalStateException("No YangParserFactory found"); - } - PARSER_FACTORY = it.next(); - } - - private YangParserTestUtils() { - // Hidden on purpose - } - - /** - * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param resource relative path to the YANG file to be parsed - * - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource) { - return parseYangResource(resource, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG source. All YANG features are supported. - * - * @param resource relative path to the YANG file to be parsed - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config) { - return parseYangResource(resource, config, null); - } - - /** - * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to - * default mode. - * - * @param resource relative path to the YANG file to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * model are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final Set<QName> supportedFeatures) { - return parseYangResource(resource, YangParserConfiguration.DEFAULT, supportedFeatures); - } - - /** - * Creates a new effective schema context containing the specified YANG source. - * - * @param resource relative path to the YANG file to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * model are resolved - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config, - final Set<QName> supportedFeatures) { - final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource); - return parseYangSources(config, supportedFeatures, source); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final File... files) { - return parseYangFiles(Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param files collection of YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Collection<File> files) { - return parseYangFiles(YangParserConfiguration.DEFAULT, files); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) { - return parseYangFiles(supportedFeatures, Arrays.asList(files)); - } - - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final Collection<File> files) { - return parseYangFiles(supportedFeatures, YangParserConfiguration.DEFAULT, files); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { - return parseYangFiles(config, Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param parserMode mode of statement parser - * @param files collection of YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, - final Collection<File> files) { - return parseYangFiles(null, config, files); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final YangParserConfiguration config, final File... files) { - return parseYangFiles(supportedFeatures, config, Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final YangParserConfiguration config, final Collection<File> files) { - return parseSources(config, supportedFeatures, - files.stream().map(e->e.toPath()).map(YangTextSchemaSource::forPath).collect(Collectors.toList())); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { - return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final YangParserConfiguration config) { - return parseYangResourceDirectory(resourcePath, null, config); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final Set<QName> supportedFeatures) { - return parseYangResourceDirectory(resourcePath, supportedFeatures, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @return effective schema context - */ - @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final Set<QName> supportedFeatures, final YangParserConfiguration config) { - final URI directoryPath; - try { - directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); - } - return parseYangFiles(supportedFeatures, config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param clazz Resource lookup base - * @param resources Resource names to be looked up - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final Class<?> clazz, final String... resources) { - return parseYangResources(clazz, Arrays.asList(resources)); - } - - public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) { - final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size()); - for (final String r : resources) { - sources.add(YangTextSchemaSource.forResource(clazz, r)); - } - return parseSources(YangParserConfiguration.DEFAULT, null, sources); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param yangDirs relative paths to the directories containing YANG files to be parsed - * @param yangFiles relative paths to the YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles, - final Set<QName> supportedFeatures) { - return parseYangResources(yangDirs, yangFiles, supportedFeatures, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed - * @param yangResources relative paths to the YANG files to be parsed - * @param statementParserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, - final List<String> yangResources, final YangParserConfiguration config) { - return parseYangResources(yangResourceDirs, yangResources, null, config); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed - * @param yangResources relative paths to the YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param statementParserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, - final List<String> yangResources, final Set<QName> supportedFeatures, - final YangParserConfiguration config) { - final List<File> allYangFiles = new ArrayList<>(); - for (final String yangDir : yangResourceDirs) { - allYangFiles.addAll(getYangFiles(yangDir)); - } - - for (final String yangFile : yangResources) { - try { - allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI())); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Invalid resource " + yangFile, e); - } - } - - return parseYangFiles(supportedFeatures, config, allYangFiles); - } - - public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { - return parseSources(config, supportedFeatures, Arrays.asList(sources)); - } - - public static EffectiveModelContext parseSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { - final YangParser parser = PARSER_FACTORY.createParser(config); - if (supportedFeatures != null) { - parser.setSupportedFeatures(supportedFeatures); - } - - try { - parser.addSources(sources); - } catch (YangSyntaxErrorException e) { - throw new IllegalArgumentException("Malformed source", e); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to read a source", e); - } - - try { - return parser.buildEffectiveModel(); - } catch (YangParserException e) { - throw new IllegalStateException("Failed to assemble SchemaContext", e); - } - } - - @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") - private static Collection<File> getYangFiles(final String resourcePath) { - final URI directoryPath; - try { - directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e); - } - return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER)); - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java new file mode 100644 index 000000000..611d18141 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java @@ -0,0 +1,119 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 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.devicemanager.oran.impl.dom.util; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.YangConstants; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import org.opendaylight.yangtools.yang.parser.api.YangParser; +import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.api.YangParserException; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; +import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; + +public final class TestYangParserUtil { + + private static final FileFilter YANG_FILE_FILTER = file -> { + final String name = file.getName(); + return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); + }; + + private static final @NonNull YangParserFactory PARSER_FACTORY; + + static { + final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); + if (!it.hasNext()) { + throw new IllegalStateException("No YangParserFactory found"); + } + PARSER_FACTORY = it.next(); + } + + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { + return parseYangFiles(config, Arrays.asList(files)); + } + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, + final Collection<File> files) { + return parseYangFiles(null, config, files.stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final Collection<Path> files) { + return parseSources(config, supportedFeatures, + files.stream().map(YangTextSchemaSource::forPath).collect(Collectors.toList())); + } + + + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { + return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); + } + + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final YangParserConfiguration config) { + final URI directoryPath; + try { + directoryPath = TestYangParserUtil.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); + } + return parseYangFiles(config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); + } + + + public static EffectiveModelContext parseSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { + final YangParser parser = PARSER_FACTORY.createParser(config); + if (supportedFeatures != null) { + parser.setSupportedFeatures(supportedFeatures); + } + + try { + parser.addSources(sources); + } catch (YangSyntaxErrorException e) { + throw new IllegalArgumentException("Malformed source", e); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to read a source", e); + } + + try { + return parser.buildEffectiveModel(); + } catch (YangParserException e) { + throw new IllegalStateException("Failed to assemble SchemaContext", e); + } + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml index 60f998630..433c51cba 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml @@ -8,10 +8,10 @@ <admin-state>unlocked</admin-state> <oper-state>enabled</oper-state> </state> - <serial-num>10283</serial-num> - <software-rev>3.8.1 (2020-10-30 11:47:59)</software-rev> - <mfg-name>ISCO</mfg-name> - <model-name>ProteusCPRI Compact</model-name> + <serial-num>1234</serial-num> + <software-rev>1.2.3 (2022-10-30 09:34:59)</software-rev> + <mfg-name>Highstreet</mfg-name> + <model-name>HS O-RU</model-name> <description>HighStreet-ONAP40</description> <contains-child>chassis-temperature-exhaust</contains-child> <contains-child>chassis-temperature-inlet</contains-child> @@ -36,7 +36,7 @@ <sensor-data> <value>30</value> <value-type>celsius</value-type> - <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -53,7 +53,7 @@ <sensor-data> <value>29</value> <value-type>celsius</value-type> - <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -82,7 +82,7 @@ <sensor-data> <value>4100</value> <value-type>rpm</value-type> - <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -212,10 +212,10 @@ </state> <parent>chassis</parent> <parent-rel-pos>7</parent-rel-pos> - <serial-num>7220530</serial-num> - <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev> + <serial-num>1020304050</serial-num> + <firmware-rev>123456 (0ABC56D1)</firmware-rev> <software-rev>0</software-rev> - <model-name>385A-SFP-2P-40-FHL-JC3</model-name> + <model-name>00AA-SFP-99-BB-CCC</model-name> <contains-child>slot0-temperature</contains-child> <contains-child>slot0-logical0</contains-child> <contains-child>slot0-logical1</contains-child> @@ -263,9 +263,9 @@ <parent>slot0-logical0</parent> <parent-rel-pos>0</parent-rel-pos> <o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-bbu</o-ran-name> - <serial-num>AYR3GA2</serial-num> - <mfg-name>FINISAR CORP.</mfg-name> - <model-name>FTLX1475D3BTL-E7</model-name> + <serial-num>ABC12DF3</serial-num> + <mfg-name>Highstreet</mfg-name> + <model-name>HS-99-56</model-name> <contains-child>slot0-logical0-bbu-temperature</contains-child> </component> <component> @@ -296,9 +296,9 @@ <parent>slot0-logical0</parent> <parent-rel-pos>1</parent-rel-pos> <o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-rrh</o-ran-name> - <serial-num>AYR3GA9</serial-num> - <mfg-name>FINISAR CORP.</mfg-name> - <model-name>FTLX1475D3BTL-E7</model-name> + <serial-num>ABC78YZ</serial-num> + <mfg-name>Highstreet</mfg-name> + <model-name>2W3E4R5T6Y</model-name> <contains-child>slot0-logical0-rrh-temperature</contains-child> </component> <component> @@ -352,10 +352,10 @@ </state> <parent>chassis</parent> <parent-rel-pos>9</parent-rel-pos> - <serial-num>7220718</serial-num> - <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev> + <serial-num>23561289</serial-num> + <firmware-rev>12.00.42-S (0ABC45HJ)</firmware-rev> <software-rev>0</software-rev> - <model-name>385A-SFP-2P-40-FHL-JC3</model-name> + <model-name>ABC-123-DEF-XYZ</model-name> <mfg-date>2021-10-12T14:41:55.234Z</mfg-date> <contains-child>slot2-temperature</contains-child> <contains-child>slot2-logical0</contains-child> diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java index f72158e06..c510a1ae6 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java @@ -54,6 +54,7 @@ public class Onf14DomAirInterfaceNotificationListener implements DOMNotification @Override public void onNotification(@NonNull DOMNotification domNotification) { + log.debug("Got event of type :: {}", domNotification.getType()); if (domNotification.getType() .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION))) { onObjectCreateNotification(domNotification); @@ -140,6 +141,7 @@ public class Onf14DomAirInterfaceNotificationListener implements DOMNotification Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION, new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + log.debug("onObjectProblemNotification log entry written"); } private void onObjectDeletionNotification(@NonNull DOMNotification domNotification) { diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java index 218ece4e7..5aa069efb 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java @@ -98,7 +98,7 @@ public class Onf14DomEthernetContainerNotificationListener implements DOMNotific new DateAndTime(cn.childByArg(new NodeIdentifier( Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)) .body().toString())); - + log.debug("onProblemNotification log entry written"); } public void onAttributeValueChangedNotification(DOMNotification notification) { diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java index 5d148d3a3..401fbbe8d 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java @@ -92,7 +92,7 @@ public class Onf14DomWireInterfaceNotificationListener implements DOMNotificatio Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION, new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); - + log.debug("onProblemNotification log entry written"); } public void onAttributeValueChangedNotification(DOMNotification notification) { diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java index 6dc9b50b5..ad79a5c43 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java @@ -82,7 +82,7 @@ public class Onf14DomTestUtils { public static NormalizedNode getNormalizedNodeFromJson() throws IOException, URISyntaxException { - schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); + schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); lhotkaCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext); streamAsString = loadTextFile(new File(Onf14DomTestUtils.class.getResource("/ControlConstruct-data-test.json").toURI())); @@ -105,7 +105,7 @@ public class Onf14DomTestUtils { public static NormalizedNode getNormalizedNodeFromXML() throws XMLStreamException, URISyntaxException, IOException, SAXException { - schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); + schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); hwContainerSchema = Inference.ofDataTreePath(schemaContext, CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER); final InputStream resourceAsStream = Onf14DomTestUtils.class.getResourceAsStream("/ControlConstruct-data-test.xml"); diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java new file mode 100644 index 000000000..004f08da3 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java @@ -0,0 +1,119 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 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.devicemanager.onf14.util; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.YangConstants; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import org.opendaylight.yangtools.yang.parser.api.YangParser; +import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.api.YangParserException; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; +import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; + +public final class TestYangParserUtil { + + private static final FileFilter YANG_FILE_FILTER = file -> { + final String name = file.getName(); + return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); + }; + + private static final @NonNull YangParserFactory PARSER_FACTORY; + + static { + final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); + if (!it.hasNext()) { + throw new IllegalStateException("No YangParserFactory found"); + } + PARSER_FACTORY = it.next(); + } + + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { + return parseYangFiles(config, Arrays.asList(files)); + } + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, + final Collection<File> files) { + return parseYangFiles(null, config, files.stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final Collection<Path> files) { + return parseSources(config, supportedFeatures, + files.stream().map(YangTextSchemaSource::forPath).collect(Collectors.toList())); + } + + + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { + return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); + } + + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final YangParserConfiguration config) { + final URI directoryPath; + try { + directoryPath = TestYangParserUtil.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); + } + return parseYangFiles(config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); + } + + + public static EffectiveModelContext parseSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { + final YangParser parser = PARSER_FACTORY.createParser(config); + if (supportedFeatures != null) { + parser.setSupportedFeatures(supportedFeatures); + } + + try { + parser.addSources(sources); + } catch (YangSyntaxErrorException e) { + throw new IllegalArgumentException("Malformed source", e); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to read a source", e); + } + + try { + return parser.buildEffectiveModel(); + } catch (YangParserException e) { + throw new IllegalStateException("Failed to assemble SchemaContext", e); + } + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java deleted file mode 100644 index ee20dccae..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.util; - -import com.google.common.annotations.Beta; -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.stream.Collectors; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.parser.api.YangParser; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.api.YangParserException; -import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; -import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * Utility class which provides convenience methods for producing effective schema context based on the supplied - * yang/yin sources or paths to these sources. - */ -@Beta -public final class YangParserTestUtils { - - private static final FileFilter YANG_FILE_FILTER = file -> { - // Locale keeps SpotBugs happy. It should not matter that much anyway. - final String name = file.getName().toLowerCase(Locale.ENGLISH); - return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); - }; - - private static final @NonNull YangParserFactory PARSER_FACTORY; - - static { - final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); - if (!it.hasNext()) { - throw new IllegalStateException("No YangParserFactory found"); - } - PARSER_FACTORY = it.next(); - } - - private YangParserTestUtils() { - // Hidden on purpose - } - - /** - * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param resource relative path to the YANG file to be parsed - * - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource) { - return parseYangResource(resource, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG source. All YANG features are supported. - * - * @param resource relative path to the YANG file to be parsed - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config) { - return parseYangResource(resource, config, null); - } - - /** - * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to - * default mode. - * - * @param resource relative path to the YANG file to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * model are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final Set<QName> supportedFeatures) { - return parseYangResource(resource, YangParserConfiguration.DEFAULT, supportedFeatures); - } - - /** - * Creates a new effective schema context containing the specified YANG source. - * - * @param resource relative path to the YANG file to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * model are resolved - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config, - final Set<QName> supportedFeatures) { - final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource); - return parseYangSources(config, supportedFeatures, source); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final File... files) { - return parseYangFiles(Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param files collection of YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Collection<File> files) { - return parseYangFiles(YangParserConfiguration.DEFAULT, files); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) { - return parseYangFiles(supportedFeatures, Arrays.asList(files)); - } - - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final Collection<File> files) { - return parseYangFiles(supportedFeatures, YangParserConfiguration.DEFAULT, files.stream().map(e->e.toPath()).collect(Collectors.toList())); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { - return parseYangFiles(config, Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param parserMode mode of statement parser - * @param files collection of YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, - final Collection<File> files) { - return parseYangFiles(null, config, files.stream().map(e->e.toPath()).collect(Collectors.toList())); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final YangParserConfiguration config, final Path... files) { - return parseYangFiles(supportedFeatures, config, Arrays.asList(files)); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @param files YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, - final YangParserConfiguration config, final Collection<Path> files) { - return parseSources(config, supportedFeatures, - files.stream().map(YangTextSchemaSource::forPath).collect(Collectors.toList())); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { - return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param parserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final YangParserConfiguration config) { - return parseYangResourceDirectory(resourcePath, null, config); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final Set<QName> supportedFeatures) { - return parseYangResourceDirectory(resourcePath, supportedFeatures, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param resourcePath relative path to the directory with YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param parserMode mode of statement parser - * @return effective schema context - */ - @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final Set<QName> supportedFeatures, final YangParserConfiguration config) { - final URI directoryPath; - try { - directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); - } - File[] files = new File(directoryPath).listFiles(YANG_FILE_FILTER); - return parseYangFiles(supportedFeatures, config, Arrays.asList(files).stream().map(e->e.toPath()).collect(Collectors.toList())); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode and all YANG features are supported. - * - * @param clazz Resource lookup base - * @param resources Resource names to be looked up - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final Class<?> clazz, final String... resources) { - return parseYangResources(clazz, Arrays.asList(resources)); - } - - public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) { - final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size()); - for (final String r : resources) { - sources.add(YangTextSchemaSource.forResource(clazz, r)); - } - return parseSources(YangParserConfiguration.DEFAULT, null, sources); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to - * default mode. - * - * @param yangDirs relative paths to the directories containing YANG files to be parsed - * @param yangFiles relative paths to the YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles, - final Set<QName> supportedFeatures) { - return parseYangResources(yangDirs, yangFiles, supportedFeatures, YangParserConfiguration.DEFAULT); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. - * - * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed - * @param yangResources relative paths to the YANG files to be parsed - * @param statementParserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, - final List<String> yangResources, final YangParserConfiguration config) { - return parseYangResources(yangResourceDirs, yangResources, null, config); - } - - /** - * Creates a new effective schema context containing the specified YANG sources. - * - * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed - * @param yangResources relative paths to the YANG files to be parsed - * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG - * models are resolved - * @param statementParserMode mode of statement parser - * @return effective schema context - */ - public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, - final List<String> yangResources, final Set<QName> supportedFeatures, - final YangParserConfiguration config) { - final List<File> allYangFiles = new ArrayList<>(); - for (final String yangDir : yangResourceDirs) { - allYangFiles.addAll(getYangFiles(yangDir)); - } - - for (final String yangFile : yangResources) { - try { - allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI())); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Invalid resource " + yangFile, e); - } - } - - return parseYangFiles(supportedFeatures, config, allYangFiles.stream().map(e->e.toPath()).collect(Collectors.toList())); - } - - public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { - return parseSources(config, supportedFeatures, Arrays.asList(sources)); - } - - public static EffectiveModelContext parseSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { - final YangParser parser = PARSER_FACTORY.createParser(config); - if (supportedFeatures != null) { - parser.setSupportedFeatures(supportedFeatures); - } - - try { - parser.addSources(sources); - } catch (YangSyntaxErrorException e) { - throw new IllegalArgumentException("Malformed source", e); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to read a source", e); - } - - try { - return parser.buildEffectiveModel(); - } catch (YangParserException e) { - throw new IllegalStateException("Failed to assemble SchemaContext", e); - } - } - - @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") - private static Collection<File> getYangFiles(final String resourcePath) { - final URI directoryPath; - try { - directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e); - } - return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER)); - } -} diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md index ac5bbe4f0..584fcdf14 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md @@ -1,20 +1,19 @@ # Connect -The 'Connect' application on OpenDaylight provides up-to-date connectivity information about the wireless devices in the network. It automatically displays new Network Elements and their connection status. Usually, the Network Elements mount themselves. If necessary, they can be mounted manually by right-clicking on the element and selecting the 'mount' action. For better understanding of alarms and status, a connection status log lists all the connection status changes of OpenDaylight mount points. +The 'Connect' application on OpenDaylight provides up-to-date connectivity information about the network nodes exposing a NETCONF/YANG interface. It automatically displays new Nodes and their connection status. Usually, the NETCONF servers of the Nodes mount themselves. If necessary, they can be mounted manually by right-clicking on the row representing a node and selecting the 'mount' action. For better understanding of alarms and status, a connection status log lists all the connection status changes of OpenDaylight mount points. ## Views The graphical user interface is divided into two sections. -### Network Elements +### Nodes -Network Elements are physical network functions (PNFs). A table view shows all configured and connected NetConf Servers of the SDN-R cluster. This view also allows to manually configure/mount a device via the '+' button. The SDN controller will start connecting to the NetConf server. +Nodes are network functions with a NETCONF/YANG management and control interface. A table view shows all configured and connected NETCONF Servers of the SDN-R cluster. This view also allows to manually configure/mount a node via the '+' button. The SDN controller will start connecting to the NETCONF server. -Network Elements can be marked as 'required'. If an element is required, it will stay available even if disconnected. If an element is not required, it will be deleted once disconnected. - -By right-clicking on an element, an action menu opens. The menu allows to mount, unmount, view the details, edit and remove the element. Additionally, it links to several applications like [Fault](pnfFault.html) and [Configure](pnfConfig.html), which will be filtered to display information relevant to the selected element. +Nodes can be marked as 'required'. If a node is required, it will stay available even if disconnected. If a node is not required, it will be deleted once disconnected. +By right-clicking on a row representing a node, an action menu opens. The menu allows to mount, unmount, view the details, edit and remove the node. Additionally, it links to several applications like Fault and Configure, which will be filtered to display information relevant to the selected node. ### Connection Status Log -The log lists the connection status changes between SDN Controller and NetConf servers (devices). +The log lists the connection status changes between SDN Controller and NETCONF servers (devices, Network Elements, network functions).
\ No newline at end of file diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnLog/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnLog/README.md deleted file mode 100644 index 85de8a30c..000000000 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnLog/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Log - -The application displays (UX) application logs. SDN-R offer a common log server, so that PNFs or other ONAP components could log there data in a common way.
\ No newline at end of file diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnTest/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnTest/README.md deleted file mode 100644 index 6bd3609c2..000000000 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/mwtnTest/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Test - -The view offers in a generic way data fetched from ONF-TR-532 devices for test and debug purposes.
\ No newline at end of file diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java index b13d4ea38..115f0f0c0 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java @@ -26,7 +26,7 @@ import java.util.Map; public class CMNotificationClient extends MessageClient { - private static final String CM_NOTIFICATION_URI = "restconf/operations/devicemanager:push-cm-notification"; + private static final String CM_NOTIFICATION_URI = "rests/operations/devicemanager:push-cm-notification"; public static final String NODE_ID = "@node-id@", COUNTER = "@counter@", TIMESTAMP = "@timestamp@", OBJECT_ID = "@object-id@", NOTIFICATION_TYPE = "@notification-type@", SOURCE_INDICATOR = "@source-indicator@", NOTIFICATION_ID = "@notification-id@", PATH = "@path@", OPERATION = "@operation@", VALUE = "@value@"; @@ -35,17 +35,17 @@ public class CMNotificationClient extends MessageClient { OPERATION, VALUE); private static final String CM_PAYLOAD = "{\n" - + " \"devicemanager:input\": {\n" - + " \"devicemanager:node-id\": \"" + NODE_ID + "\",\n" - + " \"devicemanager:counter\": \"" + COUNTER + "\",\n" - + " \"devicemanager:timestamp\": \"" + TIMESTAMP + "\",\n" - + " \"devicemanager:object-id\": \"" + OBJECT_ID + "\",\n" - + " \"devicemanager:notification-type\": \"" + NOTIFICATION_TYPE + "\",\n" - + " \"devicemanager:notification-id\": \"" + NOTIFICATION_ID + "\",\n" - + " \"devicemanager:source-indicator\": \"" + SOURCE_INDICATOR + "\",\n" - + " \"devicemanager:path\": \"" + PATH + "\",\n" - + " \"devicemanager:operation\": \"" + OPERATION + "\",\n" - + " \"devicemanager:value\": \"" + VALUE + "\"\n" + + " \"input\": {\n" + + " \"node-id\": \"" + NODE_ID + "\",\n" + + " \"counter\": \"" + COUNTER + "\",\n" + + " \"timestamp\": \"" + TIMESTAMP + "\",\n" + + " \"object-id\": \"" + OBJECT_ID + "\",\n" + + " \"notification-type\": \"" + NOTIFICATION_TYPE + "\",\n" + + " \"notification-id\": \"" + NOTIFICATION_ID + "\",\n" + + " \"source-indicator\": \"" + SOURCE_INDICATOR + "\",\n" + + " \"path\": \"" + PATH + "\",\n" + + " \"operation\": \"" + OPERATION + "\",\n" + + " \"value\": \"" + VALUE + "\"\n" + " }\n" + "}"; diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java index 6851475e8..ce2538628 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java @@ -29,19 +29,19 @@ import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageCl public class FaultNotificationClient extends MessageClient { - private static final String FAULT_NOTIFICATION_URI = "restconf/operations/devicemanager:push-fault-notification"; + private static final String FAULT_NOTIFICATION_URI = "rests/operations/devicemanager:push-fault-notification"; public static final String NODE_ID = "@node-id@", COUNTER = "@counter@", TIMESTAMP = "@timestamp@", OBJECT_ID = "@object-id@", PROBLEM = "@problem@", SEVERITY = "@severity@"; public static final List<String> REQUIRED_FIELDS = List.of(NODE_ID, COUNTER, TIMESTAMP, OBJECT_ID, PROBLEM, SEVERITY); private static final String FAULT_PAYLOAD = "{\n" - + " \"devicemanager:input\": {\n" - + " \"devicemanager:node-id\": \"" + NODE_ID + "\",\n" - + " \"devicemanager:counter\": \"" + COUNTER + "\",\n" - + " \"devicemanager:timestamp\": \"" + TIMESTAMP + "\",\n" - + " \"devicemanager:object-id\": \"" + OBJECT_ID + "\",\n" - + " \"devicemanager:problem\": \"" + PROBLEM + "\",\n" - + " \"devicemanager:severity\": \"" + SEVERITY + "\"\n" + + " \"input\": {\n" + + " \"node-id\": \"" + NODE_ID + "\",\n" + + " \"counter\": \"" + COUNTER + "\",\n" + + " \"timestamp\": \"" + TIMESTAMP + "\",\n" + + " \"object-id\": \"" + OBJECT_ID + "\",\n" + + " \"problem\": \"" + PROBLEM + "\",\n" + + " \"severity\": \"" + SEVERITY + "\"\n" + " }\n" + "}"; diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java index 169e43c47..fd31a3fd6 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java @@ -30,7 +30,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest; public class PNFMountPointClient extends MessageClient { private static final String MOUNTPOINT_URI = - "restconf/config/network-topology:network-topology/topology/topology-netconf/node/"; + "rests/data/network-topology:network-topology/topology=topology-netconf/node="; public static final String DEVICE_NAME = "@device-name@", DEVICE_IP = "@device-ip@", DEVICE_PORT = "@device-port@", USERNAME = "@username@", PASSWORD = "@password@", KEY_ID = "@key-id@"; private static final String PROTOCOL = "protocol_sec"; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java index 6c3704421..a66da6970 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java @@ -56,9 +56,9 @@ public class NetconfAccessorManager { public NetconfAccessor getAccessor(NodeId nNodeId, NetconfNode netconfNode) { NetconfAccessor res = new NetconfAccessorImpl(nNodeId, netconfNode, netconfCommunicatorManager, domContext, netconfNodeStateService); - NetconfAccessor previouse = accessorList.put(nNodeId, res); + NetconfAccessor previouse = accessorList.putIfAbsent(nNodeId, res); if (Objects.nonNull(previouse)) { - LOG.warn("Accessor with name already available. Replaced with new one."); + LOG.warn("Accessor with name already available. Don't add {}", nNodeId); } return res; } @@ -68,7 +68,11 @@ public class NetconfAccessorManager { } public void removeAccessor(NodeId nNodeId) { - accessorList.remove(nNodeId); + NetconfAccessor previouse = accessorList.remove(nNodeId); + if (Objects.nonNull(previouse)) { + LOG.warn("Accessor with name was not available during remove {}", nNodeId); + } + } diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java index 47d5fee01..d8720e823 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java @@ -95,7 +95,7 @@ public class TokenCreator { private Algorithm createAlgorithm(String alg, String secret, String pubkey) throws IllegalArgumentException, IOException { - if(alg==null) { + if (alg == null) { alg = Config.TOKENALG_HS256; } switch (alg) { @@ -153,24 +153,31 @@ public class TokenCreator { public String getBearerToken(HttpServletRequest req) { return this.getBearerToken(req, false); } + public String getBearerToken(HttpServletRequest req, boolean checkCookie) { final String authHeader = req.getHeader("Authorization"); if ((authHeader == null || !authHeader.startsWith("Bearer")) && checkCookie) { - Optional<Cookie> ocookie = - Arrays.stream(req.getCookies()).filter(c -> COOKIE_NAME_AUTH.equals(c.getName())).findFirst(); - if(ocookie.isEmpty()) { + Cookie[] cookies = req.getCookies(); + Optional<Cookie> ocookie = Optional.empty(); + if (cookies != null) { + ocookie = Arrays.stream(cookies).filter(c -> c != null && COOKIE_NAME_AUTH.equals(c.getName())) + .findFirst(); + } + if (ocookie.isEmpty()) { return null; } return ocookie.get().getValue(); } return authHeader.substring(7); } + public UserTokenPayload decode(HttpServletRequest req) throws JWTDecodeException { final String token = this.getBearerToken(req); - return token!=null?this.decode(token):null; + return token != null ? this.decode(token) : null; } - public UserTokenPayload decode(String token){ - if(token == null){ + + public UserTokenPayload decode(String token) { + if (token == null) { return null; } DecodedJWT jwt = JWT.decode(token); @@ -185,8 +192,8 @@ public class TokenCreator { } public Cookie createAuthCookie(BearerToken data) { - Cookie cookie = new Cookie(COOKIE_NAME_AUTH, data.getToken()); - cookie.setMaxAge((int)this.tokenLifetimeSeconds); + Cookie cookie = new Cookie(COOKIE_NAME_AUTH, data.getToken()); + cookie.setMaxAge((int) this.tokenLifetimeSeconds); cookie.setPath("/"); cookie.setHttpOnly(true); cookie.setSecure(true); diff --git a/sdnr/wt/oauth-provider/provider-osgi/pom.xml b/sdnr/wt/oauth-provider/provider-osgi/pom.xml index 3d4d138a2..41fe3c599 100644 --- a/sdnr/wt/oauth-provider/provider-osgi/pom.xml +++ b/sdnr/wt/oauth-provider/provider-osgi/pom.xml @@ -119,13 +119,18 @@ org.opendaylight.aaa.api.shiro.principal, org.opendaylight.aaa.shiro.realm, org.opendaylight.aaa.shiro.filters, + org.opendaylight.aaa.shiro.web.env, org.opendaylight.mdsal.binding.api, + org.opendaylight.mdsal.common.api, org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619, org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.shiro.configuration, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.authorization, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.authorization.policies, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.permission, + org.opendaylight.yangtools.concepts, org.opendaylight.yangtools.yang.binding, + org.opendaylight.yangtools.yang.common, com.fasterxml.jackson.databind, com.fasterxml.jackson.databind.deser.std, com.fasterxml.jackson.databind.ser.std, @@ -134,6 +139,7 @@ com.fasterxml.jackson.core.type, com.fasterxml.jackson.core, org.apache.commons.codec.binary, + com.google.common.base, com.google.common.collect, com.google.common.util.concurrent </Import-Package> diff --git a/sdnr/wt/websocketmanager/provider/pom.xml b/sdnr/wt/websocketmanager/provider/pom.xml index b6a7110d8..b198b61ef 100644 --- a/sdnr/wt/websocketmanager/provider/pom.xml +++ b/sdnr/wt/websocketmanager/provider/pom.xml @@ -110,6 +110,10 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> 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 95715be39..0b64d476a 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 @@ -32,6 +32,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.DOMNotificationOutput; @@ -120,7 +123,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter { */ private static final HashMap<String, WebSocketManagerSocket> clientList = new HashMap<>(); - private static final YangToolsMapper mapper = new YangToolsMapper(); + private static final ObjectMapper mapper = new YangToolsMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); private final String myUniqueSessionId; private Session session = null; @@ -133,6 +136,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter { this.myUniqueSessionId = _genSessionId(); this.sendingSyncThread = new Thread(this.sendingRunner); this.messageQueue = new ArrayBlockingQueue<>(QUEUE_SIZE); + } @Override |