summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java3
-rw-r--r--aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/CustomQueryRequest.java8
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java13
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java8
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java9
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java26
6 files changed, 35 insertions, 32 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
index 0200ccbb..56b092e6 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
+ * Modifications Copyright © 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +76,7 @@ public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin {
public void logKeyError(String keys);
- public QueryStatus processResponseData(String rv, String resource, AAIRequest request, String prefix, SvcLogicContext ctx, Map<String, String> nameValues, String modifier) throws JsonParseException, JsonMappingException, IOException, AAIServiceException ;
+ public QueryStatus processResponseData(String rv, String resource, AAIRequest request, String prefix, SvcLogicContext ctx, Map<String, String> nameValues, String modifier) throws IOException, AAIServiceException ;
public String getPathTemplateForResource(String resoourceName, String join, SvcLogicContext ctx) throws MalformedURLException;
public boolean isDeprecatedFormat(String resource, Map<String, String> nameValues);
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/CustomQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/CustomQueryRequest.java
index 52959073..aaae11a9 100644
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/CustomQueryRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/CustomQueryRequest.java
@@ -32,9 +32,7 @@ import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryRequestData;
import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryResultList;
-import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -111,14 +109,14 @@ public class CustomQueryRequest extends AAIRequest {
String key = FORMAT;
- String encoded_vnf = encodeQuery(requestProperties.getProperty(key));
- requestUrl = requestUrl.replace("{identifier}", encoded_vnf) ;
+ String encodedVnf = encodeQuery(requestProperties.getProperty(key));
+ requestUrl = requestUrl.replace("{identifier}", encodedVnf) ;
aaiService.LOGwriteDateTrace("identifier", requestProperties.getProperty(key));
return requestUrl;
}
- public AAIDatum jsonStringToObject(String jsonData) throws JsonParseException, JsonMappingException, IOException {
+ public AAIDatum jsonStringToObject(String jsonData) throws IOException {
if(jsonData == null) {
return null;
}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java
index 3d14a71c..79103dbb 100644
--- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java
@@ -79,9 +79,9 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
private static final String CLIENT_TYPE_PROPERTY_NAME = "org.onap.appc.adapter.ansible.clientType";
private static final String TRUSTSTORE_PROPERTY_NAME = "org.onap.appc.adapter.ansible.trustStore";
- private static final String TRUSTPASSWD_PROPERTY_NAME = "org.onap.appc.adapter.ansible.trustStore.trustPasswd";
+ private static final String TRUSTPASSD_PROPERTY_NAME = "org.onap.appc.adapter.ansible.trustStore.trustPasswd";
- private static final String PASSWORD = "Password";
+ private static final String PASSD = "Password";
/**
* The logger to be used
@@ -184,7 +184,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
} else if ("TRUST_CERT".equals(clientType)) {
// set path to keystore file
String trustStoreFile = props.getProperty(TRUSTSTORE_PROPERTY_NAME);
- String key = props.getProperty(TRUSTPASSWD_PROPERTY_NAME);
+ String key = props.getProperty(TRUSTPASSD_PROPERTY_NAME);
char[] trustStorePasswd = key.toCharArray();
logger.info("Creating http client with trustmanager from " + trustStoreFile);
httpClient = new ConnectionBuilder(trustStoreFile, trustStorePasswd);
@@ -222,7 +222,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
agentUrl = (String) jsonPayload.remove("AgentUrl");
user = (String) jsonPayload.remove("User");
- password = (String) jsonPayload.remove(PASSWORD);
+ password = (String) jsonPayload.remove(PASSD);
id = jsonPayload.getString("Id");
payload = jsonPayload.toString();
logger.info("Updated Payload = " + payload);
@@ -316,7 +316,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
try {
// Try to retrieve the test results (modify the URL for that)
- AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSWORD));
+ AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSD));
code = testResult.getStatusCode();
message = testResult.getStatusMessage();
@@ -331,6 +331,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
logger.info("Request response = " + message);
} catch (SvcLogicException e) {
+ logger.error(APPC_EXCEPTION_CAUGHT, e);
doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(),
"Exception encountered retrieving result : " + e.getMessage());
return;
@@ -377,7 +378,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
String message = StringUtils.EMPTY;
try {
// Try to retrieve the test results (modify the url for that)
- AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSWORD));
+ AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSD));
message = testResult.getStatusMessage();
logger.info("Request output = " + message);
ctx.setAttribute(LOG_ATTRIBUTE_NAME, message);
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
index 645a7baf..6295a255 100644
--- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright © 2018 IBM.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +36,6 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
@@ -52,7 +53,6 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResult;
import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResultCodes;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -76,7 +76,7 @@ public class ConnectionBuilder {
* Constructor that initializes an http client based on certificate
**/
public ConnectionBuilder(String certFile) throws KeyStoreException, CertificateException, IOException,
- KeyManagementException, NoSuchAlgorithmException, SvcLogicException {
+ KeyManagementException, NoSuchAlgorithmException {
/* Point to the certificate */
try(FileInputStream fs = new FileInputStream(certFile)){
@@ -121,7 +121,7 @@ public class ConnectionBuilder {
* Default if Mode == 0
*/
public ConnectionBuilder(int mode)
- throws SSLException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
+ throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
if (mode == 1) {
SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java
index 0f286257..6e2244ff 100644
--- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java
@@ -6,6 +6,8 @@
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -151,6 +153,7 @@ public class AnsibleMessageParser {
ansibleResult = new AnsibleResult(code, msg);
} catch (JSONException e) {
+ LOGGER.error("JSON exception", e);
ansibleResult = new AnsibleResult(600, "Error parsing response = " + input + ". Error = " + e.getMessage());
}
return ansibleResult;
@@ -168,6 +171,7 @@ public class AnsibleMessageParser {
JSONObject postResponse = new JSONObject(input);
ansibleResult = parseGetResponseNested(ansibleResult, postResponse);
} catch (JSONException e) {
+ LOGGER.error("JSON exception", e);
ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
"Error parsing response = " + input + ". Error = " + e.getMessage(), "");
}
@@ -196,7 +200,7 @@ public class AnsibleMessageParser {
// Results are available. process them
// Results is a dictionary of the form
- // {host :{status:s, group:g, message:m, hostname:h}, ...}
+
LOGGER.info("Processing results in response");
JSONObject results = postRsp.getJSONObject("Results");
LOGGER.info("Get JSON dictionary from Results ..");
@@ -214,10 +218,11 @@ public class AnsibleMessageParser {
LOGGER.info("Code = {}, Message = {}", subCode, message);
- if (subCode != 200 || !message.equals("SUCCESS")) {
+ if (subCode != 200 || !("SUCCESS").equals(message)) {
finalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
}
} catch (JSONException e) {
+ LOGGER.error("JSON exception", e);
ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
ansibleResult.setStatusMessage(String.format(
"Error processing response message = %s from host %s", results.getString(host), host));
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
index 2aebb83e..259b9d8d 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,25 +75,22 @@ public class DataSourceWrap implements DataSource {
@Override
public Connection getConnection() throws SQLException {
- Connection c = dataSource.getConnection();
-
- log.debug("getConnection: " + c.getClass().getName());
-
- c.setAutoCommit(true);
- return c;
+ try (Connection c = dataSource.getConnection()){
+ log.debug("getConnection: " + c.getClass().getName());
+ c.setAutoCommit(true);
+ return c;
+ }
}
-
@Override
public Connection getConnection(String username, String password) throws SQLException {
- Connection c = dataSource.getConnection(username, password);
-
- log.debug("getConnection: " + c.getClass().getName());
-
- c.setAutoCommit(true);
- return c;
+ try (Connection c = dataSource.getConnection(username, password)){
+ log.debug("getConnection: " + c.getClass().getName());
+ c.setAutoCommit(true);
+ return c;
+ }
}
- public void setDataSource(DataSource dataSource) {
+ public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}