aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider/provider/src/main/java')
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java39
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java242
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java45
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java27
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java122
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java110
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java26
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java104
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java75
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java316
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java41
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java526
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java326
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java77
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java442
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java100
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java566
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java42
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java64
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java159
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java55
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java170
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java13
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java122
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java38
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java37
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java351
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java434
30 files changed, 2420 insertions, 2264 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
index b7abe5950..3fe2a62af 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
@@ -33,28 +33,29 @@ import org.slf4j.LoggerFactory;
public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderWriter<T> {
- private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
- public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
- this(dbClient, entity, clazz, true);
- LOG.info("Create {}", this.getClass().getName());
- }
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
+ this(dbClient, entity, clazz, true);
+ LOG.info("Create {}", this.getClass().getName());
+ }
- public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean idSupported) throws ClassNotFoundException {
- super(dbClient, entity, clazz);
- if (idSupported) {
- setEsIdAttributeName("_id");
- }
- }
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean idSupported)
+ throws ClassNotFoundException {
+ super(dbClient, entity, clazz);
+ if (idSupported) {
+ setEsIdAttributeName("_id");
+ }
+ }
- QueryResult<T> getData(EntityInput input) {
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
+ QueryResult<T> getData(EntityInput input) {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
LOG.info("Request: {}", this.getDataTypeName());
- QueryBuilder query = QueryByFilter.fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
- QueryByFilter.setSortOrder(query, input.getSortorder());
- SearchResult<T> result = doReadAll(query,query.contains("range"));
- return new QueryResult<>(page, pageSize, result);
- }
+ QueryBuilder query = QueryByFilter.fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
+ QueryByFilter.setSortOrder(query, input.getSortorder());
+ SearchResult<T> result = doReadAll(query, query.contains("range"));
+ return new QueryResult<>(page, pageSize, result);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
index ec1a20880..8eb51b6aa 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
@@ -42,124 +42,128 @@ import org.slf4j.LoggerFactory;
public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor<T> {
- private final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
-
- private static final String UUID_KEY = "uuid-interface";
- private static final String NODE_KEY = "node-name";
- private static final String KEY = "node-name";
-
-
- enum Intervall {
- PMDATA15M("historicalperformance15min", "historicalperformance15min"),
- PMDATA24H("historicalperformance24h", "historicalperformance24h");
-
- String index;
- String type;
-
- Intervall(String index, String type) {
- this.index = index;
- this.type = type;
- }
-
- public String getIndex() {
- return index;
- }
-
- public String getType() {
- return type;
- }
- }
-
- private ExtRestClient dbClient;
- private Intervall mode;
-
- public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz) throws ClassNotFoundException {
- super(dbClient, entity, clazz, false);
- this.dbClient = dbClient;
- this.mode = mode;
- }
-
- /**
- * get aggregated list of ltps for filter NODE_KEY
- * @param input
- * @return
- * @throws IOException
- */
- QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
- Filter nodeFilter = QueryByFilter.getFilter(input.getFilter(), NODE_KEY);
- if (nodeFilter != null) {
- SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
- request.setQuery(QueryBuilders.matchQuery(NODE_KEY, nodeFilter.getFiltervalue()).aggregations(UUID_KEY).size(0));
- try {
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(UUID_KEY);
- String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
- long totalSize = aggs.size();
- return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
- } catch (IOException e) {
- throw new IOException("problem reading ltps for req="+request, e);
- }
- } else {
- String msg = "no nodename in filter found ";
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
-// QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
-//
-// long page = QueryByFilter.getPage(input);
-// long pageSize = QueryByFilter.getPageSize(input);
-//
-// SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
-// request.setQuery(QueryBuilders.matchAllQuery().aggregations(KEY).size(0));
-//// try {
-// SearchResponse response = this.dbClient.search(request);
-// AggregationEntries aggs = response.getAggregations(KEY);
-// String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
-// long totalSize = aggs.size();
-// return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
-//// } catch (IOException e) {
-//// throw new IOException("problem reading nodes for req="+request, e);
-//// }
-// }
- /**
- * get aggregated devices list
- * @param input filter should be empty/no filter handled, only sortorder for KEY ('node-name')
- * @return
- * @throws IOException
- */
- QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
-
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
-
- Sortorder soNode = QueryByFilter.getSortOrder(input.getSortorder(), KEY);
- SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
- QueryBuilder query = null;
- if (soNode != null) {
- query = QueryBuilders.matchAllQuery()
- .aggregations(KEY,
- soNode.getSortorder() == SortOrder.Ascending
- ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
- : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING)
- .size(0);
- } else {
- query = QueryBuilders.matchAllQuery().aggregations(KEY).size(0);
- }
- request.setQuery(query);
- try {
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(KEY);
- String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
- long totalSize = aggs.size();
- return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
- } catch (IOException e) {
- throw new IOException("problem reading nodes for req=" + request, e);
- }
-
- }
+ private final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+
+ private static final String UUID_KEY = "uuid-interface";
+ private static final String NODE_KEY = "node-name";
+ private static final String KEY = "node-name";
+
+
+ enum Intervall {
+ PMDATA15M("historicalperformance15min", "historicalperformance15min"), PMDATA24H("historicalperformance24h",
+ "historicalperformance24h");
+
+ String index;
+ String type;
+
+ Intervall(String index, String type) {
+ this.index = index;
+ this.type = type;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+
+ public String getType() {
+ return type;
+ }
+ }
+
+ private ExtRestClient dbClient;
+ private Intervall mode;
+
+ public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz)
+ throws ClassNotFoundException {
+ super(dbClient, entity, clazz, false);
+ this.dbClient = dbClient;
+ this.mode = mode;
+ }
+
+ /**
+ * get aggregated list of ltps for filter NODE_KEY
+ *
+ * @param input
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+ Filter nodeFilter = QueryByFilter.getFilter(input.getFilter(), NODE_KEY);
+ if (nodeFilter != null) {
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ request.setQuery(
+ QueryBuilders.matchQuery(NODE_KEY, nodeFilter.getFiltervalue()).aggregations(UUID_KEY).size(0));
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(UUID_KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading ltps for req=" + request, e);
+ }
+ } else {
+ String msg = "no nodename in filter found ";
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+ //
+ // long page = QueryByFilter.getPage(input);
+ // long pageSize = QueryByFilter.getPageSize(input);
+ //
+ // SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ // request.setQuery(QueryBuilders.matchAllQuery().aggregations(KEY).size(0));
+ //// try {
+ // SearchResponse response = this.dbClient.search(request);
+ // AggregationEntries aggs = response.getAggregations(KEY);
+ // String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ // long totalSize = aggs.size();
+ // return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ //// } catch (IOException e) {
+ //// throw new IOException("problem reading nodes for req="+request, e);
+ //// }
+ // }
+ /**
+ * get aggregated devices list
+ *
+ * @param input filter should be empty/no filter handled, only sortorder for KEY ('node-name')
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+
+ Sortorder soNode = QueryByFilter.getSortOrder(input.getSortorder(), KEY);
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ QueryBuilder query = null;
+ if (soNode != null) {
+ query = QueryBuilders.matchAllQuery()
+ .aggregations(KEY,
+ soNode.getSortorder() == SortOrder.Ascending
+ ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
+ : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING)
+ .size(0);
+ } else {
+ query = QueryBuilders.matchAllQuery().aggregations(KEY).size(0);
+ }
+ request.setQuery(query);
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading nodes for req=" + request, e);
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
index c1a6b2936..4dd52f43a 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
@@ -37,39 +37,34 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class DataObjectAcessorStatus extends DataObjectAcessor<Data> {
- final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
+ final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
- private final ExtRestClient dbClient;
- private final Entity entity;
+ private final ExtRestClient dbClient;
+ private final Entity entity;
- public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity)
- throws ClassNotFoundException {
- super(dbClient, entity, Data.class, false);
- this.dbClient = dbClient;
- this.entity = entity;
- }
+ public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity) throws ClassNotFoundException {
+ super(dbClient, entity, Data.class, false);
+ this.dbClient = dbClient;
+ this.entity = entity;
+ }
- QueryResult<Data> getDataStatus() throws IOException {
- SearchRequest request = getNewInstanceOfSearchRequest(entity);
- request.setQuery(
- QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
+ QueryResult<Data> getDataStatus() throws IOException {
+ SearchRequest request = getNewInstanceOfSearchRequest(entity);
+ request.setQuery(QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
+ 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() };
- long toalsize = data.length;
- return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
+ 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()};
+ long toalsize = data.length;
+ return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
- }
+ }
private static SearchRequest getNewInstanceOfSearchRequest(Entity entity) {
- return new SearchRequest(entity.getName(), entity.getName());
+ return new SearchRequest(entity.getName(), entity.getName());
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
index f75989acd..a92265a84 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
@@ -29,17 +29,18 @@ import java.util.Map;
*/
public class DataTreeChildObject {
- private final String label;
- private final String ownSeverity;
- private final String childrenSeveritySummary;
- private final boolean isMatch;
- private final Map<String,DataTreeChildObject> children;
-
- public DataTreeChildObject(String label,boolean isMatch,Map<String,DataTreeChildObject>children,String ownSeverity,String childrenSeveritySummary) {
- this.label = label;
- this.isMatch = isMatch;
- this.children = children;
- this.ownSeverity = ownSeverity;
- this.childrenSeveritySummary = childrenSeveritySummary;
- }
+ private final String label;
+ private final String ownSeverity;
+ private final String childrenSeveritySummary;
+ private final boolean isMatch;
+ private final Map<String, DataTreeChildObject> children;
+
+ public DataTreeChildObject(String label, boolean isMatch, Map<String, DataTreeChildObject> children,
+ String ownSeverity, String childrenSeveritySummary) {
+ this.label = label;
+ this.isMatch = isMatch;
+ this.children = children;
+ this.ownSeverity = ownSeverity;
+ this.childrenSeveritySummary = childrenSeveritySummary;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
index cc3f6cc55..4333dccb4 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
@@ -27,6 +27,6 @@ import java.util.HashMap;
* @author Michael Dürre
*
*/
-public class DataTreeObject extends HashMap<String,DataTreeChildObject> {
-
+public class DataTreeObject extends HashMap<String, DataTreeChildObject> {
+
}
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 4fa0a57cc..08db03475 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
@@ -75,11 +75,11 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class);
- private static final String EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE = "unable to write data to database";
- private static final String EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE = "unable to update data in database";
- private static final String EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE = "unable to remove data from database";
+ private static final String EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE = "unable to write data to database";
+ private static final String EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE = "unable to update data in database";
+ private static final String EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE = "unable to remove data from database";
- private static final boolean DEFAULT_TRUSTALLCERTS = false;
+ private static final boolean DEFAULT_TRUSTALLCERTS = false;
private final HtDatabaseClient dbClient;
private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> eventRWFaultCurrent;
@@ -96,54 +96,58 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
private final DataObjectAcessorStatus readStatus;
private final HtDatabaseEventsService databaseService;
private final HtDatabaseMaintenanceService databaseMaintenanceService;
+
public HtDatabaseClient getRawClient() {
- return this.dbClient;
+ return this.dbClient;
}
+
public ElasticSearchDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts,null,null,DEFAULT_TRUSTALLCERTS);
+ this(hosts, null, null, DEFAULT_TRUSTALLCERTS);
}
- public ElasticSearchDataProvider(HostInfo[] hosts,String authUsername,String authPassword, boolean trustAllCerts) throws Exception {
- super();
- LOG.info("Start {}", this.getClass().getName());
- this.dbClient = new HtDatabaseClient(hosts,authUsername,authPassword,trustAllCerts);
- this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer,
+ public ElasticSearchDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAllCerts)
+ throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+
+ this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword, trustAllCerts);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class);
- this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
+ this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
- this.maintenanceRW = new DataObjectAcessor<>(dbClient, Entity.Maintenancemode,
+ this.maintenanceRW = new DataObjectAcessor<>(dbClient, Entity.Maintenancemode,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data.class);
- this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
+ this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
- this.equipmentRW = new DataObjectAcessor<>(dbClient, Entity.Inventoryequipment,
+ this.equipmentRW = new DataObjectAcessor<>(dbClient, Entity.Inventoryequipment,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
- this.eventRWFaultCurrent = new DataObjectAcessor<>(dbClient, Entity.Faultcurrent,
+ this.eventRWFaultCurrent = new DataObjectAcessor<>(dbClient, Entity.Faultcurrent,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data.class);
- this.eventRWFaultLog = new DataObjectAcessor<>(dbClient, Entity.Faultlog,
+ this.eventRWFaultLog = new DataObjectAcessor<>(dbClient, Entity.Faultlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data.class);
- this.connnectionlogRW = new DataObjectAcessor<>(dbClient, Entity.Connectionlog,
+ this.connnectionlogRW = new DataObjectAcessor<>(dbClient, Entity.Connectionlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data.class);
- this.eventlogRW = new DataObjectAcessor<>(dbClient, Entity.Eventlog,
+ this.eventlogRW = new DataObjectAcessor<>(dbClient, Entity.Eventlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data.class);
- this.networkelementConnectionRW = new DataObjectAcessor<>(dbClient, Entity.NetworkelementConnection,
+ this.networkelementConnectionRW = new DataObjectAcessor<>(dbClient, Entity.NetworkelementConnection,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data.class);
- this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
+ this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
- this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
+ this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
- this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
+ this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data.class);
- this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent );
+ this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent);
- this.databaseService = new HtDatabaseEventsService(dbClient, this);
- this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
+ this.databaseService = new HtDatabaseEventsService(dbClient, this);
+ this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
}
/*-------------------------
@@ -157,8 +161,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
ReadFaultcurrentListOutputBuilder outputBuilder = new ReadFaultcurrentListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> result = this.eventRWFaultCurrent
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> result =
+ this.eventRWFaultCurrent.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.PaginationBuilder(
@@ -171,8 +175,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//eventRWFaultLog
public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) {
ReadFaultlogListOutputBuilder outputBuilder = new ReadFaultlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> result = this.eventRWFaultLog
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> result =
+ this.eventRWFaultLog.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.PaginationBuilder(
@@ -185,8 +189,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//maintenanceRW
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> result = this.maintenanceRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> result =
+ this.maintenanceRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.PaginationBuilder(
@@ -200,8 +204,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) {
ReadMediatorServerListOutputBuilder outputBuilder = new ReadMediatorServerListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> result = this.mediatorserverRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> result =
+ this.mediatorserverRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.PaginationBuilder(
@@ -212,11 +216,11 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder
//networkelementConnectionRW
- public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(
- EntityInput input) {
- ReadNetworkElementConnectionListOutputBuilder outputBuilder = new ReadNetworkElementConnectionListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> result = this.networkelementConnectionRW
- .getData(input);
+ public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(EntityInput input) {
+ ReadNetworkElementConnectionListOutputBuilder outputBuilder =
+ new ReadNetworkElementConnectionListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> result =
+ this.networkelementConnectionRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder(
@@ -229,8 +233,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//equipmentRW
public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) {
ReadInventoryListOutputBuilder outputBuilder = new ReadInventoryListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> result = this.equipmentRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> result =
+ this.equipmentRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.PaginationBuilder(
@@ -243,8 +247,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//connnectionlogRW
public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) {
ReadConnectionlogListOutputBuilder outputBuilder = new ReadConnectionlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> result = this.connnectionlogRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> result =
+ this.connnectionlogRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.PaginationBuilder(
@@ -257,8 +261,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//eventlogRW
public ReadEventlogListOutputBuilder readEventlogList(ReadEventlogListInput input) throws IOException {
ReadEventlogListOutputBuilder outputBuilder = new ReadEventlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> result = this.eventlogRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> result =
+ this.eventlogRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.PaginationBuilder(
@@ -270,8 +274,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder
public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) {
ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result = this.pm15mRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result =
+ this.pm15mRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder(
@@ -283,8 +287,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Pagination
public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) {
ReadPmdata24hListOutputBuilder outputBuilder = new ReadPmdata24hListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> result = this.pm24hRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> result =
+ this.pm24hRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.PaginationBuilder(
@@ -318,14 +322,14 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
ReadPmdata24hLtpListOutputBuilder outputBuilder = new ReadPmdata24hLtpListOutputBuilder();
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder();
- outputBuilder.setPagination(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder(
- result.getPagination()).build());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder(
+ result.getPagination()).build());
outputBuilder.setData(result.getResult().getHits());
return outputBuilder;
}
- public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input)
- throws IOException {
+ public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException {
QueryResult<String> result = pm24hRW.getDataDeviceList(input);
@@ -338,7 +342,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
}
public ReadStatusOutputBuilder readStatus() throws IOException {
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> result = readStatus.getDataStatus();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> result =
+ readStatus.getDataStatus();
ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder();
outputBuilder.setData(result.getResult().getHits());
@@ -349,7 +354,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return this.dbClient.waitForYellowStatus(unit.toMillis(timeout));
}
- public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
+ public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
NetworkElementConnectionEntity input) throws IOException {
String id = this.networkelementConnectionRW.update(input, input.getNodeId());
if (id == null) {
@@ -375,7 +380,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return builder;
}
- public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(DeleteNetworkElementConnectionInput input) throws IOException {
+ public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(
+ DeleteNetworkElementConnectionInput input) throws IOException {
boolean removed = this.networkelementConnectionRW.remove(input.getId());
if (!removed) {
throw new IOException(EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE);
@@ -425,7 +431,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
}
public CreateMaintenanceOutputBuilder createMaintenance(CreateMaintenanceInput input) throws IOException {
- String id = this.maintenanceRW.write(input, input.getNodeId());
+ String id = this.maintenanceRW.write(input, input.getNodeId());
if (id == null) {
throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
}
@@ -433,7 +439,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return builder;
}
- public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
+ public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
String id = this.mediatorserverRW.write(input, null);
if (id == null) {
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
index 16b13ba96..7efdab110 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
@@ -33,18 +33,18 @@ public class FaultEntityManager {
private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
/**
- * The leading indication for notification or events that are not in the
- * currentProblem data of the ONF Coremodel
+ * The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
*/
private static final String NOCURRENTPROBLEMINDICATION = "#";
/**
* Specific problems are not moving into current problem list
+ *
* @param problemName to be verified
* @return true if problem is current
*/
public static boolean isManagedAsCurrentProblem(String problemName) {
- return ! problemName.startsWith(NOCURRENTPROBLEMINDICATION);
+ return !problemName.startsWith(NOCURRENTPROBLEMINDICATION);
}
public static boolean isManagedAsCurrentProblem(Fault problem) {
@@ -53,6 +53,7 @@ public class FaultEntityManager {
/**
* Specific problems are not moving into current problem list
+ *
* @param fault to be verified
* @return true if cleared indication
*/
@@ -62,9 +63,10 @@ public class FaultEntityManager {
/**
* Create a specific ES id for the current log.
+ *
* @return a string with the generated ES Id
*/
- public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
+ public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
String uuId;
@@ -86,6 +88,7 @@ public class FaultEntityManager {
/**
* Create Es id
+ *
* @param fault used to create uuid for faultcurrent
* @return String with Id
*/
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
index 4a4b332d6..d255cadcd 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
@@ -63,8 +63,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Event service, writing all events into the database into the appropriate
- * index.
+ * Event service, writing all events into the database into the appropriate index.
*
* @author herbert
*/
@@ -88,7 +87,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
// --- Construct and initialize
- public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider) throws Exception {
+ public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider)
+ throws Exception {
LOG.info("Create {} start", HtDatabaseEventsService.class);
this.dataProvider = elasticSearchDataProvider;
@@ -100,27 +100,27 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWEventLogDevicemanager = new EsDataObjectReaderWriter2<>(client, Entity.Eventlog,
EventlogEntity.class, EventlogBuilder.class);
- eventRWEquipment = new EsDataObjectReaderWriter2<>(client, Entity.Inventoryequipment,
- InventoryEntity.class, InventoryBuilder.class);
+ eventRWEquipment = new EsDataObjectReaderWriter2<>(client, Entity.Inventoryequipment, InventoryEntity.class,
+ InventoryBuilder.class);
eventRWFaultCurrentDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultcurrent,
FaultcurrentEntity.class, FaultcurrentBuilder.class);
- eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog,
- FaultlogEntity.class, FaultlogBuilder.class);
+ eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog, FaultlogEntity.class,
+ FaultlogBuilder.class);
eventRWConnectionLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Connectionlog,
ConnectionlogEntity.class, ConnectionlogBuilder.class);
networkelementConnectionDB = new EsDataObjectReaderWriter2<>(client, Entity.NetworkelementConnection,
NetworkElementConnectionEntity.class, NetworkElementConnectionBuilder.class)
- .setEsIdAttributeName("_id");
+ .setEsIdAttributeName("_id");
- pmData15mDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min,
- PmdataEntity.class, PmdataEntityBuilder.class);
+ pmData15mDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min, PmdataEntity.class,
+ PmdataEntityBuilder.class);
- pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h,
- PmdataEntity.class, PmdataEntityBuilder.class);
+ pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h, PmdataEntity.class,
+ PmdataEntityBuilder.class);
} catch (Exception e) {
LOG.error("Can not start database client. Exception: {}", e);
@@ -142,6 +142,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWConnectionLogDB.write(event, null);
}
+
// -- Event log
@Override
public void writeEventLog(EventlogEntity event) {
@@ -163,7 +164,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
LOG.debug("Write fault to faultlog: {}", fault.toString());
- eventRWFaultLogDB.write(fault,null);
+ eventRWFaultLogDB.write(fault, null);
}
// -- Fault current
@@ -248,6 +249,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* write internal equipment to database
+ *
* @param internalEquipment with mandatory fields.
*/
@Override
@@ -256,14 +258,14 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
if (assertIfClientNullForNodeName(internalEquipment.getNodeId())) {
return;
}
- if(internalEquipment.getManufacturerIdentifier()==null) {
- internalEquipment = new InventoryBuilder(internalEquipment).setManufacturerIdentifier("").build();
+ if (internalEquipment.getManufacturerIdentifier() == null) {
+ internalEquipment = new InventoryBuilder(internalEquipment).setManufacturerIdentifier("").build();
}
- if(internalEquipment.getDate()==null) {
- internalEquipment = new InventoryBuilder(internalEquipment).setDate("").build();
+ if (internalEquipment.getDate() == null) {
+ internalEquipment = new InventoryBuilder(internalEquipment).setDate("").build();
}
-
- eventRWEquipment.write(internalEquipment, internalEquipment.getNodeId()+"/"+internalEquipment.getUuid());
+
+ eventRWEquipment.write(internalEquipment, internalEquipment.getNodeId() + "/" + internalEquipment.getUuid());
}
@@ -275,18 +277,22 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
* @param nodeId Id for this DB element
*/
@Override
- public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
+ public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId) {
this.networkelementConnectionDB.update(networkElementConnectionEntitiy, nodeId);
}
/**
* Update after new mountpoint registration
+ *
* @param networkElementConnectionEntitiy data
* @param nodeId of device (mountpoint name)
*/
@Override
- public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
- this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId, Arrays.asList("is-required", "username", "password"));
+ public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId) {
+ this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId,
+ Arrays.asList("is-required", "username", "password"));
}
/* please do not remove */
@@ -302,15 +308,16 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
if (e != null && (isRequired = e.isIsRequired()) != null) {
if (isRequired) {
- LOG.debug("updating connection status for {} of required ne to disconnected",nodeId);
- this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
+ LOG.debug("updating connection status for {} of required ne to disconnected", nodeId);
+ this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder()
+ .setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
} else {
- LOG.debug("remove networkelement-connection for {} entry because of non-required",nodeId);
+ LOG.debug("remove networkelement-connection for {} entry because of non-required", nodeId);
this.networkelementConnectionDB.remove(nodeId);
}
- }
- else {
- LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",nodeId);
+ } else {
+ LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",
+ nodeId);
}
}
@@ -349,6 +356,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* Verify status of client
+ *
* @param event that is printed with message
* @return true if client is null
*/
@@ -359,8 +367,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private boolean assertIfClientNullForNodeName(Object object) {
return assertIfClientNull("No DB, can not handle node: {}", object);
}
+
/**
* Verify status of client
+ *
* @param message to print including {} for object printout.
* @return true if client is null
*/
@@ -378,6 +388,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsEventBase {
/**
* Query to get older Elements
+ *
* @param netconfTimeStamp to identify older Elements
* @return QueryBuilder for older elements related to timestamp
*/
@@ -388,29 +399,31 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsFaultLogDevicemanager {
/**
* Get older Elements
+ *
* @param netconfTimeStamp to identify query elements older than this timestamp.
* @return QueryBuilder for related elements
*/
public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
}
- }
- public static class EsFaultCurrent {
+ }
+ public static class EsFaultCurrent {
/**
* @param nodeName name of the node
* @return query builder
*/
- public static QueryBuilder getQueryForOneNode( String nodeName) {
+ public static QueryBuilder getQueryForOneNode(String nodeName) {
return QueryBuilders.matchQuery("node-id", nodeName);
}
- public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
+ public static QueryBuilder getQueryForOneNodeAndObjectId(String nodeName, String objectId) {
BoolQueryBuilder bq = QueryBuilders.boolQuery();
bq.must(QueryBuilders.matchQuery("node-id", nodeName));
bq.must(QueryBuilders.matchQuery("object-id", objectId));
return bq;
}
}
+
@Override
public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
return this.networkelementConnectionDB.doReadAll().getHits();
@@ -431,28 +444,29 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
id.append(date != null ? date.getValue() : "null");
switch (granularityPeriod) {
- case Period15Min:
- pmData15mDB.write(elem, id.toString());
- break;
- case Period24Hours:
- pmData24hDB.write(elem, id.toString());
- break;
- case Unknown:
- default:
- LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
- break;
+ case Period15Min:
+ pmData15mDB.write(elem, id.toString());
+ break;
+ case Period24Hours:
+ pmData24hDB.write(elem, id.toString());
+ break;
+ case Unknown:
+ default:
+ LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
+ break;
}
- } );
+ });
}
- @NonNull GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
+ @NonNull
+ GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
return granularityPeriod != null ? granularityPeriod : GranularityPeriodType.Unknown;
}
- @Override
- public HtDatabaseClient getRawClient() {
- return this.client;
- }
+ @Override
+ public HtDatabaseClient getRawClient() {
+ return this.client;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
index 245b89003..a675f6876 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
@@ -61,6 +61,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
/**
* Get existing object for mountpoint to manage maintenance mode
+ *
* @return Object with configuration
*/
@Override
@@ -74,26 +75,23 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
}
@Override
- public
- MaintenanceEntity setMaintenance(MaintenanceEntity m) {
+ public MaintenanceEntity setMaintenance(MaintenanceEntity m) {
if (maintenanceRW != null) {
- if (maintenanceRW.write(m, m.getNodeId() ) == null) {
- throw new IllegalArgumentException("Problem writing to database: "+m.getId());
+ if (maintenanceRW.write(m, m.getNodeId()) == null) {
+ throw new IllegalArgumentException("Problem writing to database: " + m.getId());
}
- LOG.info("Wrote maintenance object {}", m.toString());
+ LOG.info("Wrote maintenance object {}", m.toString());
}
return m;
}
@Override
- public
- List<MaintenanceEntity> getAll() {
+ public List<MaintenanceEntity> getAll() {
return maintenanceRW != null ? maintenanceRW.doReadAll().getHits() : new ArrayList<>();
}
@Override
- public
- MaintenanceEntity createIfNotExists(String mountpointId) {
+ public MaintenanceEntity createIfNotExists(String mountpointId) {
MaintenanceEntity deviceMaintenanceMode = null;
if (maintenanceRW != null) {
deviceMaintenanceMode = maintenanceRW.read(mountpointId);
@@ -111,8 +109,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
}
@Override
- public
- void deleteIfNotRequired(String mountPointNodeName) {
+ public void deleteIfNotRequired(String mountPointNodeName) {
if (!this.isRequireNe(mountPointNodeName)) {
if (maintenanceRW != null) {
@@ -128,6 +125,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
/**
* Provide default maintenanceinformation for a device
+ *
* @param mountpointId nodeId of device
* @return default data
*/
@@ -143,14 +141,14 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
deviceMaintenanceModeBuilder.setStart(now);
deviceMaintenanceModeBuilder.setEnd(now);
deviceMaintenanceModeBuilder.setActive(false);
-
+
// Reference to all
//consistent to UI input to null/not empty string
//deviceMaintenanceModeBuilder.setObjectIdRef("");
//deviceMaintenanceModeBuilder.setProblem("");
-
+
return deviceMaintenanceModeBuilder.build();
- }
+ }
// -- Private
/**
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
index 0d2e39bcb..38e5b13e2 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
@@ -38,66 +38,66 @@ import org.slf4j.LoggerFactory;
public class MediatorServerDataProvider implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
- private final HtDatabaseClient dbClient;
- private final DataObjectAcessor<Data> mediatorserverRW;
- private final int REFRESH_INTERVAL = 60;
- private final Map<String, Data> entries;
- private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
- private boolean isRunning;
+ private final HtDatabaseClient dbClient;
+ private final DataObjectAcessor<Data> mediatorserverRW;
+ private final int REFRESH_INTERVAL = 60;
+ private final Map<String, Data> entries;
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+ private boolean isRunning;
- public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts, null, null);
- }
+ public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
+ this(hosts, null, null);
+ }
- public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception {
- super();
- LOG.info("Start {}", this.getClass().getName());
- this.entries = new HashMap<>();
- this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword);
- this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer, Data.class);
- this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
- }
+ public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+ this.entries = new HashMap<>();
+ this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer, Data.class);
+ this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
+ }
- private final Runnable onTick = new Runnable() {
+ private final Runnable onTick = new Runnable() {
- @Override
- public void run() {
- isRunning = true;
- runIt();
- isRunning = false;
- }
+ @Override
+ public void run() {
+ isRunning = true;
+ runIt();
+ isRunning = false;
+ }
- };
+ };
- private void runIt() {
- SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
- List<Data> data = result.getHits();
- for (Data item : data) {
- MediatorServerDataProvider.this.entries.put(item.getId(), item);
- }
- }
+ private void runIt() {
+ SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
+ List<Data> data = result.getHits();
+ for (Data item : data) {
+ MediatorServerDataProvider.this.entries.put(item.getId(), item);
+ }
+ }
- /**
- *
- * @param dbServerId
- * @return url or null if not exists
- */
- public String getHostUrl(String dbServerId) {
- Data info = this.entries.getOrDefault(dbServerId, null);
- return info == null ? null : info.getUrl();
- }
+ /**
+ *
+ * @param dbServerId
+ * @return url or null if not exists
+ */
+ public String getHostUrl(String dbServerId) {
+ Data info = this.entries.getOrDefault(dbServerId, null);
+ return info == null ? null : info.getUrl();
+ }
- public boolean triggerReloadSync() {
- if (!isRunning) {
- runIt();
- }
- return true;
- }
+ public boolean triggerReloadSync() {
+ if (!isRunning) {
+ runIt();
+ }
+ return true;
+ }
- @Override
- public void close() throws Exception {
- this.scheduler.shutdown();
- }
+ @Override
+ public void close() throws Exception {
+ this.scheduler.shutdown();
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
index 330b0baf5..8027fb2c5 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
@@ -23,41 +23,42 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
public class ODLVersionLUT {
- public static String getONAPReleaseName(String onapCCSDKVersion,String def) {
- if(onapCCSDKVersion==null) {
- return def;
- }
- if(onapCCSDKVersion.startsWith("1.6.")) {
- return "ONAP Guillin";
- }
- if(onapCCSDKVersion.startsWith("1.5.")) {
- return "ONAP Frankfurt";
- }
- if(onapCCSDKVersion.startsWith("1.4.")) {
- return "ONAP El Alto";
- }
- if(onapCCSDKVersion.startsWith("1.3.")) {
- return "ONAP El Alto";
- }
- return def;
- }
- public static String getOdlVersion(String onapCCSDKVersion,String def) {
-
- if(onapCCSDKVersion==null) {
- return def;
- }
- if(onapCCSDKVersion.startsWith("1.6.")) {
- return "sodium-SRX (0.11.X)";
- }
- if(onapCCSDKVersion.startsWith("1.5.")) {
- return "neon-SR1 (0.10.1)";
- }
- if(onapCCSDKVersion.startsWith("1.4.")) {
- return "neon-SR1 (0.10.1)";
- }
- if(onapCCSDKVersion.startsWith("1.3.")) {
- return "fluorine-SR2 (0.9.2)";
- }
- return def;
- }
+ public static String getONAPReleaseName(String onapCCSDKVersion, String def) {
+ if (onapCCSDKVersion == null) {
+ return def;
+ }
+ if (onapCCSDKVersion.startsWith("1.6.")) {
+ return "ONAP Guillin";
+ }
+ if (onapCCSDKVersion.startsWith("1.5.")) {
+ return "ONAP Frankfurt";
+ }
+ if (onapCCSDKVersion.startsWith("1.4.")) {
+ return "ONAP El Alto";
+ }
+ if (onapCCSDKVersion.startsWith("1.3.")) {
+ return "ONAP El Alto";
+ }
+ return def;
+ }
+
+ public static String getOdlVersion(String onapCCSDKVersion, String def) {
+
+ if (onapCCSDKVersion == null) {
+ return def;
+ }
+ if (onapCCSDKVersion.startsWith("1.6.")) {
+ return "sodium-SRX (0.11.X)";
+ }
+ if (onapCCSDKVersion.startsWith("1.5.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if (onapCCSDKVersion.startsWith("1.4.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if (onapCCSDKVersion.startsWith("1.3.")) {
+ return "fluorine-SR2 (0.9.2)";
+ }
+ return def;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
index a83dfd975..b6a502071 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
@@ -44,12 +44,12 @@ import org.slf4j.LoggerFactory;
public class QueryByFilter {
- private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
- private static final List<String> timestampValueNames = Arrays.asList("timestamp","start","end");
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+ private static final List<String> timestampValueNames = Arrays.asList("timestamp", "start", "end");
- private QueryByFilter() {
- //Hide
- }
+ private QueryByFilter() {
+ //Hide
+ }
static long getPage(EntityInput input) {
return getPage(input, 1);
@@ -88,7 +88,7 @@ public class QueryByFilter {
}
- public static Sortorder getSortOrder(@Nullable List<Sortorder> list, String prop) {
+ public static Sortorder getSortOrder(@Nullable List<Sortorder> list, String prop) {
if (list == null) {
return null;
}
@@ -100,7 +100,7 @@ public class QueryByFilter {
return null;
}
- public static Filter getFilter(@Nullable List<Filter> list, String prop) {
+ public static Filter getFilter(@Nullable List<Filter> list, String prop) {
if (list == null) {
return null;
}
@@ -112,161 +112,157 @@ public class QueryByFilter {
return null;
}
- public static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
+ public static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
return fromFilter(filters, "");
}
- private static String fillTimeStamp(String value) {
- int idx=value.lastIndexOf("*");
- final String REPLACE="0000-00-00T00:00:00.0Z";
- String s = value.substring(0,idx)+REPLACE.substring(idx);
- if(Integer.parseInt(s.substring(5,7))==0) {
- s=s.substring(0,5)+"01-"+s.substring(8);
+ private static String fillTimeStamp(String value) {
+ int idx = value.lastIndexOf("*");
+ final String REPLACE = "0000-00-00T00:00:00.0Z";
+ String s = value.substring(0, idx) + REPLACE.substring(idx);
+ if (Integer.parseInt(s.substring(5, 7)) == 0) {
+ s = s.substring(0, 5) + "01-" + s.substring(8);
}
- if(Integer.parseInt(s.substring(8,10))==0) {
- s=s.substring(0,8)+"01"+s.substring(10);
+ if (Integer.parseInt(s.substring(8, 10)) == 0) {
+ s = s.substring(0, 8) + "01" + s.substring(10);
}
return s;
- }
- /**
- * convert timestamp with ending placeholder in filter to elasticsearch filter
- * e.g. 2017* => gte: 2017-01-01T00:00:00Z, lt:2018-01-01T00:00:00Z
- *
- * 201* => 2010-01... 2020 ..
- * 2018-* => 2018-01... <=> 2019-01
- *
- */
- private static @Nullable QueryBuilder fromTimestampSearchFilter(String property,String value) {
- if(!value.endsWith("*")) {
+ }
+
+ /**
+ * convert timestamp with ending placeholder in filter to elasticsearch filter e.g. 2017* => gte:
+ * 2017-01-01T00:00:00Z, lt:2018-01-01T00:00:00Z
+ *
+ * 201* => 2010-01... 2020 .. 2018-* => 2018-01... <=> 2019-01
+ *
+ */
+ private static @Nullable QueryBuilder fromTimestampSearchFilter(String property, String value) {
+ if (!value.endsWith("*")) {
return null;
}
- int idx=value.lastIndexOf("*");
+ int idx = value.lastIndexOf("*");
String lowerEnd = fillTimeStamp(value);
- String upperEnd =null;
+ String upperEnd = null;
NetconfTimeStamp converter = NetconfTimeStampImpl.getConverter();
Date dt = null;
- try{
- dt=converter.getDateFromNetconf(lowerEnd);
- }
- catch(Exception e) {
+ try {
+ dt = converter.getDateFromNetconf(lowerEnd);
+ } catch (Exception e) {
}
- if(dt==null) {
+ if (dt == null) {
return null;
}
-// property.substring(0,idx)+REPLACE.substring(idx+1);
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ // property.substring(0,idx)+REPLACE.substring(idx+1);
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.setTime(dt);
int tmpvalue;
- switch(idx) {
- case 1: // (2*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1000);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 2: // (20*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+100);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 3: // (200*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 4: // (2000*)
- case 5: // (2000-*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 6: //switch 10 months (2000-0* or 2000-1*)
- tmpvalue = c.get(Calendar.MONTH);
- if(tmpvalue<9) {
- c.set(Calendar.MONTH,9);
- }
- else {
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
- c.set(Calendar.MONTH,0);
+ switch (idx) {
+ case 1: // (2*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1000);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 2: // (20*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 100);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 3: // (200*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 4: // (2000*)
+ case 5: // (2000-*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 6: //switch 10 months (2000-0* or 2000-1*)
+ tmpvalue = c.get(Calendar.MONTH);
+ if (tmpvalue < 9) {
+ c.set(Calendar.MONTH, 9);
+ } else {
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1);
+ c.set(Calendar.MONTH, 0);
}
upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 7: //switch one month (2018-01* or 2018-01-*)
- case 8:
- c.add(Calendar.MONTH, 1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 9: // (2018-01-0*)
- tmpvalue = c.get(Calendar.DAY_OF_MONTH);
- if(tmpvalue==1) {
- c.set(Calendar.DAY_OF_MONTH, 10);
- }else if(tmpvalue==10) {
- c.set(Calendar.DAY_OF_MONTH, 20);
- }else if(tmpvalue==20) {
- if(c.getActualMaximum(Calendar.DAY_OF_MONTH)<30) {
- c.set(Calendar.DAY_OF_MONTH,1);
- c.add(Calendar.MONTH,1);
+ break;
+ case 7: //switch one month (2018-01* or 2018-01-*)
+ case 8:
+ c.add(Calendar.MONTH, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 9: // (2018-01-0*)
+ tmpvalue = c.get(Calendar.DAY_OF_MONTH);
+ if (tmpvalue == 1) {
+ c.set(Calendar.DAY_OF_MONTH, 10);
+ } else if (tmpvalue == 10) {
+ c.set(Calendar.DAY_OF_MONTH, 20);
+ } else if (tmpvalue == 20) {
+ if (c.getActualMaximum(Calendar.DAY_OF_MONTH) < 30) {
+ c.set(Calendar.DAY_OF_MONTH, 1);
+ c.add(Calendar.MONTH, 1);
+ } else {
+ c.set(Calendar.DAY_OF_MONTH, 30);
+ }
+ } else if (tmpvalue == 30) {
+ c.set(Calendar.DAY_OF_MONTH, 1);
+ c.add(Calendar.MONTH, 1);
+ } else {
+ break;
}
- else {
- c.set(Calendar.DAY_OF_MONTH,30);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 10: // (2018-01-01*)
+ case 11: // (2018-01-01T*)
+ c.add(Calendar.DAY_OF_MONTH, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 12: // (2018-01-01T1*)
+ tmpvalue = c.get(Calendar.HOUR_OF_DAY);
+ if (tmpvalue == 20) {
+ c.set(Calendar.HOUR_OF_DAY, 0);
+ c.add(Calendar.DAY_OF_MONTH, 1);
+ } else {
+ c.add(Calendar.HOUR_OF_DAY, 10);
}
- }else if(tmpvalue==30) {
- c.set(Calendar.DAY_OF_MONTH,1);
- c.add(Calendar.MONTH,1);
- }
- else {
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 13: // (2018-01-01T11*)
+ case 14: // (2018-01-01T11-*)
+ c.add(Calendar.HOUR_OF_DAY, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 15: // (2018-01-01T11-3*)
+ c.add(Calendar.MINUTE, 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 16: // (2018-01-01T11-32*)
+ case 17: // (2018-01-01T11-32-*)
+ c.add(Calendar.MINUTE, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 18: // (2018-01-01T11-32-1*)
+ c.add(Calendar.SECOND, 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 19: // (2018-01-01T11-32-11*)
+ case 20: // (2018-01-01T11-32-11.*)
+ c.add(Calendar.SECOND, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
break;
- }
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 10: // (2018-01-01*)
- case 11: // (2018-01-01T*)
- c.add(Calendar.DAY_OF_MONTH,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 12: // (2018-01-01T1*)
- tmpvalue = c.get(Calendar.HOUR_OF_DAY);
- if(tmpvalue==20) {
- c.set(Calendar.HOUR_OF_DAY,0);
- c.add(Calendar.DAY_OF_MONTH,1);
- }
- else {
- c.add(Calendar.HOUR_OF_DAY,10);
- }
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 13: // (2018-01-01T11*)
- case 14: // (2018-01-01T11-*)
- c.add(Calendar.HOUR_OF_DAY,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 15: // (2018-01-01T11-3*)
- c.add(Calendar.MINUTE,10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 16: // (2018-01-01T11-32*)
- case 17: // (2018-01-01T11-32-*)
- c.add(Calendar.MINUTE,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 18: // (2018-01-01T11-32-1*)
- c.add(Calendar.SECOND,10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 19: // (2018-01-01T11-32-11*)
- case 20: // (2018-01-01T11-32-11.*)
- c.add(Calendar.SECOND,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
default:
break;
}
- if(upperEnd==null) {
+ if (upperEnd == null) {
return null;
}
return QueryBuilders.rangeQuery(property).gte(lowerEnd).lt(upperEnd);
}
+
private static QueryBuilder fromFilter(@Nullable List<Filter> filters, String prefix) {
if (filters == null || filters.size() == 0) {
return QueryBuilders.matchAllQuery();
@@ -274,17 +270,16 @@ public class QueryByFilter {
} else if (filters.size() == 1) {
QueryBuilder query;
String p = filters.get(0).getProperty();
- String v= filters.get(0).getFiltervalue();
+ String v = filters.get(0).getFiltervalue();
if ("id".equals(p)) {
p = "_id";
- }
- else {
- // v=v.toLowerCase();
+ } else {
+ // v=v.toLowerCase();
}
if (DbFilter.hasSearchParams(v)) {
- if(p!=null && timestampValueNames.contains(p.toLowerCase())) {
- query = fromTimestampSearchFilter(p,v);
- if(query!=null) {
+ if (p != null && timestampValueNames.contains(p.toLowerCase())) {
+ query = fromTimestampSearchFilter(p, v);
+ if (query != null) {
return query;
}
}
@@ -295,50 +290,45 @@ public class QueryByFilter {
RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p, v);
if (q != null) {
return q;
- }
- else {
+ } else {
return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
}
- }
- else {
+ } else {
return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
}
- }
- else {
+ } else {
BoolQueryBuilder query = new BoolQueryBuilder();
QueryBuilder tmpQuery;
for (Filter fi : filters) {
String p = fi.getProperty();
- String v=fi.getFiltervalue();
+ String v = fi.getFiltervalue();
if ("id".equals(p)) {
p = "_id";
+ } else {
+ // v=v.toLowerCase();
}
- else {
- // v=v.toLowerCase();
- }
- if(DbFilter.hasSearchParams(v)) {
- if(p!=null && timestampValueNames.contains(p.toLowerCase())) {
- tmpQuery=fromTimestampSearchFilter(p,v);
- if(tmpQuery!=null) {
+ if (DbFilter.hasSearchParams(v)) {
+ if (p != null && timestampValueNames.contains(p.toLowerCase())) {
+ tmpQuery = fromTimestampSearchFilter(p, v);
+ if (tmpQuery != null) {
query.must(tmpQuery);
- }else {
- query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ } else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,
+ DbFilter.createDatabaseRegex(v)));
}
- }else {
- query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ } else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,
+ DbFilter.createDatabaseRegex(v)));
}
- }
- else if (DbFilter.isComparisonValid(v)) {
- RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p,v);
- if(q!=null) {
+ } else if (DbFilter.isComparisonValid(v)) {
+ RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p, v);
+ if (q != null) {
query.must(q);
+ } else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v));
}
- else {
- query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
- }
- }
- else {
- query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
+ } else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v));
}
}
LOG.trace("Query result. {}", query.toJSON());
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
index 87e1a7cdb..61e524192 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
@@ -29,27 +29,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class QueryResult<T> {
- private SearchResult<T> result;
- private PaginationOutputG pagination;
-
- public QueryResult(long page, long pageSize, SearchResult<T> result) {
- this.result = result;
-
- PaginationBuilder x = new PaginationBuilder();
- x.setPage(BigInteger.valueOf(page));
- x.setSize(pageSize);
- x.setTotal(BigInteger.valueOf(result.getTotal()));
- pagination = x.build();
- }
-
- public SearchResult<T> getResult() {
- return result;
- }
-
- PaginationOutputG getPagination() {
- return pagination;
- }
-
+ private SearchResult<T> result;
+ private PaginationOutputG pagination;
+
+ public QueryResult(long page, long pageSize, SearchResult<T> result) {
+ this.result = result;
+
+ PaginationBuilder x = new PaginationBuilder();
+ x.setPage(BigInteger.valueOf(page));
+ x.setSize(pageSize);
+ x.setTotal(BigInteger.valueOf(result.getTotal()));
+ pagination = x.build();
+ }
+
+ public SearchResult<T> getResult() {
+ return result;
+ }
+
+ PaginationOutputG getPagination() {
+ return pagination;
+ }
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
index dce309c33..9b8806ab8 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
@@ -48,284 +48,290 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
public class SystemInfo {
- private static NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
- private static NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH));
- private static NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
- private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- protected static boolean showMemoryPools = false;
+ private static NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
+ protected static boolean showMemoryPools = false;
- public static String getMdSalVersion(String def) {
- return getMdSalVersion("", def);
- }
- public static String getYangToolsVersion(String def) {
- return getYangToolsVersion("", def);
- }
-
- public static String getMdSalVersion(String baseOdlDirectory,String def) {
- return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/mdsal/mdsal-binding-api/",def);
- }
- public static String getYangToolsVersion(String baseOdlDirectory,String def) {
- return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/yangtools/odl-yangtools-common/",def);
- }
- private static String getFeatureVersionByFolder(String baseOdlDirectory,String dir,String def) {
- final String regex = "^[0-9]+\\.[0-9]+\\.[0-9]+(-SNAPSHOT)?$";
- Stream<Path> entries=null;
- try {
- if(baseOdlDirectory!=null && baseOdlDirectory.length()>0 && !baseOdlDirectory.endsWith("/")) {
- baseOdlDirectory+="/";
- }
- entries = Files.list(new File(baseOdlDirectory+dir).toPath());
- } catch (IOException e) {
-
- }
- if(entries==null) {
- return def;
- }
- final Pattern pattern = Pattern.compile(regex);
-
- Iterator<Path> it = entries.iterator();
- Path p;File f;
- while(it.hasNext()) {
- p = it.next();
- f=p.toFile();
- if(f.isDirectory()) {
- final Matcher matcher = pattern.matcher(f.getName().toString());
- if(matcher.find()) {
- def= matcher.group(0);
- break;
- }
- }
- }
- entries.close();
- return def;
- }
- public static String get() throws Exception {
- StringBuilder sb = new StringBuilder();
- int maxNameLen;
+ public static String getMdSalVersion(String def) {
+ return getMdSalVersion("", def);
+ }
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- ThreadMXBean threads = ManagementFactory.getThreadMXBean();
- MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
+ public static String getYangToolsVersion(String def) {
+ return getYangToolsVersion("", def);
+ }
- //
- // print Karaf informations
- //
- maxNameLen = 25;
- sb.append("Karaf\n");
- printValue(sb, "Karaf version", maxNameLen, System.getProperty("karaf.version"));
- printValue(sb, "Karaf home", maxNameLen, System.getProperty("karaf.home"));
- printValue(sb, "Karaf base", maxNameLen, System.getProperty("karaf.base"));
- String osgi = getOsgiFramework();
- if (osgi != null) {
- printValue(sb, "OSGi Framework", maxNameLen, osgi);
- }
+ public static String getMdSalVersion(String baseOdlDirectory, String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory, "system/org/opendaylight/mdsal/mdsal-binding-api/", def);
+ }
- sb.append("JVM\n");
- printValue(sb, "Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
- printValue(sb, "Version", maxNameLen, System.getProperty("java.version"));
- printValue(sb, "Vendor", maxNameLen, runtime.getVmVendor());
- printValue(sb, "Pid", maxNameLen, getPid());
- printValue(sb, "Uptime", maxNameLen, printDuration(runtime.getUptime()));
- try {
- Class<?> sunOS = Class.forName("com.sun.management.OperatingSystemMXBean");
- printValue(sb, "Process CPU time", maxNameLen,
- printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 1000000.0));
- printValue(sb, "Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad")));
- printValue(sb, "System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad")));
- } catch (Throwable t) {
- }
- try {
- Class<?> unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
- printValue(sb, "Open file descriptors", maxNameLen,
- printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount")));
- printValue(sb, "Max file descriptors", maxNameLen,
- printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount")));
- } catch (Throwable t) {
- }
- printValue(sb, "Total compile time", maxNameLen,
- printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
+ public static String getYangToolsVersion(String baseOdlDirectory, String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory, "system/org/opendaylight/yangtools/odl-yangtools-common/",
+ def);
+ }
- sb.append("Threads\n");
- printValue(sb, "Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
- printValue(sb, "Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
- printValue(sb, "Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
- printValue(sb, "Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
+ private static String getFeatureVersionByFolder(String baseOdlDirectory, String dir, String def) {
+ final String regex = "^[0-9]+\\.[0-9]+\\.[0-9]+(-SNAPSHOT)?$";
+ Stream<Path> entries = null;
+ try {
+ if (baseOdlDirectory != null && baseOdlDirectory.length() > 0 && !baseOdlDirectory.endsWith("/")) {
+ baseOdlDirectory += "/";
+ }
+ entries = Files.list(new File(baseOdlDirectory + dir).toPath());
+ } catch (IOException e) {
- sb.append("Memory\n");
- printValue(sb, "Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
- printValue(sb, "Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
- printValue(sb, "Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
- printValue(sb, "Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
- for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
- String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = "
- + printDuration(gc.getCollectionTime());
- printValue(sb, "Garbage collector", maxNameLen, val);
- }
+ }
+ if (entries == null) {
+ return def;
+ }
+ final Pattern pattern = Pattern.compile(regex);
-// if (showMemoryPools) {
-// List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
-// sb.append("Memory Pools\n");
-// printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size()));
-// String spaces4 = " ";
-// for (MemoryPoolMXBean pool : memoryPools) {
-// String name = pool.getName();
-// MemoryType type = pool.getType();
-// printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name);
-//
-// // PeakUsage/CurrentUsage
-// MemoryUsage peakUsage = pool.getPeakUsage();
-// MemoryUsage usage = pool.getUsage();
-//
-// if (usage != null && peakUsage != null) {
-// long init = peakUsage.getInit();
-// long used = peakUsage.getUsed();
-// long committed = peakUsage.getCommitted();
-// long max = peakUsage.getMax();
-// sb.append(spaces4 + spaces4 + "Peak Usage\n");
-// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
-//
-// init = usage.getInit();
-// used = usage.getUsed();
-// committed = usage.getCommitted();
-// max = usage.getMax();
-// sb.append(spaces4 + spaces4 + "Current Usage\n");
-// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
-// }
-// }
-// }
+ Iterator<Path> it = entries.iterator();
+ Path p;
+ File f;
+ while (it.hasNext()) {
+ p = it.next();
+ f = p.toFile();
+ if (f.isDirectory()) {
+ final Matcher matcher = pattern.matcher(f.getName().toString());
+ if (matcher.find()) {
+ def = matcher.group(0);
+ break;
+ }
+ }
+ }
+ entries.close();
+ return def;
+ }
- sb.append("Classes\n");
- printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
- printValue(sb, "Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
- printValue(sb, "Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
+ public static String get() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ int maxNameLen;
- sb.append("Operating system\n");
- printValue(sb, "Name", maxNameLen, os.getName() + " version " + os.getVersion());
- printValue(sb, "Architecture", maxNameLen, os.getArch());
- printValue(sb, "Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
- try {
- printValue(sb, "Total physical memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
- printValue(sb, "Free physical memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
- printValue(sb, "Committed virtual memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
- printValue(sb, "Total swap space", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
- printValue(sb, "Free swap space", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
- } catch (Throwable t) {
- }
- return sb.toString();
- }
+ RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+ ThreadMXBean threads = ManagementFactory.getThreadMXBean();
+ MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
+ ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
- private static String getPid() {
- // In Java 9 the new process API can be used:
- // long pid = ProcessHandle.current().getPid();
- String name = ManagementFactory.getRuntimeMXBean().getName();
- String[] parts = name.split("@");
- return parts[0];
- }
+ //
+ // print Karaf informations
+ //
+ maxNameLen = 25;
+ sb.append("Karaf\n");
+ printValue(sb, "Karaf version", maxNameLen, System.getProperty("karaf.version"));
+ printValue(sb, "Karaf home", maxNameLen, System.getProperty("karaf.home"));
+ printValue(sb, "Karaf base", maxNameLen, System.getProperty("karaf.base"));
+ String osgi = getOsgiFramework();
+ if (osgi != null) {
+ printValue(sb, "OSGi Framework", maxNameLen, osgi);
+ }
- private static long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
- Method mth = os.getClass().getMethod(name);
- return (Long) mth.invoke(os);
- }
+ sb.append("JVM\n");
+ printValue(sb, "Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
+ printValue(sb, "Version", maxNameLen, System.getProperty("java.version"));
+ printValue(sb, "Vendor", maxNameLen, runtime.getVmVendor());
+ printValue(sb, "Pid", maxNameLen, getPid());
+ printValue(sb, "Uptime", maxNameLen, printDuration(runtime.getUptime()));
+ try {
+ Class<?> sunOS = Class.forName("com.sun.management.OperatingSystemMXBean");
+ printValue(sb, "Process CPU time", maxNameLen,
+ printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 1000000.0));
+ printValue(sb, "Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad")));
+ printValue(sb, "System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad")));
+ } catch (Throwable t) {
+ }
+ try {
+ Class<?> unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
+ printValue(sb, "Open file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount")));
+ printValue(sb, "Max file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount")));
+ } catch (Throwable t) {
+ }
+ printValue(sb, "Total compile time", maxNameLen,
+ printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
- private static long getValueAsLong(Class<?> osImpl, String name) throws Exception {
- if (osImpl.isInstance(os)) {
- Method mth = osImpl.getMethod(name);
- return (Long) mth.invoke(os);
- }
- return -1;
- }
+ sb.append("Threads\n");
+ printValue(sb, "Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
+ printValue(sb, "Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
+ printValue(sb, "Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
+ printValue(sb, "Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
- private static double getValueAsDouble(Class<?> osImpl, String name) throws Exception {
- if (osImpl.isInstance(os)) {
- Method mth = osImpl.getMethod(name);
- return (Double) mth.invoke(os);
- }
- return -1;
- }
+ sb.append("Memory\n");
+ printValue(sb, "Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
+ printValue(sb, "Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
+ printValue(sb, "Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
+ printValue(sb, "Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
+ for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+ String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = "
+ + printDuration(gc.getCollectionTime());
+ printValue(sb, "Garbage collector", maxNameLen, val);
+ }
- private static String printLong(long i) {
- return fmtI.format(i);
- }
+ // if (showMemoryPools) {
+ // List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
+ // sb.append("Memory Pools\n");
+ // printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size()));
+ // String spaces4 = " ";
+ // for (MemoryPoolMXBean pool : memoryPools) {
+ // String name = pool.getName();
+ // MemoryType type = pool.getType();
+ // printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name);
+ //
+ // // PeakUsage/CurrentUsage
+ // MemoryUsage peakUsage = pool.getPeakUsage();
+ // MemoryUsage usage = pool.getUsage();
+ //
+ // if (usage != null && peakUsage != null) {
+ // long init = peakUsage.getInit();
+ // long used = peakUsage.getUsed();
+ // long committed = peakUsage.getCommitted();
+ // long max = peakUsage.getMax();
+ // sb.append(spaces4 + spaces4 + "Peak Usage\n");
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+ //
+ // init = usage.getInit();
+ // used = usage.getUsed();
+ // committed = usage.getCommitted();
+ // max = usage.getMax();
+ // sb.append(spaces4 + spaces4 + "Current Usage\n");
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+ // }
+ // }
+ // }
- private static String printSizeInKb(double size) {
- return fmtI.format((long) (size / 1024)) + " kbytes";
- }
+ sb.append("Classes\n");
+ printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
+ printValue(sb, "Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
+ printValue(sb, "Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
- protected static String printDuration(double uptime) {
- uptime /= 1000;
- if (uptime < 60) {
- return fmtD.format(uptime) + " seconds";
- }
- uptime /= 60;
- if (uptime < 60) {
- long minutes = (long) uptime;
- String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- return s;
- }
- uptime /= 60;
- if (uptime < 24) {
- long hours = (long) uptime;
- long minutes = (long) ((uptime - hours) * 60);
- String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- if (minutes != 0) {
- s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- }
- return s;
- }
- uptime /= 24;
- long days = (long) uptime;
- long hours = (long) ((uptime - days) * 24);
- String s = fmtI.format(days) + (days > 1 ? " days" : " day");
- if (hours != 0) {
- s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- }
- return s;
- }
+ sb.append("Operating system\n");
+ printValue(sb, "Name", maxNameLen, os.getName() + " version " + os.getVersion());
+ printValue(sb, "Architecture", maxNameLen, os.getArch());
+ printValue(sb, "Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
+ try {
+ printValue(sb, "Total physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
+ printValue(sb, "Free physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
+ printValue(sb, "Committed virtual memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
+ printValue(sb, "Total swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
+ printValue(sb, "Free swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
+ } catch (Throwable t) {
+ }
+ return sb.toString();
+ }
- static void printSysValue(StringBuilder sb, String prop, int pad) {
- printValue(sb, prop, pad, System.getProperty(prop));
- }
+ private static String getPid() {
+ // In Java 9 the new process API can be used:
+ // long pid = ProcessHandle.current().getPid();
+ String name = ManagementFactory.getRuntimeMXBean().getName();
+ String[] parts = name.split("@");
+ return parts[0];
+ }
- static void printValue(StringBuilder sb, String name, int pad, String value) {
- sb.append(" " + // SimpleAnsi.INTENSITY_BOLD +
- name + // SimpleAnsi.INTENSITY_NORMAL +
- spaces(pad - name.length()) + " " + value + "\n");
- }
+ private static long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
+ Method mth = os.getClass().getMethod(name);
+ return (Long) mth.invoke(os);
+ }
- static String spaces(int nb) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < nb; i++) {
- sb.append(' ');
- }
- return sb.toString();
- }
+ private static long getValueAsLong(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Long) mth.invoke(os);
+ }
+ return -1;
+ }
- static String getOsgiFramework() {
- try {
- Callable<String> call = new Callable<String>() {
- @Override
- public String call() throws Exception {
- BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
- Bundle sysBundle = context.getBundle(0);
- return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
- }
- };
- return call.call();
- } catch (Throwable t) {
- // We're not in OSGi, just safely return null
- return null;
- }
- }
+ private static double getValueAsDouble(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Double) mth.invoke(os);
+ }
+ return -1;
+ }
+
+ private static String printLong(long i) {
+ return fmtI.format(i);
+ }
+
+ private static String printSizeInKb(double size) {
+ return fmtI.format((long) (size / 1024)) + " kbytes";
+ }
+
+ protected static String printDuration(double uptime) {
+ uptime /= 1000;
+ if (uptime < 60) {
+ return fmtD.format(uptime) + " seconds";
+ }
+ uptime /= 60;
+ if (uptime < 60) {
+ long minutes = (long) uptime;
+ String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ return s;
+ }
+ uptime /= 60;
+ if (uptime < 24) {
+ long hours = (long) uptime;
+ long minutes = (long) ((uptime - hours) * 60);
+ String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ if (minutes != 0) {
+ s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ }
+ return s;
+ }
+ uptime /= 24;
+ long days = (long) uptime;
+ long hours = (long) ((uptime - days) * 24);
+ String s = fmtI.format(days) + (days > 1 ? " days" : " day");
+ if (hours != 0) {
+ s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ }
+ return s;
+ }
+
+ static void printSysValue(StringBuilder sb, String prop, int pad) {
+ printValue(sb, prop, pad, System.getProperty(prop));
+ }
+
+ static void printValue(StringBuilder sb, String name, int pad, String value) {
+ sb.append(" " + // SimpleAnsi.INTENSITY_BOLD +
+ name + // SimpleAnsi.INTENSITY_NORMAL +
+ spaces(pad - name.length()) + " " + value + "\n");
+ }
+
+ static String spaces(int nb) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < nb; i++) {
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ static String getOsgiFramework() {
+ try {
+ Callable<String> call = new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
+ Bundle sysBundle = context.getBundle(0);
+ return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
+ }
+ };
+ return call.call();
+ } catch (Throwable t) {
+ // We're not in OSGi, just safely return null
+ return null;
+ }
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
index d54afd642..4f259aa4b 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
@@ -42,169 +42,167 @@ import org.slf4j.LoggerFactory;
public class YangFileProvider {
- private static final Logger LOG = LoggerFactory.getLogger(YangFileProvider.class);
-
- private static final FilenameFilter yangFilenameFilter = new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.toLowerCase().endsWith(".yang");
- }
- };
-
- private static final int BUFFER_SIZE = 1024;
-
- private final Path mainSourcePath;
- private final List<Path> additionalSources;
-
- public YangFileProvider(String path) {
- this.mainSourcePath = new File(path).toPath();
- this.additionalSources = new ArrayList<>();
- }
-
- public boolean hasFileForModule(String module, String version) {
- return this.mainSourcePath.resolve(YangFilename.createFilename(module, version)).toFile().exists();
- }
-
- public boolean hasFileForModule(String module) {
- return this.findYangFiles(module).size() > 0;
- }
-
- private List<YangFilename> findYangFiles(String module) {
- List<YangFilename> list = new ArrayList<>();
- String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
- YangFilename yangfile;
- for (String file : files) {
- files = this.mainSourcePath.toFile().list(yangFilenameFilter);
- for (String fn : files) {
- try {
- yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
- if (yangfile.getModule().equals(module)) {
- list.add(yangfile);
- }
- } catch (ParseException e) {
- LOG.warn("unable to handle yangfile {}: {}", file, e);
- }
- }
- }
- for (Path addPath : this.additionalSources) {
- files = addPath.toFile().list(yangFilenameFilter);
- for (String file : files) {
- try {
- yangfile = new YangFilename(addPath.resolve(file).toString());
- if (yangfile.getModule().equals(module)) {
- list.add(yangfile);
- }
- } catch (ParseException e) {
- LOG.warn("unable to handle yangfile {}: {}", file, e);
- }
- }
- }
- return list;
- }
-
- /**
- * get yang file from source with specified version or least newer one if
- * version is null then the latest one
- *
- * @param module
- * @param version
- * @return
- * @throws ParseException
- */
- private @Nullable YangFilename getYangFile(@Nonnull String module, @Nullable String version) throws ParseException {
- YangFilename f = null;
- List<YangFilename> list = this.findYangFiles(module);
-
- list.sort(SortByDateAscComparator.getInstance());
-
- // find specific version or nearest oldest
- if (version != null) {
- Date rev = YangFilename.parseRevision(version);
- for (YangFilename item : list) {
- if (rev.equals(item.getRevision())) {
- f = item;
- break;
- }
- if (item.getRevision().after(rev)) {
- f = item;
- break;
- }
- }
- }
- // get latest
- else {
- f = list.get(list.size() - 1);
- }
- return f;
- }
-
- /**
- * write filestream directly to output stream easier for http handling
- *
- * @param module
- * @param version
- * @param outputStream
- * @return
- * @throws IOException
- * @throws ParseException
- */
- public int writeOutput(@Nonnull String module, @Nullable String version, @Nonnull OutputStream outputStream)
- throws IOException, ParseException {
- YangFilename fn = this.getYangFile(module, version);
- if(fn==null) {
- return 0;
- }
- byte[] buffer = new byte[BUFFER_SIZE];
- int bytesRead = -1;
- int sumlen = 0;
- InputStream inputStream = null ;
- try {
- inputStream= new FileInputStream(fn.getFilename());
-
- while ((bytesRead = inputStream.read(buffer)) != -1) {
- outputStream.write(buffer, 0, bytesRead);
- sumlen += bytesRead;
- }}
- catch(IOException e) {
- LOG.warn("problem sending {}: {}",fn.getFilename(),e);
- }
- finally {
- if(inputStream!=null) {
- inputStream.close();
- }
- }
- return sumlen;
- }
-
- private static class SortByDateAscComparator implements Comparator<YangFilename> {
-
- private static SortByDateAscComparator instance;
-
- @Override
- public int compare(YangFilename o1, YangFilename o2) {
- return o1.getRevision().compareTo(o2.getRevision());
- }
-
- public static Comparator<YangFilename> getInstance() {
- if (instance == null) {
- instance = new SortByDateAscComparator();
- }
- return instance;
- }
-
- }
-
- public YangFilename getFileForModule(String module, String rev) throws ParseException {
- return this.getYangFile(module, rev);
- }
-
- public YangFilename getFileForModule(String module) throws ParseException {
- return this.getFileForModule(module, null);
- }
-
- public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
- return this.getYangFile(module, version) != null;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(YangFileProvider.class);
+
+ private static final FilenameFilter yangFilenameFilter = new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".yang");
+ }
+ };
+
+ private static final int BUFFER_SIZE = 1024;
+
+ private final Path mainSourcePath;
+ private final List<Path> additionalSources;
+
+ public YangFileProvider(String path) {
+ this.mainSourcePath = new File(path).toPath();
+ this.additionalSources = new ArrayList<>();
+ }
+
+ public boolean hasFileForModule(String module, String version) {
+ return this.mainSourcePath.resolve(YangFilename.createFilename(module, version)).toFile().exists();
+ }
+
+ public boolean hasFileForModule(String module) {
+ return this.findYangFiles(module).size() > 0;
+ }
+
+ private List<YangFilename> findYangFiles(String module) {
+ List<YangFilename> list = new ArrayList<>();
+ String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ YangFilename yangfile;
+ for (String file : files) {
+ files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ for (String fn : files) {
+ try {
+ yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ for (Path addPath : this.additionalSources) {
+ files = addPath.toFile().list(yangFilenameFilter);
+ for (String file : files) {
+ try {
+ yangfile = new YangFilename(addPath.resolve(file).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * get yang file from source with specified version or least newer one if version is null then the latest one
+ *
+ * @param module
+ * @param version
+ * @return
+ * @throws ParseException
+ */
+ private @Nullable YangFilename getYangFile(@Nonnull String module, @Nullable String version) throws ParseException {
+ YangFilename f = null;
+ List<YangFilename> list = this.findYangFiles(module);
+
+ list.sort(SortByDateAscComparator.getInstance());
+
+ // find specific version or nearest oldest
+ if (version != null) {
+ Date rev = YangFilename.parseRevision(version);
+ for (YangFilename item : list) {
+ if (rev.equals(item.getRevision())) {
+ f = item;
+ break;
+ }
+ if (item.getRevision().after(rev)) {
+ f = item;
+ break;
+ }
+ }
+ }
+ // get latest
+ else {
+ f = list.get(list.size() - 1);
+ }
+ return f;
+ }
+
+ /**
+ * write filestream directly to output stream easier for http handling
+ *
+ * @param module
+ * @param version
+ * @param outputStream
+ * @return
+ * @throws IOException
+ * @throws ParseException
+ */
+ public int writeOutput(@Nonnull String module, @Nullable String version, @Nonnull OutputStream outputStream)
+ throws IOException, ParseException {
+ YangFilename fn = this.getYangFile(module, version);
+ if (fn == null) {
+ return 0;
+ }
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int bytesRead = -1;
+ int sumlen = 0;
+ InputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(fn.getFilename());
+
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ sumlen += bytesRead;
+ }
+ } catch (IOException e) {
+ LOG.warn("problem sending {}: {}", fn.getFilename(), e);
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return sumlen;
+ }
+
+ private static class SortByDateAscComparator implements Comparator<YangFilename> {
+
+ private static SortByDateAscComparator instance;
+
+ @Override
+ public int compare(YangFilename o1, YangFilename o2) {
+ return o1.getRevision().compareTo(o2.getRevision());
+ }
+
+ public static Comparator<YangFilename> getInstance() {
+ if (instance == null) {
+ instance = new SortByDateAscComparator();
+ }
+ return instance;
+ }
+
+ }
+
+ public YangFilename getFileForModule(String module, String rev) throws ParseException {
+ return this.getYangFile(module, rev);
+ }
+
+ public YangFilename getFileForModule(String module) throws ParseException {
+ return this.getFileForModule(module, null);
+ }
+
+ public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
+ return this.getYangFile(module, version) != null;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
index fcee3cbdb..e5d0b18cd 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
@@ -29,39 +29,46 @@ import java.util.regex.Pattern;
public class YangFilename {
- private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
- private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
- private final String filename;
- private final Matcher matcher;
- private Date revision;
- private String module;
- public static Date parseRevision(String sRevision) throws ParseException {
- final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
- return fmt.parse(sRevision);
- }
- public YangFilename(String fn) throws ParseException {
- this.filename = fn;
- matcher = pattern.matcher(this.filename);
- if(!matcher.find()) {
- throw new ParseException("unknown filename format", 0);
- }
- this.module= matcher.group(1);
- this.revision=parseRevision(matcher.group(2));
-
- }
- public static String createFilename(String module, String rev) {
- return String.format("%s@%s.yang", module,rev);
- }
- public YangFilename(String module, String rev) throws ParseException {
- this(createFilename(module, rev));
- }
- public String getFilename() {
- return this.filename;
- }
- public Date getRevision() {
- return this.revision;
- }
- public String getModule() {
- return this.module;
- }
+ private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
+ private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
+ private final String filename;
+ private final Matcher matcher;
+ private Date revision;
+ private String module;
+
+ public static Date parseRevision(String sRevision) throws ParseException {
+ final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
+ return fmt.parse(sRevision);
+ }
+
+ public YangFilename(String fn) throws ParseException {
+ this.filename = fn;
+ matcher = pattern.matcher(this.filename);
+ if (!matcher.find()) {
+ throw new ParseException("unknown filename format", 0);
+ }
+ this.module = matcher.group(1);
+ this.revision = parseRevision(matcher.group(2));
+
+ }
+
+ public static String createFilename(String module, String rev) {
+ return String.format("%s@%s.yang", module, rev);
+ }
+
+ public YangFilename(String module, String rev) throws ParseException {
+ this(createFilename(module, rev));
+ }
+
+ public String getFilename() {
+ return this.filename;
+ }
+
+ public Date getRevision() {
+ return this.revision;
+ }
+
+ public String getModule() {
+ return this.module;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
index cca5eb648..c0518c664 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
@@ -42,239 +42,260 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
- * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
- * This attribute mast be of type String and contains for read and write operations the object id.
- * The function can be used without id handling.
- * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName
+ * is used. This attribute mast be of type String and contains for read and write operations the object id. The function
+ * can be used without id handling. If id handling is required the parameter needs to be specified by class definition
+ * in yang and setting the name by using setAttributeName()
*
* @param <T> Yang tools generated class object.
*/
public class EsDataObjectReaderWriter<T extends DataObject> {
- private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter.class);
-
- /** Typename for elastic search data schema **/
- private String dataTypeName;
-
- /** Elasticsearch Database client to be used **/
- private DatabaseClient db;
-
- /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
- private YangToolsMapper yangtoolsMapper;
-
- /** Class of T as attribute to allow JSON to Class object mapping **/
- private Class<T> clazz;
-
- /** Field is used to write id. If null no id handling **/
- private @Nullable Field field;
-
- /** Attribute that is used as id field for the database object **/
- private @Nullable String esIdAddAtributteName;
-
- /** Interface to be used for write operations. Rule for write: T extends S and **/
- private Class<? extends DataObject> writeInterfaceClazz; // == "S"
-
- /**
- * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
- *
- * @param db Database access client
- * @param dataTypeName typename in database schema
- * @param clazz class of type to be handled
- * @throws ClassNotFoundException
- */
- public EsDataObjectReaderWriter(DatabaseClient db, Entity dataTypeName, Class<T> clazz) throws ClassNotFoundException {
- this(db, dataTypeName.getName(), clazz);
- }
- public EsDataObjectReaderWriter(DatabaseClient db, String dataTypeName, Class<T> clazz) throws ClassNotFoundException {
- LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
-
- this.esIdAddAtributteName = null;
- this.field = null;
- this.writeInterfaceClazz = clazz;
- this.db = db;
- this.dataTypeName = dataTypeName;
- this.yangtoolsMapper = new YangToolsMapper();
- //this.yangtoolsMapper.assertBuilderClass(clazz);
- this.clazz = clazz;
-//
-// if (! db.isExistsIndex(dataTypeName)) {
-// throw new IllegalArgumentException("Index "+dataTypeName+" not existing.");
-// }
- }
-
- public String getDataTypeName() {
- return dataTypeName;
- }
- public Class<T> getClazz() {
- return clazz;
- }
- /**
- * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
- * @param esIdAttributeName is converted to UnderscoreCamelCase
- * @return this for further operations.
- */
- public EsDataObjectReaderWriter<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
- return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
- }
-
- /**
- * Attribute name of class that is containing the object id
- * @param esIdAttributeName of the implementation class for the yangtools interface.
- * Expected attribute name format is CamelCase with leading underline. @
- * @return this for further operations.
- * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
- */
- public EsDataObjectReaderWriter<T> setEsIdAttributeName(String esIdAttributeName) {
- LOG.debug("Set attribute '{}'", esIdAttributeName);
- this.esIdAddAtributteName = null; // Reset status
- this.field = null;
-
- Field attributeField;
- try {
- Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
- T object = builder.build();
- attributeField = object.getClass().getDeclaredField(esIdAttributeName);
- if (attributeField.getType().equals(String.class)) {
- attributeField.setAccessible(true);
- this.esIdAddAtributteName = esIdAttributeName; //Set new status if everything OK
- this.field = attributeField;
- } else {
- String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- }
- } catch (NoSuchFieldException e) {
- // Convert to run-time exception
- String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- } catch (SecurityException e) {
- LOG.debug("Access problem "+esIdAttributeName,e);
- throw e;
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter.class);
+
+ /** Typename for elastic search data schema **/
+ private String dataTypeName;
+
+ /** Elasticsearch Database client to be used **/
+ private DatabaseClient db;
+
+ /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
+ private YangToolsMapper yangtoolsMapper;
+
+ /** Class of T as attribute to allow JSON to Class object mapping **/
+ private Class<T> clazz;
+
+ /** Field is used to write id. If null no id handling **/
+ private @Nullable Field field;
+
+ /** Attribute that is used as id field for the database object **/
+ private @Nullable String esIdAddAtributteName;
+
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
+ private Class<? extends DataObject> writeInterfaceClazz; // == "S"
+
+ /**
+ * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
+ *
+ * @param db Database access client
+ * @param dataTypeName typename in database schema
+ * @param clazz class of type to be handled
+ * @throws ClassNotFoundException
+ */
+ public EsDataObjectReaderWriter(DatabaseClient db, Entity dataTypeName, Class<T> clazz)
+ throws ClassNotFoundException {
+ this(db, dataTypeName.getName(), clazz);
}
- return this;
- }
-
- /**
- * Specify subclass of T for write operations.
- * @param writeInterfaceClazz
- */
- public EsDataObjectReaderWriter<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
- LOG.debug("Set write interface to {}", writeInterfaceClazz);
- if (writeInterfaceClazz == null)
- throw new IllegalArgumentException("Null not allowed here.");
-
- this.writeInterfaceClazz = writeInterfaceClazz;
- return this;
- }
-
- /**
- * Write child object to database with specific id
- * @param object
- * @param @Nullable esId use the id or if null generate unique id
- * @return String with id or null
- */
- public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doWriteRaw(dataTypeName, esId, json);
- } catch (JsonProcessingException e) {
- LOG.error("Write problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public EsDataObjectReaderWriter(DatabaseClient db, String dataTypeName, Class<T> clazz)
+ throws ClassNotFoundException {
+ LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
+
+ this.esIdAddAtributteName = null;
+ this.field = null;
+ this.writeInterfaceClazz = clazz;
+ this.db = db;
+ this.dataTypeName = dataTypeName;
+ this.yangtoolsMapper = new YangToolsMapper();
+ //this.yangtoolsMapper.assertBuilderClass(clazz);
+ this.clazz = clazz;
+ //
+ // if (! db.isExistsIndex(dataTypeName)) {
+ // throw new IllegalArgumentException("Index "+dataTypeName+" not existing.");
+ // }
}
- return null;
- }
- /**
- * Update partial child object to database with match/term query
- * @param object
- * @param esId
- * @return String with esId or null
- */
- public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdate(this.dataTypeName,json,query);
- } catch (JsonProcessingException e) {
- LOG.error("Update problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public String getDataTypeName() {
+ return dataTypeName;
}
- return false;
- }
- /**
- * Write/ update partial child object to database with specific id Write if not
- * exists, else update
- * @param object
- * @param esId
- * @return String with esId or null
- */
- public @Nullable <S extends DataObject> String update(S object, String esId) {
- return this.update(object, esId,null);
- }
- public @Nullable <S extends DataObject> String update(S object, String esId,List<String> onylForInsert) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdateOrCreate(dataTypeName, esId, json,onylForInsert);
- } catch (JsonProcessingException e) {
- LOG.error("Update problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public Class<T> getClazz() {
+ return clazz;
+ }
+
+ /**
+ * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ *
+ * @param esIdAttributeName is converted to UnderscoreCamelCase
+ * @return this for further operations.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
+ return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
+ }
+
+ /**
+ * Attribute name of class that is containing the object id
+ *
+ * @param esIdAttributeName of the implementation class for the yangtools interface. Expected attribute name format
+ * is CamelCase with leading underline. @
+ * @return this for further operations.
+ * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeName(String esIdAttributeName) {
+ LOG.debug("Set attribute '{}'", esIdAttributeName);
+ this.esIdAddAtributteName = null; // Reset status
+ this.field = null;
+
+ Field attributeField;
+ try {
+ Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
+ T object = builder.build();
+ attributeField = object.getClass().getDeclaredField(esIdAttributeName);
+ if (attributeField.getType().equals(String.class)) {
+ attributeField.setAccessible(true);
+ this.esIdAddAtributteName = esIdAttributeName; //Set new status if everything OK
+ this.field = attributeField;
+ } else {
+ String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ } catch (NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ } catch (SecurityException e) {
+ LOG.debug("Access problem " + esIdAttributeName, e);
+ throw e;
+ }
+ return this;
+ }
+
+ /**
+ * Specify subclass of T for write operations.
+ *
+ * @param writeInterfaceClazz
+ */
+ public EsDataObjectReaderWriter<T> setWriteInterface(@Nonnull Class<? extends DataObject> writeInterfaceClazz) {
+ LOG.debug("Set write interface to {}", writeInterfaceClazz);
+ if (writeInterfaceClazz == null)
+ throw new IllegalArgumentException("Null not allowed here.");
+
+ this.writeInterfaceClazz = writeInterfaceClazz;
+ return this;
+ }
+
+ /**
+ * Write child object to database with specific id
+ *
+ * @param object
+ * @param @Nullable esId use the id or if null generate unique id
+ * @return String with id or null
+ */
+ public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doWriteRaw(dataTypeName, esId, json);
+ } catch (JsonProcessingException e) {
+ LOG.error("Write problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+
+ /**
+ * Update partial child object to database with match/term query
+ *
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdate(this.dataTypeName, json, query);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return false;
+ }
+
+ /**
+ * Write/ update partial child object to database with specific id Write if not exists, else update
+ *
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> String update(S object, String esId) {
+ return this.update(object, esId, null);
+ }
+
+ public @Nullable <S extends DataObject> String update(S object, String esId, List<String> onylForInsert) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdateOrCreate(dataTypeName, esId, json, onylForInsert);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
}
- return null;
- }
/**
* Read object from database, by using the id field
+ *
* @param object
* @return
*/
public @Nullable T read(String esId) {
- @Nullable T res = (T)null;
- if (esId != null) {
- String json = db.doReadJsonData(dataTypeName, esId);
- try {
- res = yangtoolsMapper.readValue(json.getBytes(), clazz);
- } catch (IOException e) {
- LOG.error("Problem: ", e);
- }
- }
+ @Nullable
+ T res = (T) null;
+ if (esId != null) {
+ String json = db.doReadJsonData(dataTypeName, esId);
+ try {
+ res = yangtoolsMapper.readValue(json.getBytes(), clazz);
+ } catch (IOException e) {
+ LOG.error("Problem: ", e);
+ }
+ }
return res;
}
/**
* Remove object
+ *
* @param esId to identify the object.
* @return success
*/
public boolean remove(String esId) {
- return db.doRemove(this.dataTypeName, esId);
+ return db.doRemove(this.dataTypeName, esId);
+ }
+
+ public int remove(QueryBuilder query) {
+ return this.db.doRemove(this.dataTypeName, query);
}
- public int remove(QueryBuilder query) {
- return this.db.doRemove(this.dataTypeName, query);
- }
/**
* Get all elements of related type
+ *
* @return all Elements
*/
public SearchResult<T> doReadAll() {
return doReadAll(null);
}
+
public SearchResult<T> doReadAll(QueryBuilder query) {
- return this.doReadAll(query,false);
- }
+ return this.doReadAll(query, false);
+ }
+
/**
* Read all existing objects of a type
+ *
* @param query for the elements
* @return the list of all objects
*/
@@ -310,26 +331,27 @@ public class EsDataObjectReaderWriter<T extends DataObject> {
return res;
}
- /* ---------------------------------------------
+ /* ---------------------------------------------
* Private functions
*/
- private void setEsId(T object, String esId) {
- if (field != null) {
- try {
- field.set(object, esId);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- LOG.debug("Field set problem.", e); }
+ private void setEsId(T object, String esId) {
+ if (field != null) {
+ try {
+ field.set(object, esId);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ LOG.debug("Field set problem.", e);
+ }
+ }
}
- }
private @Nullable T getT(String jsonString) {
- try {
- return yangtoolsMapper.readValue( jsonString, clazz );
- } catch (IOException e) {
- LOG.info("Mapping problem", e);
- return (T)null;
- }
+ try {
+ return yangtoolsMapper.readValue(jsonString, clazz);
+ } catch (IOException e) {
+ LOG.info("Mapping problem", e);
+ return (T) null;
+ }
}
}
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 f11bccb53..e0f6e4aea 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
@@ -44,20 +44,21 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
- * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
- * This attribute mast be of type String and contains for read and write operations the object id.
- * The function can be used without id handling.
- * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName
+ * is used. This attribute mast be of type String and contains for read and write operations the object id. The function
+ * can be used without id handling. If id handling is required the parameter needs to be specified by class definition
+ * in yang and setting the name by using setAttributeName()
*
- * Due to using Jackson base interfaces the org.eclipse.jdt.annotation.NonNull needs to be used here to get rid of warnings
+ * Due to using Jackson base interfaces the org.eclipse.jdt.annotation.NonNull needs to be used here to get rid of
+ * warnings
*
* @param <T> Yang tools generated class object.
*/
public class EsDataObjectReaderWriter2<T extends DataObject> {
- private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter2.class);
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter2.class);
- /** Typename for elastic search data schema **/
+ /** Typename for elastic search data schema **/
private String dataTypeName;
/** Elasticsearch Database client to be used **/
@@ -75,7 +76,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/** Attribute that is used as id field for the database object **/
private @Nullable String esIdAddAtributteName;
- /** Interface to be used for write operations. Rule for write: T extends S and **/
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
private Class<? extends DataObject> writeInterfaceClazz; // == "S"
/**
@@ -86,13 +87,20 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
* @param clazz class of type to be handled
* @throws ClassNotFoundException
*/
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz)
+ throws ClassNotFoundException {
this(db, dataTypeName.getName(), clazz, builderClazz);
}
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz) throws ClassNotFoundException {
+
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ Entity dataTypeName, @Nonnull Class<T> clazz) throws ClassNotFoundException {
this(db, dataTypeName.getName(), clazz, null);
}
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz)
+ throws ClassNotFoundException {
LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
this.esIdAddAtributteName = null;
@@ -106,6 +114,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ *
* @param esIdAttributeName is converted to UnderscoreCamelCase
* @return this for further operations.
*/
@@ -115,8 +124,9 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Attribute name of class that is containing the object id
- * @param esIdAttributeName of the implementation class for the yangtools interface.
- * Expected attribute name format is CamelCase with leading underline. @
+ *
+ * @param esIdAttributeName of the implementation class for the yangtools interface. Expected attribute name format
+ * is CamelCase with leading underline. @
* @return this for further operations.
* @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
*/
@@ -151,7 +161,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
LOG.debug(msg);
throw new IllegalArgumentException(msg);
} catch (SecurityException e) {
- LOG.debug("Access problem "+esIdAttributeName,e);
+ LOG.debug("Access problem " + esIdAttributeName, e);
throw e;
}
return this;
@@ -159,9 +169,10 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Specify subclass of T for write operations.
+ *
* @param writeInterfaceClazz
*/
- public EsDataObjectReaderWriter2<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
+ public EsDataObjectReaderWriter2<T> setWriteInterface(@Nonnull Class<? extends DataObject> writeInterfaceClazz) {
LOG.debug("Set write interface to {}", writeInterfaceClazz);
if (writeInterfaceClazz == null) {
throw new IllegalArgumentException("Null not allowed here.");
@@ -183,11 +194,12 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Write child object to database with specific id
+ *
* @param object to be written
* @param esId use the id or if null generate unique id
* @return String with id or null
*/
- public @Nullable <S extends DataObject> String write( S object, @Nullable String esId) {
+ public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
@@ -196,13 +208,15 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
LOG.error("Write problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return null;
}
+
/**
* Update partial child object to database with match/term query
+ *
* @param <S> of object
* @param object to write
* @param query for write of specific attributes
@@ -212,39 +226,41 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdate(this.dataTypeName,json,query);
+ return db.doUpdate(this.dataTypeName, json, query);
} catch (JsonProcessingException e) {
LOG.error("Update problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return false;
}
+
/**
- * Write/ update partial child object to database with specific id Write if not
- * exists, else update
+ * Write/ update partial child object to database with specific id Write if not exists, else update
+ *
* @param object
* @param esId
* @return String with esId or null
*/
public @Nullable <S extends DataObject> String update(S object, String esId) {
- return this.updateOrCreate(object, esId,null);
+ return this.updateOrCreate(object, esId, null);
}
+
/**
* See {@link doUpdateOrCreate(String dataTypeName, String esId, String json, List<String> doNotUpdateField) }
*/
- public @Nullable <S extends DataObject> String updateOrCreate(S object, String esId,List<String> onlyForInsert) {
+ public @Nullable <S extends DataObject> String updateOrCreate(S object, String esId, List<String> onlyForInsert) {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdateOrCreate(dataTypeName, esId, json,onlyForInsert);
+ return db.doUpdateOrCreate(dataTypeName, esId, json, onlyForInsert);
} catch (JsonProcessingException e) {
LOG.error("Update problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return null;
@@ -252,6 +268,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Read object from database, by using the id field
+ *
* @param object
* @return
*/
@@ -275,6 +292,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Remove object
+ *
* @param esId to identify the object.
* @return success
*/
@@ -285,18 +303,23 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
public int remove(QueryBuilder query) {
return this.db.doRemove(this.dataTypeName, query);
}
+
/**
* Get all elements of related type
+ *
* @return all Elements
*/
public SearchResult<T> doReadAll() {
return doReadAll(null);
}
+
public SearchResult<T> doReadAll(QueryBuilder query) {
- return this.doReadAll(query,false);
+ return this.doReadAll(query, false);
}
+
/**
* Read all existing objects of a type
+ *
* @param query for the elements
* @return the list of all objects
*/
@@ -304,21 +327,21 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
public SearchResult<T> doReadAll(QueryBuilder query, boolean ignoreException) {
SearchResult<T> res = new SearchResult<>();
- int idx = 0; //Idx for getAll
- int iterateLength = 100; //Step width for iterate
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
SearchResult<SearchHit> result;
List<SearchHit> hits;
do {
- if(query!=null) {
- LOG.debug("read data in {} with query {}",dataTypeName,query.toJSON());
- result=db.doReadByQueryJsonData( dataTypeName, query,ignoreException);
- }
- else {
- result = db.doReadAllJsonData(dataTypeName,ignoreException);
+ if (query != null) {
+ LOG.debug("read data in {} with query {}", dataTypeName, query.toJSON());
+ result = db.doReadByQueryJsonData(dataTypeName, query, ignoreException);
+ } else {
+ result = db.doReadAllJsonData(dataTypeName, ignoreException);
}
- hits=result.getHits();
- LOG.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), yangtoolsMapper.getMappingFailures());
+ hits = result.getHits();
+ LOG.debug("Read: {} elements: {} Failures: {}", dataTypeName, hits.size(),
+ yangtoolsMapper.getMappingFailures());
T object;
idx += result.getHits().size();
@@ -349,13 +372,14 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
try {
field.set(object, esId);
} catch (IllegalArgumentException | IllegalAccessException e) {
- LOG.debug("Field set problem.", e); }
+ LOG.debug("Field set problem.", e);
+ }
}
}
private @Nullable T getT(String jsonString) {
try {
- return yangtoolsMapper.readValue( jsonString, clazz );
+ return yangtoolsMapper.readValue(jsonString, clazz);
} catch (IOException e) {
LOG.info("Mapping problem", e);
return null;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
index 8c33a29e7..120684298 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
@@ -45,304 +45,312 @@ import org.slf4j.LoggerFactory;
public class AboutHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class);
- private static final String UNKNOWN = "unknown";
- private static final String METAINF_MAVEN = "/META-INF/maven/";
- private static final String EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE = "unable to read inner pom file: {}";
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class);
+ private static final String UNKNOWN = "unknown";
+ private static final String METAINF_MAVEN = "/META-INF/maven/";
+ private static final String EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE = "unable to read inner pom file: {}";
- private static final String URI_PRE = "/about";
- private static final String RES_BASEPATH = "about/";
+ private static final String URI_PRE = "/about";
+ private static final String RES_BASEPATH = "about/";
- private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
- private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
- private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
- private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
- private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
- private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
- private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
- private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
- private static final String PLACEHOLDER_CLUSTER_SIZE = "{cluster-size}";
- private static final String PLACEHOLDER_MDSAL_VERSION = "{mdsal-version}";
- private static final String PLACEHOLDER_YANGTOOLS_VERSION = "{yangtools-version}";
- private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
- private static final String README_FILE = "README.md";
+ private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
+ private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
+ private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
+ private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
+ private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
+ private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
+ private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
+ private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
+ private static final String PLACEHOLDER_CLUSTER_SIZE = "{cluster-size}";
+ private static final String PLACEHOLDER_MDSAL_VERSION = "{mdsal-version}";
+ private static final String PLACEHOLDER_YANGTOOLS_VERSION = "{yangtools-version}";
+ private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
+ private static final String README_FILE = "README.md";
- private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
- private final String artifactId = "sdnr-wt-data-provider-provider";
+ private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
+ private final String artifactId = "sdnr-wt-data-provider-provider";
- private final Map<String, String> data;
- private final String readmeContent;
+ private final Map<String, String> data;
+ private final String readmeContent;
- public AboutHttpServlet() {
+ public AboutHttpServlet() {
- this.data = new HashMap<>();
- this.collectStaticData();
- this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
- }
+ this.data = new HashMap<>();
+ this.collectStaticData();
+ this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
+ }
- /**
- * collect static versioning data
- */
- private void collectStaticData() {
- PomPropertiesFile props = this.getPomProperties();
- final String ccsdkVersion = this.getPomParentVersion();
- this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
- this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno"));
- this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
- this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
- this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "1.8.1-SNAPSHOT");
- this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
- this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
- this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
- }
+ /**
+ * collect static versioning data
+ */
+ private void collectStaticData() {
+ PomPropertiesFile props = this.getPomProperties();
+ final String ccsdkVersion = this.getPomParentVersion();
+ this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
+ this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno"));
+ this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
+ this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
+ this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "1.8.1-SNAPSHOT");
+ this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
+ }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- String uri = req.getRequestURI().substring(URI_PRE.length());
- LOG.debug("request for {}", uri);
- if (uri.length() <= 0 || uri.equals("/")) {
- // collect data
- this.collectData();
- // render readme
- String content = this.render();
- byte[] output = content != null ? content.getBytes() : new byte[0];
- // output
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentLength(output.length);
- resp.setContentType("text/plain");
- ServletOutputStream os = null;
- try{
- os = resp.getOutputStream();
- os.write(output);
- }
- catch(IOException e) {
- LOG.warn("problem writing response for {}: {}",uri,e);
- }
- finally {
- if(os!=null) {
- try{
- os.close();
- }
- catch(IOException e) {
- LOG.warn("problem closing response stream: {}",e);
- }
- }
- }
+ String uri = req.getRequestURI().substring(URI_PRE.length());
+ LOG.debug("request for {}", uri);
+ if (uri.length() <= 0 || uri.equals("/")) {
+ // collect data
+ this.collectData();
+ // render readme
+ String content = this.render();
+ byte[] output = content != null ? content.getBytes() : new byte[0];
+ // output
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentLength(output.length);
+ resp.setContentType("text/plain");
+ ServletOutputStream os = null;
+ try {
+ os = resp.getOutputStream();
+ os.write(output);
+ } catch (IOException e) {
+ LOG.warn("problem writing response for {}: {}", uri, e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ LOG.warn("problem closing response stream: {}", e);
+ }
+ }
+ }
- } else {
- this.doGetFile(uri, resp);
- }
- }
+ } else {
+ this.doGetFile(uri, resp);
+ }
+ }
- /**
- * load git.commit.id from jar /META-INF/git.properties
- *
- * @param def
- */
- private String getGitHash(String def) {
- String content = Resources.getFileContent(AboutHttpServlet.class, "/META-INF/git.properties");
- if (content == null) {
- return def;
- }
- String lines[] = content.split("\n");
- for (String line : lines) {
- if (line.startsWith("git.commit.id")) {
- def = line.substring("git.commit.id=".length());
- break;
- }
- }
- return def;
- }
+ /**
+ * load git.commit.id from jar /META-INF/git.properties
+ *
+ * @param def
+ */
+ private String getGitHash(String def) {
+ String content = Resources.getFileContent(AboutHttpServlet.class, "/META-INF/git.properties");
+ if (content == null) {
+ return def;
+ }
+ String lines[] = content.split("\n");
+ for (String line : lines) {
+ if (line.startsWith("git.commit.id")) {
+ def = line.substring("git.commit.id=".length());
+ break;
+ }
+ }
+ return def;
+ }
- private String getResourceFileContent(String filename) {
- LOG.debug("try ti get content of {}", filename);
- return Resources.getFileContent(AboutHttpServlet.class, RES_BASEPATH + filename);
- }
+ private String getResourceFileContent(String filename) {
+ LOG.debug("try ti get content of {}", filename);
+ return Resources.getFileContent(AboutHttpServlet.class, RES_BASEPATH + filename);
+ }
- /**
- * collect dynamic data for about.md
- */
- private void collectData() {
- LOG.info("collecting dynamic data");
- try {
- this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
- } catch (Exception e) {
- LOG.warn("problem collecting system data: {}", e);
- }
- }
+ /**
+ * collect dynamic data for about.md
+ */
+ private void collectData() {
+ LOG.info("collecting dynamic data");
+ try {
+ this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
+ } catch (Exception e) {
+ LOG.warn("problem collecting system data: {}", e);
+ }
+ }
- /**
- * get value for key out of /META-INF/MANIFEST.MF
- * @param key
- * @return
- */
- private String getManifestValue(String key) {
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF");
- if (url == null) {
- return null;
- }
- Manifest manifest;
- try {
- manifest = new Manifest(url.openStream());
- Attributes attr = manifest.getMainAttributes();
- return attr.getValue(key);
- } catch (IOException e) {
- LOG.warn("problem reading manifest: {}", e);
- }
- return null;
+ /**
+ * get value for key out of /META-INF/MANIFEST.MF
+ *
+ * @param key
+ * @return
+ */
+ private String getManifestValue(String key) {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF");
+ if (url == null) {
+ return null;
+ }
+ Manifest manifest;
+ try {
+ manifest = new Manifest(url.openStream());
+ Attributes attr = manifest.getMainAttributes();
+ return attr.getValue(key);
+ } catch (IOException e) {
+ LOG.warn("problem reading manifest: {}", e);
+ }
+ return null;
- }
- /**
- * get object representation of /META-INF/maven/groupId/artifactId/pom.properties
- * @return
- */
- private PomPropertiesFile getPomProperties() {
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties");
- PomPropertiesFile propfile;
- if (url == null) {
- return null;
- }
- try {
- propfile = new PomPropertiesFile(url.openStream());
- return propfile;
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
- /**
- * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
- * @param key
- * @return
- */
- private String getPomProperty(String key) {
- LOG.info("try to get pom property for {}", key);
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
- if (url == null) {
- return null;
- }
- PomFile pomfile;
- try {
- pomfile = new PomFile(url.openStream());
- return pomfile.getProperty(key);
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
- /**
- * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
- * @return
- */
- private String getPomParentVersion() {
- LOG.info("try to get pom parent version");
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
- if (url == null) {
- return null;
- }
- PomFile pomfile;
- try {
- pomfile = new PomFile(url.openStream());
- return pomfile.getParentVersion();
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
+ }
- /**
- * get file by uri from resources and write out to response stream
- * @param uri
- * @param resp
- */
- private void doGetFile(String uri, HttpServletResponse resp) {
- String content = this.getResourceFileContent(uri);
- if (content == null) {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- } catch (IOException e) {
- LOG.debug("unable to send error response : {}", e);
- }
- } else {
- byte[] data = content.getBytes();
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType(this.getContentType(uri));
- try {
- resp.getOutputStream().write(data);
- } catch (IOException e) {
- LOG.debug("unable to send data : {}", e);
- }
- }
+ /**
+ * get object representation of /META-INF/maven/groupId/artifactId/pom.properties
+ *
+ * @return
+ */
+ private PomPropertiesFile getPomProperties() {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties");
+ PomPropertiesFile propfile;
+ if (url == null) {
+ return null;
+ }
+ try {
+ propfile = new PomPropertiesFile(url.openStream());
+ return propfile;
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- }
+ /**
+ * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
+ *
+ * @param key
+ * @return
+ */
+ private String getPomProperty(String key) {
+ LOG.info("try to get pom property for {}", key);
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getProperty(key);
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- /**
- * create http response contentType by filename
- * @param filename
- * @return
- */
- private String getContentType(String filename) {
- String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
- switch (ext) {
- case "jpg":
- case "jpeg":
- case "svg":
- case "png":
- case "gif":
- case "bmp":
- return "image/" + ext;
- case "json":
- return "application/json";
- case "html":
- case "htm":
- return "text/html";
- case "txt":
- case "md":
- default:
- return "text/plain";
- }
- }
+ /**
+ * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
+ *
+ * @return
+ */
+ private String getPomParentVersion() {
+ LOG.info("try to get pom parent version");
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getParentVersion();
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- /**
- * render this.readmeContent with this.data
- * @return
- */
- private String render() {
- return this.render(null);
- }
+ /**
+ * get file by uri from resources and write out to response stream
+ *
+ * @param uri
+ * @param resp
+ */
+ private void doGetFile(String uri, HttpServletResponse resp) {
+ String content = this.getResourceFileContent(uri);
+ if (content == null) {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException e) {
+ LOG.debug("unable to send error response : {}", e);
+ }
+ } else {
+ byte[] data = content.getBytes();
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType(this.getContentType(uri));
+ try {
+ resp.getOutputStream().write(data);
+ } catch (IOException e) {
+ LOG.debug("unable to send data : {}", e);
+ }
+ }
- /**
- * render content with this.data
- * @param content
- * @return
- */
- private String render(String content) {
- if (content == null) {
- content = this.readmeContent;
- }
- if (content == null) {
- return null;
- }
- for (Entry<String, String> entry : this.data.entrySet()) {
- if (entry.getValue() != null && content.contains(entry.getKey())) {
- content = content.replace(entry.getKey(), entry.getValue());
- }
- }
+ }
- return content;
- }
+ /**
+ * create http response contentType by filename
+ *
+ * @param filename
+ * @return
+ */
+ private String getContentType(String filename) {
+ String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
+ switch (ext) {
+ case "jpg":
+ case "jpeg":
+ case "svg":
+ case "png":
+ case "gif":
+ case "bmp":
+ return "image/" + ext;
+ case "json":
+ return "application/json";
+ case "html":
+ case "htm":
+ return "text/html";
+ case "txt":
+ case "md":
+ default:
+ return "text/plain";
+ }
+ }
- public void setClusterSize(String value) {
- this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
- }
-} \ No newline at end of file
+ /**
+ * render this.readmeContent with this.data
+ *
+ * @return
+ */
+ private String render() {
+ return this.render(null);
+ }
+
+ /**
+ * render content with this.data
+ *
+ * @param content
+ * @return
+ */
+ private String render(String content) {
+ if (content == null) {
+ content = this.readmeContent;
+ }
+ if (content == null) {
+ return null;
+ }
+ for (Entry<String, String> entry : this.data.entrySet()) {
+ if (entry.getValue() != null && content.contains(entry.getKey())) {
+ content = content.replace(entry.getKey(), entry.getValue());
+ }
+ }
+
+ return content;
+ }
+
+ public void setClusterSize(String value) {
+ this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
+ }
+}
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 322392379..490f3cac8 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
@@ -34,24 +34,26 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
* @author Michael Dürre
*
*/
-public class DataTreeHttpServlet extends HttpServlet{
-
- /**
- * @param rawClient
- */
- public void setDatabaseClient(HtDatabaseClient rawClient) {
-
-
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- final String uri = req.getRequestURI();
- }
- private void readInventoryTree(String filter) {
-
- }
- private void doJsonResponse(HttpServletResponse resp,Object data) {
-
- }
+public class DataTreeHttpServlet extends HttpServlet {
+
+ /**
+ * @param rawClient
+ */
+ public void setDatabaseClient(HtDatabaseClient rawClient) {
+
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ final String uri = req.getRequestURI();
+ }
+
+ private void readInventoryTree(String filter) {
+
+ }
+
+ private void doJsonResponse(HttpServletResponse resp, Object data) {
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
index 87210f29a..fd2784804 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
@@ -25,37 +25,37 @@ import javax.servlet.http.HttpServletRequest;
public class GetYangSchemaRequest {
- private static final String URI_PREFIX = "/yang-schema/";
- private final String module;
- private final String version;
-
- public String getModule() {
- return this.module;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public boolean hasVersion() {
- return this.version != null;
- }
-
- public GetYangSchemaRequest(HttpServletRequest req) throws Exception {
- String uri = req.getRequestURI().substring(URI_PREFIX.length());
-
- String[] hlp = uri.split("/");
- if (hlp.length < 1) {
- throw new Exception("no module request found");
-
- } else if (hlp.length == 1) {
- this.module = hlp[0];
- this.version = null;
- } else {
- this.module = hlp[0];
- this.version = hlp[1];
- }
-
- }
+ private static final String URI_PREFIX = "/yang-schema/";
+ private final String module;
+ private final String version;
+
+ public String getModule() {
+ return this.module;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public boolean hasVersion() {
+ return this.version != null;
+ }
+
+ public GetYangSchemaRequest(HttpServletRequest req) throws Exception {
+ String uri = req.getRequestURI().substring(URI_PREFIX.length());
+
+ String[] hlp = uri.split("/");
+ if (hlp.length < 1) {
+ throw new Exception("no module request found");
+
+ } else if (hlp.length == 1) {
+ this.module = hlp[0];
+ this.version = null;
+ } else {
+ this.module = hlp[0];
+ this.version = hlp[1];
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
index ec5661acd..725256b17 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
@@ -33,81 +33,86 @@ import org.slf4j.LoggerFactory;
public class MsServlet extends BaseServlet {
- /**
- *
- */
- private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
- private static final long serialVersionUID = -5361461082028405171L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
- private static boolean trustAll = false;
- private static MediatorServerDataProvider entryProvider;
- public MsServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- public void triggerReloadDatabaseEntries() {
- LOG.debug("external reload triggered");
- entryProvider.triggerReloadSync();
- }
-
- @Override
- protected boolean isOff() {
- return false;
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
- String dbServerId = "0";
- if (uri == null)
- uri = "";
- if (uri.length() > 0) {
- uri = uri.substring("/ms/".length());
- int idx= uri.indexOf("/");
- dbServerId = uri.substring(0,idx);
- uri=uri.substring(idx);
- }
- LOG.debug("request for ms server with id={}",dbServerId);
- String url= this.getBaseUrl(dbServerId) + uri;
- LOG.debug("dest-url: {}",url);
- return url;
- }
-
- protected String getBaseUrl(String dbServerId) {
- return entryProvider.getHostUrl(dbServerId);
- }
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-
- public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
- entryProvider = mediatorServerDataProvider;
- }
-
- @Override
- protected boolean trustInsecure() {
- return trustAll;
- }
-
- @Override
- protected boolean isCorsEnabled() {
- return false;
- }
+ /**
+ *
+ */
+ private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
+ private static final long serialVersionUID = -5361461082028405171L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
+ private static boolean trustAll = false;
+ private static MediatorServerDataProvider entryProvider;
+
+ public MsServlet() {
+ super();
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
+
+ public void triggerReloadDatabaseEntries() {
+ LOG.debug("external reload triggered");
+ entryProvider.triggerReloadSync();
+ }
+
+ @Override
+ protected boolean isOff() {
+ return false;
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+ String dbServerId = "0";
+ if (uri == null)
+ uri = "";
+ if (uri.length() > 0) {
+ uri = uri.substring("/ms/".length());
+ int idx = uri.indexOf("/");
+ dbServerId = uri.substring(0, idx);
+ uri = uri.substring(idx);
+ }
+ LOG.debug("request for ms server with id={}", dbServerId);
+ String url = this.getBaseUrl(dbServerId) + uri;
+ LOG.debug("dest-url: {}", url);
+ return url;
+ }
+
+ protected String getBaseUrl(String dbServerId) {
+ return entryProvider.getHostUrl(dbServerId);
+ }
+
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
+
+ public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
+ entryProvider = mediatorServerDataProvider;
+ }
+
+ @Override
+ protected boolean trustInsecure() {
+ return trustAll;
+ }
+
+ @Override
+ protected boolean isCorsEnabled() {
+ return false;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
index 8e1ced7da..e20f453a1 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
@@ -33,35 +33,34 @@ import org.slf4j.LoggerFactory;
public class ReadyHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
- private static boolean status;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
+ private static boolean status;
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- if(isReady()) {
- resp.setStatus(HttpServletResponse.SC_OK);
- }
- else {
-
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
- }
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- private static boolean isReady() {
- return status;
- }
+ if (isReady()) {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ } else {
- public static void setStatus(boolean s) {
- status = s;
- LOG.info("status is set to ready: {}",status);
- }
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+ }
+
+ private static boolean isReady() {
+ return status;
+ }
+
+ public static void setStatus(boolean s) {
+ status = s;
+ LOG.info("status is set to ready: {}", status);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
index 967ae26cb..075f4f766 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
@@ -34,90 +34,90 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class YangSchemaHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
-
- private static final String schemaCachePath = "cache/schema/";
-
- private final YangFileProvider fileProvider;
-
- public YangSchemaHttpServlet() {
- this.fileProvider = new YangFileProvider(schemaCachePath);
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- GetYangSchemaRequest request = null;
- try {
- request = new GetYangSchemaRequest(req);
- } catch (Exception e) {
- LOG.warn("bad request for yang-schema: {}", e);
- }
- if (request != null) {
- int len;
- LOG.debug("request for yang-schema for module {} with version {}", request.getModule(),
- request.getVersion());
- if (request.hasVersion()) {
- boolean has=false;
- try {
- has = this.fileProvider.hasFileOrNewerForModule(request.getModule(), request.getVersion());
- } catch (ParseException e1) {
- LOG.warn("unable to parse revision: {}" ,e1);
- }
- if(has) {
-
- try {
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType("text/plain");
- len = this.fileProvider.writeOutput(request.getModule(), request.getVersion(),
- resp.getOutputStream());
- resp.setContentLength(len);
-
- } catch (ParseException e) {
- LOG.warn("unable to parse revision: {}", e);
- }catch (IOException | IllegalStateException e) {
- LOG.warn("unable to write out module {}@{}: {}",request.getModule(), request.getVersion(), e);
- }
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
-
- } else if (this.fileProvider.hasFileForModule(request.getModule())) {
-
- try {
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType("text/plain");
- len = this.fileProvider.writeOutput(request.getModule(), null, resp.getOutputStream());
- resp.setContentLength(len);
- } catch (ParseException e) {
- LOG.warn(e.getMessage());
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out module {}: {}",request.getModule(), e);
- }
-
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 400 bad request: {}",e);
- }
- }
-
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
+
+ private static final String schemaCachePath = "cache/schema/";
+
+ private final YangFileProvider fileProvider;
+
+ public YangSchemaHttpServlet() {
+ this.fileProvider = new YangFileProvider(schemaCachePath);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ GetYangSchemaRequest request = null;
+ try {
+ request = new GetYangSchemaRequest(req);
+ } catch (Exception e) {
+ LOG.warn("bad request for yang-schema: {}", e);
+ }
+ if (request != null) {
+ int len;
+ LOG.debug("request for yang-schema for module {} with version {}", request.getModule(),
+ request.getVersion());
+ if (request.hasVersion()) {
+ boolean has = false;
+ try {
+ has = this.fileProvider.hasFileOrNewerForModule(request.getModule(), request.getVersion());
+ } catch (ParseException e1) {
+ LOG.warn("unable to parse revision: {}", e1);
+ }
+ if (has) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), request.getVersion(),
+ resp.getOutputStream());
+ resp.setContentLength(len);
+
+ } catch (ParseException e) {
+ LOG.warn("unable to parse revision: {}", e);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}@{}: {}", request.getModule(), request.getVersion(), e);
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+
+ } else if (this.fileProvider.hasFileForModule(request.getModule())) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), null, resp.getOutputStream());
+ resp.setContentLength(len);
+ } catch (ParseException e) {
+ LOG.warn(e.getMessage());
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}: {}", request.getModule(), e);
+ }
+
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 400 bad request: {}", e);
+ }
+ }
+
+ }
}
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 2465fc622..286af7aa3 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
@@ -47,7 +47,7 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
private DataProviderServiceImpl rpcApiService;
private AboutHttpServlet aboutServlet;
private HtDatabaseClient dbClient;
-
+
// Blueprint 1
public DataProviderImpl() {
super();
@@ -57,18 +57,21 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
public void setRpcProviderService(RpcProviderService rpcProviderService) {
this.rpcProviderService = rpcProviderService;
}
+
public void setMediatorServerServlet(MsServlet servlet) {
this.mediatorServerServlet = servlet;
}
+
public void setAboutServlet(AboutHttpServlet aboutServlet) {
this.aboutServlet = aboutServlet;
}
+
public void init() throws Exception {
LOG.info("Session Initiated start {}", APPLICATION_NAME);
// Start RPC Service
- this.rpcApiService = new DataProviderServiceImpl(rpcProviderService,this.mediatorServerServlet);
+ this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet);
LOG.info("Session Initiated end. Initialization done");
}
@@ -117,13 +120,13 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
@Override
public void setReadyStatus(boolean status) {
- ReadyHttpServlet.setStatus(status);
+ ReadyHttpServlet.setStatus(status);
}
@Override
public void setStatus(StatusKey key, String value) {
- if(this.aboutServlet!=null) {
- if(key==StatusKey.CLUSTER_SIZE) {
+ if (this.aboutServlet != null) {
+ if (key == StatusKey.CLUSTER_SIZE) {
this.aboutServlet.setClusterSize(value);
}
}
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 2f3b7ee80..4b8564395 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
@@ -100,28 +100,33 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
private static final Logger LOG = LoggerFactory.getLogger(DataProviderServiceImpl.class);
public static final String CONFIGURATIONFILE = "etc/dataprovider.properties";
- private static final long DATABASE_TIMEOUT_MS = 120*1000L;
+ private static final long DATABASE_TIMEOUT_MS = 120 * 1000L;
private final ObjectRegistration<@NonNull DataProviderServiceImpl> rpcReg;
private final ElasticSearchDataProvider dataProvider;
private final ConfigurationFileRepresentation configuration;
private final EsConfig esConfig;
- private final MediatorServerDataProvider mediatorServerDataProvider;
+ private final MediatorServerDataProvider mediatorServerDataProvider;
- DataProviderServiceImpl(final RpcProviderService rpcProviderService,MsServlet mediatorServerServlet) throws Exception {
+ DataProviderServiceImpl(final RpcProviderService rpcProviderService, MsServlet mediatorServerServlet)
+ throws Exception {
this.configuration = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
this.esConfig = new EsConfig(configuration);
- this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword(),esConfig.trustAllCerts());
- this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS,TimeUnit.MILLISECONDS);
- this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword());
+ this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(), esConfig.getBasicAuthUsername(),
+ esConfig.getBasicAuthPassword(), esConfig.trustAllCerts());
+ this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),
+ esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword());
mediatorServerServlet.setDataProvider(this.mediatorServerDataProvider);
// Register ourselves as the REST API RPC implementation
LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName());
this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
}
+
private void sendResyncCallbackToApiGateway() {
- mediatorServerDataProvider.triggerReloadSync();
+ mediatorServerDataProvider.triggerReloadSync();
}
+
/**
* @return dataProvider
*/
@@ -130,8 +135,9 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
public HtDatabaseClient getRawClient() {
- return this.dataProvider.getRawClient();
+ return this.dataProvider.getRawClient();
}
+
/**
* @return data provider for Maintenance()
*/
@@ -156,22 +162,27 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
@Override
- public ListenableFuture<RpcResult<ReadFaultcurrentListOutput>> readFaultcurrentList(ReadFaultcurrentListInput input) {
+ public ListenableFuture<RpcResult<ReadFaultcurrentListOutput>> readFaultcurrentList(
+ ReadFaultcurrentListInput input) {
LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
- RpcResultBuilder<ReadFaultcurrentListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input));
+ RpcResultBuilder<ReadFaultcurrentListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadFaultlogListOutput>> readFaultlogList(ReadFaultlogListInput input) {
LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
- RpcResultBuilder<ReadFaultlogListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input));
+ RpcResultBuilder<ReadFaultlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadMaintenanceListOutput>> readMaintenanceList(ReadMaintenanceListInput input) {
LOG.debug("RPC Request: getMaintenanceEntityList with input {}", input);
- RpcResultBuilder<ReadMaintenanceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input));
+ RpcResultBuilder<ReadMaintenanceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input));
return result.buildFuture();
}
@@ -179,7 +190,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<ReadMediatorServerListOutput>> readMediatorServerList(
ReadMediatorServerListInput input) {
LOG.debug("RPC Request: getMediatorServerEntityList with input {}", input);
- RpcResultBuilder<ReadMediatorServerListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input));
+ RpcResultBuilder<ReadMediatorServerListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input));
return result.buildFuture();
}
@@ -187,7 +199,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<ReadNetworkElementConnectionListOutput>> readNetworkElementConnectionList(
ReadNetworkElementConnectionListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadNetworkElementConnectionListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input));
+ RpcResultBuilder<ReadNetworkElementConnectionListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input));
return result.buildFuture();
}
@@ -195,21 +208,25 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<ReadPmdata15mListOutput>> readPmdata15mList(ReadPmdata15mListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadPmdata15mListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input));
+ RpcResultBuilder<ReadPmdata15mListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadPmdata24hListOutput>> readPmdata24hList(ReadPmdata24hListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadPmdata24hListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input));
+ RpcResultBuilder<ReadPmdata24hListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadStatusOutput>> readStatus(ReadStatusInput input) {
LOG.debug("RPC Request: getStatusEntityList with input {}", input);
- RpcResultBuilder<ReadStatusOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readStatus());
+ RpcResultBuilder<ReadStatusOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readStatus());
return result.buildFuture();
}
@@ -217,43 +234,53 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<ReadInventoryListOutput>> readInventoryList(ReadInventoryListInput input) {
LOG.debug("RPC Request: getInventoryEntityList with input {}", input);
- RpcResultBuilder<ReadInventoryListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readInventoryList(input));
+ RpcResultBuilder<ReadInventoryListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readInventoryList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata15mLtpListOutput>> readPmdata15mLtpList(ReadPmdata15mLtpListInput input) {
+ public ListenableFuture<RpcResult<ReadPmdata15mLtpListOutput>> readPmdata15mLtpList(
+ ReadPmdata15mLtpListInput input) {
LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
- RpcResultBuilder<ReadPmdata15mLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input));
+ RpcResultBuilder<ReadPmdata15mLtpListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata15mDeviceListOutput>> readPmdata15mDeviceList(ReadPmdata15mDeviceListInput input) {
- LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
- RpcResultBuilder<ReadPmdata15mDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input));
- return result.buildFuture();
+ public ListenableFuture<RpcResult<ReadPmdata15mDeviceListOutput>> readPmdata15mDeviceList(
+ ReadPmdata15mDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata15mDeviceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input));
+ return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata24hLtpListOutput>> readPmdata24hLtpList(ReadPmdata24hLtpListInput input) {
+ public ListenableFuture<RpcResult<ReadPmdata24hLtpListOutput>> readPmdata24hLtpList(
+ ReadPmdata24hLtpListInput input) {
LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
- RpcResultBuilder<ReadPmdata24hLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input));
+ RpcResultBuilder<ReadPmdata24hLtpListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata24hDeviceListOutput>> readPmdata24hDeviceList(ReadPmdata24hDeviceListInput input) {
- LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
- RpcResultBuilder<ReadPmdata24hDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input));
- return result.buildFuture();
+ public ListenableFuture<RpcResult<ReadPmdata24hDeviceListOutput>> readPmdata24hDeviceList(
+ ReadPmdata24hDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata24hDeviceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input));
+ return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadConnectionlogListOutput>> readConnectionlogList(
ReadConnectionlogListInput input) {
LOG.debug("RPC Request: readConnectionlogList with input {}", input);
- RpcResultBuilder<ReadConnectionlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readConnectionlogList(input));
+ RpcResultBuilder<ReadConnectionlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readConnectionlogList(input));
return result.buildFuture();
}
@@ -261,7 +288,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<CreateNetworkElementConnectionOutput>> createNetworkElementConnection(
CreateNetworkElementConnectionInput input) {
LOG.debug("RPC Request: createNetworkElementConnection with input {}", input);
- RpcResultBuilder<CreateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createNetworkElementConnection(input));
+ RpcResultBuilder<CreateNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createNetworkElementConnection(input));
return result.buildFuture();
}
@@ -269,14 +297,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<UpdateNetworkElementConnectionOutput>> updateNetworkElementConnection(
UpdateNetworkElementConnectionInput input) {
LOG.debug("RPC Request: updateNetworkElementConnection with input {}", input);
- RpcResultBuilder<UpdateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateNetworkElementConnection(input));
+ RpcResultBuilder<UpdateNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateNetworkElementConnection(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<DeleteNetworkElementConnectionOutput>> deleteNetworkElementConnection(
DeleteNetworkElementConnectionInput input) {
- RpcResultBuilder<DeleteNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input));
+ RpcResultBuilder<DeleteNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input));
return result.buildFuture();
}
@@ -284,7 +314,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<DeleteMediatorServerOutput>> deleteMediatorServer(
DeleteMediatorServerInput input) {
LOG.debug("RPC Request: deleteMediatorServer with input {}", input);
- RpcResultBuilder<DeleteMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMediatorServer(input));
+ RpcResultBuilder<DeleteMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -293,7 +324,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<CreateMediatorServerOutput>> createMediatorServer(
CreateMediatorServerInput input) {
LOG.debug("RPC Request: createMediatorServer with input {}", input);
- RpcResultBuilder<CreateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMediatorServer(input));
+ RpcResultBuilder<CreateMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -301,14 +333,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<CreateMaintenanceOutput>> createMaintenance(CreateMaintenanceInput input) {
LOG.debug("RPC Request: createMaintenance with input {}", input);
- RpcResultBuilder<CreateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMaintenance(input));
+ RpcResultBuilder<CreateMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createMaintenance(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<DeleteMaintenanceOutput>> deleteMaintenance(DeleteMaintenanceInput input) {
LOG.debug("RPC Request: deleteMaintenance with input {}", input);
- RpcResultBuilder<DeleteMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMaintenance(input));
+ RpcResultBuilder<DeleteMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteMaintenance(input));
return result.buildFuture();
}
@@ -316,7 +350,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<UpdateMediatorServerOutput>> updateMediatorServer(
UpdateMediatorServerInput input) {
LOG.debug("RPC Request: updateMediatorServer with input {}", input);
- RpcResultBuilder<UpdateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMediatorServer(input));
+ RpcResultBuilder<UpdateMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -324,14 +359,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<UpdateMaintenanceOutput>> updateMaintenance(UpdateMaintenanceInput input) {
LOG.debug("RPC Request: updateMaintenance with input {}", input);
- RpcResultBuilder<UpdateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMaintenance(input));
+ RpcResultBuilder<UpdateMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateMaintenance(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadEventlogListOutput>> readEventlogList(ReadEventlogListInput input) {
LOG.debug("RPC Request: readEventlogList with input {}", input);
- RpcResultBuilder<ReadEventlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readEventlogList(input));
+ RpcResultBuilder<ReadEventlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readEventlogList(input));
return result.buildFuture();
}
@@ -352,7 +389,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
Builder<O> get() throws IOException;
}
- private static <O extends DataObject,I extends DataObject> RpcResultBuilder<O> read(GetEntityInput<O> inputgetter ) {
+ private static <O extends DataObject, I extends DataObject> RpcResultBuilder<O> read(
+ GetEntityInput<O> inputgetter) {
RpcResultBuilder<O> result;
try {
Builder<O> outputBuilder = inputgetter.get();
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
index fc3701099..001437771 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
@@ -51,7 +51,7 @@ public class EsConfig implements Configuration, IEsConfig {
private static final String PROPERTY_KEY_AUTH_USERNAME = "esAuthUsername";
private static final String PROPERTY_KEY_AUTH_PASSWORD = "esAuthPassword";
-
+
private static String defaultHostinfo = "${SDNRDBURL}";//printHosts(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
private static final String DEFAULT_VALUE_CLUSTER = "";
/** check db data in this interval [in seconds] 0 deactivated */
@@ -59,10 +59,10 @@ public class EsConfig implements Configuration, IEsConfig {
/** keep data for this time [in seconds] 30 days */
private static final String DEFAULT_ARCHIVE_LIMIT_SEC = String.valueOf(60L * 60L * 24L * 30L);
//private static final String DEFAULT_KEY_NODE = "elasticsearchnode";
- private static final String DEFAULT_VALUE_NODE = "elasticsearchnode";
- private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
- private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
- private static final String DEFAULT_VALUE_TRUSTALLCERTS = "${SDNRDBTRUSTALLCERTS}";
+ private static final String DEFAULT_VALUE_NODE = "elasticsearchnode";
+ private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
+ private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
+ private static final String DEFAULT_VALUE_TRUSTALLCERTS = "${SDNRDBTRUSTALLCERTS}";
private final ConfigurationFileRepresentation configuration;
@@ -93,9 +93,11 @@ public class EsConfig implements Configuration, IEsConfig {
String dbHosts = configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS);
return parseHosts(dbHosts);
}
+
public void setHosts(HostInfo[] hosts) {
this.configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS, printHosts(hosts));
}
+
@Override
public String getCluster() {
return configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL);
@@ -106,22 +108,27 @@ public class EsConfig implements Configuration, IEsConfig {
}
public boolean hasBasicAuthCredentials() {
- return this.getBasicAuthUsername()!=null && this.getBasicAuthPassword()!=null &&
- !this.getBasicAuthUsername().isEmpty() && !this.getBasicAuthPassword().isEmpty() ;
+ return this.getBasicAuthUsername() != null && this.getBasicAuthPassword() != null
+ && !this.getBasicAuthUsername().isEmpty() && !this.getBasicAuthPassword().isEmpty();
}
+
public String getBasicAuthUsername() {
- return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME);
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME);
}
+
public String getBasicAuthPassword() {
- return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD);
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD);
}
+
@Override
public long getArchiveCheckIntervalSeconds() {
return configuration.getPropertyLong(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL).orElse(0L);
}
+
public boolean trustAllCerts() {
- return configuration.getPropertyBoolean(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS);
+ return configuration.getPropertyBoolean(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS);
}
+
public void setArchiveCheckIntervalSeconds(long seconds) {
configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL, seconds);
}
@@ -150,10 +157,13 @@ public class EsConfig implements Configuration, IEsConfig {
configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL,
DEFAULT_ARCHIVE_INTERVAL_SEC);
configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_NODE, DEFAULT_VALUE_NODE);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME, DEFAULT_VALUE_DBUSERNAME);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD, DEFAULT_VALUE_DBPASSWORD);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS, DEFAULT_VALUE_TRUSTALLCERTS);
-
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME,
+ DEFAULT_VALUE_DBUSERNAME);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD,
+ DEFAULT_VALUE_DBPASSWORD);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS,
+ DEFAULT_VALUE_TRUSTALLCERTS);
+
}
@Override
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
index 555b38533..a9a658387 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
@@ -46,12 +46,15 @@ public class YangToolsCloner {
private YangToolsCloner(int ac) {
this.accessor = ac;
}
+
public static YangToolsCloner instance() {
return instance(ACCESSOR_METHOD);
}
+
public static YangToolsCloner instance(int ac) {
return new YangToolsCloner(ac);
}
+
/**
*
* @param source source object
@@ -88,9 +91,10 @@ public class YangToolsCloner {
* @param clazz Class of return object
* @return cloned object
*/
- public <S , T extends DataObject> T clone(S source, Class<T> clazz) {
+ public <S, T extends DataObject> T clone(S source, Class<T> clazz) {
return clone(source, clazz, null);
}
+
/**
*
* @param source source object
@@ -98,10 +102,9 @@ public class YangToolsCloner {
* @attrList if empty copy all else list of attribute Names to clone
* @return cloned object
*/
- public <S, T extends DataObject> T clone(S source, Class<T> clazz,
- @Nullable List<String> attrList) {
+ public <S, T extends DataObject> T clone(S source, Class<T> clazz, @Nullable List<String> attrList) {
if (source == null) {
- return (T)null;
+ return (T) null;
}
Field[] attributeFields;
Field sourceField;
@@ -121,7 +124,7 @@ public class YangToolsCloner {
attributeField.setAccessible(true);
try {
- if(accessor==ACCESSOR_FIELD) {
+ if (accessor == ACCESSOR_FIELD) {
sourceField = source.getClass().getDeclaredField(attributeField.getName());
sourceField.setAccessible(true);
if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
@@ -129,10 +132,9 @@ public class YangToolsCloner {
} else {
attributeField.set(object, sourceField.get(source));
}
- }
- else if(accessor==ACCESSOR_METHOD) {
+ } else if (accessor == ACCESSOR_METHOD) {
String getter = getter(attributeField.getName());
- System.out.println("getter="+getter);
+ System.out.println("getter=" + getter);
m = source.getClass().getDeclaredMethod(getter);
m.setAccessible(true);
if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
@@ -147,7 +149,7 @@ public class YangToolsCloner {
String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
LOG.debug(msg);
// throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException|SecurityException e) {
+ } catch (IllegalAccessException | SecurityException e) {
LOG.debug("Access problem " + attributeField.getName(), e);
} catch (IllegalArgumentException e) {
LOG.debug("argument problem " + attributeField.getName(), e);
@@ -160,12 +162,14 @@ public class YangToolsCloner {
}
private static String getter(String name) {
- return String.format("%s%s%s","get",name.substring(1, 2).toUpperCase(),name.substring(2));
+ return String.format("%s%s%s", "get", name.substring(1, 2).toUpperCase(), name.substring(2));
}
- public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder){
- return cloneToBuilder(source, builder,null);
+
+ public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder) {
+ return cloneToBuilder(source, builder, null);
}
- public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder,
+
+ public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder,
@Nullable List<String> attrList) {
Field[] attributeFields;
Field sourceField;
@@ -183,7 +187,7 @@ public class YangToolsCloner {
attributeField.setAccessible(true);
try {
- if(accessor==ACCESSOR_FIELD) {
+ if (accessor == ACCESSOR_FIELD) {
sourceField = source.getClass().getDeclaredField(attributeField.getName());
sourceField.setAccessible(true);
if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
@@ -191,8 +195,7 @@ public class YangToolsCloner {
} else {
attributeField.set(builder, sourceField.get(source));
}
- }
- else if(accessor==ACCESSOR_METHOD) {
+ } else if (accessor == ACCESSOR_METHOD) {
m = source.getClass().getDeclaredMethod(getter(attributeField.getName()));
m.setAccessible(true);
if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
@@ -207,7 +210,7 @@ public class YangToolsCloner {
String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
LOG.debug(msg);
// throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException|SecurityException e) {
+ } catch (IllegalAccessException | SecurityException e) {
LOG.debug("Access problem " + attributeField.getName(), e);
} catch (IllegalArgumentException e) {
LOG.debug("argument problem " + attributeField.getName(), e);
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 768e6683b..0b1e7d520 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
@@ -48,183 +48,190 @@ 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;
+
/**
- * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
- * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or
+ * deserialization of DataObject to/from JSON TODO ChoiceIn and Credentials deserialization only for
+ * LoginPasswordBuilder
*/
public class YangToolsMapper extends ObjectMapper {
- private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class);
- private static final long serialVersionUID = 1L;
- private static BundleContext context;
-
- public YangToolsMapper() {
- 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 <T> yang-tools base datatype
- * @param clazz class with interface.
- * @return builder for interface or null if not existing
- */
- @SuppressWarnings("unchecked")
- public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
- String builder = clazz.getName() + "Builder";
- try {
- Class<?> clazzBuilder = findClass(builder);
- return (Builder<T>) 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();
- }
-
- /**
- * Adapted Builder callbacks
- */
- private static class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
- private static final long serialVersionUID = 1L;
-
- @Override
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class);
+ private static final long serialVersionUID = 1L;
+ private static BundleContext context;
+
+ public YangToolsMapper() {
+ 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 <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ String builder = clazz.getName() + "Builder";
+ try {
+ Class<?> clazzBuilder = findClass(builder);
+ return (Builder<T>) 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();
+ }
+
+ /**
+ * 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);
+ 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<DateAndTime> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
}
- @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<DateAndTime>{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public CustomDateAndTimeSerializer() {
- this(null);
- }
- protected CustomDateAndTimeSerializer(Class<DateAndTime> 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 8f0de4f73..ce67c39dd 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
@@ -49,219 +49,231 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
/**
- * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
- * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or
+ * deserialization of DataObject to/from JSON TODO ChoiceIn and Credentials deserialization only for
+ * LoginPasswordBuilder
*/
public class YangToolsMapper2<T extends DataObject> extends ObjectMapper {
- private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
- private static final long serialVersionUID = 1L;
- private static String ENTITY = "Entity";
- private static String BUILDER = "Builder";
-
- private @Nullable Class<T> clazz;
- private @Nullable Class<? extends Builder<? extends T>> builderClazz;
-
- private BundleContext context;
-
- public <X extends T, B extends Builder<X>> YangToolsMapper2(Class<T> clazz, Class<B> 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 );
- Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class);
-
- this.clazz = clazz;
- this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz)) ;
- context = bundle != null ? bundle.getBundleContext() : null;
- }
-
- public YangToolsMapper2() throws ClassNotFoundException {
- this(null, null);
- }
-
-
- @Override
- public String writeValueAsString(Object value) throws JsonProcessingException {
- return super.writeValueAsString(value);
- }
- /**
- * Get Builder object for yang tools interface.
- * @param <T> yang-tools base datatype
- * @param clazz class with interface.
- * @return builder for interface or null if not existing
- */
- @SuppressWarnings("unchecked")
- public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
- try {
- //Class<?> clazzBuilder = getBuilderClass(getBuilderClassName(clazz));
- return (Builder<T>) builderClazz.newInstance();
- } 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())
- 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 <T>
- * @param clazz
- * @return builders class name
- * @throws ClassNotFoundException
- */
- private static String getBuilderClassName(Class<?> clazz) {
- return clazz.getName() + BUILDER;
-// String clazzName = clazz.getName();
-// if (clazzName.endsWith(ENTITY)) {
-// return clazzName.replace(ENTITY, BUILDER);
-// } else {
-// return clazzName + BUILDER;
-// }
- }
-
- /**
- * Search builder in context
- * @param name
- * @return
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("unchecked")
- private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
- // Try to find in other bundles
- if (context != null) {
- //OSGi environment
- for (Bundle b : context.getBundles()) {
- try {
- return (Class<B>) 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<B>) 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) {
-
- if (ac.getRawType().equals(Credentials.class)) {
- return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class;
-
- } else if (ac.getRawType().equals(DateAndTime.class)) {
- return DateAndTimeBuilder.class;
-
- } else if (ac.getRawType().equals(clazz)) {
- return builderClazz;
- }
-
- if (ac.getRawType().isInterface()) {
- String builder = getBuilderClassName(ac.getRawType());
- try {
- Class<?> innerBuilder = getBuilderClass(builder);
- 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");
- }
- }
-
- 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<@NonNull DateAndTime>{
-
- private static final long serialVersionUID = 1L;
-
- public CustomDateAndTimeSerializer() {
- this(null);
- }
- protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
- super(t);
- }
-
- @Override
- public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeString(value.getValue());
- }
-
- }
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
+ private static final long serialVersionUID = 1L;
+ private static String ENTITY = "Entity";
+ private static String BUILDER = "Builder";
+
+ private @Nullable Class<T> clazz;
+ private @Nullable Class<? extends Builder<? extends T>> builderClazz;
+
+ private BundleContext context;
+
+ public <X extends T, B extends Builder<X>> YangToolsMapper2(Class<T> clazz, Class<B> 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);
+ Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class);
+
+ this.clazz = clazz;
+ this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz));
+ context = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ public YangToolsMapper2() throws ClassNotFoundException {
+ this(null, null);
+ }
+
+
+ @Override
+ public String writeValueAsString(Object value) throws JsonProcessingException {
+ return super.writeValueAsString(value);
+ }
+
+ /**
+ * Get Builder object for yang tools interface.
+ *
+ * @param <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ try {
+ //Class<?> clazzBuilder = getBuilderClass(getBuilderClassName(clazz));
+ return (Builder<T>) builderClazz.newInstance();
+ } 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())
+ 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 <T>
+ * @param clazz
+ * @return builders class name
+ * @throws ClassNotFoundException
+ */
+ private static String getBuilderClassName(Class<?> clazz) {
+ return clazz.getName() + BUILDER;
+ // String clazzName = clazz.getName();
+ // if (clazzName.endsWith(ENTITY)) {
+ // return clazzName.replace(ENTITY, BUILDER);
+ // } else {
+ // return clazzName + BUILDER;
+ // }
+ }
+
+ /**
+ * Search builder in context
+ *
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
+ // Try to find in other bundles
+ if (context != null) {
+ //OSGi environment
+ for (Bundle b : context.getBundles()) {
+ try {
+ return (Class<B>) 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<B>) 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) {
+
+ if (ac.getRawType().equals(Credentials.class)) {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class;
+
+ } else if (ac.getRawType().equals(DateAndTime.class)) {
+ return DateAndTimeBuilder.class;
+
+ } else if (ac.getRawType().equals(clazz)) {
+ return builderClazz;
+ }
+
+ if (ac.getRawType().isInterface()) {
+ String builder = getBuilderClassName(ac.getRawType());
+ try {
+ Class<?> innerBuilder = getBuilderClass(builder);
+ 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");
+ }
+ }
+
+ 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<@NonNull DateAndTime> {
+
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
+ }
+
+ }
}