aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap
diff options
context:
space:
mode:
authorPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2021-09-22 10:22:53 -0400
committerPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2021-09-29 10:28:22 -0400
commitf78df9f30d5b7bda1b291bff34dd85bdd9411c12 (patch)
tree3bdcae2f31ebdbb6bb2ff21e13a26d83f2e74a00 /vid-app-common/src/main/java/org/onap
parenta1d209deac01bc0f8f7be96a585bdbef9cc0cdb9 (diff)
AAI Query optimization for VID
Issue-ID: VID-986 Change-Id: Ia3e012c41df4e9049ce9a1ae56ec83b276e11611 Signed-off-by: PATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/Customer.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java62
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java150
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java45
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java43
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java94
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java112
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiService.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java94
13 files changed, 801 insertions, 3 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 00137b60c..d37adba7f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -109,7 +109,7 @@ public class AaiClient implements AaiClientInterface {
private static final String BUSINESS_CUSTOMER = "/business/customers/customer/";
private static final String SERVICE_INSTANCE = "/service-instances/service-instance/";
private static final String BUSINESS_CUSTOMERS_CUSTOMER = "business/customers/customer/";
-
+ private static final String QUERY_FORMAT_RESOURCE_DSL = "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true";
protected String fromAppId = "VidAaiController";
private PortDetailsTranslator portDetailsTranslator;
@@ -919,6 +919,39 @@ public class AaiClient implements AaiClientInterface {
}
@Override
+ public AaiResponse<DSLQuerySimpleResponse> getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+ ResponseWithRequestInfo response;
+ String payload = getDSLQueryPayloadByServiceIdentifier(globalCustomerId,identifierType,serviceIdentifier);
+// Response resp = doAaiPut(QUERY_FORMAT_RESOURCE_DSL, payload, false);
+// resp.bufferEntity();
+// String rawPayload = resp.readEntity(String.class);
+// AaiResponse<DSLQuerySimpleResponse> aaiResponse = processAaiResponse(resp, DSLQuerySimpleResponse.class, rawPayload);
+
+ response = doAaiPut(QUERY_FORMAT_RESOURCE_DSL, payload, false, false);
+ AaiResponseWithRequestInfo<DSLQuerySimpleResponse> aaiResponse = processAaiResponse(response, DSLQuerySimpleResponse.class, false);
+ verifyAaiResponseValidityOrThrowExc(aaiResponse, aaiResponse.getAaiResponse().getHttpCode());
+ return aaiResponse.getAaiResponse();
+ }
+
+ private String getDSLQueryPayloadByServiceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+ String query = null;
+ String payLoad = null;
+ if(globalCustomerId != null && identifierType != null && serviceIdentifier != null) {
+ if(identifierType.equalsIgnoreCase("Service Instance Id")) {
+ query = "customer*('global-customer-id','"+globalCustomerId+"')>" +
+ "service-subscription>service-instance*('service-instance-id','"+serviceIdentifier+"')";
+ payLoad = "{\"dsl\":\"" + query + "\"}";
+ } else {
+ query = "customer*('global-customer-id','"+globalCustomerId+"')>" +
+ "service-subscription>service-instance*('service-instance-name','"+serviceIdentifier+"')";
+ payLoad = "{\"dsl\":\"" + query + "\"}";
+ }
+
+ }
+ return payLoad;
+ }
+
+ @Override
public void resetCache(String cacheName) {
cacheProvider.resetCache(cacheName);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index c322afa22..a1edc8d5c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -108,4 +108,6 @@ public interface AaiClientInterface extends ProbeInterface {
Map<String, Properties> getCloudRegionAndTenantByVnfId(String vnfId);
AaiResponse<AaiGetVnfResponse> getVnfsByParamsForChangeManagement(String subscriberId, String serviceType, String nfRole, String cloudRegion);
+
+ AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/Customer.java b/vid-app-common/src/main/java/org/onap/vid/aai/Customer.java
new file mode 100644
index 000000000..a28b3c396
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/Customer.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Customer {
+
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ public String getGlobalCustomerId() {
+ return globalCustomerId;
+ }
+
+ public void setGlobalCustomerId(String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ public String getSubscriberType() {
+ return subscriberType;
+ }
+
+ public void setSubscriberType(String subscriberType) {
+ this.subscriberType = subscriberType;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public List<CustomerRelatedNodes> getCustomerRelatedNodes() {
+ return customerRelatedNodes;
+ }
+
+ public void setCustomerRelatedNodes(List<CustomerRelatedNodes> customerRelatedNodes) {
+ this.customerRelatedNodes = customerRelatedNodes;
+ }
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("related-nodes")
+ public List<CustomerRelatedNodes> customerRelatedNodes;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java
new file mode 100644
index 000000000..7637e312e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerRelatedNodes {
+
+ public CustomerServiceSubscription getCustomerServiceSubscription() {
+ return customerServiceSubscription;
+ }
+
+ public void setCustomerServiceSubscription(CustomerServiceSubscription customerServiceSubscription) {
+ this.customerServiceSubscription = customerServiceSubscription;
+ }
+
+ @JsonProperty("service-subscription")
+ public CustomerServiceSubscription customerServiceSubscription;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java
new file mode 100644
index 000000000..9b94cf66b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerServiceSubscription {
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public List<ServiceSubscriptionRelatedNodes> getServiceSubscriptionRelatedNodes() {
+ return serviceSubscriptionRelatedNodes;
+ }
+
+ public void setServiceSubscriptionRelatedNodes(List<ServiceSubscriptionRelatedNodes> serviceSubscriptionRelatedNodes) {
+ this.serviceSubscriptionRelatedNodes = serviceSubscriptionRelatedNodes;
+ }
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("related-nodes")
+ public List<ServiceSubscriptionRelatedNodes> serviceSubscriptionRelatedNodes;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java
new file mode 100644
index 000000000..ef6f49833
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java
@@ -0,0 +1,150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerSpecificServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @JsonProperty("service-instance-name")
+ public String serviceInstanceName;
+
+ @JsonProperty("orchestration-status")
+ public String orchestrationStatus;
+
+ @JsonProperty("model-invariant-id")
+ public String modelInvariantId;
+
+ @JsonProperty("model-version-id")
+ public String modelVersionId;
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getSelfLink() {
+ return selfLink;
+ }
+
+ public void setSelfLink(String selfLink) {
+ this.selfLink = selfLink;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getEnvironmentContext() {
+ return environmentContext;
+ }
+
+ public void setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("selflink")
+ public String selfLink;
+
+ @JsonProperty("service-role")
+ public String serviceRole;
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("environment-context")
+ public String environmentContext;
+
+ @JsonProperty("workload-context")
+ public String workloadContext;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java
new file mode 100644
index 000000000..e151ffd97
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+//@JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonPropertyOrder({
+// "results"
+//})
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DSLQuerySimpleResponse {
+
+ private final List<ServiceInstanceResponseBySubscriber> results;
+
+ public DSLQuerySimpleResponse(@JsonProperty("results") List<ServiceInstanceResponseBySubscriber> results) {
+ this.results = results;
+ }
+
+ public List<ServiceInstanceResponseBySubscriber> getResults() {
+ return results;
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java
new file mode 100644
index 000000000..3c4071e9e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+//@JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonPropertyOrder({
+// "results"
+//})
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstanceResponseBySubscriber {
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ @JsonProperty("customer")
+ public Customer customer;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java
new file mode 100644
index 000000000..a991b980d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceSubscriptionRelatedNodes {
+
+ public CustomerSpecificServiceInstance getServiceInstance() {
+ return serviceInstance;
+ }
+
+ public void setServiceInstance(CustomerSpecificServiceInstance serviceInstance) {
+ this.serviceInstance = serviceInstance;
+ }
+
+ @JsonProperty("service-instance")
+ public CustomerSpecificServiceInstance serviceInstance;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java
new file mode 100644
index 000000000..f06cd9169
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ViewEditSIResult {
+
+ private String serviceInstanceId;
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ @JsonProperty("serviceInstanceId")
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ @JsonProperty("serviceInstanceName")
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+ @JsonProperty("modelInvariantId")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+ @JsonProperty("orchestrationStatus")
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+ @JsonProperty("subscriberName")
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ private String serviceInstanceName;
+ private String modelVersionId;
+ private String modelInvariantId;
+ private String orchestrationStatus;
+ private String subscriberName;
+
+
+
+
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
index a9ce40bba..e4fbecaf3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
@@ -68,6 +69,16 @@ import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
import org.togglz.core.manager.FeatureManager;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.onap.vid.aai.CustomerSpecificServiceInstance;
+import org.onap.vid.aai.DSLQuerySimpleResponse;
+import org.onap.vid.aai.model.ServiceRelationships;
+import org.onap.vid.aai.model.ViewEditSIResult;
+
@RestController
public class AaiController extends RestrictedBaseController {
@@ -268,14 +279,27 @@ public class AaiController extends RestrictedBaseController {
public ResponseEntity<String> SearchServiceInstances(HttpServletRequest request,
@RequestParam(value = "subscriberId", required = false) String subscriberId,
@RequestParam(value = "serviceInstanceIdentifier", required = false) String instanceIdentifier,
+ @RequestParam(value = "serviceInstanceIdentifierType", required = false) String instanceIdentifierType,
@RequestParam(value = "project", required = false) List<String> projects,
@RequestParam(value = "owningEntity", required = false) List<String> owningEntities) throws IOException {
ResponseEntity responseEntity;
RoleValidator roleValidator = roleProvider.getUserRolesValidator(request);
- AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService
- .getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+ AaiResponse<ServiceInstancesSearchResults> searchResult = null;
+
+ if( instanceIdentifier != null && isValidInstanceIdentifierType(instanceIdentifierType)) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== search_service_instances search by subscriberId "
+ + " instanceIdentifier and instanceIdentifierType start");
+ searchResult = aaiService
+ .getServiceInstanceSearchResultsByIdentifierType(subscriberId, instanceIdentifier,
+ instanceIdentifierType, roleValidator, owningEntities, projects);
+ } else {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== search_service_instances search by subscriberId "
+ + "instanceIdentifier instanceIdentifier and instanceIdentifierType start");
+ searchResult = aaiService
+ .getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+ }
String httpMessage = searchResult.getT() != null ?
objectMapper.writeValueAsString(searchResult.getT()) :
@@ -291,6 +315,85 @@ public class AaiController extends RestrictedBaseController {
return responseEntity;
}
+ @RequestMapping(value = {
+ "/aai_get_service_instance_by_id_and_type/{globalCustomerId}/{serviceInstanceIdentifier}/{serviceIdentifierType}/{subscriberName}",
+ "/aai_get_service_instance_by_id_and_type/{globalCustomerId}/{serviceInstanceIdentifier}/{serviceIdentifierType}"},
+ method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServiceInstanceByIdAndType(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceInstanceIdentifier") String serviceInstanceIdentifier,
+ @PathVariable("serviceIdentifierType") String serviceIdentifierType,
+ @PathVariable("subscriberName") java.util.Optional<String> subscriberName) throws IOException {
+
+ AaiResponse aaiResponse = null;
+ String orchStatus = null;
+ String siid, siName, modelVerId, modelInvId = null;
+ String errorMessage = null;
+ int statusCode = -1;
+ ViewEditSIResult viewEditSIResult = new ViewEditSIResult();
+ if(!subscriberName.equals(Optional.empty()) && serviceInstanceIdentifier != null) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type. "
+ + "Search node query to get Service Type: "+serviceInstanceIdentifier);
+ ResponseEntity entity = convertResponseToResponseEntity(doAaiGet(
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceIdentifier, false));
+ JSONParser jsonParser = new JSONParser();
+ try {
+ if(entity != null) {
+ org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) jsonParser.parse(
+ entity.getBody().toString());
+ JSONArray jSONArray = (JSONArray)jsonObject.get("result-data");
+ org.json.simple.JSONObject jSONObject = (org.json.simple.JSONObject)jSONArray.get(0);
+ String resourceLink = jSONObject.get("resource-link").toString();
+ String serviceType = resourceLink.split("/")[9];
+ aaiResponse = aaiService.getServiceInstanceBySubscriberIdAndSIID(globalCustomerId,serviceType,
+ serviceInstanceIdentifier);
+ if(aaiResponse != null && aaiResponse.getT() != null) {
+ viewEditSIResult.setOrchestrationStatus(((ServiceRelationships) aaiResponse.getT()).orchestrationStatus);
+ viewEditSIResult.setServiceInstanceId(((ServiceRelationships) aaiResponse.getT()).serviceInstanceId);
+ viewEditSIResult.setServiceInstanceName(((ServiceRelationships) aaiResponse.getT()).serviceInstanceName);
+ viewEditSIResult.setModelVersionId(((ServiceRelationships) aaiResponse.getT()).modelVersionId);
+ viewEditSIResult.setModelInvariantId(((ServiceRelationships) aaiResponse.getT()).modelInvariantId);
+ viewEditSIResult.setSubscriberName(subscriberName.get());
+ } else {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No response for getServiceInstanceBySubscriberIdAndSIID: "+serviceInstanceIdentifier);
+ errorMessage = aaiResponse.getErrorMessage();
+ }
+ statusCode = aaiResponse.getHttpCode();
+ } else {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No response for nodes-query for siid: "+serviceInstanceIdentifier);
+ statusCode = entity.getStatusCode().value();
+ errorMessage = aaiResponse.getErrorMessage();
+ }
+ } catch (Exception e) {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type" + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type" + e.toString());
+ }
+ } else {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type. Use DSL query to get SI details."+serviceInstanceIdentifier);
+ aaiResponse = aaiService
+ .getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId, serviceIdentifierType, serviceInstanceIdentifier);
+ if(aaiResponse != null && aaiResponse.getT() != null) {
+ CustomerSpecificServiceInstance siData = ((DSLQuerySimpleResponse)aaiResponse.getT()).getResults().get(0).getCustomer().
+ customerRelatedNodes.get(0).getCustomerServiceSubscription().
+ getServiceSubscriptionRelatedNodes().get(0).getServiceInstance();
+ viewEditSIResult.setOrchestrationStatus(siData.getOrchestrationStatus());
+ viewEditSIResult.setServiceInstanceId(siData.serviceInstanceId);
+ viewEditSIResult.setServiceInstanceName(siData.serviceInstanceName);
+ viewEditSIResult.setModelVersionId(siData.modelVersionId);
+ viewEditSIResult.setModelInvariantId(siData.modelInvariantId);
+ viewEditSIResult.setSubscriberName(((DSLQuerySimpleResponse)aaiResponse.getT()).getResults().get(0).getCustomer().subscriberName);
+ } else {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No result for DSL query :"+serviceInstanceIdentifier);
+ errorMessage = aaiResponse.getErrorMessage();
+ }
+ statusCode = aaiResponse.getHttpCode();
+ }
+ String httpMessage = viewEditSIResult != null ? objectMapper.writeValueAsString(viewEditSIResult) : errorMessage;
+ return new ResponseEntity<>(httpMessage,HttpStatus.valueOf(statusCode));
+ }
+
+
@RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET)
public ResponseEntity<String> viewEditGetComponentList(
@PathVariable("namedQueryId") String namedQueryId,
@@ -577,4 +680,9 @@ public class AaiController extends RestrictedBaseController {
return null;
}
}
+ private boolean isValidInstanceIdentifierType(String instanceIdentifierType) {
+ return instanceIdentifierType != null
+ && ( instanceIdentifierType.equalsIgnoreCase("Service Instance Id") ||
+ instanceIdentifierType.equalsIgnoreCase("Service Instance Name"));
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
index bc26b5eb0..7be2dd2ee 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
@@ -102,4 +102,8 @@ public interface AaiService {
List<Network> getL3NetworksByCloudRegion(String cloudRegionId, String tenantId, String networkRole);
ModelVer getNewestModelVersionByInvariantId(String modelInvariantId);
+
+ AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier);
+ AaiResponse getServiceInstanceSearchResultsByIdentifierType(String subscriberId, String instanceIdentifier, String instanceIdentifierType, RoleValidator roleValidator, List<String> owningEntities, List<String> projects);
+ AaiResponse getServiceInstanceBySubscriberIdAndSIID(String globalCustomerId, String serviceType, String serviceId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
index 1e79ab4c8..21e5409c3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -48,8 +48,12 @@ import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.AaiGetVnfResponse;
import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.Customer;
+import org.onap.vid.aai.CustomerSpecificServiceInstance;
+import org.onap.vid.aai.DSLQuerySimpleResponse;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.ServiceInstance;
+import org.onap.vid.aai.ServiceInstanceResponseBySubscriber;
import org.onap.vid.aai.ServiceInstancesSearchResults;
import org.onap.vid.aai.ServiceSubscription;
import org.onap.vid.aai.ServiceSubscriptions;
@@ -750,4 +754,94 @@ public class AaiServiceImpl implements AaiService {
public ModelVer getNewestModelVersionByInvariantId(String modelInvariantId){
return aaiClient.getLatestVersionByInvariantId(modelInvariantId);
}
+
+ @Override
+ public AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+ return aaiClient.getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId,identifierType,serviceIdentifier);
+ }
+
+ @Override
+ public AaiResponse getServiceInstanceSearchResultsByIdentifierType(String subscriberId, String instanceIdentifier,
+ String instanceIdentifierType,
+ RoleValidator roleValidator,
+ List<String> owningEntities, List<String> projects) {
+ List<List<ServiceInstanceSearchResult>> resultList = new ArrayList<>();
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+
+ if (subscriberId != null && instanceIdentifier != null && isValidInstanceIdentifierType(instanceIdentifierType)) {
+ resultList.add(getServicesBySubscriberAndServiceInstance(subscriberId, instanceIdentifier, instanceIdentifierType, roleValidator));
+ }
+ if (owningEntities != null) {
+ resultList.add(getServicesByOwningEntityId(owningEntities, roleValidator));
+ }
+ if (projects != null) {
+ resultList.add(getServicesByProjectNames(projects, roleValidator));
+ }
+ if (!resultList.isEmpty()) {
+ serviceInstancesSearchResults.serviceInstances = Intersection.of(resultList);
+ }
+
+ return new AaiResponse<>(serviceInstancesSearchResults, null, HttpStatus.SC_OK);
+ }
+
+ private boolean isValidInstanceIdentifierType(String instanceIdentifierType) {
+ return instanceIdentifierType != null
+ && ( instanceIdentifierType.equalsIgnoreCase("Service Instance Id") ||
+ instanceIdentifierType.equalsIgnoreCase("Service Instance Name"));
+ }
+ private List<ServiceInstanceSearchResult> getServicesBySubscriberAndServiceInstance(String subscriberId,
+ String instanceIdentifier,
+ String instanceIdentifierType,
+ RoleValidator roleValidator) {
+ LOGGER.info("Starting getServicesBySubscriberAndServiceInstance subscriberId : {}, " +
+ "instanceIdentifier : {}, instanceIdentifierType: {} ",
+ subscriberId,instanceIdentifier, instanceIdentifierType);
+ ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+ if( instanceIdentifier == null || instanceIdentifierType == null) {
+ return results;
+ }
+ ServiceInstanceResponseBySubscriber serviceInstanceResponseBySubscriber = null;
+ Customer customer = null;
+ CustomerSpecificServiceInstance serviceInstance = null;
+ String subscriberName,serviceType,serviceInstanceId, serviceInstanceName,modelInvariantId,modelVersionId= null;
+ ServiceInstanceSearchResult serviceInstanceSearchResult = null;
+
+ AaiResponse<DSLQuerySimpleResponse> aaiResponse =
+ aaiClient.getServiceInstanceBySubscriberIdAndInstanceIdentifier(subscriberId,instanceIdentifierType,
+ instanceIdentifier);
+ if( aaiResponse != null && aaiResponse.getT() !=null && aaiResponse.getT().getResults() != null){
+ serviceInstanceResponseBySubscriber = aaiResponse.getT().getResults().get(0);
+ customer = serviceInstanceResponseBySubscriber.getCustomer();
+ serviceInstance = customer.getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().
+ getServiceSubscriptionRelatedNodes().get(0).getServiceInstance();
+ subscriberName = customer.getSubscriberName();
+ serviceType = customer.getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().getServiceType();
+ serviceInstanceId = serviceInstance.getServiceInstanceId();
+ serviceInstanceName = serviceInstance.getServiceInstanceName();
+ modelInvariantId = serviceInstance.getModelInvariantId();
+ modelVersionId = serviceInstance.getModelVersionId();
+
+ serviceInstanceSearchResult =
+ new ServiceInstanceSearchResult(serviceInstanceId, subscriberId, serviceType,
+ serviceInstanceName, subscriberName, modelInvariantId,
+ modelVersionId, null, false);
+ serviceInstanceSearchResult.setIsPermitted(roleValidator.isServicePermitted(serviceInstanceSearchResult));
+
+ LOGGER.info("Result from AAI, getServicesBySubscriberAndServiceInstance serviceType : {}, " +
+ "serviceInstanceId : {}, serviceInstanceName: {} , modelInvariantId : {}, " +
+ "modelVersionId :{}, permission :{}",
+ serviceType, serviceInstanceId, serviceInstanceName, modelInvariantId,
+ modelVersionId, serviceInstanceSearchResult.getIsPermitted());
+ results.add(serviceInstanceSearchResult);
+ } else {
+ LOGGER.error("Inside getServicesBySubscriberAndServiceInstance response NULL");
+ }
+
+ return results;
+ }
+
+ @Override
+ public AaiResponse getServiceInstanceBySubscriberIdAndSIID(String globalCustomerId, String serviceType, String serviceId) {
+ return aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceId);
+ }
}