import org.onap.ccsdk.sli.adaptors.aai.query.Result;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.openecomp.aai.inventory.v11.GenericVnf;
-import org.openecomp.aai.inventory.v11.Image;
-import org.openecomp.aai.inventory.v11.InventoryResponseItem;
-import org.openecomp.aai.inventory.v11.InventoryResponseItems;
-import org.openecomp.aai.inventory.v11.L3Network;
-import org.openecomp.aai.inventory.v11.LogicalLink;
-import org.openecomp.aai.inventory.v11.Metadata;
-import org.openecomp.aai.inventory.v11.Metadatum;
-import org.openecomp.aai.inventory.v11.Pnf;
-import org.openecomp.aai.inventory.v11.RelatedToProperty;
-import org.openecomp.aai.inventory.v11.Relationship;
-import org.openecomp.aai.inventory.v11.RelationshipData;
-import org.openecomp.aai.inventory.v11.RelationshipList;
-import org.openecomp.aai.inventory.v11.ResultData;
-import org.openecomp.aai.inventory.v11.SearchResults;
-import org.openecomp.aai.inventory.v11.ServiceInstance;
-import org.openecomp.aai.inventory.v11.Vlan;
-import org.openecomp.aai.inventory.v11.Vlans;
-import org.openecomp.aai.inventory.v11.Vserver;
+import org.onap.aai.inventory.v14.GenericVnf;
+import org.onap.aai.inventory.v14.Image;
+import org.onap.aai.inventory.v14.InventoryResponseItem;
+import org.onap.aai.inventory.v14.InventoryResponseItems;
+import org.onap.aai.inventory.v14.L3Network;
+import org.onap.aai.inventory.v14.LogicalLink;
+import org.onap.aai.inventory.v14.Metadata;
+import org.onap.aai.inventory.v14.Metadatum;
+import org.onap.aai.inventory.v14.Pnf;
+import org.onap.aai.inventory.v14.RelatedToProperty;
+import org.onap.aai.inventory.v14.Relationship;
+import org.onap.aai.inventory.v14.RelationshipData;
+import org.onap.aai.inventory.v14.RelationshipList;
+import org.onap.aai.inventory.v14.ResultData;
+import org.onap.aai.inventory.v14.SearchResults;
+import org.onap.aai.inventory.v14.ServiceInstance;
+import org.onap.aai.inventory.v14.Vlan;
+import org.onap.aai.inventory.v14.Vlans;
+import org.onap.aai.inventory.v14.Vserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if(!itemRemoved)
return QueryStatus.NOT_FOUND;
-
-// AAIRequest masterRequest = new GenericVnfRequest();
-// masterRequest.addRequestProperty(GenericVnfRequest.VNF_ID, vnfId);
-// relationshipRequest.addMasterRequest(masterRequest);
-// Map<String, String> attributes = objectToProperties(vnf);
-// try {
-// Boolean result = getExecutor().delete(relationshipRequest, attributes.get(AAIRequest.RESOURCE_VERSION));
-// } catch (AAIServiceException e) {
-// return QueryStatus.FAILURE;
-// }
-
try {
this.postGenericVnfData(vnf.getVnfId(), vnf);
} catch (AAIServiceException exc) {
Method setter = null;
try {
setter = resourceClass.getMethod("set"+StringUtils.capitalize(value), type);
- if(type.getName().startsWith("java.lang") || "boolean".equals(type.getName()) || "long".equals(type.getName())) {
+ if(type.getName().startsWith("java.lang") || "boolean".equals(type.getName()) || "long".equals(type.getName()) || "int".equals(type.getName())) {
try {
- setter.setAccessible(true);
Object arglist[] = new Object[1];
arglist[0] = params.get(id);
if(arglist[0] != null) {
if(!type.getName().equals("java.lang.String")) {
// getLogger().debug(String.format("Processing %s with parameter %s", types[0].getName(), value));
- if("boolean".equals(type.getName())) {
+ if("java.lang.Long".equals(type.getName()) || "java.lang.Integer".equals(type.getName())) {
+ String fv = params.get(id);
+ if(fv == null || fv.isEmpty()) {
+ arglist[0] = null;
+ } else {
+ arglist[0] = valueOf(type, params.get(id));
+ }
+ } else if("boolean".equals(type.getName())) {
arglist[0] = valueOf(Boolean.class, params.get(id));
+ } else if("int".equals(type.getName())) {
+ arglist[0] = valueOf(Integer.class, params.get(id));
} else if("long".equals(type.getName())) {
+ String fv = params.get(id);
+ if(fv == null || fv.isEmpty()) {
+ arglist[0] = null;
+ } else {
arglist[0] = valueOf(Long.class, params.get(id));
+ }
} else {
arglist[0] = valueOf(type, params.get(id));
}
Method method = getters.get(attribute);
if(method != null) {
try {
- method.setAccessible(true);
Object arglist[] = new Object[0];
// arglist[0] = value;
Class<?>[] types = method.getParameterTypes();
if(getRelationshipListMethod != null){
try {
- getRelationshipListMethod.setAccessible(true);
obj = getRelationshipListMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method setRelationshipListMethod = resourceClass.getMethod("setRelationshipList", RelationshipList.class);
if(setRelationshipListMethod != null){
try {
- setRelationshipListMethod.setAccessible(true);
Object arglist[] = new Object[1];
arglist[0] = relationshipList;
Relationship relationship = new Relationship();
relationships.add(relationship);
relationship.setRelatedTo(relatedTo);
+ String relationshipLabel = "relationship-list.relationship[" + i + "].relationship-label";
+ if(params.containsKey(searchKey)) {
+ relationship.setRelationshipLabel(params.get(relationshipLabel));
+ }
+ getLogger().debug("About to process related link of {}", relatedLink);
if(relatedLink != null) {
+ if(relatedLink.contains("v$"))
+ relatedLink = relatedLink.replace("v$", "v14");
relationship.setRelatedLink(relatedLink);
} else {
Map<String, String> relParams = new HashMap<>();
- while(true) {
- String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
- String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
- if(!params.containsKey(searchRelationshipKey))
- break;
+ while(true) {
+ String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
+ String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
+ if(!params.containsKey(searchRelationshipKey))
+ break;
- relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
- j++;
- }
+ relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
+ j++;
+ }
AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
for(Map.Entry<String,String> entry : relParams.entrySet()) {
rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
String path = rlRequest.updatePathDataValues(null);
relationship.setRelatedLink(path);
}
- {
- int k = 0;
- // process related to properties
- Map<String, String> relParams = new HashMap<String, String>();
-
- while(true) {
- String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
- String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
- if(!params.containsKey(searchRelatedToKey))
- break;
-
- RelatedToProperty relDatum = new RelatedToProperty();
- relDatum.setPropertyKey(params.get(searchRelatedToKey));
- relDatum.setPropertyValue(params.get(searchRelatedToValue));
- relationship.getRelatedToProperty().add(relDatum);
-
- relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
- k++;
- }
- }
+ {
+ int k = 0;
+ // process related to properties
+ Map<String, String> relParams = new HashMap<String, String>();
+
+ while(true) {
+ String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
+ String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
+ if(!params.containsKey(searchRelatedToKey))
+ break;
+
+ RelatedToProperty relDatum = new RelatedToProperty();
+ relDatum.setPropertyKey(params.get(searchRelatedToKey));
+ relDatum.setPropertyValue(params.get(searchRelatedToValue));
+ relationship.getRelatedToProperty().add(relDatum);
+
+ relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
+ k++;
+ }
+ }
i++;
}
}
Method getVLansMethod = resourceClass.getMethod("getVlans");
if(getVLansMethod != null){
try {
- getVLansMethod.setAccessible(true);
obj = getVLansMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method setVlansMethod = resourceClass.getMethod("setVlans", Vlans.class);
if(setVlansMethod != null){
try {
- setVlansMethod.setAccessible(true);
Object arglist[] = new Object[1];
arglist[0] = vlanList;
Method getMetadataMethod = resourceClass.getMethod("getMetadata");
if(getMetadataMethod != null){
try {
- getMetadataMethod.setAccessible(true);
obj = getMetadataMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method setMetadataMethod = resourceClass.getMethod("setMetadata", Metadata.class);
if(setMetadataMethod != null){
try {
- setMetadataMethod.setAccessible(true);
Object arglist[] = new Object[1];
arglist[0] = metadataList;
}
if(getRelationshipListMethod != null){
try {
- getRelationshipListMethod.setAccessible(true);
obj = getRelationshipListMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method setRelationshipListMethod = resourceClass.getMethod("setRelationshipList", RelationshipList.class);
if(setRelationshipListMethod != null){
try {
- setRelationshipListMethod.setAccessible(true);
Object arglist[] = new Object[1];
arglist[0] = relationshipList;
relatedLink = params.get(relatedLinkKey);
}
- Relationship relationship = new Relationship();
- relationships.add(relationship);
- relationship.setRelatedTo(relatedTo);
- if (relatedLink != null) {
- relationship.setRelatedLink(relatedLink);
- } else {
- Map<String, String> relParams = new HashMap<>();
- int j = 0;
-
- while (true) {
- String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data["
- + j + "].relationship-key";
- String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data["
- + j + "].relationship-value";
- if (!params.containsKey(searchRelationshipKey))
- break;
-
- RelationshipData relDatum = new RelationshipData();
- relDatum.setRelationshipKey(params.get(searchRelationshipKey));
- relDatum.setRelationshipValue(params.get(searchRelationshipValue));
- relationship.getRelationshipData().add(relDatum);
-
- relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
- j++;
- }
- AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
- for (Map.Entry<String, String> entry : relParams.entrySet()) {
- rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
- }
- String path = rlRequest.updatePathDataValues(null);
- relationship.setRelatedLink(path);
- }
- {
- int k = 0;
- // process related to properties
- Map<String, String> relParams = new HashMap<String, String>();
-
- while(true) {
- String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
- String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
- if(!params.containsKey(searchRelatedToKey))
- break;
-
- RelatedToProperty relDatum = new RelatedToProperty();
- relDatum.setPropertyKey(params.get(searchRelatedToKey));
- relDatum.setPropertyValue(params.get(searchRelatedToValue));
- relationship.getRelatedToProperty().add(relDatum);
-
- relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
- k++;
- }
- }
-
- i++;
- }
+ Relationship relationship = new Relationship();
+ relationships.add(relationship);
+ relationship.setRelatedTo(relatedTo);
+
+ String relationshipLabel = "relationship-list.relationship[" + i + "].relationship-label";
+ if(params.containsKey(searchKey)) {
+ relationship.setRelationshipLabel(params.get(relationshipLabel));
+ }
+
+ if (relatedLink != null) {
+ if(relatedLink.contains("v$"))
+ relatedLink = relatedLink.replace("v$", "v14");
+ relationship.setRelatedLink(relatedLink);
+ } else {
+ Map<String, String> relParams = new HashMap<>();
+ int j = 0;
+
+ while (true) {
+ String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data["
+ + j + "].relationship-key";
+ String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data["
+ + j + "].relationship-value";
+ if (!params.containsKey(searchRelationshipKey))
+ break;
+
+ RelationshipData relDatum = new RelationshipData();
+ relDatum.setRelationshipKey(params.get(searchRelationshipKey));
+ relDatum.setRelationshipValue(params.get(searchRelationshipValue));
+ relationship.getRelationshipData().add(relDatum);
+
+ relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
+ j++;
+ }
+ AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
+ for (Map.Entry<String, String> entry : relParams.entrySet()) {
+ rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
+ }
+ String path = rlRequest.updatePathDataValues(null);
+ relationship.setRelatedLink(path);
+ }
+ {
+ int k = 0;
+ // process related to properties
+ Map<String, String> relParams = new HashMap<String, String>();
+
+ while(true) {
+ String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
+ String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
+ if(!params.containsKey(searchRelatedToKey))
+ break;
+
+ RelatedToProperty relDatum = new RelatedToProperty();
+ relDatum.setPropertyKey(params.get(searchRelatedToKey));
+ relDatum.setPropertyValue(params.get(searchRelatedToValue));
+ relationship.getRelatedToProperty().add(relDatum);
+
+ relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
+ k++;
+ }
+ }
+
+ i++;
+ }
}
return QueryStatus.SUCCESS;
Method getMetadataMethod = resourceClass.getMethod("getMetadata");
if(getMetadataMethod != null){
try {
- getMetadataMethod.setAccessible(true);
obj = getMetadataMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method setMetadataMethod = resourceClass.getMethod("setMetadata", Metadata.class);
if(setMetadataMethod != null){
try {
- setMetadataMethod.setAccessible(true);
setMetadataMethod.invoke(instance, metadata);
} catch (InvocationTargetException x) {
}
Method getResourceVersionMethod = resourceClass.getMethod("getResourceVersion");
if(getResourceVersionMethod != null){
try {
- getResourceVersionMethod.setAccessible(true);
Object object = getResourceVersionMethod.invoke(instance);
if(object != null)
resourceVersion = object.toString();
}
if(getRelationshipListMethod != null){
try {
- getRelationshipListMethod.setAccessible(true);
obj = getRelationshipListMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
Method getResourceVersionMethod = resourceClass.getMethod("getResourceVersion");
if(getResourceVersionMethod != null){
try {
- getResourceVersionMethod.setAccessible(true);
resourceVersion = (String) getResourceVersionMethod.invoke(instance);
} catch (InvocationTargetException x) {
}
Method getMetadataMethod = resourceClass.getMethod("getMetadata");
if(getMetadataMethod != null){
try {
- getMetadataMethod.setAccessible(true);
obj = getMetadataMethod.invoke(instance);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();