summaryrefslogtreecommitdiffstats
path: root/aai-service
diff options
context:
space:
mode:
Diffstat (limited to 'aai-service')
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java33
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java9
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java45
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java25
4 files changed, 37 insertions, 75 deletions
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 2e2620a3..382cc53c 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
@@ -91,14 +91,7 @@ public abstract class AAIRequest {
if(tokens != null && tokens.length == 2) {
resoource = tokens[1];
masterResource = tokens[0];
- //
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(resoource) ;
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: ()", e.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoource) ;
if(clazz == null) {
return null;
@@ -107,13 +100,7 @@ public abstract class AAIRequest {
}
if(nameValues.containsKey("selflink")){
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(resoource) ;
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: " + e.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoource) ;
if(clazz != null)
return new SelfLinkRequest(clazz);
@@ -419,7 +406,7 @@ public abstract class AAIRequest {
return AAIService.getObjectMapper();
}
- public static Class<? extends AAIDatum> getClassFromResource(String resoourceName) throws ClassNotFoundException {
+ public static Class<? extends AAIDatum> getClassFromResource(String resoourceName) {
String className = GenericVnf.class.getName();
String[] split = resoourceName.split("-");
for(int i = 0; i < split.length; i++) {
@@ -428,26 +415,18 @@ public abstract class AAIRequest {
String caps = StringUtils.join(split);
className = className.replace("GenericVnf", caps);
- Class<? extends AAIDatum> clazz = null;
try {
- clazz = (Class<? extends AAIDatum>)Class.forName(className);
+ return (Class<? extends AAIDatum>)Class.forName(className);
} catch (ClassNotFoundException e) {
LOG.warn("AAIRequest does not support class: " + e.getMessage());
return null;
}
-
- return clazz;
}
protected static AAIRequest getRequestFromResource(String resoourceName) {
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(resoourceName);
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: " + e.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoourceName);
+
if(clazz == null) {
return null;
}
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 c8c5b92d..73454694 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
@@ -1476,13 +1476,8 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
LOG.info("AAI Deprecation - the format of request key is no longer supported. Please rewrite this key : " + key);
String normResource = resource.split(":")[0];
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = AAIRequest.getClassFromResource(normResource) ;
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: " + e.getMessage());
- return key;
- }
+ Class<? extends AAIDatum> clazz = AAIRequest.getClassFromResource(normResource) ;
+
if(clazz == null)
return key;
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 126b9b26..102835d9 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
@@ -275,33 +275,28 @@ public class AAIServiceUtils {
if(AAIRequest.getResourceNames().contains(tag)){
LOG.info(tag);
// get the class from tag
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = AAIRequest.getClassFromResource(tag);
- String fieldName = AAIServiceUtils.getPrimaryIdFromClass(clazz);
-
- String value = it.next();
- if(!StringUtils.isEmpty(value)){
- nameValues.put(String.format("%s.%s", tag, fieldName), value);
- switch(tag) {
- case "cloud-region":
- case "entitlement":
- case "license":
- case "route-target":
- case "service-capability":
- case "ctag-pool":
- String secondaryFieldName = AAIServiceUtils.getSecondaryIdFromClass(clazz);
- if(secondaryFieldName != null) {
- value = it.next();
- nameValues.put(String.format("%s.%s", tag, secondaryFieldName), value);
- }
- break;
- default:
- break;
+ Class<? extends AAIDatum> clazz = AAIRequest.getClassFromResource(tag);
+ String fieldName = AAIServiceUtils.getPrimaryIdFromClass(clazz);
+
+ String value = it.next();
+ if(!StringUtils.isEmpty(value)){
+ nameValues.put(String.format("%s.%s", tag, fieldName), value);
+ switch(tag) {
+ case "cloud-region":
+ case "entitlement":
+ case "license":
+ case "route-target":
+ case "service-capability":
+ case "ctag-pool":
+ String secondaryFieldName = AAIServiceUtils.getSecondaryIdFromClass(clazz);
+ if(secondaryFieldName != null) {
+ value = it.next();
+ nameValues.put(String.format("%s.%s", tag, secondaryFieldName), value);
}
+ break;
+ default:
+ break;
}
- } catch (ClassNotFoundException exc) {
- LOG.info("Caught exception", exc);
}
}
}
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 a272cf07..20923cc3 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
@@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.adaptors.aai;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
@@ -34,7 +33,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
+
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
import org.openecomp.aai.inventory.v11.L3Network;
import org.openecomp.aai.inventory.v11.L3Networks;
@@ -141,13 +140,7 @@ public class GenericRequest extends AAIRequest {
String encoded_region = encodeQuery(cloudRegionId);
request_url = request_url.replace(token, String.format("%s/%s/%s", splitKey[0], encoded_owner, encoded_region));
} else {
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(splitKey[0]);
- } catch (ClassNotFoundException exc) {
- LOG.warn("AAIRequest does not support class: " + exc.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(splitKey[0]);
if(clazz != null) {
if(clazz == this.model) {
@@ -155,15 +148,15 @@ public class GenericRequest extends AAIRequest {
Field field = fields[0];
String fieldName = field.getName();
XmlElement annotation = field.getAnnotation(XmlElement.class);
- String primaryId = null;
- if(annotation != null) {
- primaryId = annotation.name();
+ String primaryId = null;
+ if(annotation != null) {
+ primaryId = annotation.name();
if("##default".equals(primaryId)) {
primaryId = fieldName;
}
- } else {
- primaryId = fieldName;
- }
+ } else {
+ primaryId = fieldName;
+ }
String token = String.format("%s/{%s}", splitKey[0], primaryId);
@@ -215,7 +208,7 @@ public class GenericRequest extends AAIRequest {
}
@Override
- public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
+ public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
return this.getRequestUrl(method, null);
}