Removing Named Query.
[policy/models.git] / models-interactions / model-impl / aai / src / main / java / org / onap / policy / aai / AaiManager.java
index d95068b..5b48424 100644 (file)
@@ -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<String, String> 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<Integer, String> 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 <T> 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> T getQuery(final String url, final String username, final String password, final UUID requestId,
-            final String key, final Class<T> classOfResponse) {
-
-        Map<String, String> headers = createHeaders(requestId);
-
-        String urlGet = url + key;
-
-        int attemptsLeft = 3;
-
-        while (attemptsLeft-- > 0) {
-            NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet);
-            Pair<Integer, String> 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 <T> 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> T composeResponse(final Pair<Integer, String> httpDetails, final String url,
-            final Class<T> 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.
      *