summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-interfaces-service/bundle/src
diff options
context:
space:
mode:
authorDilip kumar Pampana <dp583p@att.com>2018-01-08 15:08:21 -0500
committerPatrick Brady <pb071s@att.com>2018-01-09 22:13:48 +0000
commit108ff43f43cb3a662514c6f27d806fe3a86caade (patch)
tree0ba58fbb226450fc47b93e8c356c31d3c9ef282d /appc-inbound/appc-interfaces-service/bundle/src
parent57c37a4a6f390ed059897d5b382a59d1e1443852 (diff)
Appc Interface Services
Scope Overlap API Or REST service Issue-ID: APPC-348 Change-Id: Id32b4c88f57a9f9ce2234598d03dcca5946d4683 Signed-off-by: Dilip kumar Pampana <dp583p@att.com>
Diffstat (limited to 'appc-inbound/appc-interfaces-service/bundle/src')
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java66
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java76
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java86
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java53
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java76
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java78
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java79
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java156
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java40
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml44
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java41
11 files changed, 795 insertions, 0 deletions
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java
new file mode 100644
index 000000000..df9371f66
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.InterfacesServiceService;
+import org.onap.appc.interfaces.service.InterfacesServiceProviderImpl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class InterfacesServiceProvider{
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(InterfacesServiceProvider.class);
+
+ private final DataBroker dataBroker;
+ private final RpcProviderRegistry rpcProviderRegistry;
+ private RpcRegistration <InterfacesServiceService> serviceRegistration;
+
+ public InterfacesServiceProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) {
+ this.dataBroker = dataBroker;
+ this.rpcProviderRegistry = rpcProviderRegistry;
+ }
+ /**
+ * Method called when the blueprint container is created.
+ */
+ public void init() {
+ // initialize data broker
+ this.serviceRegistration = this.rpcProviderRegistry.addRpcImplementation(InterfacesServiceService.class,
+ new InterfacesServiceProviderImpl());
+ log.info("DataCollectorProvider Session Initiated");
+ }
+ /**
+ * Method called when the blueprint container is destroyed.
+ */
+ public void close() {
+ if(this.serviceRegistration != null){
+ this.serviceRegistration.close();
+ }
+ log.info("DataCollectorProvider Closed");
+ }
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java
new file mode 100644
index 000000000..8e114a3c6
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service;
+
+import java.util.concurrent.Future;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.InterfacesServiceService;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.response.info.ResponseInfoBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.status.StatusBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.onap.appc.interfaces.service.executor.ServiceExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.Futures;
+
+public class InterfacesServiceProviderImpl implements InterfacesServiceService{
+
+ private static final Logger log = LoggerFactory.getLogger(InterfacesServiceProviderImpl.class);
+
+ @Override
+ public Future<RpcResult<ExecuteServiceOutput>> executeService(ExecuteServiceInput input) {
+
+ log.info("Received Request: " + input.getRequest().getRequestId() + " Action : " +
+ input.getRequest().getAction() + " with RequestData :" + input.getRequest().getRequestData() + " and data-Type : " + input.getRequest().getRequestDataType());
+ String request_id = input.getRequest().getRequestId();
+ String action = input.getRequest().getAction();
+ ResponseInfoBuilder responseInfoBuilder = new ResponseInfoBuilder();
+ ExecuteServiceOutputBuilder executeServicebuilder = new ExecuteServiceOutputBuilder();
+ ServiceExecutor serviceExecutor = new ServiceExecutor();
+ StatusBuilder statusBuilder = new StatusBuilder();
+ try{
+ String response = serviceExecutor.execute(action, input.getRequest().getRequestData(), input.getRequest().getRequestDataType());
+ responseInfoBuilder.setBlock(response);
+ responseInfoBuilder.setRequestId(request_id);
+ statusBuilder.setCode("400");
+ statusBuilder.setMessage("success");
+ }
+ catch(Exception e){
+ log.error("Error" + e.getMessage());
+ e.printStackTrace();
+ statusBuilder.setCode("401");
+ statusBuilder.setMessage("failuer");
+ }
+ executeServicebuilder.setResponseInfo(responseInfoBuilder.build());
+ executeServicebuilder.setStatus(statusBuilder.build());
+ RpcResult<ExecuteServiceOutput> result = RpcResultBuilder.<ExecuteServiceOutput>status(true).withResult(executeServicebuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java
new file mode 100644
index 000000000..50a47831d
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.data;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ActionIdentifier {
+
+ @JsonProperty("service-instance-id")
+ private String serviceInstanceID;
+
+ @JsonProperty("vnf-id")
+ private String vnfId;
+
+ @JsonProperty("vf-module-id")
+ private String vfModuleId;
+
+ @JsonProperty("vserver-id")
+ private String vServerId;
+
+ @JsonProperty("vnfc-name")
+ private String vnfcName;
+
+ public String getServiceInstanceID() {
+ return serviceInstanceID;
+ }
+
+ public void setServiceInstanceID(String serviceInstanceID) {
+ this.serviceInstanceID = serviceInstanceID;
+ }
+
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ public String getVfModuleId() {
+ return vfModuleId;
+ }
+
+ public void setVfModuleId(String vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+
+ public String getvServerId() {
+ return vServerId;
+ }
+
+ public void setvServerId(String vServerId) {
+ this.vServerId = vServerId;
+ }
+
+ public String getVnfcName() {
+ return vnfcName;
+ }
+
+ public void setVnfcName(String vnfcName) {
+ this.vnfcName = vnfcName;
+ }
+
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java
new file mode 100644
index 000000000..eff4814de
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.data;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Request {
+
+ @JsonProperty("action")
+ private String action;
+
+ @JsonProperty("action-identifiers")
+ private ActionIdentifier actionIdentifiers;
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public ActionIdentifier getActionIdentifiers() {
+ return actionIdentifiers;
+ }
+
+ public void setActionIdentifiers(ActionIdentifier actionIdentifiers) {
+ this.actionIdentifiers = actionIdentifiers;
+ }
+
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java
new file mode 100644
index 000000000..bfeb70fce
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.data;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ScopeOverlap {
+
+ @JsonProperty("vnf-id")
+ private String vnfId;
+
+ @JsonProperty("current-request")
+ private Request currentRequest;
+
+ @JsonProperty("in-progress-requests")
+ private List<Request> inProgressRequests;
+
+ private String overlap;
+
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ public Request getCurrentRequest() {
+ return currentRequest;
+ }
+
+ public void setCurrentRequest(Request currentRequest) {
+ this.currentRequest = currentRequest;
+ }
+
+ public List<Request> getInProgressRequest() {
+ return inProgressRequests;
+ }
+
+ public void setInProgressRequest(List<Request> inProgressRequests) {
+ this.inProgressRequests = inProgressRequests;
+ }
+
+ public String getOverlap() {
+ return overlap;
+ }
+
+ public void setOverlap(String overlap) {
+ this.overlap = overlap;
+ }
+
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java
new file mode 100644
index 000000000..b37a5e4c8
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.executor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.appc.interfaces.service.utils.ServiceConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RequestValidator {
+
+ private static final Logger log = LoggerFactory.getLogger(RequestValidator.class);
+
+ public static void validate(String action, String requestData, String requestDataType) throws Exception {
+ log.debug("Received validation for action= " + action + " Data :" + requestData);
+ try {
+ if (requestData.isEmpty()) {
+ throw new Exception("Request Data is Empty");
+ }
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode payloadObject = objectMapper.readTree(requestData);
+ log.info("payloadObject" + payloadObject);
+ if (payloadObject.get(ServiceConstants.VNF) == null)
+ throw new Exception("VNF-ID is null");
+ String vnfId = payloadObject.get(ServiceConstants.VNF).toString();
+ if (vnfId.isEmpty())
+ throw new Exception("VNF-ID is blank");
+ if (payloadObject.get(ServiceConstants.CURRENTREQUEST) == null)
+ throw new Exception("Current request is null");
+ String cRequest = payloadObject.get(ServiceConstants.CURRENTREQUEST).toString();
+ if (cRequest.isEmpty())
+ throw new Exception("Current Request is blank");
+ JsonNode currentRequest = payloadObject.get(ServiceConstants.CURRENTREQUEST);
+ if (currentRequest.get(ServiceConstants.ACTION) == null)
+ throw new Exception("Action is null in Current Request");
+ String cRequestAction = currentRequest.get(ServiceConstants.ACTION).toString();
+ if (cRequestAction.isEmpty())
+ throw new Exception("Action is blank in Current Request");
+ if (currentRequest.get(ServiceConstants.ACTIONIDENTIFIER) == null)
+ throw new Exception("Action Identifier is null in Current Request");
+ String cRequestActionIdentifier = currentRequest.get(ServiceConstants.ACTIONIDENTIFIER).toString();
+ if (cRequestActionIdentifier.isEmpty())
+ throw new Exception("Action Identifier is blank in Current Request");
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.debug("Error while validating: " + e.getMessage());
+ throw e;
+ }
+ }
+
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java
new file mode 100644
index 000000000..f72157656
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.executor;
+
+import java.io.IOException;
+
+import org.onap.appc.interfaces.service.InterfacesServiceProviderImpl;
+import org.onap.appc.interfaces.service.executorImpl.ServiceExecutorImpl;
+import org.onap.appc.interfaces.service.utils.ServiceConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public class ServiceExecutor {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceExecutor.class);
+ public String execute(String action, String requestData, String requestDataType) throws Exception{
+ String response = null;
+ log.info("Received execute request for action : " + action + " with Payload : " + requestData);
+ try{
+ RequestValidator.validate(action, requestData, requestData);
+ switch (action) {
+ case ServiceConstants.REQUESTOVERLAP:
+ response = isRequestOverLap(requestData);
+ break;
+ case ServiceConstants.GEDATABYMODEL:
+ response = getDataByModel(action, requestData, requestDataType);
+ break;
+ default:
+ throw new Exception(" Action " + action + " not found while processing request ");
+ }
+ }catch(Exception e){
+ log.info("Error while checking for ScopeOverlap " + e.getMessage());
+ e.printStackTrace();
+ throw e;
+ }
+ return response;
+ }
+
+ private String getDataByModel(String action, String requestData, String requestDataType) {
+
+ return null;
+ }
+
+ private String isRequestOverLap(String requestData) throws Exception {
+
+ ServiceExecutorImpl serviceExecutor = new ServiceExecutorImpl();
+ try {
+ return serviceExecutor.isRequestOverLap(requestData);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java
new file mode 100644
index 000000000..3b30c3e8c
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.executorImpl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.appc.aai.client.aai.AaiService;
+import org.onap.appc.interfaces.service.data.Request;
+import org.onap.appc.interfaces.service.data.ScopeOverlap;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Strings;
+
+public class ServiceExecutorImpl {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(ServiceExecutorImpl.class);
+ private AAIClient aaiClient;
+ public String isRequestOverLap(String requestData) throws Exception {
+ String response = "\"requestOverlap\" : ";
+ log.info("Response from ServiceExecutorImpl");
+ ScopeOverlap scopeOverlap = new ScopeOverlap();
+ ObjectMapper mapper = new ObjectMapper();
+ scopeOverlap = mapper.readValue(requestData, ScopeOverlap.class);
+ // return response + String.valueOf(checkForOverLap(scopeOverlap));
+ boolean isOverlap = checkForOverLap(scopeOverlap);
+ scopeOverlap.setOverlap(String.valueOf(isOverlap));
+ if (scopeOverlap.getOverlap() != null && scopeOverlap.getOverlap().equalsIgnoreCase("false")){
+ log.info(response + "false");
+ return response + "false";
+ }
+ else{
+ log.info(response + "true");
+ return response + "true";
+ }
+ }
+
+ private boolean checkForOverLap(ScopeOverlap scopeOverlap) throws Exception {
+ log.info("Checking for isScopeOverlap");
+ if (scopeOverlap.getInProgressRequest() == null) {
+ return Boolean.FALSE;
+ }else if ( scopeOverlap.getInProgressRequest().isEmpty()){
+ return Boolean.FALSE;
+ }
+ else if (scopeOverlap.getInProgressRequest().size() == 0) {
+ return Boolean.FALSE;
+ }
+ if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfId() != null) {
+ return Boolean.TRUE;
+ } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVfModuleId() != null) {
+ return Boolean.TRUE;
+ } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId() != null) {
+ return isVserverOrVnfcIdOverLap(scopeOverlap);
+ } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfcName() != null) {
+ return isVserverOrVnfcIdOverLap(scopeOverlap);
+ } else {
+ throw new Exception(" Action Identifier doesn't have VnfId, VfModuleId, VServerId, VnfcName ");
+ }
+ }
+
+ private boolean isVnfcNameOverLap(ScopeOverlap scopeOverlap) throws Exception {
+
+ AaiService aaiService =new AaiService(aaiClient);
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<String, String>();
+ List<String> inProgressVServerIds = new ArrayList<String>();
+ String currentVnfcVserverId = new String();
+ String currentRequestVnfcName = scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfcName();
+ String currentRequestVServerId = scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId();
+ List<Request> inProgressRequests = scopeOverlap.getInProgressRequest();
+ params.put("vnfId", scopeOverlap.getVnfId());
+ try {
+ aaiService.getGenericVnfInfo(params, ctx);
+ int vm_count = Integer.parseInt(ctx.getAttribute("vm-count"));
+ for(Request inprogressRequest:inProgressRequests){
+ if(inprogressRequest.getActionIdentifiers().getVnfcName() != null){
+ for (int i = 0; i < vm_count; i++){
+ if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
+ .equals(inprogressRequest.getActionIdentifiers().getVnfcName()))
+ inProgressVServerIds.add(ctx.getAttribute("vm[" + i + "].vserver-id"));
+ log.debug("Received vserver-id from AAI: "+ inProgressVServerIds);
+ }
+ }
+ }
+ for(Request inProgVserverIds:inProgressRequests)
+ if(inProgVserverIds.getActionIdentifiers().getvServerId()!=null)
+ inProgressVServerIds.add(inProgVserverIds.getActionIdentifiers().getvServerId());
+ if(currentRequestVnfcName != null){
+ for (int i = 0; i < vm_count; i++)
+ if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
+ .equals(currentRequestVnfcName))
+ currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
+ log.debug("Received vserver-id from AAI: "+ currentVnfcVserverId);
+ return inProgressVServerIds.contains(currentVnfcVserverId);
+ }
+ for (Request request : inProgressRequests) {
+ if(!Strings.isNullOrEmpty(currentRequestVServerId) && currentRequestVServerId.equalsIgnoreCase(request.getActionIdentifiers().getvServerId()))
+ return Boolean.TRUE;
+ }
+ if(currentRequestVServerId != null) {
+ return inProgressVServerIds.contains(currentRequestVServerId);
+ }
+ return Boolean.FALSE;
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.debug(e.getMessage());
+ throw e;
+ }
+ }
+
+ private boolean isVserverOrVnfcIdOverLap(ScopeOverlap scopeOverlap) throws Exception {
+ List<Request> inProgressRequests = scopeOverlap.getInProgressRequest();
+ for (Request request : inProgressRequests) {
+ if(request.getActionIdentifiers().getVnfId()!= null)
+ return Boolean.TRUE ;
+ }
+ for (Request request : inProgressRequests) {
+ if(request.getActionIdentifiers().getVfModuleId()!= null)
+ return Boolean.TRUE ;
+ }
+ String currentVserverID = scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId();
+ for (Request request : inProgressRequests) {
+ if(currentVserverID != null && currentVserverID.equalsIgnoreCase(request.getActionIdentifiers().getvServerId()))
+ return Boolean.TRUE ;
+ }
+ return isVnfcNameOverLap(scopeOverlap);
+ }
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java
new file mode 100644
index 000000000..2ac4172a8
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaces.service.utils;
+
+public class ServiceConstants {
+
+ public static final String REQUESTOVERLAP = "isScopeOverlap";
+ public static final String GEDATABYMODEL = "getdatabymodel";
+ public static final String VNF = "vnf-id";
+ public static final String VNFCNAME = "vnfc-name";
+ public static final String VFMODULE = "vf-module-id";
+ public static final String VSERVER = "vserver-id";
+ public static final String CURRENTREQUEST = "current-request";
+ public static final String INPROGRESSREQUEST = "in-progress-requests";
+ public static final String ACTION = "action";
+ public static final String ACTIONIDENTIFIER = "action-identifiers";
+ public static final String SERVICEINSTANCEID = "service-instance-id";
+}
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
new file mode 100644
index 000000000..239aa2354
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright ? 2016 AT&T and others. All rights reserved. -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <reference id="rpcRegistry"
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" />
+
+ <bean id="provider" class="org.onap.appc.interfaces.service.InterfacesServiceProvider"
+ init-method="init" destroy-method="close">
+ <argument ref="dataBroker" />
+ <argument ref="rpcRegistry" />
+ </bean>
+</blueprint>
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java
new file mode 100644
index 000000000..0c91964c2
--- /dev/null
+++ b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.interfaceService.serviceExecutor;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import org.onap.appc.interfaces.service.executorImpl.ServiceExecutorImpl;
+
+public class TestServiceExecutor {
+
+ @Test
+ public void serviceExecutorTest() throws Exception {
+ ServiceExecutorImpl sei = new ServiceExecutorImpl();
+ String requestData = "{\"vnf-id\":\"ibcx8888v\",\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id\",\"vnf-id\" : \"vnf-id\",\"vnfc-name\" : \"vnfc-name\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id\"}},\"in-progress-requests\" :[{\"action\" : \"HealthCheck\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id1\",\"vnf-id\" : \"vnf-id1\",\"vnfc-name\" : \"vnfc-name1\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id1\"}},{\"action\" : \"CheckLock\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id2\",\"vnf-id\" : \"vnf-id2\",\"vnfc-name\" : \"vnfc-name2\",\"vf-module-id\" : \"vf-module-id2\",\"vserver-id\": \"vserver-id2\"}}]}";
+ sei.isRequestOverLap(requestData);
+ }
+}