From 80ebbf5b525b1a251f8e0eebd4a841d85716cf65 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Wed, 3 Feb 2021 13:56:31 +0100 Subject: Update common and data-provider common and data-provider migrated to Aluminium Issue-ID: CCSDK-3111 Signed-off-by: Ravi Pendurty Change-Id: Ifb4ddb60f84ca7585137e04bc94d44885fe1f5f4 Signed-off-by: Ravi Pendurty --- sdnr/wt/common/pom.xml | 29 ++- .../sdnr/wt/common/database/HtDatabaseClient.java | 1 + .../sdnr/wt/common/database/SearchResult.java | 11 +- .../sdnr/wt/common/http/BaseHTTPClient.java | 41 +++- .../sdnr/wt/common/http/BaseHTTPResponse.java | 10 +- .../features/sdnr/wt/common/http/BaseServlet.java | 8 +- ...ServletInputStreamFromByteArrayInputStream.java | 15 ++ ...ServletOutputStreamToByteArrayOutputStream.java | 18 +- .../test/ServletOutputStreamToStringWriter.java | 20 +- sdnr/wt/common/src/test/resources/testpom.xml | 4 +- sdnr/wt/data-provider/feature/pom.xml | 4 +- sdnr/wt/data-provider/installer/pom.xml | 12 +- sdnr/wt/data-provider/model/pom.xml | 8 +- .../model/types/NetconfTimeStampImpl.java | 21 +- .../dataprovider/model/types/ScalarTypeObject.java | 49 +++++ .../wt/dataprovider/model/types/YangHelper2.java | 31 ++- .../pm/types/rev191129/PmDataTypeBuilder.java | 53 ++--- sdnr/wt/data-provider/pom.xml | 4 +- sdnr/wt/data-provider/provider/java.sh | 14 ++ sdnr/wt/data-provider/provider/pom.xml | 27 ++- .../data-provider/provider/simplelogger.properties | 34 +++ .../data/ElasticSearchDataProvider.java | 36 +-- .../data/acessor/DataObjectAcessorStatus.java | 12 +- .../data/rpctypehelper/QueryResult.java | 19 +- .../database/EsDataObjectReaderWriter2.java | 12 +- .../wt/dataprovider/http/DataTreeHttpServlet.java | 3 - .../dataprovider/http/about/AboutHttpServlet.java | 17 +- .../wt/dataprovider/http/about/ODLVersionLUT.java | 1 + .../wt/dataprovider/impl/DataProviderImpl.java | 16 +- .../dataprovider/impl/DataProviderServiceImpl.java | 34 +-- .../dataprovider/yangtools/DateAndTimeBuilder.java | 15 -- .../wt/dataprovider/yangtools/YangToolsMapper.java | 205 ++--------------- .../dataprovider/yangtools/YangToolsMapper2.java | 244 +-------------------- .../yangtools/YangToolsMapperHelper.java | 244 +++++++++++++++++++++ .../yangtools/builder/DateAndTimeBuilder.java | 36 +++ .../YangToolsBuilderAnnotationIntrospector.java | 130 +++++++++++ .../YangToolsDeserializerModifier.java | 117 ++++++++++ .../mapperextensions/YangToolsModule.java | 50 +++++ .../serialize/BaseIdentityDeserializer.java | 64 ++++++ .../yangtools/serialize/ClassDeserializer.java | 45 ++++ .../yangtools/serialize/DateAndTimeSerializer.java | 51 +++++ .../yangtools/serialize/EnumSerializer.java | 36 +++ .../serialize/IdentifierDeserializer.java | 71 ++++++ .../yangtools/serialize/MapSerializer.java | 37 ++++ .../serialize/TypeObjectDeserializer.java | 87 ++++++++ .../yangtools/serialize/TypeObjectSerializer.java | 51 +++++ .../sdnr/wt/dataprovider/test/TestAbout.java | 22 +- .../wt/dataprovider/test/TestCRUDforDatabase.java | 22 +- .../wt/dataprovider/test/TestDataMappings.java | 10 +- .../wt/dataprovider/test/TestEventService.java | 3 +- .../sdnr/wt/dataprovider/test/TestTree.java | 61 +++--- .../dataprovider/test/TestYangGenSalMapping.java | 27 ++- .../test/TestYangGenSalMappingOpenRoadm.java | 148 ++++++++++--- .../wt/dataprovider/test/issues/TestIssue227.java | 126 +++++++++++ .../provider/src/test/resources/TestTree/1.json | 17 ++ .../provider/src/test/resources/TestTree/10.json | 15 ++ .../provider/src/test/resources/TestTree/11.json | 18 ++ .../provider/src/test/resources/TestTree/12.json | 15 ++ .../provider/src/test/resources/TestTree/13.json | 20 ++ .../provider/src/test/resources/TestTree/14.json | 15 ++ .../provider/src/test/resources/TestTree/15.json | 15 ++ .../provider/src/test/resources/TestTree/16.json | 15 ++ .../provider/src/test/resources/TestTree/17.json | 17 ++ .../provider/src/test/resources/TestTree/18.json | 18 ++ .../provider/src/test/resources/TestTree/19.json | 20 ++ .../provider/src/test/resources/TestTree/2.json | 15 ++ .../provider/src/test/resources/TestTree/20.json | 20 ++ .../provider/src/test/resources/TestTree/21.json | 17 ++ .../provider/src/test/resources/TestTree/3.json | 15 ++ .../provider/src/test/resources/TestTree/4.json | 15 ++ .../provider/src/test/resources/TestTree/5.json | 25 +++ .../provider/src/test/resources/TestTree/6.json | 17 ++ .../provider/src/test/resources/TestTree/7.json | 17 ++ .../provider/src/test/resources/TestTree/8.json | 17 ++ .../provider/src/test/resources/TestTree/9.json | 19 ++ .../TestYangGenSalMappingOpenRoadm/pmdata1.json | 18 ++ .../TestYangGenSalMappingOpenRoadm/pmdata2.json | 14 ++ .../TestYangGenSalMappingOpenRoadm/pmdata3.json | 14 ++ .../provider/src/test/resources/log4j.properties | 9 + .../src/test/resources/simplelogger.properties | 36 --- .../src/test/resources/testequipment/1.json | 17 -- .../src/test/resources/testequipment/10.json | 15 -- .../src/test/resources/testequipment/11.json | 18 -- .../src/test/resources/testequipment/12.json | 15 -- .../src/test/resources/testequipment/13.json | 20 -- .../src/test/resources/testequipment/14.json | 15 -- .../src/test/resources/testequipment/15.json | 15 -- .../src/test/resources/testequipment/16.json | 15 -- .../src/test/resources/testequipment/17.json | 17 -- .../src/test/resources/testequipment/18.json | 18 -- .../src/test/resources/testequipment/19.json | 20 -- .../src/test/resources/testequipment/2.json | 15 -- .../src/test/resources/testequipment/20.json | 20 -- .../src/test/resources/testequipment/21.json | 17 -- .../src/test/resources/testequipment/3.json | 15 -- .../src/test/resources/testequipment/4.json | 15 -- .../src/test/resources/testequipment/5.json | 25 --- .../src/test/resources/testequipment/6.json | 17 -- .../src/test/resources/testequipment/7.json | 17 -- .../src/test/resources/testequipment/8.json | 17 -- .../src/test/resources/testequipment/9.json | 19 -- sdnr/wt/data-provider/setup/pom.xml | 15 +- sdnr/wt/pom.xml | 2 +- 103 files changed, 2166 insertions(+), 1132 deletions(-) create mode 100644 sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java create mode 100755 sdnr/wt/data-provider/provider/java.sh create mode 100644 sdnr/wt/data-provider/provider/simplelogger.properties delete mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/DateAndTimeBuilder.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapperHelper.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/builder/DateAndTimeBuilder.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsBuilderAnnotationIntrospector.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsDeserializerModifier.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsModule.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/BaseIdentityDeserializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/ClassDeserializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/DateAndTimeSerializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/EnumSerializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/IdentifierDeserializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/MapSerializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectDeserializer.java create mode 100644 sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectSerializer.java create mode 100644 sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/issues/TestIssue227.java create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/1.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/10.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/11.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/12.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/13.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/14.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/15.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/16.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/17.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/18.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/19.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/2.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/20.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/21.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/3.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/4.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/5.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/6.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/7.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/8.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestTree/9.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata1.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata2.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata3.json create mode 100644 sdnr/wt/data-provider/provider/src/test/resources/log4j.properties delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json delete mode 100644 sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json (limited to 'sdnr/wt') diff --git a/sdnr/wt/common/pom.xml b/sdnr/wt/common/pom.xml index 54ffc01c3..97c8ed862 100644 --- a/sdnr/wt/common/pom.xml +++ b/sdnr/wt/common/pom.xml @@ -29,14 +29,14 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.1.1-SNAPSHOT org.onap.ccsdk.features.sdnr.wt sdnr-wt-common 1.1.1-SNAPSHOT - jar + bundle ccsdk-features :: ${project.artifactId} @@ -47,7 +47,6 @@ - true true yyyy-MM-dd HH:mm ${maven.build.timestamp} UTC @@ -63,7 +62,7 @@ javax.servlet - servlet-api + javax.servlet-api org.osgi @@ -77,23 +76,22 @@ org.elasticsearch.client elasticsearch-rest-client - ${elasticsearch-rest-client.version} - - - com.fasterxml.jackson.core - jackson-core + + + + com.fasterxml.jackson.core jackson-annotations + + + + - com.fasterxml.jackson.core - jackson-databind - - - com.google.code.findbugs - annotations + com.google.code.findbugs + annotations @@ -114,7 +112,6 @@ com.github.alexcojocaru elasticsearch-maven-plugin - 6.16 ${skipTests} testCluster diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java index 1ae9f1e6c..232b68c73 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java @@ -261,6 +261,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A total = response.getTotal(); } catch (IOException e) { + LOG.warn("Possible Database connection failure. If this error persists, please check Database connectivity"); LOG.warn("error do search {}: {}", queryBuilder, e); } return new SearchResult(response != null ? response.getHits() : new SearchHit[] {}, total); diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java index 5a011eec9..529853e08 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java @@ -45,10 +45,6 @@ public class SearchResult { this.total = total; } - // public SearchResult(List hits,long total) { - // this.hits = hits; - // this.total = total; - // } public SearchResult() { this.hits = new ArrayList<>(); this.total = 0; @@ -69,4 +65,11 @@ public class SearchResult { public void add(T object) { this.hits.add(object); } + + @Override + public String toString() { + return "SearchResult [hits=" + hits + ", total=" + total + "]"; + } + + } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java index 155e51609..198fb920c 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java @@ -48,7 +48,11 @@ import java.security.interfaces.RSAPrivateKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.annotation.Nonnull; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -56,7 +60,7 @@ import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; -import javax.xml.bind.DatatypeConverter; +import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,6 +115,29 @@ public class BaseHTTPClient { throws IOException { return this.sendRequest(uri, method, body != null ? body.getBytes(CHARSET) : null, headers); } + public BaseHTTPResponse sendRequest(HttpServletRequest req) throws IOException { + final String method = req.getMethod(); + byte[] buffer=null; + + if(!"GET".equals(method)) { + InputStream is = req.getInputStream(); + buffer=is.readAllBytes(); + is.close(); + + } + return this.sendRequest(req.getRequestURI(), method, buffer,mapHeaders(req)); + } + + private Map mapHeaders(HttpServletRequest req) { + Map headers = new HashMap<>(); + Enumeration keys = req.getHeaderNames(); + String key; + while(keys.hasMoreElements()) { + key=keys.nextElement(); + headers.put(key,req.getHeader(key)); + } + return headers; + } protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, byte[] body, Map headers) throws IOException { @@ -164,10 +191,16 @@ public class BaseHTTPClient { // Receive answer int responseCode = ((HttpURLConnection) http).getResponseCode(); String sresponse = ""; + Map responseHeaders = null; InputStream response = null; try { if (responseCode >= 200 && responseCode < 300) { response = http.getInputStream(); + responseHeaders = new HashMap<>(); + for(Entry> entry:http.getHeaderFields().entrySet()) { + responseHeaders.put(entry.getKey(), String.join(";", entry.getValue())); + } + } else { response = ((HttpURLConnection) http).getErrorStream(); if (response == null) { @@ -195,7 +228,7 @@ public class BaseHTTPClient { } LOG.debug("ResponseCode: " + responseCode); LOG.trace("Response (len:{}): {}", String.valueOf(lensum), sresponse); - return new BaseHTTPResponse(responseCode, sresponse); + return new BaseHTTPResponse(responseCode, sresponse,responseHeaders); } public static SSLContext setupSsl(boolean trustall) @@ -299,7 +332,7 @@ public class BaseHTTPClient { String data = new String(pem); String[] tokens = data.split(beginDelimiter); tokens = tokens[1].split(endDelimiter); - return DatatypeConverter.parseBase64Binary(tokens[0]); + return Base64.getDecoder().decode(tokens[0]); } protected static RSAPrivateKey generatePrivateKeyFromDER(byte[] keyBytes) @@ -337,4 +370,6 @@ public class BaseHTTPClient { return SSLCERT_PEM; } + + } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java index 91a2cc27c..a0fd7220e 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java @@ -21,6 +21,8 @@ */ package org.onap.ccsdk.features.sdnr.wt.common.http; +import java.util.Map; + public class BaseHTTPResponse { public static final int CODE404 = 404; @@ -28,10 +30,14 @@ public class BaseHTTPResponse { public static final BaseHTTPResponse UNKNOWN = new BaseHTTPResponse(-1, ""); public final int code; public final String body; - + public final Map headers; public BaseHTTPResponse(int code, String body) { + this(code, body, null); + } + public BaseHTTPResponse(int code, String body, Map rawData) { this.code = code; this.body = body; + this.headers = rawData; } @Override @@ -40,6 +46,6 @@ public class BaseHTTPResponse { } public boolean isSuccess() { - return this.code == CODE200; + return this.code >= CODE200 && this.code<300; } } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java index 59e4e7705..f66070200 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java @@ -32,7 +32,6 @@ import java.security.NoSuchAlgorithmException; import java.util.Enumeration; import java.util.List; import java.util.Map; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; @@ -41,7 +40,6 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -328,9 +326,9 @@ public abstract class BaseServlet extends HttpServlet { response = http.getInputStream(); } else { response = http.getErrorStream(); - if (response == null) { - http.getInputStream(); - } +// if (response == null) { +// response = http.getInputStream(); +// } } LOG.debug("ResponseCode: {}", responseCode); diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java index b926ff65c..6475ac3c9 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import java.io.ByteArrayInputStream; import java.io.IOException; +import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; public class ServletInputStreamFromByteArrayInputStream extends ServletInputStream { @@ -42,4 +43,18 @@ public class ServletInputStreamFromByteArrayInputStream extends ServletInputStre return bis.read(); } + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) { + } + } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java index 1914d9b67..3ea607cc0 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; public class ServletOutputStreamToByteArrayOutputStream extends ServletOutputStream { @@ -32,12 +33,21 @@ public class ServletOutputStreamToByteArrayOutputStream extends ServletOutputStr // end of variables + public ByteArrayOutputStream getByteArrayOutputStream() { + return out; + } + @Override - public void write(int arg0) throws IOException { - out.write(arg0); + public void setWriteListener(WriteListener writeListener) { } - public ByteArrayOutputStream getByteArrayOutputStream() { - return out; + @Override + public void write(int b) throws IOException { + out.write(b); + } + + @Override + public boolean isReady() { + return false; } } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java index 57ed596ae..48d9f940f 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import java.io.IOException; import java.io.StringWriter; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; public class ServletOutputStreamToStringWriter extends ServletOutputStream { @@ -31,13 +32,28 @@ public class ServletOutputStreamToStringWriter extends ServletOutputStream { private StringWriter out = new StringWriter(); // end of variables + public StringWriter getStringWriter() { + return out; + } + @Override public void write(int arg0) throws IOException { out.write(arg0); } - public StringWriter getStringWriter() { - return out; + @Override + public String toString() { + return out.toString(); } + @Override + public boolean isReady() { + return false; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + } + + } diff --git a/sdnr/wt/common/src/test/resources/testpom.xml b/sdnr/wt/common/src/test/resources/testpom.xml index 1adf713c1..6fba87af9 100644 --- a/sdnr/wt/common/src/test/resources/testpom.xml +++ b/sdnr/wt/common/src/test/resources/testpom.xml @@ -29,13 +29,13 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.0.0-SNAPSHOT org.onap.ccsdk.features.sdnr.wt sdnr-wt-common - 1.1.1-SNAPSHOT + 1.0.0-SNAPSHOT jar ccsdk-features :: ${project.artifactId} diff --git a/sdnr/wt/data-provider/feature/pom.xml b/sdnr/wt/data-provider/feature/pom.xml index f16715772..38c158113 100644 --- a/sdnr/wt/data-provider/feature/pom.xml +++ b/sdnr/wt/data-provider/feature/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent single-feature-parent - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-feature 1.1.1-SNAPSHOT feature diff --git a/sdnr/wt/data-provider/installer/pom.xml b/sdnr/wt/data-provider/installer/pom.xml index 00bc0e061..074d88aa4 100755 --- a/sdnr/wt/data-provider/installer/pom.xml +++ b/sdnr/wt/data-provider/installer/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent odlparent-lite - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-installer 1.1.1-SNAPSHOT pom @@ -47,7 +47,7 @@ - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 ${application.name}-feature ${project.version} xml @@ -60,12 +60,12 @@ - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 ${application.name}-provider ${project.version} - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 ${application.name}-setup ${project.version} @@ -127,7 +127,7 @@ validate - ${project.build.directory}/assembly/system/org/onap/ccsdk/features/sdnr/wt/sdnr-wt-data-provider-setup/${project.version} + ${project.build.directory}/assembly/system/org/onap/ccsdk/features/sdnr/wt/aluminium/sr1/sdnr-wt-data-provider-setup/${project.version} ${basedir}/../setup/target diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml index 0f8ce415a..b3f39d955 100644 --- a/sdnr/wt/data-provider/model/pom.xml +++ b/sdnr/wt/data-provider/model/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-model 1.1.1-SNAPSHOT bundle @@ -61,6 +61,10 @@ sdnr-wt-common ${project.version} + + com.fasterxml.jackson.core + jackson-databind + diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java index c7f921708..bd71d5ba1 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java @@ -24,6 +24,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.Date; +import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.slf4j.Logger; @@ -66,6 +67,10 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { private static final Logger LOG = LoggerFactory.getLogger(NetconfTimeStamp.class); private static final NetconfTimeStamp CONVERTER = new NetconfTimeStampImpl(); + private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z"; + //private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z"; + + private static final DateAndTime TESTPATTERN = new DateAndTime(TESTPATTERNSTRING); /** * Specify the input format expected from netconf, and from specific devices. @@ -91,7 +96,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Use this function to get the converter - * + * * @return global converter */ public static NetconfTimeStamp getConverter() { @@ -110,7 +115,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format - * + * * @return String with Date in NETCONF/YANG Format Version 1.0. */ @Override @@ -132,7 +137,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * + * * @param date specifying the date and time * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. */ @@ -143,7 +148,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * + * * @param date specifying the date and time * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. */ @@ -189,6 +194,14 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { return "Malformed date: " + netconfTime; // Error handling } + /** + * Return testpattern + * @return + */ + public static @Nullable DateAndTime getTestpatternDateAndTime() { + return TESTPATTERN; + } + /*---------------------------------------------------- * Private functions */ diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java new file mode 100644 index 000000000..da52f3125 --- /dev/null +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.model.types; + +public class ScalarTypeObject { + + // constants + // end of constants + + // variables + // end of variables + + // constructors + // end of constructors + + // getters and setters + // end of getters and setters + + // private methods + // end of private methods + + // public methods + // end of public methods + + // static methods + // end of static methods + + // private classes + // end of private classes +} diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java index 339bf7c6e..dd90d29c8 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java @@ -69,10 +69,18 @@ public class YangHelper2 { public static @NonNull Integer getInteger(@Nullable Uint16 val) { return val.intValue(); } + + public static @NonNull Long getInteger(@Nullable Long val) { + return val; + } + + public static @NonNull Long getInteger(@Nullable Uint32 val) { + return val.longValue(); + } /** * Aluminium version */ - public static ,T extends Identifiable> Map getListOrMapALUMINIUM(Class clazz, List list) { + public static ,T extends Identifiable> Map getListOrMap(Class clazz, List list) { Map map = new HashMap<>(); for(T listelement:list) { Constructor constructor; @@ -86,17 +94,20 @@ public class YangHelper2 { } return map; } - public static ,T extends Identifiable> Map getListOrMapALUMINIUM(Class clazz, T listElement) { - return getListOrMapALUMINIUM(clazz, Arrays.asList(listElement) ); + public static ,T extends Identifiable> Map getListOrMap(Class clazz, T listElement) { + return getListOrMap(clazz, Arrays.asList(listElement) ); } - /** - * Sodium version - */ - public static ,T extends Identifiable> List getListOrMap(Class clazz, List list) { - return list; + public static Uint32 getLongOrUint32(long longVal) { + return Uint32.valueOf(longVal); + } + public static Uint32 getLongOrUint32(Long longVal) { + return Uint32.valueOf(longVal); + } + public static Uint64 getBigIntegerOrUint64(BigInteger value) { + return Uint64.valueOf(value); } - public static ,T extends Identifiable> List getListOrMap(Class clazz, T listElement) { - return Arrays.asList(listElement); + public static Class getScalarTypeObjectClass() { + return org.opendaylight.yangtools.yang.binding.ScalarTypeObject.class; } } diff --git a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java index b660787c6..f89197b82 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java @@ -1,11 +1,7 @@ package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Optional; import org.opendaylight.yangtools.yang.common.Uint64; /** @@ -17,20 +13,17 @@ import org.opendaylight.yangtools.yang.common.Uint64; * finished by the user. This class is generated only once to prevent loss of user code. * */ -@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "with") +@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "set") public class PmDataTypeBuilder { private Uint64 _uint64; - private BigInteger _unint64; private Long _int64; private BigDecimal _decimal64; - public PmDataTypeBuilder() { - System.out.println("-- Builder"); - } + public PmDataTypeBuilder() {} - public PmDataTypeBuilder setUnint64(String v) { - _unint64 = new BigInteger(v); - return this; + //Aluminium uses constructor + public PmDataTypeBuilder(String v) { + this.setUint64(v); } public PmDataTypeBuilder setUint64(String v) { @@ -39,7 +32,7 @@ public class PmDataTypeBuilder { } public PmDataTypeBuilder setInt64(String v) { - _int64 = new Long(v); + _int64 = Long.valueOf(v); return this; } @@ -49,37 +42,17 @@ public class PmDataTypeBuilder { } public PmDataType build() { - Optional> cons1; - try { - cons1 = Optional.of(PmDataType.class.getConstructor(BigInteger.class)); - } catch (NoSuchMethodException | SecurityException e) { - cons1 = Optional.empty(); - } - Optional> cons2; - try { - cons2 = Optional.of(PmDataType.class.getConstructor(Uint64.class)); - } catch (NoSuchMethodException | SecurityException e) { - cons2 = Optional.empty(); - } - - try { - if (_unint64 != null) { - return cons1.get().newInstance(_unint64); - } else if (_uint64 != null) { - return cons2.get().newInstance(_uint64); - } else if (_int64 != null) { - return new PmDataType(_int64); - } else { - return new PmDataType(_decimal64); - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - throw new IllegalArgumentException("Wrong stuff"); + if (_uint64 != null) { + return new PmDataType(_uint64); + } else if (_int64 != null) { + return new PmDataType(_int64); + } else { + return new PmDataType(_decimal64); } } public static PmDataType getDefaultInstance(String defaultValue) { - return new PmDataTypeBuilder().setInt64("-1").build(); + return new PmDataTypeBuilder().setUint64(defaultValue).build(); } } diff --git a/sdnr/wt/data-provider/pom.xml b/sdnr/wt/data-provider/pom.xml index 605cd2008..c8c8e9912 100755 --- a/sdnr/wt/data-provider/pom.xml +++ b/sdnr/wt/data-provider/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent odlparent-lite - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-top 1.1.1-SNAPSHOT pom diff --git a/sdnr/wt/data-provider/provider/java.sh b/sdnr/wt/data-provider/provider/java.sh new file mode 100755 index 000000000..26d5aea4b --- /dev/null +++ b/sdnr/wt/data-provider/provider/java.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Java startup helper +# if JAVA_HOME is specified, use related version + +echo "Java run helper" + +if [ ! -z "$JAVA_HOME" ] ; then + echo "JAVA_HOME=$JAVA_HOME" + $JAVA_HOME/bin/java "$@" +else + echo "Java on path" + java "$@" +fi + diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml index cb40f71cc..8e56b7024 100644 --- a/sdnr/wt/data-provider/provider/pom.xml +++ b/sdnr/wt/data-provider/provider/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-provider 1.1.1-SNAPSHOT bundle @@ -79,24 +79,31 @@ javax.servlet - servlet-api + javax.servlet-api org.osgi org.osgi.core provided - + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + org.apache.karaf.shell org.apache.karaf.shell.core provided - - - - - + + + + + org.opendaylight.netconf sal-netconf-connector @@ -149,7 +156,7 @@ exec - java + ${basedir}/java.sh -jar ${basedir}/../../data-provider/setup/target/sdnr-dmt.jar diff --git a/sdnr/wt/data-provider/provider/simplelogger.properties b/sdnr/wt/data-provider/provider/simplelogger.properties new file mode 100644 index 000000000..f29f44e61 --- /dev/null +++ b/sdnr/wt/data-provider/provider/simplelogger.properties @@ -0,0 +1,34 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +#org.slf4j.simpleLogger.defaultLogLevel=info + +# Logging detail level for a SimpleLogger instance named "xxxxx". +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, the default logging detail level is used. +#org.slf4j.simpleLogger.log.xxxxx= + +# Set to true if you want the current date and time to be included in output messages. +# Default is false, and will output the number of milliseconds elapsed since startup. +#org.slf4j.simpleLogger.showDateTime=false + +# The date and time format to be used in the output messages. +# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. +# If the format is not specified or is invalid, the default format is used. +# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java index 7a30542b4..0a966aef6 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java @@ -47,6 +47,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity; @@ -55,6 +56,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMediatorServerListOutputBuilder; @@ -72,13 +74,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implements IEntityDataProvider*/ { +public class ElasticSearchDataProvider { private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class); @@ -165,9 +164,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement * Provide access to model API */ - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.PaginationBuilder - //eventRWFaultCurrent public ReadFaultcurrentListOutputBuilder readFaultCurrentList(EntityInput input) { ReadFaultcurrentListOutputBuilder outputBuilder = new ReadFaultcurrentListOutputBuilder(); @@ -181,9 +177,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.PaginationBuilder - //eventRWFaultLog public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) { ReadFaultlogListOutputBuilder outputBuilder = new ReadFaultlogListOutputBuilder(); QueryResult result = @@ -195,9 +188,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.PaginationBuilder - //maintenanceRW public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) { ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder(); QueryResult result = @@ -209,9 +199,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Pagination - //mediatorserverRW public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) { ReadMediatorServerListOutputBuilder outputBuilder = new ReadMediatorServerListOutputBuilder(); @@ -224,9 +211,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.PaginationBuilder - //networkelementConnectionRW public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(EntityInput input) { ReadNetworkElementConnectionListOutputBuilder outputBuilder = new ReadNetworkElementConnectionListOutputBuilder(); @@ -239,9 +223,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.PaginationBuilder - //equipmentRW public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) { ReadInventoryListOutputBuilder outputBuilder = new ReadInventoryListOutputBuilder(); QueryResult result = @@ -253,9 +234,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.PaginationBuilder - //connnectionlogRW public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) { ReadConnectionlogListOutputBuilder outputBuilder = new ReadConnectionlogListOutputBuilder(); QueryResult result = @@ -267,9 +245,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.PaginationBuilder - //eventlogRW public ReadEventlogListOutputBuilder readEventlogList(ReadEventlogListInput input) throws IOException { ReadEventlogListOutputBuilder outputBuilder = new ReadEventlogListOutputBuilder(); QueryResult result = @@ -281,12 +256,11 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.PaginationBuilder public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) { ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder(); QueryResult result = this.pm15mRW.getData(input); + LOG.debug("Read data: readPmdata15mList: {}", result); outputBuilder.setData(result.getResult().getHits()); outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.PaginationBuilder( @@ -294,8 +268,6 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement return outputBuilder; } - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data - //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Pagination public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) { ReadPmdata24hListOutputBuilder outputBuilder = new ReadPmdata24hListOutputBuilder(); QueryResult result = diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java index 3926d3f51..efb52213d 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor; import java.io.IOException; - import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; @@ -31,6 +30,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryResult; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder; @@ -55,9 +55,13 @@ public class DataObjectAcessorStatus extends DataObjectAcessor { SearchResponse response = this.dbClient.search(request); AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY); - Data[] data = {new DataBuilder().setFaults(new FaultsBuilder().setCriticals(aggs.getOrDefault("Critical", 0L)) - .setMajors(aggs.getOrDefault("Major", 0L)).setMinors(aggs.getOrDefault("Minor", 0L)) - .setWarnings(aggs.getOrDefault("Warning", 0L)).build()).build()}; + Data[] data = {new DataBuilder() + .setFaults( + new FaultsBuilder().setCriticals(YangHelper2.getLongOrUint32(aggs.getOrDefault("Critical", 0L))) + .setMajors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Major", 0L))) + .setMinors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Minor", 0L))) + .setWarnings(YangHelper2.getLongOrUint32(aggs.getOrDefault("Warning", 0L))).build()) + .build()}; long toalsize = data.length; return new QueryResult(1L, 1L, new SearchResult(data, toalsize)); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java index 4cd015a7f..6e653baf2 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java @@ -22,8 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper; import java.math.BigInteger; - import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PaginationOutputG; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.PaginationBuilder; @@ -36,9 +36,9 @@ public class QueryResult { this.result = result; PaginationBuilder x = new PaginationBuilder(); - x.setPage(BigInteger.valueOf(page)); - x.setSize(pageSize); - x.setTotal(BigInteger.valueOf(result.getTotal())); + x.setPage(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(page))); + x.setSize(YangHelper2.getLongOrUint32(pageSize)); + x.setTotal(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(result.getTotal()))); pagination = x.build(); } @@ -46,9 +46,9 @@ public class QueryResult { this.result = result; PaginationBuilder x = new PaginationBuilder(); - x.setPage(BigInteger.valueOf(queryByFilter.getPage())); - x.setSize(queryByFilter.getPageSize()); - x.setTotal(BigInteger.valueOf(result.getTotal())); + x.setPage(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(queryByFilter.getPage()))); + x.setSize(YangHelper2.getLongOrUint32(queryByFilter.getPageSize())); + x.setTotal(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(result.getTotal()))); pagination = x.build(); } @@ -61,6 +61,11 @@ public class QueryResult { return pagination; } + @Override + public String toString() { + return "QueryResult [result=" + result + ", pagination=" + pagination + "]"; + } + } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java index bf1aff372..603c25bae 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java @@ -33,6 +33,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper2; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -142,7 +143,7 @@ public class EsDataObjectReaderWriter2 { * @return this for further operations. */ public EsDataObjectReaderWriter2 setEsIdAttributeNameCamelized(String esIdAttributeName) { - return setEsIdAttributeName(YangToolsMapper2.toCamelCaseAttributeName(esIdAttributeName)); + return setEsIdAttributeName(YangToolsMapperHelper.toCamelCaseAttributeName(esIdAttributeName)); } /** @@ -360,14 +361,13 @@ public class EsDataObjectReaderWriter2 { result = db.doReadAllJsonData(dataTypeName, ignoreException); } hits = result.getHits(); - LOG.debug("Read: {} elements: {} Failures: {}", dataTypeName, hits.size(), - yangtoolsMapper.getMappingFailures()); + LOG.debug("Read: {} elements: {}", dataTypeName, hits.size()); T object; for (SearchHit hit : hits) { object = getT(hit.getSourceAsString()); - LOG.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), - hit.getSourceAsString(), object, yangtoolsMapper.getMappingFailures()); + LOG.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n", hit.getId(), + hit.getSourceAsString(), object); if (object != null) { setEsId(object, hit.getId()); res.add(object); @@ -397,7 +397,7 @@ public class EsDataObjectReaderWriter2 { try { return yangtoolsMapper.readValue(jsonString, clazz); } catch (IOException e) { - LOG.info("Mapping problem", e); + LOG.info("Mapping problem {}:", clazz.getName(), e); return null; } } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java index 085d3816a..bb4023abc 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java @@ -28,16 +28,13 @@ import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataTreeProviderImpl; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java index 81b9645fe..fd6be82db 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java @@ -73,7 +73,7 @@ public class AboutHttpServlet extends HttpServlet { private static final String README_FILE = "README.md"; private static final String NO_DEVICEMANAGERS_RUNNING_MESSAGE = null; - private final String groupId = "org.onap.ccsdk.features.sdnr.wt"; + private final String groupId = this.getGroupIdOrDefault("org.onap.ccsdk.features.sdnr.wt"); private final String artifactId = "sdnr-wt-data-provider-provider"; private final Map BUNDLESTATE_LUT; @@ -97,7 +97,18 @@ public class AboutHttpServlet extends HttpServlet { } - // public void setBundleService(BundleService bundleService) { + protected String getGroupIdOrDefault(String def) { + String symbolicName = this.getManifestValue("Bundle-SymbolicName"); + if(symbolicName!=null) { + int idx = symbolicName.indexOf(this.artifactId); + if(idx>0) { + return symbolicName.substring(0, idx-1); + } + } + return def; + } + + // public void setBundleService(BundleService bundleService) { // this.bundleService = bundleService; // } @@ -199,7 +210,7 @@ public class AboutHttpServlet extends HttpServlet { * @param key * @return */ - private String getManifestValue(String key) { + protected String getManifestValue(String key) { URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF"); if (url == null) { return null; 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 b08e5ad16..491775eb0 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 @@ -60,6 +60,7 @@ public class ODLVersionLUT { } if(odlMdsalVersionLUT==null) { odlMdsalVersionLUT = new HashMap<>(); + odlMdsalVersionLUT.put("6.0.7","aluminium-SR1 (0.13.1)"); odlMdsalVersionLUT.put("6.0.4","aluminium-SR0 (0.13.0)"); odlMdsalVersionLUT.put("5.0.14","magnesium-SR2 (0.12.2)"); odlMdsalVersionLUT.put("5.0.10","magnesium-SR1 (0.12.1)"); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java index ac0ee92f1..5c1ea98b2 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java @@ -22,6 +22,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClientException; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet; @@ -74,11 +75,16 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable { public void init() throws Exception { LOG.info("Session Initiated start {}", APPLICATION_NAME); - - // Start RPC Service - this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet); - this.treeServlet.setDatabaseClient(this.rpcApiService.getRawClient()); - LOG.info("Session Initiated end. Initialization done"); + try { + // Start RPC Service + this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet); + this.treeServlet.setDatabaseClient(this.rpcApiService.getRawClient()); + LOG.info("Session Initiated end. Initialization done"); + } catch (Exception e) { + if (e instanceof HtDatabaseClientException) + LOG.error("IOException: Could not connect to the Database. Please check Database connectivity"); + throw e; + } } @Override diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java index 30819dca2..5ef7a0ad9 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java @@ -57,6 +57,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListInput; @@ -85,9 +87,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -165,7 +164,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readFaultcurrentList( ReadFaultcurrentListInput input) { - LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input); + LOG.debug("RPC Request: readFaultCurrentList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input)); return result.buildFuture(); @@ -173,7 +172,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readFaultlogList(ReadFaultlogListInput input) { - LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input); + LOG.debug("RPC Request: readFaultlogList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input)); return result.buildFuture(); @@ -181,7 +180,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readMaintenanceList(ReadMaintenanceListInput input) { - LOG.debug("RPC Request: getMaintenanceEntityList with input {}", input); + LOG.debug("RPC Request: readMaintenanceList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input)); return result.buildFuture(); @@ -190,7 +189,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readMediatorServerList( ReadMediatorServerListInput input) { - LOG.debug("RPC Request: getMediatorServerEntityList with input {}", input); + LOG.debug("RPC Request: readMediatorServerList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input)); return result.buildFuture(); @@ -199,7 +198,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readNetworkElementConnectionList( ReadNetworkElementConnectionListInput input) { - LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input); + LOG.debug("RPC Request: readNetworkElementConnectionList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input)); return result.buildFuture(); @@ -208,7 +207,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata15mList(ReadPmdata15mListInput input) { - LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input); + LOG.debug("RPC Request: readPmdata15mList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input)); return result.buildFuture(); @@ -217,7 +216,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata24hList(ReadPmdata24hListInput input) { - LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input); + LOG.debug("RPC Request: readPmdata24hList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input)); return result.buildFuture(); @@ -226,7 +225,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readStatus(ReadStatusInput input) { - LOG.debug("RPC Request: getStatusEntityList with input {}", input); + LOG.debug("RPC Request: readStatusEntityList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readStatus()); return result.buildFuture(); @@ -234,7 +233,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readInventoryList(ReadInventoryListInput input) { - LOG.debug("RPC Request: getInventoryEntityList with input {}", input); + LOG.debug("RPC Request: readInventoryList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readInventoryList(input)); return result.buildFuture(); @@ -243,7 +242,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata15mLtpList( ReadPmdata15mLtpListInput input) { - LOG.debug("RPC Request: readPmdataLtpList with input {}", input); + LOG.debug("RPC Request: readPmdata15mLtpList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input)); return result.buildFuture(); @@ -252,7 +251,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata15mDeviceList( ReadPmdata15mDeviceListInput input) { - LOG.debug("RPC Request: readPmdataDeviceList with input {}", input); + LOG.debug("RPC Request: readPmdata15mDeviceList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input)); return result.buildFuture(); @@ -261,7 +260,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata24hLtpList( ReadPmdata24hLtpListInput input) { - LOG.debug("RPC Request: readPmdataLtpList with input {}", input); + LOG.debug("RPC Request: readPmdata24hLtpList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input)); return result.buildFuture(); @@ -270,7 +269,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readPmdata24hDeviceList( ReadPmdata24hDeviceListInput input) { - LOG.debug("RPC Request: readPmdataDeviceList with input {}", input); + LOG.debug("RPC Request: readPmdata24hDeviceList with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input)); return result.buildFuture(); @@ -306,6 +305,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> deleteNetworkElementConnection( DeleteNetworkElementConnectionInput input) { + LOG.debug("RPC Request: deleteNetworkElementConnection with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input)); return result.buildFuture(); @@ -376,7 +376,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture> readGuiCutThroughEntry( ReadGuiCutThroughEntryInput input) { - LOG.debug("RPC Request: readGuiCutThroughEntry with input {}", input); + LOG.debug("RPC Request: getGuiCutThroughEntry with input {}", input); RpcResultBuilder result = read(() -> DataProviderServiceImpl.this.dataProvider.readGuiCutThroughEntry(input)); return result.buildFuture(); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/DateAndTimeBuilder.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/DateAndTimeBuilder.java deleted file mode 100644 index 628890018..000000000 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/DateAndTimeBuilder.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; - -public class DateAndTimeBuilder { - private final String _value; - - public DateAndTimeBuilder(String v) { - this._value = v; - } - - public DateAndTime build() { - return new DateAndTime(_value); - } -} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java index 0b1e7d520..e7580c69a 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java @@ -21,33 +21,15 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools; -import java.io.IOException; -import javax.annotation.Nullable; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value; -import com.fasterxml.jackson.databind.introspect.AnnotatedClass; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.mapperextensions.YangToolsBuilderAnnotationIntrospector; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.mapperextensions.YangToolsModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or @@ -56,182 +38,23 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types. */ public class YangToolsMapper extends ObjectMapper { + @SuppressWarnings("unused") private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class); private static final long serialVersionUID = 1L; - private static BundleContext context; public YangToolsMapper() { + this(new YangToolsBuilderAnnotationIntrospector()); + } + + protected YangToolsMapper(YangToolsBuilderAnnotationIntrospector yangToolsBuilderAnnotationIntrospector) { super(); + configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE); setSerializationInclusion(Include.NON_NULL); - setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector()); - SimpleModule dateAndTimeSerializerModule = new SimpleModule(); - dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer()); - registerModule(dateAndTimeSerializerModule); - Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper.class); - context = bundle != null ? bundle.getBundleContext() : null; - } - - @Override - public String writeValueAsString(Object value) throws JsonProcessingException { - // TODO Auto-generated method stub - return super.writeValueAsString(value); - } - - /** - * Get Builder object for yang tools interface. - * - * @param yang-tools base datatype - * @param clazz class with interface. - * @return builder for interface or null if not existing - */ - @SuppressWarnings("unchecked") - public @Nullable Builder getBuilder(Class clazz) { - String builder = clazz.getName() + "Builder"; - try { - Class clazzBuilder = findClass(builder); - return (Builder) clazzBuilder.newInstance(); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { - LOG.debug("Problem ", e); - return null; - } - } - - /** - * Callback for handling mapping failures. - * - * @return - */ - public int getMappingFailures() { - return 0; - } - - /** - * Provide mapping of string to attribute names, generated by yang-tools. "netconf-id" converted to "_netconfId" - * - * @param name with attribute name, not null or empty - * @return converted string or null if name was empty or null - */ - public @Nullable static String toCamelCaseAttributeName(final String name) { - if (name == null || name.isEmpty()) - return null; - - final StringBuilder ret = new StringBuilder(name.length()); - if (!name.startsWith("_")) - ret.append('_'); - int start = 0; - for (final String word : name.split("-")) { - if (!word.isEmpty()) { - if (start++ == 0) { - ret.append(Character.toLowerCase(word.charAt(0))); - } else { - ret.append(Character.toUpperCase(word.charAt(0))); - } - ret.append(word.substring(1)); - } - } - return ret.toString(); + enable(MapperFeature.USE_GETTERS_AS_SETTERS); + setAnnotationIntrospector(yangToolsBuilderAnnotationIntrospector); + registerModule(new YangToolsModule()); } - /** - * Adapted Builder callbacks - */ - private static class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector { - private static final long serialVersionUID = 1L; - - @Override - public Class findPOJOBuilder(AnnotatedClass ac) { - try { - String builder = null; - if (ac.getRawType().equals(Credentials.class)) { - builder = - "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder"; - //System.out.println(DataContainer.class.isAssignableFrom(ac.getRawType())); - //System.out.println(ChoiceIn.class.isAssignableFrom(ac.getRawType())); - - } else if (ac.getRawType().equals(DateAndTime.class)) { - builder = DateAndTimeBuilder.class.getName(); - } - - else { - if (ac.getRawType().isInterface()) { - builder = ac.getName() + "Builder"; - } - } - if (builder != null) { - //System.out.println("XX1: "+ac.getRawType()); - //System.out.println("XX2: "+builder); - //Class innerBuilder = Class.forName(builder); - Class innerBuilder = findClass(builder); - //System.out.println("Builder found: "+ innerBuilder); - return innerBuilder; - } - } catch (ClassNotFoundException e) { - // No problem .. try next - } - return super.findPOJOBuilder(ac); - } - - @Override - public Value findPOJOBuilderConfig(AnnotatedClass ac) { - if (ac.hasAnnotation(JsonPOJOBuilder.class)) { - return super.findPOJOBuilderConfig(ac); - } - return new JsonPOJOBuilder.Value("build", "set"); - } - } - - private static Class findClass(String name) throws ClassNotFoundException { - // Try to find in other bundles - if (context != null) { - //OSGi environment - for (Bundle b : context.getBundles()) { - try { - return b.loadClass(name); - } catch (ClassNotFoundException e) { - // No problem, this bundle doesn't have the class - } - } - throw new ClassNotFoundException("Can not find Class in OSGi context."); - } else { - return Class.forName(name); - } - // not found in any bundle - } - - public static class DateAndTimeBuilder { - - private final String _value; - - public DateAndTimeBuilder(String v) { - this._value = v; - } - - public DateAndTime build() { - return new DateAndTime(_value); - } - - } - public static class CustomDateAndTimeSerializer extends StdSerializer { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public CustomDateAndTimeSerializer() { - this(null); - } - - protected CustomDateAndTimeSerializer(Class t) { - super(t); - } - - @Override - public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeString(value.getValue()); - } - - } } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java index 8f05437c9..a19f114e3 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java @@ -21,31 +21,12 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value; -import com.fasterxml.jackson.databind.introspect.AnnotatedClass; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import javax.annotation.Nullable; import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.mapperextensions.YangToolsBuilderAnnotationIntrospector; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.TypeObject; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,17 +35,13 @@ import org.slf4j.LoggerFactory; * deserialization of DataObject to/from JSON TODO ChoiceIn and Credentials deserialization only for * LoginPasswordBuilder */ -public class YangToolsMapper2 extends ObjectMapper { +public class YangToolsMapper2 extends YangToolsMapper { private static final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class); private static final long serialVersionUID = 1L; - private static String BUILDER = "Builder"; - private @Nullable final Class clazz; private @Nullable final Class> builderClazz; - private BundleContext context; - /** * Generic Object creation of yangtools java class builder pattern. * @@ -77,32 +54,10 @@ public class YangToolsMapper2 extends ObjectMapper { */ public > YangToolsMapper2(@NonNull Class clazz, @Nullable Class builderClazz) throws ClassNotFoundException { - super(); - configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE); - setSerializationInclusion(Include.NON_NULL); - setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector()); - SimpleModule dateAndTimeSerializerModule = new SimpleModule(); - dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer()); - registerModule(dateAndTimeSerializerModule); - - SimpleModule pmDataTypeSerializerModule = new SimpleModule(); - pmDataTypeSerializerModule.addSerializer(PmDataType.class, new CustomPMDataTypeSerializer()); - registerModule(pmDataTypeSerializerModule); - Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class); + super(new YangToolsBuilderAnnotationIntrospector(clazz, builderClazz)); - this.clazz = clazz; - this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz)); - context = bundle != null ? bundle.getBundleContext() : null; - } - - public > YangToolsMapper2(@NonNull Class clazz) throws ClassNotFoundException { - this(clazz, null); - } - - @Override - public String writeValueAsString(Object value) throws JsonProcessingException { - return super.writeValueAsString(value); + this.builderClazz = + builderClazz != null ? builderClazz : getBuilderClass(YangToolsMapperHelper.getBuilderClassName(clazz)); } /** @@ -115,74 +70,18 @@ public class YangToolsMapper2 extends ObjectMapper { public @Nullable Builder getBuilder(Class clazz) { try { if (builderClazz != null) - return builderClazz.newInstance(); + return builderClazz.getDeclaredConstructor().newInstance(); else return null; - } catch (InstantiationException | IllegalAccessException e) { - LOG.debug("Problem ", e); - return null; - } - } - - /** - * Callback for handling mapping failures. - * - * @return - */ - public int getMappingFailures() { - return 0; - } - - /** - * Provide mapping of string to attribute names, generated by yang-tools. "netconf-id" converted to "_netconfId" - * - * @param name with attribute name, not null or empty - * @return converted string or null if name was empty or null - */ - public @Nullable static String toCamelCaseAttributeName(final String name) { - if (name == null || name.isEmpty()) + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { + LOG.warn("Problem intantiating Builder", e); return null; - - final StringBuilder ret = new StringBuilder(name.length()); - if (!name.startsWith("_")) - ret.append('_'); - int start = 0; - for (final String word : name.split("-")) { - if (!word.isEmpty()) { - if (start++ == 0) { - ret.append(Character.toLowerCase(word.charAt(0))); - } else { - ret.append(Character.toUpperCase(word.charAt(0))); - } - ret.append(word.substring(1)); - } } - return ret.toString(); - } - - /** - * Verify if builder is available - * - * @throws ClassNotFoundException - **/ - public Class assertBuilderClass(Class clazz) throws ClassNotFoundException { - return getBuilderClass(getBuilderClassName(clazz)); } // --- Private functions - /** - * Create name of builder class - * - * @param - * @param clazz - * @return builders class name - * @throws ClassNotFoundException - */ - private static String getBuilderClassName(Class clazz) { - return clazz.getName() + BUILDER; - } - /** * Search builder in context * @@ -192,128 +91,7 @@ public class YangToolsMapper2 extends ObjectMapper { */ @SuppressWarnings("unchecked") private > Class getBuilderClass(String name) throws ClassNotFoundException { - // Try to find in other bundles - if (context != null) { - //OSGi environment - for (Bundle b : context.getBundles()) { - LOG.info("Search in bundle: {}", b.getSymbolicName()); - try { - return (Class) b.loadClass(name); - } catch (ClassNotFoundException e) { - // No problem, this bundle doesn't have the class - } - } - throw new ClassNotFoundException("Can not find Class in OSGi context."); - } else { - return (Class) Class.forName(name); - } - // not found in any bundle - } - - // --- Classes - - /** - * Adapted Builder callbacks - */ - private class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector { - private static final long serialVersionUID = 1L; - - @Override - public Class findPOJOBuilder(AnnotatedClass ac) { - Class clazz2build = ac.getRawType(); - if (clazz2build.equals(Credentials.class)) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class; - - } else if (clazz2build.equals(DateAndTime.class)) { - return DateAndTimeBuilder.class; - // } else if (ac.getRawType().equals(PmDataType.class)) { - // LOG.info("Builder class"); - // return PMDataTypeBuilder.class; - } else if (clazz2build.equals(clazz)) { - return builderClazz; - } - - if (clazz2build.isInterface() || TypeObject.class.isAssignableFrom(clazz2build)) { - String builder = getBuilderClassName(clazz2build); - LOG.info("Search: {}", builder); - Class innerBuilder; - try { - innerBuilder = Class.forName(builder); - LOG.info("Found1: {}", innerBuilder); - return innerBuilder; - } catch (ClassNotFoundException e) { - LOG.info("Could not find {}", clazz2build); - // No problem .. try next - } - try { - innerBuilder = getBuilderClass(builder); - LOG.info("Found2: {}", innerBuilder); - return innerBuilder; - } catch (ClassNotFoundException e) { - LOG.info("Could not find {}", clazz2build); - // No problem .. try next - } - } - Class clazz = super.findPOJOBuilder(ac); - return clazz; - } - - @Override - public Value findPOJOBuilderConfig(AnnotatedClass ac) { - if (ac.hasAnnotation(JsonPOJOBuilder.class)) { - return super.findPOJOBuilderConfig(ac); - } - return new JsonPOJOBuilder.Value("build", "set"); - } - } - - public static class DateAndTimeBuilder { - - private final String _value; - - public DateAndTimeBuilder(String v) { - this._value = v; - } - - public DateAndTime build() { - return new DateAndTime(_value); - } - + return (Class) YangToolsMapperHelper.getBuilderClass(name); } - public static class CustomDateAndTimeSerializer extends StdSerializer<@NonNull DateAndTime> { - private static final long serialVersionUID = 1L; - - public CustomDateAndTimeSerializer() { - this(null); - } - - protected CustomDateAndTimeSerializer(Class t) { - super(t); - } - - @Override - public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeString(value.getValue()); - } - - } - public static class CustomPMDataTypeSerializer extends StdSerializer<@NonNull PmDataType> { - - private static final long serialVersionUID = 1L; - - public CustomPMDataTypeSerializer() { - this(null); - } - - protected CustomPMDataTypeSerializer(Class t) { - super(t); - } - - @Override - public void serialize(PmDataType value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeString(value.toString()); - } - - } } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapperHelper.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapperHelper.java new file mode 100644 index 000000000..a2afab0a8 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapperHelper.java @@ -0,0 +1,244 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools; + +import com.fasterxml.jackson.databind.DeserializationContext; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nullable; +import org.opendaylight.yangtools.concepts.Builder; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class YangToolsMapperHelper { + + private static final Logger LOG = LoggerFactory.getLogger(YangToolsMapperHelper.class); + private static final String TYPEOBJECT_INSTANCE_METHOD = "getDefaultInstance"; + private static final String BUILDER = "Builder"; + + private static BundleContext context = getBundleContext(); + private static ConcurrentHashMap> cache = new ConcurrentHashMap<>(); + + private YangToolsMapperHelper() { + //Make unaccessible + } + + public static Class findClass(String name) throws ClassNotFoundException { + + //Try first in cache + Class res = cache.get(name); + if (res != null) { + return res; + } + //Try first in actual bundle + try { + return loadClass(null, name); + } catch (ClassNotFoundException e) { + // No problem, this bundle doesn't have the class + } + // Try to find in other bundles + if (context != null) { + //OSGi environment + for (Bundle b : context.getBundles()) { + try { + return loadClass(b, name); + } catch (ClassNotFoundException e) { + // No problem, this bundle doesn't have the class + } + } + } + // really not found in any bundle + throw new ClassNotFoundException("Can not find class '"+name+"'"); + } + + private static Class loadClass(Bundle b, String name) throws ClassNotFoundException { + Class res = b == null ? Class.forName(name) : b.loadClass(name); + cache.put(name, res); + return res; + } + + /** + * Verify if builder is available + * + * @throws ClassNotFoundException + **/ + public static Class assertBuilderClass(Class clazz) throws ClassNotFoundException { + return getBuilderClass(getBuilderClassName(clazz)); + } + + public static Class getBuilderClass(String name) throws ClassNotFoundException { + return findClass(name); + } + + public static Class getBuilderClass(Class clazz) throws ClassNotFoundException { + return findClass(getBuilderClassName(clazz)); + } + + /** + * Create name of builder class + * + * @param + * @param clazz + * @return builders class name + * @throws ClassNotFoundException + */ + public static String getBuilderClassName(Class clazz) { + return clazz.getName() + BUILDER; + } + + @SuppressWarnings("unchecked") + public static > Class findBuilderClass(DeserializationContext ctxt, Class clazz) throws ClassNotFoundException { + return (Class) findClass(getBuilderClassName(clazz)); + } + + public static > Optional> findBuilderClassOptional(DeserializationContext ctxt, Class clazz) { + try { + return Optional.of(findBuilderClass(ctxt, clazz)); + } catch (ClassNotFoundException e) { + return Optional.empty(); + } + } + + public static boolean hasClassDeclaredMethod(Class clazz, String name) { + Method[] methods = clazz.getDeclaredMethods(); + for (Method m : methods) { + if (m.getName().equals(name)) { + return true; + } + } + return false; + } + + @SuppressWarnings("unchecked") + public static Optional getInstanceByConstructor(Class clazz, String arg) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + List> ctypes = getConstructorParameterTypes(clazz, String.class); + Optional oObj; + for (Class ctype : ctypes) { + if (ctype.equals(String.class)) { + return Optional.of((T) clazz.getConstructor(ctype).newInstance(arg)); + } else if ((oObj = getDefaultInstance(ctype, arg)).isPresent()) { + return Optional.of((T) clazz.getConstructor(ctype).newInstance(oObj.get())); + } else { + // TODO: recursive instantiation down to string constructor or + // getDefaultInstance method + LOG.debug("Not implemented arg:'{}' class:'{}'", arg, clazz); + } + } + return Optional.empty(); + } + + @SuppressWarnings("unchecked") + public static Optional getDefaultInstance(@Nullable Class clazz, String arg) + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException { + LOG.trace("arg:'{}' clazz '{}'", arg, clazz.getName()); + if (clazz != null) { + Method[] methods = clazz.getDeclaredMethods(); + for (Method m : methods) { + //TODO Verify argument type to avoid exception + if (m.getName().equals(TYPEOBJECT_INSTANCE_METHOD)) { + Method method = clazz.getDeclaredMethod(TYPEOBJECT_INSTANCE_METHOD, String.class); + LOG.trace("Invoke {} available {}",TYPEOBJECT_INSTANCE_METHOD, method != null); + return Optional.of((T) method.invoke(null, arg)); + } + } + } + return Optional.empty(); + } + + public static Optional getDefaultInstance(Optional> optionalClazz, String arg) + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException { + if (optionalClazz.isPresent()) { + return getDefaultInstance(optionalClazz.get(), arg); + } + return Optional.empty(); + } + + public static List> getConstructorParameterTypes(Class clazz, Class prefer) { + + Constructor[] constructors = clazz.getConstructors(); + List> res = new ArrayList<>(); + for (Constructor c : constructors) { + Class[] ptypes = c.getParameterTypes(); + if (ptypes.length == 1) { + res.add(ptypes[0]); + } + + if (prefer != null && ptypes.length == 1 && ptypes[0].equals(prefer)) { + return Arrays.asList(prefer); + } + } + return res; + } + + public static boolean implementsInterface(Class clz, Class ifToImplement) { + Class[] ifs = clz.getInterfaces(); + for (Class iff : ifs) { + if (iff.equals(ifToImplement)) { + return true; + } + } + return false; + } + + /** + * Provide mapping of string to attribute names, generated by yang-tools. "netconf-id" converted to "_netconfId" + * + * @param name with attribute name, not null or empty + * @return converted string or null if name was empty or null + */ + public @Nullable static String toCamelCaseAttributeName(final String name) { + if (name == null || name.isEmpty()) + return null; + + final StringBuilder ret = new StringBuilder(name.length()); + if (!name.startsWith("_")) + ret.append('_'); + int start = 0; + for (final String word : name.split("-")) { + if (!word.isEmpty()) { + if (start++ == 0) { + ret.append(Character.toLowerCase(word.charAt(0))); + } else { + ret.append(Character.toUpperCase(word.charAt(0))); + } + ret.append(word.substring(1)); + } + } + return ret.toString(); + } + + private static BundleContext getBundleContext() { + Bundle bundle = FrameworkUtil.getBundle(YangToolsMapperHelper.class); + return bundle != null ? bundle.getBundleContext() : null; + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/builder/DateAndTimeBuilder.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/builder/DateAndTimeBuilder.java new file mode 100644 index 000000000..8dbaf4ab9 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/builder/DateAndTimeBuilder.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.builder; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; + +public class DateAndTimeBuilder { + private final String _value; + + public DateAndTimeBuilder(String v) { + this._value = v; + } + + public DateAndTime build() { + return new DateAndTime(_value); + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsBuilderAnnotationIntrospector.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsBuilderAnnotationIntrospector.java new file mode 100644 index 000000000..0a119e0a7 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsBuilderAnnotationIntrospector.java @@ -0,0 +1,130 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.mapperextensions; + +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value; +import com.fasterxml.jackson.databind.cfg.MapperConfig; +import com.fasterxml.jackson.databind.introspect.AnnotatedClass; +import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; +import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import java.math.BigInteger; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.builder.DateAndTimeBuilder; +//import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.builders.rev201110.read.network.element.connection.list.output.DataBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector { + + private static final Logger LOG = LoggerFactory.getLogger(YangToolsBuilderAnnotationIntrospector.class); + private static final long serialVersionUID = 1L; + + private final Map, String> customDeserializer; + + public YangToolsBuilderAnnotationIntrospector() { + this(null, null); + } + + public YangToolsBuilderAnnotationIntrospector(Class cls, Class builderClass) { + this.customDeserializer = new HashMap<>(); + if (cls != null && builderClass != null) { + this.customDeserializer.put(cls, builderClass.getName()); + } + this.customDeserializer.put(DateAndTime.class, DateAndTimeBuilder.class.getName()); + this.customDeserializer.put(Credentials.class, LoginPasswordBuilder.class.getName()); + } + + @Override + public Class findPOJOBuilder(AnnotatedClass ac) { + try { + String builder = null; + if (this.customDeserializer.containsKey(ac.getRawType())) { + builder = this.customDeserializer.get(ac.getRawType()); + } else { + if (ac.getRawType().isInterface()) { + builder = ac.getName() + "Builder"; + } + } + if (builder != null) { + LOG.trace("map {} with builder {}", ac.getName(), builder); + Class innerBuilder = YangToolsMapperHelper.findClass(builder); + return innerBuilder; + } + } catch (ClassNotFoundException e) { + LOG.trace("builder class not found for {}", ac.getName()); + } + return super.findPOJOBuilder(ac); + } + + @Override + public Value findPOJOBuilderConfig(AnnotatedClass ac) { + if (ac.hasAnnotation(JsonPOJOBuilder.class)) { + return super.findPOJOBuilderConfig(ac); + } + return new JsonPOJOBuilder.Value("build", "set"); + } + + @Override + public AnnotatedMethod resolveSetterConflict(MapperConfig config, AnnotatedMethod setter1, + AnnotatedMethod setter2) { + Class p1 = setter1.getRawParameterType(0); + Class p2 = setter2.getRawParameterType(0); + AnnotatedMethod res = null; + + if (this.isAssignable(p1, p2, Map.class, List.class)) { + res = p1.isAssignableFrom(List.class) ? setter1 : setter2; //prefer List setter + } else if (this.isAssignable(p1, p2, Uint64.class, BigInteger.class)) { + res = setter1; + } else if (this.isAssignable(p1, p2, Uint32.class, Long.class)) { + res = setter1; + } else if (this.isAssignable(p1, p2, Uint16.class, Integer.class)) { + res = setter1; + } else if (this.isAssignable(p1, p2, Uint8.class, Short.class)) { + res = setter1; + } + if (res == null) { + res = super.resolveSetterConflict(config, setter1, setter2); + } + LOG.debug("{} (m1={} <=> m2={} => result:{})", setter1.getName(), p1.getSimpleName(), p2.getSimpleName(), + res.getRawParameterType(0).getSimpleName()); + + return res; + } + + private boolean isAssignable(Class p1, Class p2, Class c1, Class c2) { + return ((p1.isAssignableFrom(c1) && p2.isAssignableFrom(c2)) + || (p2.isAssignableFrom(c1) && p1.isAssignableFrom(c2))); + + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsDeserializerModifier.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsDeserializerModifier.java new file mode 100644 index 000000000..634a3bc5b --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsDeserializerModifier.java @@ -0,0 +1,117 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.mapperextensions; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.BeanDescription; +import com.fasterxml.jackson.databind.DeserializationConfig; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.KeyDeserializer; +import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.NoSuchElementException; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.ScalarTypeObject; +//import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.ScalarTypeObject; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.BaseIdentityDeserializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.ClassDeserializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.IdentifierDeserializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.TypeObjectDeserializer; +import org.opendaylight.yangtools.yang.binding.BaseIdentity; +import org.opendaylight.yangtools.yang.binding.Identifier; +import org.opendaylight.yangtools.yang.binding.TypeObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class YangToolsDeserializerModifier extends BeanDeserializerModifier { + + private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier.class); + private static final String getEnumMethodName="valueOf"; + + @Override + public JsonDeserializer> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, + BeanDescription beanDesc, final JsonDeserializer deserializer) { + return new JsonDeserializer>() { + + @Override + public Enum deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { + Class clazz = type.getRawClass(); + + try { + Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class); + Enum result = (Enum) method.invoke(null, jp.getValueAsString()); + LOG.debug("Deserialize '{}' with class '{}' to '{}'", jp.getValueAsString(), clazz.getName(), result); + return result; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | NoSuchElementException | SecurityException e) { + LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(), + jp.getValueAsString(), e); + } + throw new IOException( + "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString()); + } + }; + } + + @Override + public JsonDeserializer modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, + JsonDeserializer deserializer) { + final JavaType type = beanDesc.getType(); + final Class rawClass = type.getRawClass(); + + JsonDeserializer deser = super.modifyDeserializer(config, beanDesc, deserializer); + + if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) { + deser = new TypeObjectDeserializer(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, YangHelper2.getScalarTypeObjectClass())) { + deser = new TypeObjectDeserializer(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) { + deser = new BaseIdentityDeserializer(deser); + } else if (rawClass.equals(Class.class)) { + deser = new ClassDeserializer(rawClass); + } + + LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName()); + return deser; + } + + @Override + public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) { + KeyDeserializer res; + if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) { + res = new IdentifierDeserializer(); + } else { + res = super.modifyKeyDeserializer(config, type, deser); + } + LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName()); + return res; + } + + void test() { + com.fasterxml.jackson.databind.util.ClassUtil xy; + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsModule.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsModule.java new file mode 100644 index 000000000..46f69d4f9 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/mapperextensions/YangToolsModule.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.mapperextensions; + +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.DateAndTimeSerializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.EnumSerializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.IdentifierDeserializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.MapSerializer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.serialize.TypeObjectSerializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementKey; +import org.opendaylight.yangtools.yang.binding.TypeObject; + +public class YangToolsModule extends SimpleModule { + + private static final long serialVersionUID = 1L; + + public YangToolsModule() { + super(); + setDeserializerModifier(new YangToolsDeserializerModifier()); + + addKeyDeserializer(MeasurementKey.class, new IdentifierDeserializer()); + addSerializer(DateAndTime.class, new DateAndTimeSerializer()); + addSerializer(TypeObject.class, new TypeObjectSerializer()); + addSerializer(Enum.class, new EnumSerializer()); + addSerializer(Map.class, new MapSerializer()); + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/BaseIdentityDeserializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/BaseIdentityDeserializer.java new file mode 100644 index 000000000..10f18e796 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/BaseIdentityDeserializer.java @@ -0,0 +1,64 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BaseIdentityDeserializer extends JsonDeserializer { + + private static final Logger LOG = LoggerFactory.getLogger(BaseIdentityDeserializer.class); + private final JsonDeserializer deser; + + public BaseIdentityDeserializer(final JsonDeserializer deser) { + this.deser = deser; + } + + @SuppressWarnings("unchecked") + @Override + public T deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { + LOG.debug("BaseIdentityDeserializer class for '{}'",parser.getValueAsString()); + String clazzToSearch = parser.getValueAsString(); + // clazz from Elasticsearch is full qualified + int lastDot = clazzToSearch.lastIndexOf("."); + if (lastDot > -1) { + clazzToSearch = clazzToSearch.substring(lastDot+1); + } else { + clazzToSearch = clazzToSearch.substring(0, 1).toUpperCase() + clazzToSearch.substring(1); + } + Class clazz; + try { + clazz = YangToolsMapperHelper.findClass(clazzToSearch); + if (clazz != null) + return (T)clazz; + } catch (ClassNotFoundException e) { + LOG.warn("BaseIdentityDeserializer class not found for '"+parser.getValueAsString()+"'",e); + } + return (T) deser.deserialize(parser, ctxt); + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/ClassDeserializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/ClassDeserializer.java new file mode 100644 index 000000000..2627c2ae0 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/ClassDeserializer.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer; +import java.io.IOException; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; + +public class ClassDeserializer extends FromStringDeserializer> { + + private static final long serialVersionUID = 1L; + + public ClassDeserializer(Class vc) { + super(vc); + } + + @Override + protected Class _deserialize(String value, DeserializationContext ctxt) throws IOException { + try { + return YangToolsMapperHelper.findClass(value); + } catch (ClassNotFoundException e) { + throw new IOException("Can not find class "+value,e); + } + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/DateAndTimeSerializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/DateAndTimeSerializer.java new file mode 100644 index 000000000..a35aad75a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/DateAndTimeSerializer.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; + +/** + * DateAndTime shouldn't be encapsulated into a json object to be able to use elasticsearch date time query functions. + */ +public class DateAndTimeSerializer extends StdSerializer<@NonNull DateAndTime> { + + private static final long serialVersionUID = 1L; + + public DateAndTimeSerializer() { + this(null); + } + + protected DateAndTimeSerializer(Class t) { + super(t); + } + + @Override + public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(value.getValue()); + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/EnumSerializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/EnumSerializer.java new file mode 100644 index 000000000..f8220c2d4 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/EnumSerializer.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; + +@SuppressWarnings("rawtypes") +public class EnumSerializer extends JsonSerializer { + + @Override + public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(value.name()); + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/IdentifierDeserializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/IdentifierDeserializer.java new file mode 100644 index 000000000..0837b8a19 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/IdentifierDeserializer.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IdentifierDeserializer extends KeyDeserializer { + + private static final Logger LOG = LoggerFactory.getLogger(IdentifierDeserializer.class); + + public IdentifierDeserializer() {} + + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException { + Class clazz = ctxt.getClass(); + final String arg = key; + LOG.debug("Deserialization for key:{}",key); + // find constructor argument types + List> ctypes = YangToolsMapperHelper.getConstructorParameterTypes(clazz, String.class); + for (Class ctype : ctypes) { + try { + if (ctype.equals(String.class)) { + return clazz.getConstructor(ctype).newInstance(arg); + } else if (ctype.equals(Uint16.class)) { + return clazz.getConstructor(ctype).newInstance(Uint16.valueOf(arg)); + + } else if (ctype.equals(Uint32.class)) { + return clazz.getConstructor(ctype).newInstance(Uint32.valueOf(arg)); + } else if (ctype.equals(Uint64.class)) { + return clazz.getConstructor(ctype).newInstance(Uint64.valueOf(arg)); + } + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { + LOG.warn("unable to instantiate class {} with arg {}: ", clazz, arg, e); + throw new IllegalArgumentException( + "unable to instantiate class " + clazz.getName() + " with arg '" + arg + "' ", e); + } + } + return null; + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/MapSerializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/MapSerializer.java new file mode 100644 index 000000000..e5c966a74 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/MapSerializer.java @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.util.Map; + +@SuppressWarnings("rawtypes") +public class MapSerializer extends JsonSerializer { + + @Override + public void serialize(Map value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeObject(value.values()); + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectDeserializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectDeserializer.java new file mode 100644 index 000000000..5beca0d47 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectDeserializer.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.NoSuchElementException; +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; +import org.opendaylight.yangtools.concepts.Builder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TypeObjectDeserializer extends JsonDeserializer { + + private static final Logger LOG = LoggerFactory.getLogger(TypeObjectDeserializer.class); + private final JavaType type; + private final JsonDeserializer deser; + + + public TypeObjectDeserializer(final JavaType type, final JsonDeserializer deser) { + this.type = type; + this.deser = deser; + } + + @SuppressWarnings("unchecked") + @Override + public T deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { + + Class clazz = (Class) type.getRawClass(); + final String arg = parser.getValueAsString(); + LOG.debug("Try to build arg:'{}' with class {}",arg, clazz); + Optional oRes = Optional.empty(); + try { + //try get method for default instance + if ((oRes = YangToolsMapperHelper.getDefaultInstance(clazz, arg)).isEmpty()) { + //try to find builder with getDefaultInstance method + Optional>> oBuilderClazz = YangToolsMapperHelper.findBuilderClassOptional(ctxt, clazz); + LOG.debug("Try builder class present:{}",oBuilderClazz.isPresent()); + if (oBuilderClazz.isEmpty() + || ((oRes = YangToolsMapperHelper.getDefaultInstance(oBuilderClazz.get(), arg)).isEmpty())) { + //try to find constructor with string + LOG.debug("Try constructor"); + if ((oRes = YangToolsMapperHelper.getInstanceByConstructor(clazz, arg)).isEmpty()) { + //forward to standard deserializer or throw if not available + LOG.debug("Try default deserializer"); + oRes = Optional.of((T) deser.deserialize(parser, ctxt)); + } + } + } + LOG.debug("Deserialize string value:{} for class:{} success:{}", arg, clazz, oRes.isPresent()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException + | NoSuchElementException | SecurityException | InstantiationException e) { + LOG.warn("problem deserializing {} with value {}: {}", clazz.getName(), arg, e); + } + if (oRes.isPresent()) { + return oRes.get(); + } else { + throw new IllegalArgumentException("Could not find constructor for arg:'" + arg + "' and class: " + clazz); + } + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectSerializer.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectSerializer.java new file mode 100644 index 000000000..1269d0746 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/serialize/TypeObjectSerializer.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.yangtools.serialize; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.opendaylight.yangtools.yang.binding.TypeObject; + +public class TypeObjectSerializer extends JsonSerializer { + + @Override + public void serialize(TypeObject value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + //stringValue + Method[] methods = value.getClass().getDeclaredMethods(); + String name; + for (Method method : methods) { + name = method.getName(); + if (name.equals("stringValue") || name.equals("getValue")) { + try { + gen.writeString((String)method.invoke(value)); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | IOException e) { + throw new IOException("No String getter method supported TypeObject for "+value.getClass(),e); + } + } + } + } +} diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java index 92ac04702..624451ca7 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java @@ -21,6 +21,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -31,6 +32,8 @@ import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.jline.utils.Log; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -103,7 +106,12 @@ public class TestAbout { assertTrue(printOut.getByteArrayOutputStream().size() > 0); } - + @Test + public void testGetGroupId() { + AboutHelperServlet sv = new AboutHelperServlet(); + assertNotNull(sv.getGroupIdOrDefault(null)); + } + private class AboutHelperServlet extends AboutHttpServlet { @@ -116,6 +124,16 @@ public class TestAbout { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); } - + @Override + public String getGroupIdOrDefault(String def) { + return super.getGroupIdOrDefault(def); + } + @Override + protected String getManifestValue(String key) { + if(key == "Bundle-SymbolicName") { + return "org.onap.ccsdk.features.sdnr.wt.sdnr-wt-data-provider-provider"; + } + return super.getManifestValue(key); + } } } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java index 5f78999d0..b7a4db51b 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java @@ -42,7 +42,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest; import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper2; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInputBuilder; @@ -61,7 +61,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultlog; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInputBuilder; @@ -306,7 +306,7 @@ public class TestCRUDforDatabase { CreateNetworkElementConnectionOutputBuilder create = null; CreateNetworkElementConnectionInput input = new CreateNetworkElementConnectionInputBuilder().setNodeId(name) - .setIsRequired(true).setHost(url).setPort(port).build(); + .setIsRequired(true).setHost(url).setPort(YangHelper2.getLongOrUint32(port)).build(); String dbId = null; try { @@ -342,7 +342,7 @@ public class TestCRUDforDatabase { final long port2 = 5960; UpdateNetworkElementConnectionInput updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId) - .setHost(url2).setPort(port2).setIsRequired(false).build(); + .setHost(url2).setPort(YangHelper2.getLongOrUint32(port2)).setIsRequired(false).build(); UpdateNetworkElementConnectionOutputBuilder updateOutput = null; try { updateOutput = dbProvider.updateNetworkElementConnection(updateInput); @@ -1363,18 +1363,20 @@ public class TestCRUDforDatabase { + "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultlog\",\n" + "\"source-type\": \"Netconf\",\n" + "\"node-id\": \"sim4\",\n" + "\"problem\": \"signalIsLost\"\n" + "}"; - YangToolsMapper2 yangtoolsMapper = new YangToolsMapper2<>(Faultlog.class,null); - FaultlogEntity log = yangtoolsMapper.readValue(jsonString, Faultlog.class); - System.out.println(log); - System.out.println(yangtoolsMapper.writeValueAsString(log)); + YangToolsMapper yangtoolsMapper = new YangToolsMapper(); + Faultlog log = yangtoolsMapper.readValue(jsonString, Faultlog.class); + System.out.println(yangtoolsMapper.writeValueAsString((new FaultlogBuilder(log).build()))); + System.out.println("Check3"); } catch (IOException e) { - fail(e.getMessage()); + e.printStackTrace(); + fail("Fail"); } } private Pagination getPagination(long pageSize, int page) { - return new PaginationBuilder().setPage(BigInteger.valueOf(page)).setSize(pageSize).build(); + return new PaginationBuilder().setPage(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(page))) + .setSize(YangHelper2.getLongOrUint32(pageSize)).build(); } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java index 6584d0503..eaaa31107 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java @@ -21,9 +21,10 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; +import static org.junit.Assert.fail; import java.io.IOException; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data; public class TestDataMappings { @@ -35,7 +36,7 @@ public class TestDataMappings { + "\"layer-protocol-name\": \"MWPS\",\n" + "\"radio-signal-id\": \"Test11\",\n" + "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n" - + "\"granularity-period\": \"PERIOD_15MIN\",\n" + + "\"granularity-period\": \"Period15Min\",\n" + "\"scanner-id\": \"PM_RADIO_15M_9\",\n" + "\"performance-data\": {\n" + "\"es\": 0,\n" @@ -84,14 +85,15 @@ public class TestDataMappings { + "}"; // @formatter:on @Test - public void testPmData15m() { + public void testPmData15m() throws ClassNotFoundException { - YangToolsMapper mapper = new YangToolsMapper(); + YangToolsMapper2 mapper = new YangToolsMapper2(Data.class, null); try { Data data = mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class); System.out.println(data); } catch (IOException e) { e.printStackTrace(); + fail("Can not parse data"); } } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java index 95abfdd58..7e63c183c 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java @@ -40,6 +40,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryReq import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity.HtDatabaseEventsService; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus; @@ -281,7 +282,7 @@ public class TestEventService { * @return */ private static NetworkElementConnectionEntity createNeConnection(String nodeId, NetworkElementDeviceType devType) { - return new NetworkElementConnectionBuilder().setNodeId(nodeId).setHost("host").setPort(1234L) + return new NetworkElementConnectionBuilder().setNodeId(nodeId).setHost("host").setPort(YangHelper2.getLongOrUint32(1234L)) .setCoreModelCapability("123").setStatus(ConnectionLogStatus.Connected).setDeviceType(devType) .setIsRequired(true).build(); } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java index 294dd436f..53c72115d 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Arrays; import java.util.concurrent.TimeUnit; import org.apache.sshd.common.util.io.IoUtils; @@ -43,12 +42,9 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataTreeProviderImpl; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; -/** - * @author Michael Dürre - * - */ public class TestTree { + private static String resourceDirectoryPath="/"+TestTree.class.getSimpleName()+"/"; private static ElasticSearchDataProvider dbProvider; private static HtDatabaseClient dbRawProvider; @@ -65,38 +61,29 @@ public class TestTree { } private static void fillTestData() throws IOException { - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.5", getFileContent("/testequipment/1.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.7.0", getFileContent("/testequipment/2.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.55.1.2", getFileContent("/testequipment/3.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.65.1.2", getFileContent("/testequipment/4.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/SHELF-1.1.0.0", getFileContent("/testequipment/5.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.5", getFileContent("/testequipment/6.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.8", getFileContent("/testequipment/7.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.6.5", getFileContent("/testequipment/8.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/ODU-1.56.0.0", getFileContent("/testequipment/9.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.56.1.2", getFileContent("/testequipment/10.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.65.0.0", getFileContent("/testequipment/11.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.65.1.4", getFileContent("/testequipment/12.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.6.0", getFileContent("/testequipment/13.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.8.0", getFileContent("/testequipment/14.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.9.0", getFileContent("/testequipment/15.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.55.1.4", getFileContent("/testequipment/16.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.7", getFileContent("/testequipment/17.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.55.0.0", getFileContent("/testequipment/18.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.1.0", getFileContent("/testequipment/19.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.5.0", getFileContent("/testequipment/20.json")); - dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.6", getFileContent("/testequipment/21.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.5", getFileContent("1.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.7.0", getFileContent("2.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.55.1.2", getFileContent("3.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.65.1.2", getFileContent("4.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/SHELF-1.1.0.0", getFileContent("5.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.5", getFileContent("6.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.8", getFileContent("7.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.6.5", getFileContent("8.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/ODU-1.56.0.0", getFileContent("9.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.56.1.2", getFileContent("10.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.65.0.0", getFileContent("11.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.65.1.4", getFileContent("12.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.6.0", getFileContent("13.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.8.0", getFileContent("14.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.9.0", getFileContent("15.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.55.1.4", getFileContent("16.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.7", getFileContent("17.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.55.0.0", getFileContent("18.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.1.0", getFileContent("19.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.5.0", getFileContent("20.json")); + dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.6", getFileContent("21.json")); } - /** - * @param string - * @return - * @throws URISyntaxException - * @throws IOException - */ - private static String getFileContent(String filename) throws IOException { - return String.join("\n",IoUtils.readAllLines(TestTree.class.getResourceAsStream(filename))); - } @Test public void testInventoryTree() throws IOException { @@ -148,4 +135,8 @@ public class TestTree { e = DataTreeHttpServlet.getEntity("/tree/read-inventoryequipment-tree/"); System.out.println(e); } + + private static String getFileContent(String filename) throws IOException { + return String.join("\n",IoUtils.readAllLines(TestTree.class.getResourceAsStream(resourceDirectoryPath+filename))); + } } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java index f7ab7c383..3c9d4946b 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java @@ -28,6 +28,7 @@ import java.util.List; import org.eclipse.jdt.annotation.Nullable; import org.json.JSONObject; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; @@ -37,7 +38,9 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteIndexRequest; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapperHelper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; @@ -284,8 +287,8 @@ public class TestYangGenSalMapping { ReadPmdata15mListInputBuilder inputBuilder = new ReadPmdata15mListInputBuilder(); PaginationBuilder paginationBuilder = new PaginationBuilder(); - paginationBuilder.setPage(new BigInteger("1")); - paginationBuilder.setSize(20L); + paginationBuilder.setPage(YangHelper2.getBigIntegerOrUint64(new BigInteger("1"))); + paginationBuilder.setSize(YangHelper2.getLongOrUint32(20L)); inputBuilder.setPagination(paginationBuilder.build()); ReadPmdata15mListInput input = inputBuilder.build(); @@ -295,8 +298,8 @@ public class TestYangGenSalMapping { long page = getPage(input); long pageSize = getPageSize(input); - QueryBuilder query = fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize); - setSortOrder(query, input.getSortorder()); + QueryBuilder query = fromFilter(YangHelper.getList(input.getFilter())).from((page - 1) * pageSize).size(pageSize); + setSortOrder(query, YangHelper.getList(input.getSortorder())); SearchResult result = pm15mRW.doReadAll(query); @@ -337,15 +340,15 @@ public class TestYangGenSalMapping { out(method()); String input; input = "id-dd-dd"; - System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input)); + System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input)); input = "idDdGg"; - System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input)); + System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input)); input = "_idDdGg"; - System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input)); + System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input)); input = "--ff--gfg"; - System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input)); + System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input)); input = ""; - System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input)); + System.out.println("Map " + input + " to " + YangToolsMapperHelper.toCamelCaseAttributeName(input)); } /* --------------------------------- @@ -361,7 +364,7 @@ public class TestYangGenSalMapping { org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.DataBuilder dataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.DataBuilder(); dataBuilder.setDescription(description); - dataBuilder.setTreeLevel(treeLevel); + dataBuilder.setTreeLevel(YangHelper2.getLongOrUint32(treeLevel)); return dataBuilder; } @@ -429,8 +432,8 @@ public class TestYangGenSalMapping { long totalSize) { org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Pagination value = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.PaginationBuilder() - .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize)) - .build(); + .setPage(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(page))).setSize(YangHelper2.getLongOrUint32(pageSize)) + .setTotal(YangHelper2.getBigIntegerOrUint64(BigInteger.valueOf(totalSize))).build(); outputBuilder.setPagination(value); } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java index 0a195e03b..56df62819 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java @@ -21,47 +21,130 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Arrays; +import java.util.Map; +import org.apache.sshd.common.util.io.IoUtils; +import org.eclipse.jdt.annotation.Nullable; import org.jline.utils.Log; import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper2; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataTypeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.BIPErrorCounter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementKey; +import org.opendaylight.yangtools.yang.common.Uint64; -public class TestYangGenSalMappingOpenRoadm { +public class TestYangGenSalMappingOpenRoadm extends Mockito { + + private static String resourceDirectoryPath = "/" + TestYangGenSalMappingOpenRoadm.class.getSimpleName() + "/"; @Test - public void testOpenroadmPM() throws IOException, ClassNotFoundException { - out(method()); - // @formatter:off - String jsonString = "{\n" - + " \"time-stamp\":\"2020-09-24T22:59:48.6Z\", \n" - + " \"node-name\":\"Rdm-1\",\n" - + " \"uuid-interface\":\"physical-link\",\n" - + " \"scanner-id\":\"ryyyyyyyryryr\",\n" - + " \"granularity-period\":\"Period24Hours\",\n" - + " \"performance-data\":{\n" - + " \"measurement\":[{\n" - + " \"pm-value\":{\"uint64\":1464170942461338033},\n" - + " \"pm-key\":\"org.opendaylight" - + ".yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin\"\n" - + " }]\n" - + " }\n" - + "}\n"; - // @formatter:on - // Map to JSON String to Object - PmDataTypeBuilder builder = new PmDataTypeBuilder(); - builder.setInt64("10"); - PmDataType pmDataType = builder.build(); - out("Result is: "+pmDataType); - - YangToolsMapper2 mapper2 = new YangToolsMapper2<>(PmdataEntity.class, null); - out("Created mapper"); + public void testOpenroadmPMBuilder() throws IOException, ClassNotFoundException { + out("Test: " + method()); + + MeasurementBuilder measurementBuilder1 = new MeasurementBuilder(); + measurementBuilder1.setPmKey(OpticalPowerInputOSCMin.class); + measurementBuilder1.setPmValue(new PmDataType(Uint64.valueOf(64L))); + Measurement measurement1 = measurementBuilder1.build(); + + MeasurementBuilder measurementBuilder2 = new MeasurementBuilder(); + measurementBuilder2.setPmKey(BIPErrorCounter.class); + measurementBuilder2.setPmValue(new PmDataType(Uint64.valueOf(65L))); + Measurement measurement2 = measurementBuilder2.build(); + + PerformanceDataBuilder performanceDataBuilder = new PerformanceDataBuilder(); + performanceDataBuilder.setMeasurement( + YangHelper2.getListOrMap(MeasurementKey.class, Arrays.asList(measurement1, measurement2))); + + PmdataEntityBuilder pmDataEntitybuilder = new PmdataEntityBuilder(); + pmDataEntitybuilder.setPerformanceData(performanceDataBuilder.build()); + + PmdataEntity pmDataType = pmDataEntitybuilder.build(); + + YangToolsMapper mapper2 = new YangToolsMapper(); + String jsonString = mapper2.writeValueAsString(pmDataType); + out("Result json after mapping: " + jsonString); + PmdataEntity generatepmdNode = mapper2.readValue(jsonString.getBytes(), PmdataEntity.class); + out("Original: " + pmDataType.toString()); + out("Mapped : " + generatepmdNode.toString()); + assertTrue("Can mapping not working", generatepmdNode.equals(pmDataType)); + } + + @Test + public void testOpenroadmPMString1() throws IOException, ClassNotFoundException { + out("Test: " + method()); + String jsonString2 = getFileContent("pmdata1.json"); + YangToolsMapper mapper2 = new YangToolsMapper(); + PmdataEntity generatepmdNode = mapper2.readValue(jsonString2.getBytes(), PmdataEntity.class); + out("String1:"+generatepmdNode.toString()); // Print it with specified indentation + assertTrue("GranularityPeriod", generatepmdNode.getGranularityPeriod().equals(GranularityPeriodType.Period15Min)); + assertTrue("NodeName", generatepmdNode.getNodeName().equals("NTS_RDM2")); + @Nullable PerformanceData performanceData = generatepmdNode.getPerformanceData(); + assertNotNull("PerformanceData", performanceData); + @Nullable Map measurement = performanceData.getMeasurement(); + assertNotNull("Measurement", measurement); + Measurement measurement1 = measurement.get(new MeasurementKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin.class)); + assertTrue("Measurement=64", measurement1.getPmValue().stringValue().equals("64")); + } + + @Test + public void testOpenroadmPMString2() throws IOException, ClassNotFoundException { + out("Test: " + method()); + String jsonString2 = getFileContent("pmdata2.json"); + YangToolsMapper mapper2 = new YangToolsMapper(); + PmdataEntity generatepmdNode = mapper2.readValue(jsonString2.getBytes(), PmdataEntity.class); + out(generatepmdNode.toString()); // Print it with specified indentation + } + + @Test + public void testOpenroadmPMString3() throws IOException, ClassNotFoundException { + out("Test: " + method()); + String jsonString2 = getFileContent("pmdata3.json"); + YangToolsMapper2 mapper2 = + new YangToolsMapper2<>( + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class, + null); + PmdataEntity generatepmdNode = mapper2.readValue(jsonString2.getBytes(), PmdataEntity.class); out(generatepmdNode.toString()); // Print it with specified indentation } + + @Test + public void testOpenroadmPMString4() throws IOException, ClassNotFoundException { + out("Test: " + method()); + String jsonString = getFileContent("pmdata3.json"); + YangToolsMapper2 mapper = + new YangToolsMapper2<>( + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class, + null); + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data data = + mapper.readValue(jsonString.getBytes(), + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class); + + assertTrue("GranularityPeriod", data.getGranularityPeriod().equals(GranularityPeriodType.Period15Min)); + assertTrue("NodeName", data.getNodeName().equals("openroadm1")); + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata15m.entity.@Nullable PerformanceData performanceData = + data.getPerformanceData(); + assertNotNull("PerformanceData", performanceData); + @Nullable Map measurement = performanceData.getMeasurement(); + assertNotNull("Measurement", measurement); + Measurement measurement1 = measurement.get(new MeasurementKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.DelayTCM2Up.class)); + assertTrue("Measurement=11298624220985537708", measurement1.getPmValue().stringValue().equals("11298624220985537708")); + } /* * --------------------------------- Private */ @@ -72,9 +155,12 @@ public class TestYangGenSalMappingOpenRoadm { } private static void out(String text) { - System.out.println("----------------------"); - System.out.println(text); - Log.info("Log: "+text); + Log.info("Log: " + text); + } + + private static String getFileContent(String filename) throws IOException { + return String.join("\n", + IoUtils.readAllLines(TestTree.class.getResourceAsStream(resourceDirectoryPath + filename))); } } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/issues/TestIssue227.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/issues/TestIssue227.java new file mode 100644 index 000000000..9cfc3ead0 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/issues/TestIssue227.java @@ -0,0 +1,126 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 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.dataprovider.test.issues; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import java.io.IOException; +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.yangtools.yang.common.Uint32; + +public class TestIssue227 extends Mockito { + + static String inputJsonString = "{\"value1\":\"forty-two\", \"value2\":\"forty-three\"}"; + static String inputJsonNumber = "{\"value1\":42, \"value2\":43}"; + + @Test + public void testWithException() { + String inputJson = inputJsonNumber; + System.out.println("Input " + inputJson); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + + doMapping(mapper, inputJson); + } + + @Test + public void testWithMixin() { + String inputJson = inputJsonNumber; + System.out.println("Input " + inputJson); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + mapper.addMixIn(TestBuilder.class, IgnoreFooSetValueIntMixIn.class); + + doMapping(mapper, inputJson); + } + + + private void doMapping(ObjectMapper mapper, String json) { + TestBuilder foo; + try { + foo = mapper.readValue(json.getBytes(), TestBuilder.class); + System.out.println("Foo " + foo); + System.out.println(mapper.writeValueAsString(foo)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + static class TestBuilder { + + private String value1; + private String value2; + + String getValue1() { + return value1; + } + + public void setValue1(String value) { + this.value1 = value; + } + + public void setValue1(int value) { + this.value1 = String.valueOf(value); + } + + public void setValue1(long value) { + this.value1 = String.valueOf(value); + } + + public void setValue1(Uint32 value) { + this.value1 = String.valueOf(value); + } + + public String getValue2() { + return value2; + } + + public void setValue2(String value) { + this.value2 = value; + } + + public void setValue2(int value) { + this.value2 = String.valueOf(value); + } + + @Override + public String toString() { + return "Foo [value1=" + value1 + ", value2=" + value2 + "]"; + } + + } + + + private abstract class IgnoreFooSetValueIntMixIn { + @JsonProperty + public abstract void setValue1(String value); + + @JsonProperty + public abstract void setValue2(String value); + } +} + + diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/1.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/1.json new file mode 100644 index 000000000..bcf5e1d0a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/1.json @@ -0,0 +1,17 @@ + { + "description": "WS/p8.module/a2.module#5", + "date": "2013-04-13T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.1.5.5", + "parent-uuid": "CARD-1.1.5.0", + "contained-holder": [ + "SUBRACK-1.55.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "310330015", + "part-type-id": "3EM23141AD01", + "model-identifier": "CRPQABVFAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/10.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/10.json new file mode 100644 index 000000000..6eed5d6a8 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/10.json @@ -0,0 +1,15 @@ + { + "description": "MWR#56Ch#1/a2.moduletraff", + "date": "2017-09-09T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.56.1.2", + "parent-uuid": "ODU-1.56.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "Serial1", + "part-type-id": "Partnumber", + "model-identifier": "model-id", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/11.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/11.json new file mode 100644 index 000000000..46a4d0650 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/11.json @@ -0,0 +1,18 @@ + { + "description": "MWR-ng Dir#6.5-Ch#1", + "date": "2014-01-16T00:00:00.0Z", + "version": "MWR-ng", + "node-id": "sim1", + "uuid": "IDU-1.65.0.0", + "parent-uuid": "network-element", + "contained-holder": [ + "PORT-1.65.1.4", + "PORT-1.65.1.2" + ], + "tree-level": 0, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "WAUZZI", + "part-type-id": "3DB76047BAAA02", + "model-identifier": "model-id-s3s", + "type-name": "MWR-ng" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/12.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/12.json new file mode 100644 index 000000000..02d592e56 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/12.json @@ -0,0 +1,15 @@ + { + "description": "MWR#55Ch#0/RxDiv", + "date": "2014-01-08T00:00:00.0Z", + "version": "2017", + "node-id": "sim1", + "uuid": "CARD-1.65.1.4", + "parent-uuid": "IDU-1.65.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "Serie2017-13", + "part-type-id": "partNo2017-12", + "model-identifier": "model-id-s3s", + "type-name": "RxDiv" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/13.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/13.json new file mode 100644 index 000000000..85c3723b7 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/13.json @@ -0,0 +1,20 @@ + { + "description": "WS/p8.module", + "date": "2013-11-23T00:00:00.0Z", + "version": "234", + "node-id": "sim1", + "uuid": "CARD-1.1.6.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [ + "PORT-1.1.6.5", + "PORT-1.1.6.7", + "PORT-1.1.6.6", + "PORT-1.1.6.8" + ], + "tree-level": 1, + "manufacturer-identifier": "SAN", + "serial": "serial-number-124", + "part-type-id": "part-number-12", + "model-identifier": "model-id-12", + "type-name": "p8.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/14.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/14.json new file mode 100644 index 000000000..1fa236e10 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/14.json @@ -0,0 +1,15 @@ +{ + "description": "WS/DS3", + "date": "2008-10-21T00:00:00.0Z", + "version": "unknown", + "node-id": "sim1", + "uuid": "CARD-1.1.8.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "sd-dsa-eqw", + "part-type-id": "unknown", + "model-identifier": "model-id-s3s", + "type-name": "p4.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/15.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/15.json new file mode 100644 index 000000000..ff40c4e8b --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/15.json @@ -0,0 +1,15 @@ +{ + "description": "WS/wind", + "date": "2007-02-19T00:00:00.0Z", + "version": "wind", + "node-id": "sim1", + "uuid": "CARD-1.1.9.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "CIT", + "serial": "proto-type", + "part-type-id": "party-yea", + "model-identifier": "model-id-s3s", + "type-name": "wind" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/16.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/16.json new file mode 100644 index 000000000..fbd62e04d --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/16.json @@ -0,0 +1,15 @@ + { + "description": "MWR#55Ch#1/RxDiv", + "date": "2014-01-07T00:00:00.0Z", + "version": "2017", + "node-id": "sim1", + "uuid": "CARD-1.55.1.4", + "parent-uuid": "IDU-1.55.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "Serie2017-12", + "part-type-id": "partNo2017-12", + "model-identifier": "model-id-s3s", + "type-name": "RxDiv" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/17.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/17.json new file mode 100644 index 000000000..1704468f3 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/17.json @@ -0,0 +1,17 @@ +{ + "description": "WS/CORE-MAIN/a2.module#7", + "date": "2009-01-19T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.1.1.7", + "parent-uuid": "CARD-1.1.1.0", + "contained-holder": [ + "SUBRACK-1.17.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "91T403003322", + "part-type-id": "1AB187280031", + "model-identifier": "mod2", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/18.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/18.json new file mode 100644 index 000000000..eaec335b4 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/18.json @@ -0,0 +1,18 @@ + { + "description": "MWR-ng Dir#5.5-Ch#1", + "date": "2014-01-15T00:00:00.0Z", + "version": "MWR-ng", + "node-id": "sim1", + "uuid": "IDU-1.55.0.0", + "parent-uuid": "network-element", + "contained-holder": [ + "PORT-1.55.1.2", + "PORT-1.55.1.4" + ], + "tree-level": 0, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "Serie2017-14", + "part-type-id": "3DB76047BAAA02", + "model-identifier": "model-id-s3s", + "type-name": "MWR-ng" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/19.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/19.json new file mode 100644 index 000000000..9a7eb62a7 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/19.json @@ -0,0 +1,20 @@ + { + "description": "WS/CORE-MAIN", + "date": "2015-08-17T00:00:00.0Z", + "version": "123", + "node-id": "sim1", + "uuid": "CARD-1.1.1.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [ + "PORT-1.1.1.6", + "PORT-1.1.1.5", + "PORT-1.1.1.8", + "PORT-1.1.1.7" + ], + "tree-level": 1, + "manufacturer-identifier": "SAN", + "serial": "asdf-asdasd-asd", + "part-type-id": "part-number-2", + "model-identifier": "model-id-2", + "type-name": "latest" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/2.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/2.json new file mode 100644 index 000000000..ff352653a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/2.json @@ -0,0 +1,15 @@ + { + "description": "WS/DS1", + "date": "2007-08-27T00:00:00.0Z", + "version": "p1.module", + "node-id": "sim1", + "uuid": "CARD-1.1.7.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "CIT", + "serial": "serial-number-s3s", + "part-type-id": "part-number-s3s", + "model-identifier": "model-id-s3s", + "type-name": "p1.module_A" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/20.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/20.json new file mode 100644 index 000000000..179794027 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/20.json @@ -0,0 +1,20 @@ + { + "description": "WS/p8.module", + "date": "2013-10-21T00:00:00.0Z", + "version": "234", + "node-id": "sim1", + "uuid": "CARD-1.1.5.0", + "parent-uuid": "SHELF-1.1.0.0", + "contained-holder": [ + "PORT-1.1.5.6", + "PORT-1.1.5.5", + "PORT-1.1.5.8", + "PORT-1.1.5.7" + ], + "tree-level": 1, + "manufacturer-identifier": "SAN", + "serial": "africa", + "part-type-id": "part-number-12", + "model-identifier": "model-id-12", + "type-name": "p8.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/21.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/21.json new file mode 100644 index 000000000..c76d6715e --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/21.json @@ -0,0 +1,17 @@ +{ + "description": "WS/p8.module/a2.module#6", + "date": "", + "version": "", + "node-id": "sim1", + "uuid": "a2.module-1.1.5.6", + "parent-uuid": "CARD-1.1.5.0", + "contained-holder": [ + "SUBRACK-1.56.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "", + "serial": "", + "part-type-id": "", + "model-identifier": "", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/3.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/3.json new file mode 100644 index 000000000..1dc6dfce2 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/3.json @@ -0,0 +1,15 @@ +{ + "description": "MWR#55Ch#1/a2.moduletraff", + "date": "2013-04-13T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.55.1.2", + "parent-uuid": "IDU-1.55.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "310330015", + "part-type-id": "3EM23141AD01", + "model-identifier": "CRPQABVFAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/4.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/4.json new file mode 100644 index 000000000..ab1132692 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/4.json @@ -0,0 +1,15 @@ + { + "description": "MWR#65Ch#1/a2.moduletraff", + "date": "2013-04-13T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.65.1.2", + "parent-uuid": "IDU-1.65.0.0", + "contained-holder": [], + "tree-level": 1, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "310330008", + "part-type-id": "3EM23141AD01", + "model-identifier": "CRPQABVFAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/5.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/5.json new file mode 100644 index 000000000..e54173fe6 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/5.json @@ -0,0 +1,25 @@ +{ + "description": "WS-8", + "date": "2017-09-09T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "SHELF-1.1.0.0", + "parent-uuid": "network-element", + "contained-holder": [ + "SLOT-1.1.1.0", + "SLOT-1.1.2.0", + "SLOT-1.1.3.0", + "SLOT-1.1.4.0", + "SLOT-1.1.5.0", + "SLOT-1.1.6.0", + "SLOT-1.1.7.0", + "SLOT-1.1.8.0", + "SLOT-1.1.9.0" + ], + "tree-level": 0, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "Serial1", + "part-type-id": "Partnumber", + "model-identifier": "model-id", + "type-name": "WS-8" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/6.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/6.json new file mode 100644 index 000000000..8486033b0 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/6.json @@ -0,0 +1,17 @@ + { + "description": "WS/CORE-MAIN/a2.module#5", + "date": "2005-11-09T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.1.1.5", + "parent-uuid": "CARD-1.1.1.0", + "contained-holder": [ + "SUBRACK-1.15.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "0003548168", + "part-type-id": "3FE25774AA01", + "model-identifier": "VAUIAEYAAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/7.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/7.json new file mode 100644 index 000000000..5c583bec7 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/7.json @@ -0,0 +1,17 @@ +{ + "description": "WS/CORE-MAIN/a2.module#8", + "date": "2010-02-05T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.1.1.8", + "parent-uuid": "CARD-1.1.1.0", + "contained-holder": [ + "SUBRACK-1.18.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "01T441601301", + "part-type-id": "1AB376720002", + "model-identifier": "NGI7AMLMAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/8.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/8.json new file mode 100644 index 000000000..a86819a7d --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/8.json @@ -0,0 +1,17 @@ +{ + "description": "WS/p8.module/a2.module#5", + "date": "2013-04-13T00:00:00.0Z", + "version": "a2.module-newest", + "node-id": "sim1", + "uuid": "a2.module-1.1.6.5", + "parent-uuid": "CARD-1.1.6.0", + "contained-holder": [ + "SUBRACK-1.65.0.0" + ], + "tree-level": 2, + "manufacturer-identifier": "ONF-Wireless-Transport", + "serial": "310330008", + "part-type-id": "3EM23141AD01", + "model-identifier": "CRPQABVFAA", + "type-name": "a2.module" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/9.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/9.json new file mode 100644 index 000000000..914033bb4 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/9.json @@ -0,0 +1,19 @@ + { + "description": "MWR-hyper Dir#5.6-Ch#1", + "date": "", + "version": "extrem-hyper", + "node-id": "sim1", + "uuid": "ODU-1.56.0.0", + "parent-uuid": "network-element", + "contained-holder": [ + "PORT-1.56.1.2", + "PORT-1.56.1.3", + "PORT-1.56.1.4" + ], + "tree-level": 0, + "manufacturer-identifier": "", + "serial": "", + "part-type-id": "", + "model-identifier": "", + "type-name": "MWR-hyper" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata1.json b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata1.json new file mode 100644 index 000000000..aa3a1ccb4 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata1.json @@ -0,0 +1,18 @@ +{ + "performance-data": { + "measurement": [ + { + "pm-key": "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin", + "pm-value": "64" + }, + { + "pm-key": "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.BIPErrorCounter", + "pm-value": "65" + } + ] + }, + "uuid-interface": "device", + "granularity-period": "Period15Min", + "time-stamp": "2020-11-24T14:57:29.6Z", + "node-name": "NTS_RDM2" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata2.json b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata2.json new file mode 100644 index 000000000..d784cf056 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata2.json @@ -0,0 +1,14 @@ +{ + "performance-data": { + "measurement": [ + { + "pm-key": "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.CodeViolations", + "pm-value": "11298624220985537708" + } + ] + }, + "uuid-interface": "device", + "granularity-period": "Period15Min", + "time-stamp": "2020-11-24T14:57:29.6Z", + "node-name": "NTS_RDM2" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata3.json b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata3.json new file mode 100644 index 000000000..0747e3171 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/TestYangGenSalMappingOpenRoadm/pmdata3.json @@ -0,0 +1,14 @@ +{ + "performance-data": { + "measurement": [ + { + "pm-key": "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.DelayTCM2Up", + "pm-value": "11298624220985537708" + } + ] + }, + "uuid-interface": "shared-risk-group", + "granularity-period": "Period15Min", + "time-stamp": "2020-10-24T08:17:02.5Z", + "node-name": "openroadm1" +} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties new file mode 100644 index 000000000..e4fcb0130 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties @@ -0,0 +1,9 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=DEBUG, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties deleted file mode 100644 index 85525bf4b..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -# ============LICENSE_START======================================================= -# ONAP : ccsdk features -# ================================================================================ -# Copyright (C) 2020 AT&T 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======================================================= -# -# -# SLF4J's SimpleLogger configuration file -# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. - -# Default logging detail level for all instances of SimpleLogger. -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, defaults to "info". -org.slf4j.simpleLogger.defaultLogLevel=debug -org.slf4j.simpleLogger.showDateTime=true - -org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z -org.slf4j.simpleLogger.showThreadName=true -org.slf4j.simpleLogger.showLogName=true -org.slf4j.simpleLogger.showShortLogName=false -org.slf4j.simpleLogger.org.onap.ccsdk.features.sdnr.wt.dataprovider=DEBUG -org.slf4j.simpleLogger.org.onap.ccsdk.features.sdnr.wt.common=DEBUG - diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json deleted file mode 100644 index bcf5e1d0a..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json +++ /dev/null @@ -1,17 +0,0 @@ - { - "description": "WS/p8.module/a2.module#5", - "date": "2013-04-13T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.1.5.5", - "parent-uuid": "CARD-1.1.5.0", - "contained-holder": [ - "SUBRACK-1.55.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "310330015", - "part-type-id": "3EM23141AD01", - "model-identifier": "CRPQABVFAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json deleted file mode 100644 index 6eed5d6a8..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "description": "MWR#56Ch#1/a2.moduletraff", - "date": "2017-09-09T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.56.1.2", - "parent-uuid": "ODU-1.56.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "Serial1", - "part-type-id": "Partnumber", - "model-identifier": "model-id", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json deleted file mode 100644 index 46a4d0650..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json +++ /dev/null @@ -1,18 +0,0 @@ - { - "description": "MWR-ng Dir#6.5-Ch#1", - "date": "2014-01-16T00:00:00.0Z", - "version": "MWR-ng", - "node-id": "sim1", - "uuid": "IDU-1.65.0.0", - "parent-uuid": "network-element", - "contained-holder": [ - "PORT-1.65.1.4", - "PORT-1.65.1.2" - ], - "tree-level": 0, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "WAUZZI", - "part-type-id": "3DB76047BAAA02", - "model-identifier": "model-id-s3s", - "type-name": "MWR-ng" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json deleted file mode 100644 index 02d592e56..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "description": "MWR#55Ch#0/RxDiv", - "date": "2014-01-08T00:00:00.0Z", - "version": "2017", - "node-id": "sim1", - "uuid": "CARD-1.65.1.4", - "parent-uuid": "IDU-1.65.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "Serie2017-13", - "part-type-id": "partNo2017-12", - "model-identifier": "model-id-s3s", - "type-name": "RxDiv" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json deleted file mode 100644 index 85c3723b7..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json +++ /dev/null @@ -1,20 +0,0 @@ - { - "description": "WS/p8.module", - "date": "2013-11-23T00:00:00.0Z", - "version": "234", - "node-id": "sim1", - "uuid": "CARD-1.1.6.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [ - "PORT-1.1.6.5", - "PORT-1.1.6.7", - "PORT-1.1.6.6", - "PORT-1.1.6.8" - ], - "tree-level": 1, - "manufacturer-identifier": "SAN", - "serial": "serial-number-124", - "part-type-id": "part-number-12", - "model-identifier": "model-id-12", - "type-name": "p8.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json deleted file mode 100644 index 1fa236e10..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "WS/DS3", - "date": "2008-10-21T00:00:00.0Z", - "version": "unknown", - "node-id": "sim1", - "uuid": "CARD-1.1.8.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "sd-dsa-eqw", - "part-type-id": "unknown", - "model-identifier": "model-id-s3s", - "type-name": "p4.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json deleted file mode 100644 index ff40c4e8b..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "WS/wind", - "date": "2007-02-19T00:00:00.0Z", - "version": "wind", - "node-id": "sim1", - "uuid": "CARD-1.1.9.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "CIT", - "serial": "proto-type", - "part-type-id": "party-yea", - "model-identifier": "model-id-s3s", - "type-name": "wind" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json deleted file mode 100644 index fbd62e04d..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "description": "MWR#55Ch#1/RxDiv", - "date": "2014-01-07T00:00:00.0Z", - "version": "2017", - "node-id": "sim1", - "uuid": "CARD-1.55.1.4", - "parent-uuid": "IDU-1.55.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "Serie2017-12", - "part-type-id": "partNo2017-12", - "model-identifier": "model-id-s3s", - "type-name": "RxDiv" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json deleted file mode 100644 index 1704468f3..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "WS/CORE-MAIN/a2.module#7", - "date": "2009-01-19T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.1.1.7", - "parent-uuid": "CARD-1.1.1.0", - "contained-holder": [ - "SUBRACK-1.17.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "91T403003322", - "part-type-id": "1AB187280031", - "model-identifier": "mod2", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json deleted file mode 100644 index eaec335b4..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json +++ /dev/null @@ -1,18 +0,0 @@ - { - "description": "MWR-ng Dir#5.5-Ch#1", - "date": "2014-01-15T00:00:00.0Z", - "version": "MWR-ng", - "node-id": "sim1", - "uuid": "IDU-1.55.0.0", - "parent-uuid": "network-element", - "contained-holder": [ - "PORT-1.55.1.2", - "PORT-1.55.1.4" - ], - "tree-level": 0, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "Serie2017-14", - "part-type-id": "3DB76047BAAA02", - "model-identifier": "model-id-s3s", - "type-name": "MWR-ng" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json deleted file mode 100644 index 9a7eb62a7..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json +++ /dev/null @@ -1,20 +0,0 @@ - { - "description": "WS/CORE-MAIN", - "date": "2015-08-17T00:00:00.0Z", - "version": "123", - "node-id": "sim1", - "uuid": "CARD-1.1.1.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [ - "PORT-1.1.1.6", - "PORT-1.1.1.5", - "PORT-1.1.1.8", - "PORT-1.1.1.7" - ], - "tree-level": 1, - "manufacturer-identifier": "SAN", - "serial": "asdf-asdasd-asd", - "part-type-id": "part-number-2", - "model-identifier": "model-id-2", - "type-name": "latest" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json deleted file mode 100644 index ff352653a..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "description": "WS/DS1", - "date": "2007-08-27T00:00:00.0Z", - "version": "p1.module", - "node-id": "sim1", - "uuid": "CARD-1.1.7.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "CIT", - "serial": "serial-number-s3s", - "part-type-id": "part-number-s3s", - "model-identifier": "model-id-s3s", - "type-name": "p1.module_A" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json deleted file mode 100644 index 179794027..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json +++ /dev/null @@ -1,20 +0,0 @@ - { - "description": "WS/p8.module", - "date": "2013-10-21T00:00:00.0Z", - "version": "234", - "node-id": "sim1", - "uuid": "CARD-1.1.5.0", - "parent-uuid": "SHELF-1.1.0.0", - "contained-holder": [ - "PORT-1.1.5.6", - "PORT-1.1.5.5", - "PORT-1.1.5.8", - "PORT-1.1.5.7" - ], - "tree-level": 1, - "manufacturer-identifier": "SAN", - "serial": "africa", - "part-type-id": "part-number-12", - "model-identifier": "model-id-12", - "type-name": "p8.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json deleted file mode 100644 index c76d6715e..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "WS/p8.module/a2.module#6", - "date": "", - "version": "", - "node-id": "sim1", - "uuid": "a2.module-1.1.5.6", - "parent-uuid": "CARD-1.1.5.0", - "contained-holder": [ - "SUBRACK-1.56.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "", - "serial": "", - "part-type-id": "", - "model-identifier": "", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json deleted file mode 100644 index 1dc6dfce2..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "MWR#55Ch#1/a2.moduletraff", - "date": "2013-04-13T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.55.1.2", - "parent-uuid": "IDU-1.55.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "310330015", - "part-type-id": "3EM23141AD01", - "model-identifier": "CRPQABVFAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json deleted file mode 100644 index ab1132692..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "description": "MWR#65Ch#1/a2.moduletraff", - "date": "2013-04-13T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.65.1.2", - "parent-uuid": "IDU-1.65.0.0", - "contained-holder": [], - "tree-level": 1, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "310330008", - "part-type-id": "3EM23141AD01", - "model-identifier": "CRPQABVFAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json deleted file mode 100644 index e54173fe6..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "description": "WS-8", - "date": "2017-09-09T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "SHELF-1.1.0.0", - "parent-uuid": "network-element", - "contained-holder": [ - "SLOT-1.1.1.0", - "SLOT-1.1.2.0", - "SLOT-1.1.3.0", - "SLOT-1.1.4.0", - "SLOT-1.1.5.0", - "SLOT-1.1.6.0", - "SLOT-1.1.7.0", - "SLOT-1.1.8.0", - "SLOT-1.1.9.0" - ], - "tree-level": 0, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "Serial1", - "part-type-id": "Partnumber", - "model-identifier": "model-id", - "type-name": "WS-8" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json deleted file mode 100644 index 8486033b0..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json +++ /dev/null @@ -1,17 +0,0 @@ - { - "description": "WS/CORE-MAIN/a2.module#5", - "date": "2005-11-09T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.1.1.5", - "parent-uuid": "CARD-1.1.1.0", - "contained-holder": [ - "SUBRACK-1.15.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "0003548168", - "part-type-id": "3FE25774AA01", - "model-identifier": "VAUIAEYAAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json deleted file mode 100644 index 5c583bec7..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "WS/CORE-MAIN/a2.module#8", - "date": "2010-02-05T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.1.1.8", - "parent-uuid": "CARD-1.1.1.0", - "contained-holder": [ - "SUBRACK-1.18.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "01T441601301", - "part-type-id": "1AB376720002", - "model-identifier": "NGI7AMLMAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json deleted file mode 100644 index a86819a7d..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "WS/p8.module/a2.module#5", - "date": "2013-04-13T00:00:00.0Z", - "version": "a2.module-newest", - "node-id": "sim1", - "uuid": "a2.module-1.1.6.5", - "parent-uuid": "CARD-1.1.6.0", - "contained-holder": [ - "SUBRACK-1.65.0.0" - ], - "tree-level": 2, - "manufacturer-identifier": "ONF-Wireless-Transport", - "serial": "310330008", - "part-type-id": "3EM23141AD01", - "model-identifier": "CRPQABVFAA", - "type-name": "a2.module" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json deleted file mode 100644 index 914033bb4..000000000 --- a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json +++ /dev/null @@ -1,19 +0,0 @@ - { - "description": "MWR-hyper Dir#5.6-Ch#1", - "date": "", - "version": "extrem-hyper", - "node-id": "sim1", - "uuid": "ODU-1.56.0.0", - "parent-uuid": "network-element", - "contained-holder": [ - "PORT-1.56.1.2", - "PORT-1.56.1.3", - "PORT-1.56.1.4" - ], - "tree-level": 0, - "manufacturer-identifier": "", - "serial": "", - "part-type-id": "", - "model-identifier": "", - "type-name": "MWR-hyper" -} \ No newline at end of file diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml index df739806a..1e83f061f 100644 --- a/sdnr/wt/data-provider/setup/pom.xml +++ b/sdnr/wt/data-provider/setup/pom.xml @@ -29,11 +29,11 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.1.1-SNAPSHOT - org.onap.ccsdk.features.sdnr.wt + org.onap.ccsdk.features.sdnr.wt.aluminium.sr1 sdnr-wt-data-provider-setup 1.1.1-SNAPSHOT jar @@ -62,12 +62,12 @@ commons-cli - org.slf4j - slf4j-api + org.slf4j + slf4j-api - org.slf4j - slf4j-log4j12 + org.slf4j + slf4j-log4j12 ${project.groupId} @@ -80,7 +80,6 @@ ${project.version} - @@ -135,7 +134,7 @@ sdnr-dmt - false + false org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.Program diff --git a/sdnr/wt/pom.xml b/sdnr/wt/pom.xml index 1f4d88c43..43a540eef 100644 --- a/sdnr/wt/pom.xml +++ b/sdnr/wt/pom.xml @@ -29,7 +29,7 @@ org.onap.ccsdk.parent odlparent-lite - 2.1.0 + 2.1.1-SNAPSHOT -- cgit 1.2.3-korg