summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/index.rst1
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java40
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java41
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java3
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java9
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java16
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java27
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java14
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java57
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java6
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java127
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java187
-rw-r--r--sdnr/wt/data-provider/provider/pom.xml2
-rw-r--r--sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml94
-rwxr-xr-xsdnr/wt/featureaggregator/installer/pom.xml11
-rwxr-xr-xsdnr/wt/featureaggregator/pom.xml1
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts18
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts7
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts57
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts10
-rw-r--r--sdnr/wt/odlux/framework/pom.xml2
22 files changed, 528 insertions, 206 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 1da5c6c03..5aa247913 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,6 +1,7 @@
=================
SDN-R Online help
=================
+.. _master_index:
Below are the references for SDN-R User Documentation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
index e7b15bd0f..9a369ea5b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
@@ -130,7 +130,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
public @Nullable String doWriteRaw(String indexName,String dataTypeName, @Nullable String esId, String json) {
IndexResponse response = null;
- IndexRequest indexRequest = new IndexRequest(indexName,dataTypeName,esId);
+ IndexRequest indexRequest = new IndexRequest(indexName,dataTypeName,esId,this.doRefreshAfterWrite);
indexRequest.source(json);
try {
response = this.index(indexRequest );
@@ -142,9 +142,9 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
LOG.warn("Response null during write: {} {}", esId, json);
return null;
}
- if(this.doRefreshAfterWrite) {
- this.doRefresh(dataTypeName);
- }
+// if(this.doRefreshAfterWrite) {
+// this.doRefresh(dataTypeName);
+// }
return response.getId();
}
@@ -167,16 +167,16 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
@Override
public boolean doRemove(String dataTypeName, String esId) {
- DeleteRequest deleteRequest = new DeleteRequest(dataTypeName,dataTypeName,esId);
+ DeleteRequest deleteRequest = new DeleteRequest(dataTypeName,dataTypeName,esId,this.doRefreshAfterWrite);
DeleteResponse response = null;
try {
response = this.delete(deleteRequest);
} catch (IOException e) {
LOG.warn("Problem deleting from db: {}",e.getMessage());
}
- if(this.doRefreshAfterWrite) {
- this.doRefresh(dataTypeName);
- }
+// if(this.doRefreshAfterWrite) {
+// this.doRefresh(dataTypeName);
+// }
return response!=null?response.isDeleted():false;
}
@@ -257,7 +257,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
return null;
}
boolean success = false;
- UpdateRequest request = new UpdateRequest(dataTypeName, dataTypeName, esId);
+ UpdateRequest request = new UpdateRequest(dataTypeName, dataTypeName, esId,this.doRefreshAfterWrite);
request.source(new JSONObject(json),onlyForInsert);
try {
UpdateResponse response = this.update(request);
@@ -265,15 +265,15 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
} catch (IOException e) {
LOG.warn("Problem updating {} with id {} and data {}: {}", dataTypeName, esId, json, e);
}
- if(this.doRefreshAfterWrite) {
- this.doRefresh(dataTypeName);
- }
+// if(this.doRefreshAfterWrite) {
+// this.doRefresh(dataTypeName);
+// }
return success ? esId : null;
}
@Override
public boolean doUpdate(String dataTypeName, String json, QueryBuilder query) {
boolean success = false;
- UpdateByQueryRequest request = new UpdateByQueryRequest(dataTypeName, dataTypeName );
+ UpdateByQueryRequest request = new UpdateByQueryRequest(dataTypeName, dataTypeName ,this.doRefreshAfterWrite);
request.source(new JSONObject(json),query);
try {
UpdateByQueryResponse response = this.update(request);
@@ -281,9 +281,9 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
} catch (IOException e) {
LOG.warn("Problem updating items in {} with query {} and data {}: {}", dataTypeName, query, json, e);
}
- if(this.doRefreshAfterWrite) {
- this.doRefresh(dataTypeName);
- }
+// if(this.doRefreshAfterWrite) {
+// this.doRefresh(dataTypeName);
+// }
return success;
}
@@ -292,7 +292,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
@Override
public int doRemove(String dataTypeName, QueryBuilder query) {
int del=0;
- DeleteByQueryRequest request = new DeleteByQueryRequest(dataTypeName);
+ DeleteByQueryRequest request = new DeleteByQueryRequest(dataTypeName,this.doRefreshAfterWrite);
request.source(query);
try {
DeleteByQueryResponse response = this.deleteByQuery(request);
@@ -300,9 +300,9 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
} catch (IOException e) {
LOG.warn("Problem delete in {} with query {}:{} ", dataTypeName, query.toJSON(), e);
}
- if(this.doRefreshAfterWrite) {
- this.doRefresh(dataTypeName);
- }
+// if(this.doRefreshAfterWrite) {
+// this.doRefresh(dataTypeName);
+// }
return del;
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
index 061941bfb..e7261f3e5 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
@@ -35,12 +35,31 @@ public abstract class BaseRequest {
private static final Logger LOG = LoggerFactory.getLogger(BaseRequest.class);
+ public static final int DEFAULT_RETRIES = 1;
+
protected final Request request;
private String query;
+ private final boolean refresh;
+
public BaseRequest(String method, String endpoint) {
- LOG.debug("create request {} {}", method, endpoint);
- this.request = new Request(method, endpoint);
- query=null;
+ LOG.debug("create request {} {}" ,method, endpoint);
+ this.refresh = false;
+ this.request = new Request(method, endpoint);
+ query = null;
+ }
+
+ public BaseRequest(String method, String endpoint, boolean refresh) {
+ LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
+ this.refresh = refresh;
+ this.request = new Request(method, String.format("%s?refresh=%s", endpoint, String.valueOf(refresh)));
+ query = null;
+ }
+
+ public BaseRequest(String method, String endpoint, boolean refresh, int retries) {
+ LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
+ this.refresh = refresh;
+ this.request = new Request(method, String.format("%s?refresh=%s&retry_on_conflict=%d", endpoint, String.valueOf(refresh),retries));
+ query = null;
}
public Request getInner() {
@@ -58,9 +77,11 @@ public abstract class BaseRequest {
}
return value;
}
+
@Override
public String toString() {
- return this.request.getMethod() + " "+this.request.getEndpoint()+ " : "+(this.query!=null?this.query:"no query");
+ return this.request.getMethod() + " " + this.request.getEndpoint() + " : "
+ + (this.query != null ? this.query : "no query");
}
protected void setQuery(QueryBuilder query) {
@@ -72,8 +93,16 @@ public abstract class BaseRequest {
}
public void setQuery(String content) {
- this.query=content;
- LOG.trace("query={}",content);
+ this.query = content;
+ LOG.trace("query={}", content);
this.request.setJsonEntity(this.query);
}
+
+ protected String getQuery() {
+ return this.query;
+ }
+
+ protected boolean doRefresh() {
+ return this.refresh;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
index 934c0f6df..6f060196e 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
@@ -47,9 +47,10 @@ public class CreateIndexRequest extends BaseRequest{
super.setQuery(o);
}
@SuppressWarnings("hiding")
- public void mappings(JSONObject mappings) {
+ public CreateIndexRequest mappings(JSONObject mappings) {
this.mappings=mappings;
this.setRequest();
+ return this;
}
public void settings(JSONObject settings) {
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
index ded69dd17..15c876e48 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
@@ -26,11 +26,16 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
public class DeleteByQueryRequest extends BaseRequest {
public DeleteByQueryRequest(String alias) {
- super("POST",String.format("/%s/_delete_by_query",alias));
+ this(alias, false);
}
- public void source(QueryBuilder query) {
+ public DeleteByQueryRequest(String alias, boolean refresh) {
+ super("POST",String.format("/%s/_delete_by_query",alias), refresh);
+ }
+
+ public DeleteByQueryRequest source(QueryBuilder query) {
this.setQuery(query);
+ return this;
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
index 325b529e5..63202b169 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
@@ -23,8 +23,22 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
public class DeleteRequest extends BaseRequest {
+ private final String alias;
+ private final String esId;
public DeleteRequest(String alias,String dataType,String esId) {
- super("DELETE",String.format("/%s/%s/%s",alias,dataType,BaseRequest.urlEncodeValue(esId)));
+ this(alias, dataType, esId, false);
+ }
+ public DeleteRequest(String alias,String dataType,String esId, boolean refresh) {
+ super("DELETE",String.format("/%s/%s/%s",alias,dataType,BaseRequest.urlEncodeValue(esId)), refresh);
+ this.alias = alias;
+ this.esId = esId;
+ }
+ protected String getAlias() {
+ return this.alias;
+ }
+
+ protected String getEsId() {
+ return this.esId;
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
index cf4aabbbb..a3ee578a9 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
@@ -23,20 +23,39 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
import javax.annotation.Nullable;
-public class IndexRequest extends BaseRequest{
+public class IndexRequest extends BaseRequest {
+
+ private final String alias;
+ private final String esId;
public IndexRequest(String alias, String dataType) {
- this(alias,dataType,null);
+ this(alias, dataType, null);
+ }
+
+ public IndexRequest(String alias, String dataType, @Nullable String esId) {
+ super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
+ : String.format("/%s/%s", alias, dataType));
+ this.alias = alias;
+ this.esId = esId;
}
- public IndexRequest(String alias,String dataType, @Nullable String esId) {
- super("POST",esId!=null?String.format("/%s/%s/%s",alias,dataType,BaseRequest.urlEncodeValue(esId)):String.format("/%s/%s",alias,dataType));
+ public IndexRequest(String alias, String dataType, @Nullable String esId, boolean refresh) {
+ super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
+ : String.format("/%s/%s", alias, dataType),refresh);
+ this.alias = alias;
+ this.esId = esId;
}
public void source(String content) {
super.setQuery(content);
}
+ protected String getAlias() {
+ return this.alias;
+ }
+ protected String getEsId() {
+ return this.esId;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
index 1eb6037f4..8bca04ff6 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
@@ -29,9 +29,15 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
public class UpdateByQueryRequest extends BaseRequest {
private JSONObject params;
-
+ private final String alias;
+
public UpdateByQueryRequest(String alias, String dataType) {
- super("POST", String.format("/%s/%s/_update_by_query", alias, dataType));
+ this(alias, dataType, false);
+ }
+
+ public UpdateByQueryRequest(String alias, String dataType, boolean refresh) {
+ super("POST", String.format("/%s/%s/_update_by_query", alias, dataType), refresh);
+ this.alias = alias;
this.params = null;
}
@@ -103,4 +109,8 @@ public class UpdateByQueryRequest extends BaseRequest {
}
+ protected String getAlias() {
+ return this.alias;
+ }
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
index 7445e155d..16923b238 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
@@ -33,12 +33,36 @@ public class UpdateRequest extends BaseRequest {
private static final Logger LOG = LoggerFactory.getLogger(UpdateRequest.class);
private JSONObject params;
+ private String alias;
+ private String esId;
+ private int retries;
public UpdateRequest(String alias, String dataType, String esId) {
- super("POST", String.format("/%s/%s/%s/_update", alias, dataType, BaseRequest.urlEncodeValue(esId)));
+ this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES);
+ }
+ public UpdateRequest(String alias, String dataType, String esId, boolean refresh) {
+ this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES, refresh);
+ }
+ public UpdateRequest(String alias, String dataType, String esId, int retries) {
+ this(alias, dataType, esId, retries, false);
+ }
+
+ public UpdateRequest(String alias, String dataType, String esId, int retries, boolean refresh) {
+ this(String.format("/%s/%s/%s/_update", alias, dataType, BaseRequest.urlEncodeValue(esId)), refresh);
+ this.alias = alias;
+ this.esId = esId;
+ this.retries = retries;
+ }
+
+ public UpdateRequest(String uri, boolean refresh) {
+ super("POST", uri, refresh, BaseRequest.DEFAULT_RETRIES);
this.params = null;
+ this.retries = 1;
+
}
+
+
private UpdateRequest withParam(String key, JSONObject p) {
if (this.params == null) {
this.params = new JSONObject();
@@ -54,16 +78,18 @@ public class UpdateRequest extends BaseRequest {
this.params.put(key, p);
return this;
}
+
public void source(JSONObject map) {
- this.source(map,null);
+ this.source(map, null);
}
+
public void source(JSONObject map, List<String> onlyForInsert) {
JSONObject outer = new JSONObject();
JSONObject script = new JSONObject();
script.put("lang", "painless");
- script.put("source", this.createInline(map,onlyForInsert));
- if(this.params!=null) {
- script.put("params",this.params);
+ script.put("source", this.createInline(map, onlyForInsert));
+ if (this.params != null) {
+ script.put("params", this.params);
}
outer.put("script", script);
outer.put("upsert", map);
@@ -72,16 +98,16 @@ public class UpdateRequest extends BaseRequest {
}
private String createInline(JSONObject map, List<String> onlyForInsert) {
- if(onlyForInsert==null) {
+ if (onlyForInsert == null) {
onlyForInsert = new ArrayList<String>();
}
- String s = "",k="";
+ String s = "", k = "";
Object value;
String pkey;
int i = 0;
for (Object key : map.keySet()) {
- k=String.valueOf(key);
- if(onlyForInsert.contains(k)) {
+ k = String.valueOf(key);
+ if (onlyForInsert.contains(k)) {
continue;
}
value = map.get(k);
@@ -93,7 +119,7 @@ public class UpdateRequest extends BaseRequest {
this.withParam(pkey, (JSONArray) value);
}
- s += String.format("ctx._source['%s']=%s;", key, "params."+pkey);
+ s += String.format("ctx._source['%s']=%s;", key, "params." + pkey);
} else {
s += String.format("ctx._source['%s']=%s;", key, escpaped(value));
}
@@ -113,4 +139,15 @@ public class UpdateRequest extends BaseRequest {
}
+ protected String getAlias() {
+ return this.alias;
+ }
+
+ protected String getEsId() {
+ return this.esId;
+ }
+
+ protected int getRetries() {
+ return this.retries;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
index 2fe81bb1b..a3a1b16e1 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
@@ -49,6 +49,10 @@ public class BaseResponse {
}
JSONObject getJson(Response response) {
+ if(response==null) {
+ LOG.warn("unable to parse response. response is null.");
+ return null;
+ }
try {
String sresponse = EntityUtils.toString(response.getEntity());
LOG.debug("parsing response={}", sresponse);
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
index c7bba0e7d..d4dee0441 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
@@ -30,13 +30,15 @@ public class DeleteResponse extends BaseResponse {
public DeleteResponse(Response response) {
super(response);
- int code = response.getStatusLine().getStatusCode();
- if (code < 210) {
+ if (this.isResponseSucceeded()) {
JSONObject o = this.getJson(response);
if (o != null) {
this.isDeleted = "deleted".equals(o.getString("result"));
}
+ else {
+ this.isDeleted=false;
+ }
}
else {
this.isDeleted=false;
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
index d04aac678..04259b9f6 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
@@ -23,6 +23,8 @@ package org.onap.ccsdk.features.sdnr.wt.common.test;
import static org.junit.Assert.*;
+import java.io.IOException;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
@@ -32,50 +34,63 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
public class TestDbClient {
-
+
private static HtDatabaseClient dbClient;
private static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
.valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
dbClient = new HtDatabaseClient(hosts);
dbClient.waitForYellowStatus(20000);
}
+
@Test
public void testCRUD() {
final String IDX = "test23-knmoinsd";
final String ID = "abcddd";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
+
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ clearIndexData(IDX);
//Create
- String esId=dbClient.doWriteRaw(IDX, ID, JSON);
- assertEquals("inserted id is wrong",ID,esId);
+ String esId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertEquals("inserted id is wrong", ID, esId);
//Read
SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",1,result.getTotal());
- assertEquals("data not valid", JSON,result.getHits().get(0).getSourceAsString());
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
//Update
- esId= dbClient.doUpdateOrCreate(IDX, ID, JSON2);
- assertEquals("update response not successfull",ID,esId);
+ esId = dbClient.doUpdateOrCreate(IDX, ID, JSON2);
+ assertEquals("update response not successfull", ID, esId);
//check that update with null fails
- assertNull("update with id null should not be possible",dbClient.doUpdateOrCreate(IDX,null,JSON2));
+ assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
//Verify update
- result = dbClient.doReadByQueryJsonData( IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",1,result.getTotal());
- assertEquals("data not valid", JSON2,result.getHits().get(0).getSourceAsString());
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
//test second read
String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
-
+
@Override
public void setEsId(String id) {
-
+
}
-
+
@Override
public String getEsId() {
return ID;
@@ -83,59 +98,79 @@ public class TestDbClient {
});
//test all read
result = dbClient.doReadAllJsonData(IDX);
- assertNotNull("all read not working",result);
-
- assertEquals("read works not as expected", JSON2,resStr);
+ assertNotNull("all read not working", result);
+
+ assertEquals("read works not as expected", JSON2, resStr);
//Delete
- boolean del=dbClient.doRemove(IDX, new IsEsObject() {
-
+ boolean del = dbClient.doRemove(IDX, new IsEsObject() {
+
@Override
public void setEsId(String id) {
-
+
}
+
@Override
public String getEsId() {
return ID;
}
});
- assertTrue("item not deleted",del);
+ assertTrue("item not deleted", del);
//Verify
result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",0,result.getTotal());
-
-
+ assertEquals("amount of results is wrong", 0, result.getTotal());
+
+ }
+
+ /**
+ * @param iDX
+ */
+ private void clearIndexData(String idx) {
+ try {
+ dbClient.deleteByQuery(new DeleteByQueryRequest(idx, true).source(QueryBuilders.matchAllQuery()));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
+
@Test
public void testCRUD2() {
- final String IDX = "test23-knmoinsd";
+ final String IDX = "test23-knmoins3d";
final String ID = "abcddd";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
//Create
- String esId=dbClient.doWriteRaw(IDX, ID, JSON);
- assertEquals("inserted id is wrong",ID,esId);
+ String esId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertEquals("inserted id is wrong", ID, esId);
//Read
SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",1,result.getTotal());
- assertEquals("data not valid", JSON,result.getHits().get(0).getSourceAsString());
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
QueryBuilder matchQuery = QueryBuilders.matchQuery("_id", ID);
//Update
- assertTrue("update response not successfull",dbClient.doUpdate(IDX, JSON2,matchQuery ));
+ assertTrue("update response not successfull", dbClient.doUpdate(IDX, JSON2, matchQuery));
//check that update with null fails
- assertNull("update with id null should not be possible",dbClient.doUpdateOrCreate(IDX,null,JSON2));
+ assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
//Verify update
- result = dbClient.doReadByQueryJsonData( IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",1,result.getTotal());
- assertEquals("data not valid", JSON2,result.getHits().get(0).getSourceAsString());
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
//test second read
String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
-
+
@Override
public void setEsId(String id) {
-
+
}
-
+
@Override
public String getEsId() {
return ID;
@@ -143,18 +178,16 @@ public class TestDbClient {
});
//test all read
result = dbClient.doReadAllJsonData(IDX);
- assertNotNull("all read not working",result);
-
- assertEquals("read works not as expected", JSON2,resStr);
+ assertNotNull("all read not working", result);
+
+ assertEquals("read works not as expected", JSON2, resStr);
//Delete
- int del=dbClient.doRemove(IDX, matchQuery);
- assertTrue("item not deleted",del>0);
+ int del = dbClient.doRemove(IDX, matchQuery);
+ assertTrue("item not deleted", del > 0);
//Verify
result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong",0,result.getTotal());
-
-
-
+ assertEquals("amount of results is wrong", 0, result.getTotal());
+
}
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
index d876f6609..2226c5e7e 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
@@ -35,6 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteAliasReque
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteIndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.IndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.NodeStatsRequest;
@@ -50,7 +51,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteByQueryRe
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteIndexResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.GetResponse;
-import org.onap.ccsdk.features.sdnr.wt.common.database.responses.IndexResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ListIndicesResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.NodeStatsResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
@@ -78,17 +78,19 @@ public class TestDbRequests {
.valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
@BeforeClass
- public static void init() {
+ public static void init() throws Exception {
dbClient = new HtDatabaseClient(hosts);
}
+
@AfterClass
public static void deinit() {
- if(dbClient!=null) {
+ if (dbClient != null) {
dbClient.close();
}
}
+
@Test
public void testHealth() {
@@ -108,10 +110,11 @@ public class TestDbRequests {
public void testCount() {
}
+
@Test
public void testIndexAndAliasList() {
- final String ALIAS="asdoi32kmasd";
- final String IDX=ALIAS+"-v1";
+ final String ALIAS = "asdoi32kmsasd";
+ final String IDX = ALIAS + "-v1";
CreateIndexRequest request = new CreateIndexRequest(IDX);
CreateIndexResponse response = null;
try {
@@ -121,7 +124,7 @@ public class TestDbRequests {
}
assertNotNull(response);
- CreateAliasRequest request3 = new CreateAliasRequest(IDX,ALIAS);
+ CreateAliasRequest request3 = new CreateAliasRequest(IDX, ALIAS);
CreateAliasResponse response3 = null;
try {
response3 = dbClient.createAlias(request3);
@@ -130,18 +133,18 @@ public class TestDbRequests {
}
assertNotNull(response3);
assertTrue(response3.isResponseSucceeded());
-
+
assertTrue("index not existing", dbClient.isExistsIndex(IDX));
- ListIndicesResponse response2=null;
+ ListIndicesResponse response2 = null;
try {
- response2 = dbClient.getIndices();
+ response2 = dbClient.getIndices();
} catch (ParseException | IOException e) {
fail(e.getMessage());
}
assertNotNull(response2);
assertNotNull(response2.getEntries());
- assertTrue(response2.getEntries().size()>0);
-
+ assertTrue(response2.getEntries().size() > 0);
+
DeleteIndexRequest request11 = new DeleteIndexRequest(IDX);
DeleteIndexResponse response11 = null;
@@ -185,9 +188,16 @@ public class TestDbRequests {
@Test
public void testInsertAndDelete() {
- final String IDX = "test23-knmoinsd";
+ final String IDX = "tesnt23-knmoinsd";
final String ID = "abcddd";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX).mappings(defaultMappings(IDX, false)));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
this.insert(IDX, ID, JSON);
// delete data
DeleteRequest request2 = new DeleteRequest(IDX, IDX, ID);
@@ -217,11 +227,28 @@ public class TestDbRequests {
this.deleteIndex(IDX);
}
+ /**
+ * @param b
+ * @return
+ */
+ private JSONObject defaultMappings(String idx, boolean useStrict) {
+ String mapping = "{}";
+ return new JSONObject(String.format("{\"%s\":{%s\"properties\":%s}}", idx,
+ useStrict ? "\"dynamic\": false," : "\"dynamic\": true,", mapping));
+ }
+
@Test
public void testInsertAndDeleteByQuery() {
- final String IDX = "test34-knmoinsd";
+ final String IDX = "test534-knmoinsd";
final String ID = "abcdddseae";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
this.insert(IDX, ID, JSON);
// delete data
@@ -258,17 +285,13 @@ public class TestDbRequests {
// create data
IndexRequest request = new IndexRequest(IDX, IDX, ID);
request.source(JSON);
- IndexResponse response = null;
- try {
- response = dbClient.index(request);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
+ String responseId = null;
+ responseId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertNotNull(responseId);
if (ID != null) {
- assertEquals("id not correct", ID, response.getId());
+ assertEquals("id not correct", ID, responseId);
} else {
- ID = response.getId();
+ ID = responseId;
}
// do db refresh
try {
@@ -277,26 +300,28 @@ public class TestDbRequests {
fail(e.getMessage());
}
// verify data exists
- GetRequest request3 = new GetRequest(IDX, IDX, ID);
- GetResponse response3 = null;
- try {
- response3 = dbClient.get(request3);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
+ String response3 = null;
+ response3 = dbClient.doReadJsonData(IDX, ID);
assertNotNull(response3);
- JSONAssert.assertEquals("could not verify update", JSON, response3.getSourceAsBytesRef(), true);
+ JSONAssert.assertEquals("could not verify update", JSON, response3, true);
}
@Test
public void testSearch() {
- final String IDX = "test44-moinsd";
+ final String IDX = "testb44-moinsd";
final String ID = "abe";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
final String ID2 = "abe2";
final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
final String ID3 = "abe3";
final String JSON3 = "{\"data\":{\"inner\":\"more3\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
this.insert(IDX, ID, JSON);
this.insert(IDX, ID2, JSON2);
this.insert(IDX, ID3, JSON3);
@@ -310,18 +335,24 @@ public class TestDbRequests {
}
assertNotNull(response);
assertEquals("not all items found", 3, response.getHits().length);
- assertEquals("incorrect index",IDX,response.getHits()[0].getIndex());
- assertEquals("incorrect type",IDX,response.getHits()[0].getType());
+ assertEquals("incorrect index", IDX, response.getHits()[0].getIndex());
+ assertEquals("incorrect type", IDX, response.getHits()[0].getType());
this.deleteIndex(IDX);
}
@Test
public void testUpdate() {
- final String IDX = "test4534-moinsd";
+ final String IDX = "test45134-moinsd";
final String ID = "assbe";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
-
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
this.insert(IDX, ID, JSON);
UpdateRequest request = new UpdateRequest(IDX, IDX, ID);
UpdateResponse response = null;
@@ -354,11 +385,17 @@ public class TestDbRequests {
@Test
public void testUpdateByQuery() {
- final String IDX = "test224534-moinsd";
+ final String IDX = "test224534k-moinsd";
final String ID = "asssabe";
final String JSON = "{\"data\":{\"inner\":\"more\"}}";
final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
-
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
this.insert(IDX, ID, JSON);
UpdateByQueryRequest request = new UpdateByQueryRequest(IDX, IDX);
UpdateByQueryResponse response = null;
@@ -397,18 +434,21 @@ public class TestDbRequests {
final String JSON3 = "{ \"node-id\":\"sim3\",\"severity\":\"minor\"}";
final String JSON4 = "{ \"node-id\":\"sim4\",\"severity\":\"warning\"}";
final String JSON5 = "{ \"node-id\":\"sim5\",\"severity\":\"major\"}";
- final String MAPPINGS = "{\""+IDX+"\":{\"properties\":{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"}}}}";
- //create index with mapping keyword
- CreateIndexRequest irequest = new CreateIndexRequest(IDX);
- irequest.mappings(new JSONObject(MAPPINGS));
+ final String MAPPINGS = String.format("{\"" + IDX + "\":{\"properties\":%s}}",
+ "{\"node-id\":{\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"}}");
+ // create index with mapping keyword
CreateIndexResponse iresponse = null;
try {
- iresponse = dbClient.createIndex(irequest);
+ if (!dbClient.isExistsIndex(IDX)) {
+ iresponse = dbClient.createIndex(new CreateIndexRequest(IDX).mappings(new JSONObject(MAPPINGS)));
+ assertNotNull(iresponse);
+ assertTrue(iresponse.isAcknowledged());
+ }
} catch (IOException e1) {
- fail("unable to create index: "+e1.getMessage());
+ this.deleteIndex(IDX);
+ fail("unable to create index: " + e1.getMessage());
}
- assertNotNull(iresponse);
- assertTrue(iresponse.isAcknowledged());
+
// fill index
this.insert(IDX, null, JSON);
this.insert(IDX, null, JSON2);
@@ -436,21 +476,21 @@ public class TestDbRequests {
List<String> items1 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 0));
List<String> items2 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 2));
- assertEquals("pagination does not work", 2,items1.size());
- assertEquals("pagination does not work", 2,items2.size());
- for(String s:items1) {
- assertFalse("pagination overlap is not allowed",items2.contains(s));
+ assertEquals("pagination does not work", 2, items1.size());
+ assertEquals("pagination does not work", 2, items2.size());
+ for (String s : items1) {
+ assertFalse("pagination overlap is not allowed", items2.contains(s));
}
- for(String s:items2) {
- assertFalse("pagination overlap is not allowed",items1.contains(s));
+ for (String s : items2) {
+ assertFalse("pagination overlap is not allowed", items1.contains(s));
}
this.deleteIndex(IDX);
}
-
+
@Test
public void testStatistics() {
- NodeStatsResponse stats=null;
+ NodeStatsResponse stats = null;
try {
stats = dbClient.stats(new NodeStatsRequest());
} catch (IOException e) {
@@ -460,18 +500,18 @@ public class TestDbRequests {
System.out.println(stats.getNodesInfo());
System.out.println(stats.getNodeStatistics());
}
-
- //@Test
+
+ // @Test
public void testPreventAutoCreateIndex() {
- final String IDX1="acidx1";
- final String ID1="acid1";
- final String IDX2="acidx2";
- final String ID2="acid2";
- final String OBJ="{\"test\":5}";
-
- ClusterSettingsResponse settingsResponse=null;
- String esId=null;
- //set setting to allow autocreate
+ final String IDX1 = "acidx1";
+ final String ID1 = "acid1";
+ final String IDX2 = "acidx2";
+ final String ID2 = "acid2";
+ final String OBJ = "{\"test\":5}";
+
+ ClusterSettingsResponse settingsResponse = null;
+ String esId = null;
+ // set setting to allow autocreate
try {
settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
} catch (IOException e) {
@@ -479,10 +519,10 @@ public class TestDbRequests {
}
assertNotNull(settingsResponse);
assertTrue(settingsResponse.isAcknowledged());
- //test if something new can be created
+ // test if something new can be created
esId = dbClient.doWriteRaw(IDX1, IDX1, ID1, OBJ);
assertEquals(ID1, esId);
- //set setting to deny autocreate
+ // set setting to deny autocreate
try {
settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
} catch (IOException e) {
@@ -490,10 +530,10 @@ public class TestDbRequests {
}
assertNotNull(settingsResponse);
assertTrue(settingsResponse.isAcknowledged());
- //test if something new cannot be created
+ // test if something new cannot be created
esId = dbClient.doWriteRaw(IDX2, IDX2, ID2, OBJ);
assertNull(esId);
- //set setting to allow autocreate
+ // set setting to allow autocreate
try {
settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
} catch (IOException e) {
@@ -501,22 +541,23 @@ public class TestDbRequests {
}
assertNotNull(settingsResponse);
assertTrue(settingsResponse.isAcknowledged());
-
+
}
- private void deleteAlias(String idx,String alias) {
+
+ private void deleteAlias(String idx, String alias) {
try {
- dbClient.deleteAlias( new DeleteAliasRequest(idx,alias));
+ dbClient.deleteAlias(new DeleteAliasRequest(idx, alias));
} catch (IOException e) {
}
}
+
private void deleteIndex(String idx) {
try {
- dbClient.deleteIndex( new DeleteIndexRequest(idx));
+ dbClient.deleteIndex(new DeleteIndexRequest(idx));
} catch (IOException e) {
}
}
-
}
diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml
index dd2e03a2a..0d133f8d4 100644
--- a/sdnr/wt/data-provider/provider/pom.xml
+++ b/sdnr/wt/data-provider/provider/pom.xml
@@ -52,7 +52,7 @@
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<buildtime>${maven.build.timestamp}</buildtime>
<databaseport>49402</databaseport>
- <odlux.buildno>50.53aa73a(20/03/12)</odlux.buildno>
+ <odlux.buildno>52.3b24c2d(20/04/08)</odlux.buildno>
</properties>
<dependencies>
diff --git a/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml b/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml
new file mode 100644
index 000000000..8ed30e18a
--- /dev/null
+++ b/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ ONAP : ccsdk features
+ ~ ================================================================================
+ ~ Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ ~ All rights reserved.
+ ~ ================================================================================
+ ~ Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ ~ ================================================================================
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~ ============LICENSE_END=======================================================
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-feature-aggregator-devicemanager-base</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-apigateway-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-websocketmanager2-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-data-provider-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-netconfnode-state-service-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-devicemanager-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-mountpoint-registrar-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-mountpoint-state-provider-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sdnr/wt/featureaggregator/installer/pom.xml b/sdnr/wt/featureaggregator/installer/pom.xml
index bd8c3abdc..185ff1f53 100755
--- a/sdnr/wt/featureaggregator/installer/pom.xml
+++ b/sdnr/wt/featureaggregator/installer/pom.xml
@@ -58,6 +58,13 @@
<type>xml</type>
<classifier>features</classifier>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-feature-aggregator-devicemanager-base</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
</dependencies>
<build>
@@ -145,7 +152,7 @@
</execution>
</executions>
</plugin>
- <plugin>
+ <plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
@@ -168,7 +175,7 @@
</configuration>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/sdnr/wt/featureaggregator/pom.xml b/sdnr/wt/featureaggregator/pom.xml
index 671cc07da..69140321b 100755
--- a/sdnr/wt/featureaggregator/pom.xml
+++ b/sdnr/wt/featureaggregator/pom.xml
@@ -43,6 +43,7 @@
<modules>
<module>feature</module>
<module>feature-devicemanager</module>
+ <module>feature-devicemanager-base</module>
<module>installer</module>
</modules>
</project>
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts
index 5b4498df8..45cdfe64d 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts
+++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts
@@ -40,23 +40,19 @@ export class UpdatViewDescription extends Action {
}
export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatch: Dispatch, getState: () => IApplicationStoreState ) => {
- const { configuration: { connectedNetworkElements : { rows }} } = getState();
- dispatch(new SetCollectingSelectionData(true));
- const networkElement = rows.find(r => r.nodeId === nodeId) || await restService.getMountedNetworkElementByMountId(nodeId);
- if (!networkElement) {
- console.error(new Error(`NetworkElement : [${nodeId}] does not exist.`));
- return dispatch(new UpdateDeviceDescription("", { }, [ ]));
- }
- if (!networkElement.nodeDetails || !networkElement.nodeDetails.availableCapabilities) {
+ const availableCapabilities = await restService.getCapabilitiesByMoutId(nodeId);
+
+ if (!availableCapabilities || availableCapabilities.length <= 0) {
throw new Error(`NetworkElement : [${nodeId}] has no capabilities.`);
}
+
const parser = new YangParser();
const capParser = /^\(.*\?revision=(\d{4}-\d{2}-\d{2})\)(\S+)$/i;
- for (let i = 0; i < networkElement.nodeDetails.availableCapabilities.length; ++i){
- const capRaw = networkElement.nodeDetails.availableCapabilities[i];
- const capMatch = capRaw && capParser.exec(capRaw);
+ for (let i = 0; i < availableCapabilities.length; ++i){
+ const capRaw = availableCapabilities[i];
+ const capMatch = capRaw && capParser.exec(capRaw.capability);
try {
capMatch && await parser.addCapability(capMatch[2], capMatch[1]);
} catch (err) {
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts
index d0ed03a8d..0d28e6653 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts
+++ b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts
@@ -22,6 +22,13 @@ import { convertPropertyNames, replaceHyphen } from "../../../../framework/src/u
import { NetworkElementConnection } from "../models/networkElementConnection";
class RestService {
+ public async getCapabilitiesByMoutId(nodeId: string): Promise<{ "capabilityOrigin": string, "capability": string }[] | null> {
+ const path = `/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/${nodeId}`;
+ const capabilitiesResult = await requestRest<{ node: { "node-id": string, "netconf-node-topology:available-capabilities": { "available-capability": { "capabilityOrigin": string, "capability": string }[] }}[] }>(path, { method: "GET" });
+ return capabilitiesResult && capabilitiesResult.node && capabilitiesResult.node.length > 0 &&
+ capabilitiesResult.node[0]["netconf-node-topology:available-capabilities"]["available-capability"].map(obj => convertPropertyNames(obj, replaceHyphen)) || null;
+ }
+
public async getMountedNetworkElementByMountId(nodeId: string): Promise<NetworkElementConnection | null> {
// const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf/node/' + nodeId;
// const connectedNetworkElement = await requestRest<NetworkElementConnection>(path, { method: "GET" });
diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts
index a6d81c10c..a3bdc6828 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts
+++ b/sdnr/wt/odlux/apps/connectApp/src/actions/commonNetworkElementsActions.ts
@@ -38,7 +38,7 @@ export class SetPanelAction extends Action {
}
export class AddWebUriList extends Action {
- constructor(public searchedElements: guiCutThrough[], public notSearchedElements: string[], public newlySearchedElements?: string[]) {
+ constructor(public searchedElements: guiCutThrough[], public notSearchedElements: string[], public unsupportedElements: string[], public newlySearchedElements?: string[] ) {
super();
}
}
@@ -72,35 +72,52 @@ export const findWebUrisForGuiCutThroughAsyncAction = (networkElements: NetworkE
let notConnectedElements: string[] = [];
let elementsToSearch: string[] = [];
let prevFoundElements: string[] = [];
+ let unsupportedElements: string[]= [];
networkElements.forEach(item => {
- const id = item.id as string;
- if (item.status === "Connected") {
-
- // element is connected and is added to search list, if it doesn't exist already
- const exists = guiCutThrough.searchedElements.filter(element => element.nodeId === id).length > 0;
- if (!exists) {
- elementsToSearch.push(id);
-
- //element was found previously, but not searched for a weburi
- if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
- prevFoundElements.push(id);
+ const id = item.id as string;
+ if (item.status === "Connected") {
+
+ if(item.coreModelCapability!== "Unsupported"){
+ // element is connected and is added to search list, if it doesn't exist already
+ const exists = guiCutThrough.searchedElements.filter(element => element.nodeId === id).length > 0;
+ if (!exists) {
+ elementsToSearch.push(id);
+
+ //element was found previously, but wasn't connected
+ if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
+ prevFoundElements.push(id);
+ }
+ }
+ }else{
+ // element does not support core model and must not be searched for a weburi
+ const id = item.id as string;
+ const exists = guiCutThrough.unsupportedElements.filter(element => element === id).length > 0;
+ if(!exists){
+ unsupportedElements.push(id);
+
+ //element was found previously, but wasn't connected
+ if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
+ prevFoundElements.push(id);
+ }
+ }
}
}
- }
- else {
- // element isn't connected and cannot be searched for a weburi
- if (!guiCutThrough.notSearchedElements.includes(id)) {
- notConnectedElements.push(item.id as string);
+ else {
+ // element isn't connected and cannot be searched for a weburi
+ if (!guiCutThrough.notSearchedElements.includes(id)) {
+ notConnectedElements.push(item.id as string);
+ }
}
- }
});
- if (elementsToSearch.length > 0 || notConnectedElements.length > 0) {
+
+ if (elementsToSearch.length > 0 || notConnectedElements.length > 0 || unsupportedElements.length>0 ) {
const result = await connectService.getAllWebUriExtensionsForNetworkElementListAsync(elementsToSearch);
- dispatcher(new AddWebUriList(result, notConnectedElements, prevFoundElements));
+ dispatcher(new AddWebUriList(result, notConnectedElements, unsupportedElements, prevFoundElements));
}
+
isBusy = false;
}
diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts
index 23a801424..302a981eb 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts
+++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.ts
@@ -43,14 +43,17 @@ const currentOpenPanelHandler: IActionHandler<PanelId> = (state = null, action)
interface guiCutThroughState {
searchedElements: guiCutThrough[];
notSearchedElements: string[];
+ unsupportedElements: string[];
}
-const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { searchedElements: [], notSearchedElements: [] }, action) => {
+const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { searchedElements: [], notSearchedElements: [], unsupportedElements:[] }, action) => {
if (action instanceof AddWebUriList) {
let notSearchedElements: string[];
let searchedElements: guiCutThrough[];
+ let unsupportedElements: string[];
notSearchedElements = state.notSearchedElements.concat(action.notSearchedElements);
+ unsupportedElements = state.unsupportedElements.concat(action.unsupportedElements);
//remove elements, which were just searched
if (action.newlySearchedElements) {
@@ -61,13 +64,14 @@ const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { sear
searchedElements = state.searchedElements.concat(action.searchedElements);
- state = { searchedElements: searchedElements, notSearchedElements: notSearchedElements }
+ state = { searchedElements: searchedElements, notSearchedElements: notSearchedElements, unsupportedElements: unsupportedElements }
} else if (action instanceof RemoveWebUri) {
const nodeId = action.element;
const webUris = state.searchedElements.filter(item => item.nodeId !== nodeId);
const knownElements = state.notSearchedElements.filter(item => item !== nodeId);
- state = { notSearchedElements: knownElements, searchedElements: webUris };
+ const unsupportedElement = state.unsupportedElements.filter(item => item != nodeId);
+ state = { notSearchedElements: knownElements, searchedElements: webUris, unsupportedElements: unsupportedElement };
}
return state;
}
diff --git a/sdnr/wt/odlux/framework/pom.xml b/sdnr/wt/odlux/framework/pom.xml
index 5c7f846f0..b125a4537 100644
--- a/sdnr/wt/odlux/framework/pom.xml
+++ b/sdnr/wt/odlux/framework/pom.xml
@@ -46,7 +46,7 @@
<properties>
<buildtime>${maven.build.timestamp}</buildtime>
<distversion>ONAP Frankfurt (Neon, mdsal ${odl.mdsal.version})</distversion>
- <buildno>50.53aa73a(20/03/12)</buildno>
+ <buildno>52.3b24c2d(20/04/08)</buildno>
<odlux.version>ONAP SDN-R | ONF Wireless for ${distversion} - Build: ${buildtime} ${buildno} ${project.version}</odlux.version>
</properties>