diff options
Diffstat (limited to 'aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java')
-rw-r--r-- | aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java b/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java index 4badf22..8137601 100644 --- a/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java +++ b/aai-service/provider/src/main/java/org/openecomp/sdnc/sli/aai/AAIRequest.java @@ -55,7 +55,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.openecomp.aai.inventory.v10.*; +import org.openecomp.aai.inventory.v11.*; public abstract class AAIRequest { protected static final Logger LOG = LoggerFactory.getLogger(AAIRequest.class); @@ -114,6 +114,7 @@ public abstract class AAIRequest { case "nodes-query": return new NodesQueryRequest(); case "custom-query": + case "formatted-query": return new CustomQueryRequest(); case "linterface": return new LInterfaceRequest(LInterfaceRequest.TYPE.L2_BRIDGE_SBG); @@ -145,6 +146,11 @@ public abstract class AAIRequest { * Map containing bitset value of the path to its path mapping */ private static Map<BitSet, String> bitsetPaths = new LinkedHashMap<BitSet, String>(); + + + public static Set<String> getResourceNames() { + return tagValues.keySet(); + } public static void setProperties(Properties props, AAIService aaiService) { @@ -231,17 +237,23 @@ public abstract class AAIRequest { aaiService.getLogger().warn("Could not deserialize object of type " + lInterfaceRequest.getClass().getSimpleName(), exc) ; } -// public abstract URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException; - public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException { String request_url = null; - request_url = target_uri + getRequestPath(); + request_url = target_uri + updatePathDataValues(resourceVersion); - Set<String> uniqueResources = extractUniqueResourceSetFromKeys(requestProperties.stringPropertyNames()); + URL http_req_url = new URL(request_url); -// request_url = processPathData(request_url, requestProperties); + aaiService.LOGwriteFirstTrace(method, http_req_url.toString()); + + return http_req_url; + } + + public String updatePathDataValues(Object resourceVersion) throws UnsupportedEncodingException, MalformedURLException { + String request_url = getRequestPath(); + + Set<String> uniqueResources = extractUniqueResourceSetFromKeys(requestProperties.stringPropertyNames()); for(String resoourceName:uniqueResources) { AAIRequest locRequest = AAIRequest.createRequest(resoourceName, new HashMap<String, String>()); @@ -254,19 +266,14 @@ public abstract class AAIRequest { } catch (Exception e) { e.printStackTrace(); } -// request_url = locRequest.processPathData(request_url, requestProperties); } } 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; + return request_url; } @@ -366,7 +373,7 @@ public abstract class AAIRequest { return AAIService.getObjectMapper(); } - protected static Class<? extends AAIDatum> getClassFromResource(String resoourceName) throws ClassNotFoundException { + public static Class<? extends AAIDatum> getClassFromResource(String resoourceName) throws ClassNotFoundException { String className = GenericVnf.class.getName(); String[] split = resoourceName.split("-"); for(int i = 0; i < split.length; i++) { @@ -415,6 +422,19 @@ public abstract class AAIRequest { return query_pairs; } + public static Map<String, String> splitPath(String path) throws UnsupportedEncodingException { + Map<String, String> query_pairs = new LinkedHashMap<String, String>(); + + if(path != null && !path.isEmpty()) { + String[] pairs = path.split("/"); + for (String pair : pairs) { + int idx = pair.indexOf("="); + query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); + } + } + return query_pairs; + } + protected boolean expectsDataFromPUTRequest() { return false; } |