summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common
diff options
context:
space:
mode:
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-04-06 10:33:41 +0200
committerMichael D�rre <michael.duerre@highstreet-technologies.com>2021-04-06 09:01:07 +0000
commit24cac2175588a81a2ebecb5c08b91455cfc24d0b (patch)
tree179e41ba8a16ce579fa679d3283d047a41857b26 /sdnr/wt/common
parent9fb395380431345b7da7a765651185815a9ac91d (diff)
source out odl mapper
put odl mapper code into seperate bundle Issue-ID: CCSDK-3254 Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com> Change-Id: I3debef0be8e44e7c68c95a6d06b7e50813bbea43
Diffstat (limited to 'sdnr/wt/common')
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java55
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java19
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java14
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java9
-rw-r--r--sdnr/wt/common/src/test/resources/testpom.xml6
5 files changed, 46 insertions, 57 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
index f8734d5a6..1f67e5ef8 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
@@ -29,10 +29,8 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.spec.InvalidKeySpecException;
import java.text.ParseException;
-
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
-
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -140,57 +138,6 @@ public class ExtRestClient {
}
}
- // private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
- //
- // private final String certFilename;
- //
- // SSLCercAuthHttpClientConfigCallback(String certfile) {
- // this.certFilename = certfile;
- // }
- //
- // @Override
- // public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
- // if (this.certFilename == null) {
- // return httpClientBuilder;
- // }
- //
- // char[] keystorePass = "MY PASSWORD".toCharArray();
- //
- // FileInputStream fis = null;
- //
- // // Loading KEYSTORE in JKS format
- // KeyStore keyStorePci = null;
- // try {
- // keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
- // } catch (KeyStoreException e1) {
- // LOG.warn("unable to load keystore: {}",e1);
- // }
- // if (keyStorePci != null) {
- // try {
- // fis = new FileInputStream(this.certFilename);
- // keyStorePci.load(fis, keystorePass);
- // } catch (Exception e) {
- // LOG.error("Error loading keystore: " + this.certFilename);
- // } finally {
- // if (fis != null) {
- // try {
- // fis.close();
- // } catch (IOException e) {
- //
- // }
- // }
- // }
- // }
- // SSLContext sslcontext=null;
- // try {
- // sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
- // } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
- // | KeyStoreException e) {
- // LOG.warn("unable to load sslcontext: {}",e);
- // }
- // return httpClientBuilder.setSSLContext(sslcontext);
- // }
- // }
private final RestClient client;
private final boolean isES7;
@@ -298,7 +245,7 @@ public class ExtRestClient {
/**
* Search for database entries
- *
+ *
* @param request inputRequest
* @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
* @return Response with related entries
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
index 82c036406..70e41c280 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
@@ -37,9 +37,28 @@ public class DbFilter {
return restFilterValue == null ? false : restFilterValue.contains("*") || restFilterValue.contains("?");
}
+ public static boolean hasSearchParams(List<String> restFilterValues) {
+ for (String restFilterValue : restFilterValues) {
+ if (!hasSearchParams(restFilterValue)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isComparisonValid(String restFilterValue) {
return restFilterValue == null ? false : restFilterValue.contains(">") || restFilterValue.contains("<");
}
+
+ public static boolean isComparisonValid(List<String> restFilterValues) {
+ for (String restFilterValue : restFilterValues) {
+ if (!isComparisonValid(restFilterValue)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isDatetimeKeyValue(String key, String value) {
return timestampValueNames.contains(key.toLowerCase());
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
index 7b22fd5e7..582d749d5 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
@@ -21,6 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.queries;
+import java.util.List;
import org.json.JSONObject;
public class QueryBuilders {
@@ -34,6 +35,11 @@ public class QueryBuilders {
o.put(key, value);
return new QueryBuilder().setQuery("term", o);
}
+ public static QueryBuilder multiTermQuery(String key, List<String> value) {
+ JSONObject o = new JSONObject();
+ o.put(key, value);
+ return new QueryBuilder().setQuery("terms", o);
+ }
public static QueryBuilder matchQuery(String key, Object value) {
JSONObject o = new JSONObject();
@@ -41,6 +47,14 @@ public class QueryBuilders {
return new QueryBuilder().setQuery("match", o);
}
+ public static QueryBuilder matchQuery(String key, List<?> values) {
+ BoolQueryBuilder query = boolQuery();
+ for (Object value : values) {
+ query.should(matchQuery(key, value));
+ }
+ return query;
+ }
+
public static BoolQueryBuilder boolQuery() {
return new BoolQueryBuilder();
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
index 937e2d898..ffb31c676 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
@@ -370,6 +370,15 @@ public class BaseHTTPClient {
return SSLCERT_PEM;
}
+ public static String decodeBasicAuthHeaderUsername(String authHeader) {
+ if(authHeader.startsWith("Basic")) {
+ authHeader = authHeader.substring(6);
+ }
+ final String decoded = new String(Base64.getDecoder().decode(authHeader));
+ String[] tmp = decoded.split(":");
+ return tmp.length > 0 ? tmp[0] : null;
+ }
+
}
diff --git a/sdnr/wt/common/src/test/resources/testpom.xml b/sdnr/wt/common/src/test/resources/testpom.xml
index e57fed436..6fba87af9 100644
--- a/sdnr/wt/common/src/test/resources/testpom.xml
+++ b/sdnr/wt/common/src/test/resources/testpom.xml
@@ -29,13 +29,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
<artifactId>sdnr-wt-common</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ccsdk-features :: ${project.artifactId}</name>
@@ -63,7 +63,7 @@
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>