X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-interactions%2Fmodel-impl%2Faai%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Faai%2FAaiManager.java;h=5b484243ac9e8c3654a9aa02a73198c8ee4746b8;hb=6de5a0c9e2acf3a799f53c9fedf8a40861b6ddbe;hp=d95068b2bc81392dd7a549c14db74701136f943d;hpb=c34a4b6b2e111462cde7f5663b8fbbc4ad86fc7e;p=policy%2Fmodels.git diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java index d95068b2b..5b484243a 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -217,142 +217,6 @@ public final class AaiManager { return null; } - /** - * Post a query to A&AI. - * - * @param url the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param request the request to issue towards A&AI - * @param requestId the UUID of the request - * @return the response from A&AI - */ - public AaiNqResponse postQuery(String url, String username, String password, AaiNqRequest request, UUID requestId) { - - final Map headers = createHeaders(requestId); - - url = url + "/aai/search/named-query"; - - logger.debug("RestManager.post before"); - String requestJson = Serialization.gsonPretty.toJson(request); - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson); - Pair httpDetails = - restManager.post(url, username, password, headers, APPLICATION_JSON, requestJson); - logger.debug("RestManager.post after"); - - if (httpDetails == null) { - logger.info("AAI POST Null Response to {}", url); - return null; - } - - int httpResponseCode = httpDetails.first; - - logger.info(url); - logger.info("{}", httpResponseCode); - logger.info(httpDetails.second); - - if (httpDetails.second != null) { - return composeResponse(httpDetails, url, AaiNqResponse.class); - } - return null; - } - - /** - * Perform a GET request for a particular virtual server towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the key of the virtual server - * @return the response for the virtual server from A&AI - */ - public AaiGetVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVserverResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF ID towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the ID of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfId(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF name towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET query for a particular entity towards A&AI. - * - * @param the generic type for the response - * @param url the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @param classOfResponse the class of the response to return - * @return the response for the virtual server from A&AI - */ - private T getQuery(final String url, final String username, final String password, final UUID requestId, - final String key, final Class classOfResponse) { - - Map headers = createHeaders(requestId); - - String urlGet = url + key; - - int attemptsLeft = 3; - - while (attemptsLeft-- > 0) { - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet); - Pair httpDetailsGet = restManager.get(urlGet, username, password, headers); - if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to {}", urlGet); - return null; - } - - int httpResponseCode = httpDetailsGet.first; - - logger.info(urlGet); - logger.info("{}", httpResponseCode); - logger.info(httpDetailsGet.second); - - if (httpResponseCode == 200) { - T responseGet = composeResponse(httpDetailsGet, urlGet, classOfResponse); - if (responseGet != null) { - return responseGet; - } - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - } - - return null; - } /** * Create the headers for the HTTP request. @@ -370,28 +234,6 @@ public final class AaiManager { return headers; } - /** - * This method uses Google's GSON to create a response object from a JSON string. - * - * @param the generic type - * @param httpDetails the HTTP response - * @param url the URL from which the response came - * @param classOfResponse The response class - * @return an instance of the response class - * @throws JsonSyntaxException on GSON errors instantiating the response - */ - private T composeResponse(final Pair httpDetails, final String url, - final Class classOfResponse) { - try { - T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second); - return response; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); - return null; - } - } - /** * Perform a GET request for a particular PNF by PNF ID towards A&AI. *