summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java15
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java10
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java7
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java10
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/HttpMethod.java10
-rwxr-xr-xaai-service/provider/src/main/resources/aaiclient.properties3
-rwxr-xr-xaai-service/provider/src/test/resources/aaiclient.properties3
7 files changed, 43 insertions, 15 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
index 0050afbc4..d362d0e06 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
@@ -48,7 +48,6 @@ import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
-import javax.ws.rs.HttpMethod;
import org.apache.commons.codec.binary.Base64;
import org.onap.ccsdk.sli.adaptors.aai.AAIService.TransactionIdTracker;
@@ -63,8 +62,6 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.client.urlconnection.HTTPSProperties;
import org.apache.http.impl.EnglishReasonPhraseCatalog;
/**
@@ -132,7 +129,6 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
if(keystorePath != null && keystorePassword != null && (new File(keystorePath)).exists())
{
- DefaultClientConfig config = new DefaultClientConfig();
//both jersey and HttpURLConnection can use this
SSLContext ctx = null;
try {
@@ -159,12 +155,6 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
}
ctx.init(kmf.getKeyManagers(), null, null);
- config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties( new HostnameVerifier() {
- @Override
- public boolean verify( String s, SSLSession sslSession ) {
- return ignoreCertificateHostError;
- }
- }, ctx));
CTX = ctx;
LOG.debug("SSLContext created");
@@ -261,6 +251,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
responseMessage = con.getResponseMessage();
} catch(Exception exc) {
responseMessage = EnglishReasonPhraseCatalog.INSTANCE.getReason(responseCode,null);
+ } finally {
if(responseMessage == null)
responseMessage = NOT_PROVIDED;
}
@@ -402,6 +393,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
responseMessage = con.getResponseMessage();
} catch(Exception exc) {
responseMessage = EnglishReasonPhraseCatalog.INSTANCE.getReason(responseCode,null);
+ } finally {
if(responseMessage == null)
responseMessage = NOT_PROVIDED;
}
@@ -483,6 +475,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
responseMessage = conn.getResponseMessage();
} catch(Exception exc) {
responseMessage = EnglishReasonPhraseCatalog.INSTANCE.getReason(responseCode,null);
+ } finally {
if(responseMessage == null)
responseMessage = NOT_PROVIDED;
}
@@ -564,6 +557,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
responseMessage = con.getResponseMessage();
} catch(Exception exc) {
responseMessage = EnglishReasonPhraseCatalog.INSTANCE.getReason(responseCode,null);
+ } finally {
if(responseMessage == null)
responseMessage = NOT_PROVIDED;
}
@@ -638,6 +632,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
responseMessage = con.getResponseMessage();
} catch(Exception exc) {
responseMessage = EnglishReasonPhraseCatalog.INSTANCE.getReason(responseCode,null);
+ } finally {
if(responseMessage == null)
responseMessage = NOT_PROVIDED;
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
index 9943589b2..aa16ef39e 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
@@ -102,6 +102,8 @@ public abstract class AAIDeclarations implements AAIClient {
public static final String TARGET_URI = "org.onap.ccsdk.sli.adaptors.aai.uri";
+ public static final String AAI_VERSION = "org.onap.ccsdk.sli.adaptors.aai.version";
+
// Availability zones query
public static final String QUERY_PATH = "org.onap.ccsdk.sli.adaptors.aai.path.query";
@@ -137,6 +139,8 @@ public abstract class AAIDeclarations implements AAIClient {
// node query (1602)
public static final String QUERY_NODES_PATH = "org.onap.ccsdk.sli.adaptors.aai.query.nodes";
+ private static final String VERSION_PATTERN = "/v$/";
+
protected abstract Logger getLogger();
public abstract AAIExecutorInterface getExecutor();
@@ -1264,7 +1268,7 @@ public abstract class AAIDeclarations implements AAIClient {
getLogger().debug("About to process related link of {}", relatedLink);
if(relatedLink != null) {
if(relatedLink.contains("v$"))
- relatedLink = relatedLink.replace("v$", "v14");
+ relatedLink = relatedLink.replace(VERSION_PATTERN, "/v14/");
relationship.setRelatedLink(relatedLink);
} else {
Map<String, String> relParams = new HashMap<>();
@@ -1553,7 +1557,7 @@ public abstract class AAIDeclarations implements AAIClient {
if (relatedLink != null) {
if(relatedLink.contains("v$"))
- relatedLink = relatedLink.replace("v$", "v14");
+ relatedLink = relatedLink.replace(VERSION_PATTERN, AAIRequest.getSupportedAAIVersion());
relationship.setRelatedLink(relatedLink);
} else {
Map<String, String> relParams = new HashMap<>();
@@ -1753,7 +1757,7 @@ public abstract class AAIDeclarations implements AAIClient {
private QueryStatus processDeleteRelationshipList(String resource, String key, SvcLogicContext ctx, HashMap<String, String> nameValues) {
try {
- AAIRequest request = AAIRequest.createRequest(resource, nameValues);
+ AAIRequest request = AAIRequest.createRequest(resource.split(":")[0], nameValues);
if(request == null) {
return QueryStatus.FAILURE;
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
index 7ac9423c7..b62156494 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
@@ -32,6 +32,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
@@ -173,7 +174,7 @@ public abstract class AAIRequest {
}
InputStream in = url.openStream();
- Reader reader = new InputStreamReader(in, "UTF-8");
+ Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8);
Properties properties = new Properties();
properties.load(reader);
@@ -468,4 +469,8 @@ public abstract class AAIRequest {
public String getTargetUri() {
return targetUri;
}
+
+ public static final String getSupportedAAIVersion() {
+ return configProperties.getProperty(AAIDeclarations.AAI_VERSION, "/v14/");
+ }
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
index 10aec46aa..6af9f9cd6 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
@@ -48,6 +48,8 @@ import org.slf4j.LoggerFactory;
public class AAIServiceUtils {
+ private static final String VERSION_PATTERN = "/v$/";
+
private static final Logger LOG = LoggerFactory.getLogger(AAIService.class);
private AAIServiceUtils() {
@@ -191,7 +193,13 @@ public class AAIServiceUtils {
if (term.startsWith("$") && (ctx != null)) {
// Resolve any index variables.
- return ("'" + resolveCtxVariable(term.substring(1), ctx) + "'");
+ term = ("'" + resolveCtxVariable(term.substring(1), ctx) + "'");
+ if (term.contains(VERSION_PATTERN) && (ctx != null)) {
+ return term.replace(VERSION_PATTERN, AAIRequest.getSupportedAAIVersion());
+ }
+ return term;
+ } else if (term.contains(VERSION_PATTERN) && (ctx != null)) {
+ return term.replace(VERSION_PATTERN, AAIRequest.getSupportedAAIVersion());
} else if (term.startsWith("'") || term.startsWith("\"")) {
return (term);
} else {
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/HttpMethod.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/HttpMethod.java
new file mode 100755
index 000000000..28d79cfc8
--- /dev/null
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/HttpMethod.java
@@ -0,0 +1,10 @@
+package org.onap.ccsdk.sli.adaptors.aai;
+
+public interface HttpMethod {
+ public static final String GET = "GET";
+ public static final String HEAD = "HEAD";
+ public static final String PATCH = "PATCH";
+ public static final String POST = "POST";
+ public static final String PUT = "PUT";
+ public static final String DELETE = "DELETE";
+}
diff --git a/aai-service/provider/src/main/resources/aaiclient.properties b/aai-service/provider/src/main/resources/aaiclient.properties
index 3d803c108..d23078d8f 100755
--- a/aai-service/provider/src/main/resources/aaiclient.properties
+++ b/aai-service/provider/src/main/resources/aaiclient.properties
@@ -41,6 +41,9 @@ org.onap.ccsdk.sli.adaptors.aai.uri=https://aai.api.simpledemo.onap.org:8443
connection.timeout=60000
read.timeout=60000
+# aai version
+org.onap.ccsdk.sli.adaptors.aai.version=/v14/
+
# query
org.onap.ccsdk.sli.adaptors.aai.path.query=/aai/v14/search/sdn-zone-query
org.onap.ccsdk.sli.adaptors.aai.query.nodes=/aai/v14/search/nodes-query?search-node-type={node-type}&filter={entity-identifier}:EQUALS:{entity-name}
diff --git a/aai-service/provider/src/test/resources/aaiclient.properties b/aai-service/provider/src/test/resources/aaiclient.properties
index 3d803c108..d23078d8f 100755
--- a/aai-service/provider/src/test/resources/aaiclient.properties
+++ b/aai-service/provider/src/test/resources/aaiclient.properties
@@ -41,6 +41,9 @@ org.onap.ccsdk.sli.adaptors.aai.uri=https://aai.api.simpledemo.onap.org:8443
connection.timeout=60000
read.timeout=60000
+# aai version
+org.onap.ccsdk.sli.adaptors.aai.version=/v14/
+
# query
org.onap.ccsdk.sli.adaptors.aai.path.query=/aai/v14/search/sdn-zone-query
org.onap.ccsdk.sli.adaptors.aai.query.nodes=/aai/v14/search/nodes-query?search-node-type={node-type}&filter={entity-identifier}:EQUALS:{entity-name}