diff options
Diffstat (limited to 'aai-service')
11 files changed, 67 insertions, 69 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 cf1392f6..a3aecda1 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 @@ -44,7 +44,6 @@ import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Properties; -import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; @@ -82,6 +81,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { private String userPassword; private final String applicationId; private static final String HTTP_URL_CONNECTION_RESULT="HttpURLConnection result: {} : {}"; + private static final String ENTRY_DOESNT_EXIST="Entry does not exist."; /** * class Constructor @@ -281,7 +281,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, responseMessage, mapper.writeValueAsString(response)); } } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { - LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist."); + LOGwriteEndingTrace(responseCode, responseMessage, ENTRY_DOESNT_EXIST); ErrorResponse errorresponse = null; try { errorresponse = mapper.readValue(reader, ErrorResponse.class); @@ -289,7 +289,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { errorresponse = new ErrorResponse(); RequestError requestError = new RequestError(); ServiceException serviceException = new ServiceException(); - serviceException.setText("Entry does not exist."); + serviceException.setText(ENTRY_DOESNT_EXIST); requestError.setServiceException(serviceException); errorresponse.setRequestError(requestError ); } @@ -501,7 +501,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { LOGwriteEndingTrace(responseCode, responseMessage, stringBuilder.toString()); response = true; } else if(responseCode == HttpURLConnection.HTTP_NOT_FOUND ) { - LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist."); + LOGwriteEndingTrace(responseCode, responseMessage, ENTRY_DOESNT_EXIST); response = false; } else { ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class); @@ -574,7 +574,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { response = mapper.readValue(reader, clas); LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, "SUCCESS", mapper.writeValueAsString(response)); } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { - LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", "Entry does not exist."); + LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", ENTRY_DOESNT_EXIST); return response; } else { BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) ); 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 4a3f9236..20f92656 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 @@ -147,6 +147,8 @@ public abstract class AAIDeclarations implements AAIClient { protected abstract Logger getLogger(); public abstract AAIExecutorInterface getExecutor(); + + private static final String RELATIONSHIP_DATA= "Retrofitting relationship data: "; @Override @@ -891,7 +893,7 @@ public abstract class AAIDeclarations implements AAIClient { AAIServiceUtils.populateRelationshipDataFromPath(list); } } catch(Exception exc) { - getLogger().debug("Retrofiting relationship data: " + exc.getMessage()); + getLogger().debug(RELATIONSHIP_DATA + exc.getMessage()); } String preFix; @@ -1226,7 +1228,7 @@ public abstract class AAIDeclarations implements AAIClient { try { getRelationshipListMethod = resourceClass.getMethod("getRelationshipList"); } catch(Exception exc) { - getLogger().debug("Retrofiting relationship data: " + exc.getMessage()); + getLogger().debug(RELATIONSHIP_DATA + exc.getMessage()); } if(getRelationshipListMethod != null){ @@ -1509,7 +1511,7 @@ public abstract class AAIDeclarations implements AAIClient { try { getRelationshipListMethod = resourceClass.getMethod("getRelationshipList"); } catch(Exception exc) { - getLogger().debug("Retrofiting relationship data: " + exc.getMessage()); + getLogger().debug(RELATIONSHIP_DATA + exc.getMessage()); } if(getRelationshipListMethod != null){ try { @@ -1798,7 +1800,7 @@ public abstract class AAIDeclarations implements AAIClient { try { getRelationshipListMethod = resourceClass.getMethod("getRelationshipList"); } catch(Exception exc) { - getLogger().debug("Retrofiting relationship data: " + exc.getMessage()); + getLogger().debug(RELATIONSHIP_DATA + exc.getMessage()); } if(getRelationshipListMethod != null){ try { 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 82df6981..c66ae06f 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 @@ -433,8 +433,7 @@ public abstract class AAIRequest { if(clazz == null) { return null; } - GenericRequest request = new GenericRequest(clazz); - return request; + return new GenericRequest(clazz); } public static Map<String, String> splitQuery(String query) throws UnsupportedEncodingException { diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java index 78b0f0eb..43038947 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * Modifications Copyright (C) 2019 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 @@ -21,7 +23,6 @@ package org.onap.ccsdk.sli.adaptors.aai; - import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -113,7 +114,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe private final String targetUri; private final String networkVserverPath; - private final String svc_inst_qry_path; + private final String svc_inst_query_path; private final String ubb_notify_path; private final String selflinkAvpn; @@ -147,16 +148,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe this(getProperties(url)); } - private static Properties getProperties(URL url) { - Properties properties = new Properties(); - try { - properties.load(url.openStream()); - } catch (IOException exc) { - LOG.error("getProperties", exc); - } - return properties; - } - public AAIService(Properties props) { LOG.info("Entered AAIService.ctor"); @@ -222,7 +213,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe networkVserverPath =props.getProperty(NETWORK_VSERVER_PATH); props.getProperty(SVC_INSTANCE_PATH); - svc_inst_qry_path = props.getProperty(SVC_INST_QRY_PATH); + svc_inst_query_path = props.getProperty(SVC_INST_QRY_PATH); props.getProperty(PARAM_SERVICE_TYPE, "service-type"); props.getProperty(P_INTERFACE_PATH); @@ -324,11 +315,21 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe methodsField.set(null, methods); } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); + LOG.error("Exception occured", e); } } + private static Properties getProperties(URL url) { + Properties properties = new Properties(); + try { + properties.load(url.openStream()); + } catch (IOException exc) { + LOG.error("getProperties", exc); + } + return properties; + } + public void setExecutor(AAIExecutorInterface executor) { this.executor = executor; } @@ -426,7 +427,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe InputStream inputStream = null; try { - String path = svc_inst_qry_path; + String path = svc_inst_query_path; path = path.replace("{svc-instance-id}", encodeQuery(svc_instance_id)); String request_url = targetUri+path; @@ -474,6 +475,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { inputStream.close(); } catch(Exception exc) { + LOG.warn("Error closing Inputstream", exc); } } } @@ -729,7 +731,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { inputStream.close(); } catch(Exception exc) { - + LOG.warn("Error closing InputStream", exc); } } } @@ -846,7 +848,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe if(inputStream != null) inputStream.close(); } catch (Exception exc) { - + LOG.warn("Error closing Input stream", exc); } } } @@ -906,7 +908,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { inputStream.close(); } catch(Exception exc) { - + LOG.warn("Error closing Input stream", exc); } } } @@ -976,7 +978,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { inputStream.close(); } catch(Exception exc) { - + LOG.warn("Error closing Input stream", exc); } } } @@ -1208,12 +1210,14 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { u = new URL(url); } catch (MalformedURLException e) { + LOG.warn("MalformedURLException", e); return false; } try { u.toURI(); } catch (URISyntaxException e) { + LOG.warn("URISyntaxException", e); return false; } @@ -1228,6 +1232,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe try { u = new URI(url); } catch (URISyntaxException e) { + LOG.warn("URISyntaxException", e); return false; } 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 6af9f9cd..6c48c63d 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 @@ -5,6 +5,8 @@ * 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. * You may obtain a copy of the License at @@ -153,7 +155,7 @@ public class AAIServiceUtils { String term1 = null; String op = null; String term2 = null; - HashMap<String, String> results = new HashMap<String, String>(); + HashMap<String, String> results = new HashMap<>(); for (int i = 0; i < keyTerms.length; i++) { if (term1 == null) { @@ -267,7 +269,7 @@ public class AAIServiceUtils { } protected static HashMap<String,String> pathToHashMap(String path) { - HashMap<String, String> nameValues = new HashMap<String, String>(); + HashMap<String, String> nameValues = new HashMap<>(); String[] split = path.split("/"); diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequest.java index fb234505..6011858d 100644 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequest.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. @@ -67,14 +68,14 @@ public class EchoRequest extends AAIRequest { public String toJSONString() { ObjectMapper mapper = getObjectMapper(); EchoResponse tenant = (EchoResponse)requestDatum; - String json_text = null; + String jsonText = null; try { - json_text = mapper.writeValueAsString(tenant); + jsonText = mapper.writeValueAsString(tenant); } catch (JsonProcessingException exc) { handleException(this, exc); return null; } - return json_text; + return jsonText; } diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java index 51535960..35f190e5 100644 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java @@ -5,6 +5,8 @@ * 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. * You may obtain a copy of the License at @@ -104,19 +106,19 @@ public class GenericQueryRequest extends AAIRequest { String encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{identifier}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("identifier", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(IDENTIFIER, requestProperties.getProperty(key)); key = VALUE; encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{value}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("value", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(VALUE, requestProperties.getProperty(key)); key = START_NODE_TYPE; encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{start-node-type}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("start-node-type", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(START_NODE_TYPE, requestProperties.getProperty(key)); return request_url; } diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java index 7987aefc..45824846 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java @@ -5,6 +5,8 @@ * 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. * You may obtain a copy of the License at @@ -18,7 +20,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.onap.ccsdk.sli.adaptors.aai; import java.io.UnsupportedEncodingException; @@ -70,7 +72,7 @@ public class GenericRequest extends AAIRequest { String request_url = getRequestPath(resourceName); - Map<String, String> queryParams = new HashMap<String, String> (); + Map<String, String> queryParams = new HashMap<> (); if(resourceVersion != null) { queryParams.put("resource-version", resourceVersion.toString()); } diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NamedQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NamedQueryRequest.java index 691ae27a..d1995f04 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NamedQueryRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NamedQueryRequest.java @@ -5,6 +5,8 @@ * 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. * You may obtain a copy of the License at @@ -107,7 +109,7 @@ public class NamedQueryRequest extends AAIRequest { if(innerChild != null) { if(innerChild instanceof ObjectNode) { ObjectNode on = ObjectNode.class.cast(innerChild); - List<String> namesToDelete = new ArrayList<String>(); + List<String> namesToDelete = new ArrayList<>(); Iterator<String> names = on.fieldNames(); while(names.hasNext()) { String name = names.next(); @@ -125,7 +127,7 @@ public class NamedQueryRequest extends AAIRequest { if(innerChild != null) { if(innerChild instanceof ObjectNode) { ObjectNode on = ObjectNode.class.cast(innerChild); - List<String> namesToDelete = new ArrayList<String>(); + List<String> namesToDelete = new ArrayList<>(); Iterator<String> names = on.fieldNames(); while(names.hasNext()) { String name = names.next(); @@ -143,7 +145,7 @@ public class NamedQueryRequest extends AAIRequest { if(innerChild != null) { if(innerChild instanceof ObjectNode) { ObjectNode on = ObjectNode.class.cast(innerChild); - List<String> namesToDelete = new ArrayList<String>(); + List<String> namesToDelete = new ArrayList<>(); Iterator<String> names = on.fieldNames(); while(names.hasNext()) { String name = names.next(); @@ -194,7 +196,7 @@ public class NamedQueryRequest extends AAIRequest { if(requestProperties.containsKey(key)) { encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{named-query-uuid}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("named-query-uuid", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(NAMED_QUERY_UUID, requestProperties.getProperty(key)); } key = PREFIX; @@ -202,7 +204,7 @@ public class NamedQueryRequest extends AAIRequest { if(requestProperties.containsKey(key)) { encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{prefix}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("prefix", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(PREFIX, requestProperties.getProperty(key)); } return request_url; diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java index 0099e933..dafc4a70 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java @@ -5,6 +5,8 @@ * 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. * You may obtain a copy of the License at @@ -48,26 +50,6 @@ public class NodesQueryRequest extends AAIRequest { } -// @Override -// public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException { -// -// String request_url = targetUri+generic_search_path; -// String key = START_NODE_TYPE; -// -// String encoded_vnf = encodeQuery(requestProperties.getProperty(key)); -// request_url = request_url.replace("{vnf-id}", encoded_vnf) ; -// -// if(resourceVersion != null) { -// request_url = request_url +"?resource-version="+resourceVersion; -// } -// URL http_req_url = new URL(request_url); -// -// aaiService.LOGwriteFirstTrace(method, http_req_url.toString()); -// -// -// return http_req_url; -// } - @Override public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException { @@ -125,7 +107,7 @@ public class NodesQueryRequest extends AAIRequest { String encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{entity-identifier}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("entity-identifier", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(ENTITY_IDENTIFIER, requestProperties.getProperty(key)); key = ENTITY_VALUE; @@ -137,7 +119,7 @@ public class NodesQueryRequest extends AAIRequest { encoded_vnf = encodeQuery(requestProperties.getProperty(key)); request_url = request_url.replace("{node-type}", encoded_vnf) ; - aaiService.LOGwriteDateTrace("node-type", requestProperties.getProperty(key)); + aaiService.LOGwriteDateTrace(NODE_TYPE, requestProperties.getProperty(key)); return request_url; } diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java index 789c1316..8ecc0b3e 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.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. @@ -83,7 +84,7 @@ public class UpdateRequest extends AAIRequest { request.requestProperties.put(key, value); } - public static String processPathData(String request_url, Properties requestProperties) throws UnsupportedEncodingException { + public static String processPathData(String requestUrl, Properties requestProperties) { // if(request != null) { // Class<?> clazz = request.getClass(); @@ -97,7 +98,7 @@ public class UpdateRequest extends AAIRequest { // } // request.processPathData(request_url, requestProperties); - return request_url; + return requestUrl; } public void processRequestPathValues(Map<String, String> nameValues) { |