aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java103
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdater.java34
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java1
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java478
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java91
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java91
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java96
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java89
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java99
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/AAIEntityNotFound.java29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/CloudConfigurationNotFoundException.java29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/NoRecipeException.java (renamed from mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java)17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/RequestConflictedException.java30
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/WorkflowEngineConnectionException.java29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/AAIEntityNotFoundMapper.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/CloudConfigurationNotFoundMapper.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/NoRecipeExceptionMapper.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/RequestConflictMapper.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/WorkflowEngineConnectionMapper.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java217
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java113
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java116
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java125
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java110
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java104
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java23
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java140
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java143
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java189
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java190
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java154
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java145
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json131
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json56
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java6
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java15
54 files changed, 3681 insertions, 61 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java
new file mode 100644
index 0000000000..eb52625bb6
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 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.so.apihandler.filters;
+
+import java.io.IOException;
+import java.sql.Timestamp;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+@Provider
+@ResponseUpdater
+public class ResponseUpdateFilter implements ContainerResponseFilter {
+
+ protected static Logger logger = LoggerFactory.getLogger(ResponseUpdateFilter.class);
+
+ @Context
+ private HttpServletRequest httpServletRequest;
+
+ @Context
+ private Providers providers;
+
+ @Autowired
+ protected RequestsDbClient infraActiveRequestsClient;
+
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+ throws IOException {
+ try {
+ logger.info("updating requests status");
+ updateRequestDBToFailed(responseContext);
+ } catch (Exception e) {
+ logger.warn("Error in outgoing JAX-RS Inteceptor updating request db to failed", e);
+ }
+ }
+
+ private void updateRequestDBToFailed(ContainerResponseContext responseContext) {
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ if (requestId != null && !Response.Status.Family.familyOf(responseContext.getStatus())
+ .equals(Response.Status.Family.SUCCESSFUL)) {
+ InfraActiveRequests currentRequest = infraActiveRequestsClient.getInfraActiveRequestbyRequestId(requestId);
+ if (currentRequest != null) {
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ RequestError error;
+ try {
+ error = (RequestError) responseContext.getEntity();
+ } catch (Exception e) {
+ logger.warn("Error Casting Entity to Request Error, generating unknown Error", e);
+ error = new RequestError();
+ ServiceException serviceException = new ServiceException();
+ serviceException.setText("Unknown Error Occured during processing");
+ error.setServiceException(serviceException);
+ }
+ if (error.getServiceException() != null && error.getServiceException().getText() != null
+ && !error.getServiceException().getText().isEmpty()) {
+ currentRequest.setStatusMessage(error.getServiceException().getText());
+ } else {
+ currentRequest.setStatusMessage("Unknown Error Occured during processing");
+ }
+ currentRequest.setRequestStatus(Status.FAILED.toString());
+ currentRequest.setEndTime(endTimeStamp);
+ currentRequest.setProgress(100L);
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ }
+ }
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdater.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdater.java
new file mode 100644
index 0000000000..eb2dad03f3
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdater.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandler.filters;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.ws.rs.NameBinding;
+
+
+@NameBinding
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+public @interface ResponseUpdater {
+}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java
index 21e9b44b19..42198e2d0c 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java
@@ -30,6 +30,7 @@ public class DuplicateRequestException extends ApiException {
}
+
public static class Builder extends ApiException.Builder<Builder> {
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java
index 620103be4e..3b62e318e4 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java
@@ -27,6 +27,7 @@ public class RecipeNotFoundException extends ApiException {
super(builder);
}
+
public static class Builder extends ApiException.Builder<Builder> {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
index 7c0d327db7..00d36b3ff9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
@@ -27,6 +27,16 @@ import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.so.apihandler.filters.RequestIdFilter;
import org.onap.so.apihandler.filters.RequestUriFilter;
import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
+import org.onap.so.apihandlerinfra.infra.rest.Network;
+import org.onap.so.apihandlerinfra.infra.rest.ServiceInstance;
+import org.onap.so.apihandlerinfra.infra.rest.VfModules;
+import org.onap.so.apihandlerinfra.infra.rest.Vnf;
+import org.onap.so.apihandlerinfra.infra.rest.Volumes;
+import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.AAIEntityNotFoundMapper;
+import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.CloudConfigurationNotFoundMapper;
+import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.NoRecipeExceptionMapper;
+import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.RequestConflictMapper;
+import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.WorkflowEngineConnectionMapper;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
import org.onap.so.apihandlerinfra.tenantisolation.ModelDistributionRequest;
@@ -50,6 +60,11 @@ public class JerseyConfiguration extends ResourceConfig {
register(CloudOrchestration.class);
register(CloudResourcesOrchestration.class);
register(OrchestrationRequests.class);
+ register(VfModules.class);
+ register(Vnf.class);
+ register(Network.class);
+ register(Volumes.class);
+ register(ServiceInstance.class);
register(JaxRsFilterLogging.class);
register(ManualTasks.class);
register(TasksHandler.class);
@@ -63,6 +78,11 @@ public class JerseyConfiguration extends ResourceConfig {
register(WorkflowSpecificationsHandler.class);
register(InstanceManagement.class);
register(ResumeOrchestrationRequest.class);
+ register(AAIEntityNotFoundMapper.class);
+ register(CloudConfigurationNotFoundMapper.class);
+ register(NoRecipeExceptionMapper.class);
+ register(RequestConflictMapper.class);
+ register(WorkflowEngineConnectionMapper.class);
// this registration seems to be needed to get predictable
// execution behavior for the above JSON Exception Mappers
register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index 45b521d984..cbfe927adf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -25,14 +25,12 @@ package org.onap.so.apihandlerinfra;
import java.io.IOException;
import java.io.StringWriter;
-import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.StringTokenizer;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
@@ -778,23 +776,4 @@ public class MsoRequest {
}
- public Optional<URL> buildSelfLinkUrl(String url, String requestId) {
- Optional<URL> selfLinkUrl = Optional.empty();
- String version = "";
- try {
- URL aUrl = new URL(url);
- String aPath = aUrl.getPath();
- if (aPath.indexOf("/v") == -1) {
- version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V") + 4);
- } else {
- version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v") + 4);
- }
- String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId);
- selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath));
- } catch (Exception e) {
- selfLinkUrl = Optional.empty(); // ignore
- logger.info(e.getMessage());
- }
- return selfLinkUrl;
- }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 24034e91af..86e2f5ce93 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -52,7 +52,6 @@ import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
-import org.onap.so.apihandlerinfra.TestApi;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
@@ -61,6 +60,7 @@ import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.client.CatalogDbClient;
@@ -96,7 +96,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
-public class RequestHandlerUtils {
+public class RequestHandlerUtils extends AbstractRestHandler {
private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class);
@@ -184,8 +184,8 @@ public class RequestHandlerUtils {
ObjectMapper mapper = new ObjectMapper();
jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
- Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(),
- requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl =
+ buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
if (selfLinkUrl.isPresent()) {
jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
} else {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index a397676ee2..b290a796e2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -50,7 +50,7 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
-import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
@@ -86,6 +86,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -96,7 +97,7 @@ import io.swagger.annotations.ApiOperation;
@Component
@Path("/onap/so/infra/serviceInstantiation")
@Api(value = "/onap/so/infra/serviceInstantiation", description = "Infrastructure API Requests for Service Instances")
-public class ServiceInstances {
+public class ServiceInstances extends AbstractRestHandler {
private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
private static String NAME = "name";
@@ -108,6 +109,9 @@ public class ServiceInstances {
private Environment env;
@Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
private CatalogDbClient catalogDbClient;
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
new file mode 100644
index 0000000000..5b51d85e41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
@@ -0,0 +1,478 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class BpmnRequestBuilder {
+
+ private static final String CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND = "Cloud Configuration could not be found";
+
+ private static final String CLOUD_REGION_ID = "cloud-region-id";
+
+ private static final String CLOUD_OWNER = "cloud-owner";
+
+ private static final String TENANT_ID = "tenant-id";
+
+ private static final String GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID =
+ "Generic Vnf Not Found In Inventory, VnfId: ";
+
+ private static final String VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID = "VF Module Not Found In Inventory, VnfId: ";
+
+ private static final Logger logger = LoggerFactory.getLogger(BpmnRequestBuilder.class);
+
+ @Autowired
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private AAIResourcesClient aaiResourcesClient;
+
+ public ServiceInstancesRequest buildVFModuleDeleteRequest(String vnfId, String vfModuleId, ModelType modelType)
+ throws AAIEntityNotFound {
+ GenericVnf vnf = getGenericVnf(vnfId);
+ if (vnf == null) {
+ throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
+ }
+ VfModule vfModule = getAAIVfModule(vnfId, vfModuleId);
+ if (vfModule == null) {
+ throw new AAIEntityNotFound(VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " vfModuleId: " + vfModuleId);
+ }
+ return createServiceInstancesRequest(vnf, vfModule, modelType);
+ }
+
+ public ServiceInstancesRequest buildVolumeGroupDeleteRequest(String vnfId, String volumeGroupId)
+ throws AAIEntityNotFound {
+ GenericVnf vnf = getGenericVnf(vnfId);
+ if (vnf == null) {
+ throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
+ }
+ VolumeGroup volumeGroup = getVolumeGroup(vnfId, volumeGroupId);
+ if (volumeGroup == null) {
+ throw new AAIEntityNotFound(
+ VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " volumeGroupId: " + volumeGroupId);
+ }
+ return createServiceInstancesRequest(vnf, volumeGroup);
+ }
+
+ public ServiceInstancesRequest buildServiceDeleteRequest(String serviceInstanceId) throws AAIEntityNotFound {
+ ServiceInstance serviceInstance = getServiceInstance(serviceInstanceId);
+ if (serviceInstance == null) {
+ throw new AAIEntityNotFound(
+ "ServiceInstance Not Found In Inventory, ServiceInstanceId: " + serviceInstanceId);
+ }
+ return createServiceInstancesRequest(serviceInstance);
+ }
+
+ public ServiceInstancesRequest buildVnfDeleteRequest(String vnfId) throws AAIEntityNotFound {
+ GenericVnf vnf = getGenericVnf(vnfId);
+ if (vnf == null) {
+ throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
+ }
+ return createServiceInstancesRequest(vnf);
+ }
+
+ public ServiceInstancesRequest buildNetworkDeleteRequest(String networkId) throws AAIEntityNotFound {
+ L3Network network = getNetwork(networkId);
+ if (network == null) {
+ throw new AAIEntityNotFound("Network Not Found In Inventory, NetworkId: " + networkId);
+ }
+ return createServiceInstancesRequest(network);
+ }
+
+ protected ServiceInstancesRequest createServiceInstancesRequest(ServiceInstance serviceInstance) {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = mapServiceRequestDetails(serviceInstance);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ protected ServiceInstancesRequest createServiceInstancesRequest(GenericVnf vnf) {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = mapVnfRequestDetails(vnf);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ protected ServiceInstancesRequest createServiceInstancesRequest(GenericVnf vnf, VfModule vfModule,
+ ModelType modelType) {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = mapRequestDetails(vnf, vfModule, modelType);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ protected ServiceInstancesRequest createServiceInstancesRequest(GenericVnf vnf, VolumeGroup volumeGroup) {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = mapRequestDetails(vnf, volumeGroup);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ protected ServiceInstancesRequest createServiceInstancesRequest(L3Network network) {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = mapNetworkRequestDetails(network);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ protected RequestDetails mapRequestDetails(GenericVnf vnf, VfModule vfModule, ModelType modelType) {
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(createRequestInfo());
+ if (vfModule.getVfModuleName() != null) {
+ requestDetails.getRequestInfo().setInstanceName(vfModule.getVfModuleName());
+ }
+ requestDetails.setModelInfo(mapVfModuleModelInformation(vfModule, modelType));
+
+ requestDetails.setCloudConfiguration(mapCloudConfiguration(vnf, vfModule));
+ requestDetails.setRequestParameters(createRequestParameters());
+ return requestDetails;
+ }
+
+ protected RequestDetails mapRequestDetails(GenericVnf vnf, VolumeGroup volumeGroup) {
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(createRequestInfo());
+ if (volumeGroup.getVolumeGroupName() != null) {
+ requestDetails.getRequestInfo().setInstanceName(volumeGroup.getVolumeGroupName());
+ }
+ requestDetails.setModelInfo(mapVolumeGroupModelInformation(volumeGroup));
+ requestDetails.setCloudConfiguration(mapCloudConfigurationVolume(vnf, volumeGroup));
+ requestDetails.setRequestParameters(createRequestParameters());
+ return requestDetails;
+ }
+
+ protected RequestDetails mapVnfRequestDetails(GenericVnf vnf) {
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(createRequestInfo());
+ if (vnf.getVnfName() != null) {
+ requestDetails.getRequestInfo().setInstanceName(vnf.getVnfName());
+ }
+ requestDetails.setModelInfo(mapVnfModelInformation(vnf));
+ requestDetails.setRequestParameters(createRequestParameters());
+ return requestDetails;
+ }
+
+ protected RequestDetails mapServiceRequestDetails(ServiceInstance serviceInstance) {
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(createRequestInfo());
+ if (serviceInstance.getServiceInstanceName() != null) {
+ requestDetails.getRequestInfo().setInstanceName(serviceInstance.getServiceInstanceName());
+ }
+ requestDetails.setModelInfo(mapServiceModelInformation(serviceInstance));
+ requestDetails.setRequestParameters(createRequestParameters());
+ return requestDetails;
+ }
+
+ protected RequestDetails mapNetworkRequestDetails(L3Network network) {
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(createRequestInfo());
+ if (network.getNetworkName() != null) {
+ requestDetails.getRequestInfo().setInstanceName(network.getNetworkName());
+ }
+ requestDetails.setCloudConfiguration(mapCloudConfigurationNetwork(network));
+ requestDetails.setModelInfo(mapNetworkModelInformation(network));
+ requestDetails.setRequestParameters(createRequestParameters());
+ return requestDetails;
+ }
+
+ protected ModelInfo mapVfModuleModelInformation(VfModule vfModule, ModelType modelType) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(vfModule.getModelCustomizationId());
+ modelInfo.setModelCustomizationUuid(vfModule.getModelCustomizationId());
+ modelInfo.setModelType(modelType);
+ return modelInfo;
+ }
+
+ protected ModelInfo mapVolumeGroupModelInformation(VolumeGroup volumeGroup) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(volumeGroup.getModelCustomizationId());
+ modelInfo.setModelCustomizationUuid(volumeGroup.getModelCustomizationId());
+ modelInfo.setModelType(ModelType.volumeGroup);
+ return modelInfo;
+ }
+
+ protected ModelInfo mapServiceModelInformation(ServiceInstance serviceInstance) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId(serviceInstance.getModelVersionId());
+ modelInfo.setModelType(ModelType.service);
+ return modelInfo;
+ }
+
+ protected ModelInfo mapVnfModelInformation(GenericVnf vnf) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(vnf.getModelCustomizationId());
+ modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId());
+ modelInfo.setModelType(ModelType.vnf);
+ return modelInfo;
+ }
+
+ protected ModelInfo mapNetworkModelInformation(L3Network network) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.network);
+ modelInfo.setModelCustomizationId(network.getModelCustomizationId());
+ modelInfo.setModelCustomizationUuid(network.getModelCustomizationId());
+ return modelInfo;
+ }
+
+ public CloudConfiguration mapCloudConfiguration(GenericVnf vnf, VfModule vfModule) {
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
+ Optional<org.onap.so.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
+ String tenantId = null;
+ String cloudOwner = null;
+ String lcpRegionId = null;
+ if (relationshipsOpt.isPresent()) {
+ tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null);
+ cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null);
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null);
+ }
+
+ if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
+ Map<String, String[]> filters = createQueryRequest("vfModuleId", vfModule.getVfModuleId());
+ Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
+ if (request.isPresent()) {
+ if (request.get().getRequestDetails() != null
+ && request.get().getRequestDetails().getCloudConfiguration() != null) {
+ if (request.get().getRequestDetails().getCloudConfiguration().getTenantId() != null) {
+ tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
+ }
+ if (request.get().getRequestDetails().getCloudConfiguration().getCloudOwner() != null) {
+ cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
+ }
+ if (request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId() != null) {
+ lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
+ }
+ }
+ } else {
+ throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
+ }
+ }
+ cloudConfig.setTenantId(tenantId);
+ cloudConfig.setCloudOwner(cloudOwner);
+ cloudConfig.setLcpCloudRegionId(lcpRegionId);
+ return cloudConfig;
+ }
+
+ public CloudConfiguration mapCloudConfigurationVolume(GenericVnf vnf, VolumeGroup volumeGroup) {
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
+ Optional<org.onap.so.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
+ String tenantId = null;
+ String cloudOwner = null;
+ String lcpRegionId = null;
+ if (relationshipsOpt.isPresent()) {
+ tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null);
+ cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null);
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null);
+ }
+
+ if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
+ Map<String, String[]> filters = createQueryRequest("volumeGroupId", volumeGroup.getVolumeGroupId());
+ Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
+ if (request.isPresent()) {
+ tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
+ cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
+ lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
+ } else {
+ throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
+ }
+ }
+ cloudConfig.setTenantId(tenantId);
+ cloudConfig.setCloudOwner(cloudOwner);
+ cloudConfig.setLcpCloudRegionId(lcpRegionId);
+ return cloudConfig;
+ }
+
+ public CloudConfiguration mapCloudConfigurationNetwork(L3Network network) {
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ String tenantId = null;
+ String cloudOwner = null;
+ String lcpRegionId = null;
+
+ Map<String, String[]> filters = createQueryRequest("networkId", network.getNetworkId());
+ Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
+ if (request.isPresent()) {
+ if (request.get().getRequestDetails() != null
+ && request.get().getRequestDetails().getCloudConfiguration() != null) {
+ if (request.get().getRequestDetails().getCloudConfiguration().getTenantId() != null) {
+ tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
+ }
+ if (request.get().getRequestDetails().getCloudConfiguration().getCloudOwner() != null) {
+ cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
+ }
+ if (request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId() != null) {
+ lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
+ }
+ }
+ } else {
+ throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
+ }
+
+ cloudConfig.setTenantId(tenantId);
+ cloudConfig.setCloudOwner(cloudOwner);
+ cloudConfig.setLcpCloudRegionId(lcpRegionId);
+ return cloudConfig;
+ }
+
+ public Optional<ServiceInstancesRequest> findServiceInstanceRequest(Map<String, String[]> filters) {
+ List<InfraActiveRequests> completeRequests = infraActiveRequestsClient.getRequest(filters);
+ InfraActiveRequests foundRequest = completeRequests.get(0);
+ ServiceInstancesRequest siRequest;
+ try {
+ siRequest = mapper.readValue(foundRequest.getRequestBody(), ServiceInstancesRequest.class);
+ return Optional.of(siRequest);
+ } catch (Exception e) {
+ logger.error("Could not read Create Instance Request", e);
+ }
+ return Optional.empty();
+ }
+
+ public Map<String, String[]> createQueryRequest(String name, String instanceId) {
+ Map<String, String[]> filters = new HashMap<>();
+ filters.put(name, new String[] {"EQ", instanceId});
+ filters.put("requestStatus", new String[] {"EQ", Status.COMPLETE.toString()});
+ filters.put("action", new String[] {"EQ", "createInstance"});
+ return filters;
+ }
+
+ public RequestInfo createRequestInfo() {
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSuppressRollback(false);
+ requestInfo.setSource(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ requestInfo.setRequestorId(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ return requestInfo;
+ }
+
+ public RequestParameters createRequestParameters() {
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(true);
+ requestParams.setTestApi("GR_API");
+ return requestParams;
+ }
+
+ public VfModule getAAIVfModule(String vnfId, String vfModuleId) {
+ return this.getAaiResourcesClient()
+ .get(VfModule.class, AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId))
+ .orElseGet(() -> {
+ logger.debug("No Vf Module found in A&AI VnfId: {}" + ", VfModuleId: {}", vnfId, vfModuleId);
+ return null;
+ });
+ }
+
+ public GenericVnf getGenericVnf(String vnfId) {
+ return this.getAaiResourcesClient()
+ .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+ .orElseGet(() -> {
+ logger.debug("No Generic VNF found in A&AI VnfId: {}", vnfId);
+ return null;
+ });
+ }
+
+ public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
+ GenericVnf vnf = getGenericVnf(vnfId);
+ AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
+ List<AAIResourceUri> listVserverWrapper;
+ Optional<AAIResourceUri> volumeGroupURI;
+ if (wrapper.getRelationships().isPresent()) {
+ listVserverWrapper = wrapper.getRelationships().get().getRelatedUris(AAIObjectType.VOLUME_GROUP);
+ volumeGroupURI = listVserverWrapper.stream()
+ .filter(resourceURI -> resourceURI.getURIKeys().get("volume-group-id").equals(volumeGroupId))
+ .findFirst();
+ } else {
+ throw new AAIEntityNotFound(
+ VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " volumeGroupId: " + volumeGroupId);
+ }
+ return this.getAaiResourcesClient().get(VolumeGroup.class, volumeGroupURI.get()).orElseGet(() -> {
+ logger.debug("No VolumeGroup in A&AI found: {}", vnfId);
+ return null;
+ });
+ }
+
+ public ServiceInstance getServiceInstance(String serviceInstanceId) {
+ return this.getAaiResourcesClient()
+ .get(ServiceInstance.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId))
+ .orElseGet(() -> {
+ logger.debug("No Service Instance found in A&AI ServiceInstanceId: {}", serviceInstanceId);
+ return null;
+ });
+ }
+
+ public L3Network getNetwork(String networkId) {
+ return this.getAaiResourcesClient()
+ .get(L3Network.class, AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId))
+ .orElseGet(() -> {
+ logger.debug("No Network found in A&AI NetworkId: {}", networkId);
+ return null;
+ });
+ }
+
+ public AAIResourcesClient getAaiResourcesClient() {
+ if (aaiResourcesClient == null) {
+ aaiResourcesClient = new AAIResourcesClient();
+ }
+ return aaiResourcesClient;
+ }
+
+ public void setAaiResourcesClient(AAIResourcesClient aaiResourcesClient) {
+ this.aaiResourcesClient = aaiResourcesClient;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
new file mode 100644
index 0000000000..c44f1f0e0a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/serviceInstantiation")
+public class Network {
+
+ private static Logger logger = LoggerFactory.getLogger(Network.class);
+
+ @Autowired
+ private NetworkRestHandler networkRestHandler;
+
+ @Autowired
+ private BpmnRequestBuilder requestBuilder;
+
+ @DELETE
+ @ResponseUpdater
+ @Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete provided Network instance", response = Response.class)
+ @Transactional
+ public Response deleteNetworkInstance(@PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext)
+ throws Exception {
+ InfraActiveRequests currentRequest = null;
+ String requestId = networkRestHandler.getRequestId(requestContext);
+ String requestorId = "Unknown";
+ String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
+ String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
+ currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId,
+ networkInstanceId, requestorId, source, requestURI);
+ ServiceInstancesRequest request = requestBuilder.buildNetworkDeleteRequest(networkInstanceId);
+ networkRestHandler.saveInstanceName(request, currentRequest);
+ networkRestHandler.checkDuplicateRequest(serviceInstanceId, networkInstanceId,
+ request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
+ Recipe recipe = networkRestHandler.findNetworkRecipe(Action.deleteInstance.toString());
+ networkRestHandler.callWorkflowEngine(networkRestHandler.buildRequestParams(request,
+ networkRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, networkInstanceId),
+ recipe.getOrchestrationUri());
+ ServiceInstancesResponse response =
+ networkRestHandler.createResponse(networkInstanceId, requestId, requestContext);
+ return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
new file mode 100644
index 0000000000..bf10fcc183
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/serviceInstantiation")
+public class ServiceInstance {
+
+ private static Logger logger = LoggerFactory.getLogger(ServiceInstance.class);
+
+ @Autowired
+ private ServiceInstanceRestHandler requestHandler;
+
+ @Autowired
+ private BpmnRequestBuilder requestBuilder;
+
+ @DELETE
+ @ResponseUpdater
+ @Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete a Service instance", response = ServiceInstancesResponse.class)
+ @Transactional
+ public Response deleteServiceInstance(@PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext)
+ throws Exception {
+ InfraActiveRequests currentRequest = null;
+ String requestId = requestHandler.getRequestId(requestContext);
+ String requestorId = "Unknown";
+ String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
+ String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
+ currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, requestorId,
+ source, requestURI);
+ ServiceInstancesRequest request = requestBuilder.buildServiceDeleteRequest(serviceInstanceId);
+ requestHandler.saveInstanceName(request, currentRequest);
+ requestHandler.checkDuplicateRequest(serviceInstanceId,
+ request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
+ Recipe recipe = requestHandler.findServiceRecipe(request.getRequestDetails().getModelInfo().getModelUuid(),
+ Action.deleteInstance.toString());
+ requestHandler.callWorkflowEngine(requestHandler.buildRequestParams(request,
+ requestHandler.getRequestUri(requestContext), requestId, serviceInstanceId),
+ recipe.getOrchestrationUri());
+ ServiceInstancesResponse response = requestHandler.createResponse(serviceInstanceId, requestId, requestContext);
+ return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
new file mode 100644
index 0000000000..1a2688f0b3
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/serviceInstantiation")
+public class VfModules {
+
+ private static Logger logger = LoggerFactory.getLogger(VfModules.class);
+
+ @Autowired
+ private VFModuleRestHandler restHandler;
+
+ @Autowired
+ private BpmnRequestBuilder requestBuilder;
+
+ @DELETE
+ @ResponseUpdater
+ @Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete a VfModule instance", response = ServiceInstancesResponse.class)
+ @Transactional
+ public Response deleteVfModuleInstance(@PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext)
+ throws Exception {
+ InfraActiveRequests currentRequest = null;
+
+ String requestId = restHandler.getRequestId(requestContext);
+ String requestorId = "Unknown";
+ String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
+ String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
+ currentRequest = restHandler.createInfraActiveRequestForDelete(requestId, vfmoduleInstanceId, serviceInstanceId,
+ vnfInstanceId, requestorId, source, requestURL);
+ ServiceInstancesRequest request =
+ requestBuilder.buildVFModuleDeleteRequest(vnfInstanceId, vfmoduleInstanceId, ModelType.vfModule);
+ restHandler.saveInstanceName(request, currentRequest);
+ restHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, vfmoduleInstanceId,
+ request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
+ Recipe recipe =
+ restHandler.findVfModuleRecipe(request.getRequestDetails().getModelInfo().getModelCustomizationId(),
+ ModelType.vfModule.toString(), Action.deleteInstance.toString());
+ restHandler
+ .callWorkflowEngine(restHandler.buildRequestParams(request, restHandler.getRequestUri(requestContext),
+ requestId, serviceInstanceId, vnfInstanceId, vfmoduleInstanceId), recipe.getOrchestrationUri());
+ ServiceInstancesResponse response = restHandler.createResponse(vfmoduleInstanceId, requestId, requestContext);
+ return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
new file mode 100644
index 0000000000..b161713a71
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/serviceInstantiation")
+public class Vnf {
+
+ private static Logger logger = LoggerFactory.getLogger(Vnf.class);
+
+ @Autowired
+ private BpmnRequestBuilder requestBuilder;
+
+ @Autowired
+ private VnfRestHandler vnfRestHandler;
+
+ @DELETE
+ @ResponseUpdater
+ @Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete a Vnf instance", response = ServiceInstancesResponse.class)
+ @Transactional
+ public Response deleteVnfInstance(@PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
+ @Context ContainerRequestContext requestContext) throws Exception {
+ InfraActiveRequests currentRequest = null;
+ String requestId = vnfRestHandler.getRequestId(requestContext);
+ String requestorId = "Unknown";
+ String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
+ String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
+ currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfInstanceId,
+ requestorId, source, requestURL);
+ ServiceInstancesRequest request = requestBuilder.buildVnfDeleteRequest(vnfInstanceId);
+ vnfRestHandler.saveInstanceName(request, currentRequest);
+ vnfRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId,
+ request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
+ Recipe recipe = vnfRestHandler.findVnfModuleRecipe(
+ request.getRequestDetails().getModelInfo().getModelCustomizationId(), "vnf", "deleteInstance");
+ vnfRestHandler.callWorkflowEngine(vnfRestHandler.buildRequestParams(request,
+ vnfRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, vnfInstanceId),
+ recipe.getOrchestrationUri());
+ ServiceInstancesResponse response = vnfRestHandler.createResponse(vnfInstanceId, requestId, requestContext);
+ return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
new file mode 100644
index 0000000000..afabdd9c60
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import io.swagger.annotations.ApiOperation;
+
+@Component("VolumesV8")
+@Path("/onap/so/infra/serviceInstantiation")
+public class Volumes {
+
+ private static Logger logger = LoggerFactory.getLogger(Volumes.class);
+
+ @Autowired
+ private BpmnRequestBuilder requestBuilder;
+
+ @Autowired
+ private VFModuleRestHandler vfModuleRestHandler;
+
+ @Autowired
+ private VolumeRestHandler volumeRestHandler;
+
+ @DELETE
+ @ResponseUpdater
+ @Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete a VfModule instance", response = ServiceInstancesResponse.class)
+ @Transactional
+ public Response deleteVfModuleInstance(@PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("volumeGroupInstanceId") String volumeGroupId, @Context ContainerRequestContext requestContext)
+ throws Exception {
+ InfraActiveRequests currentRequest = null;
+ String requestId = volumeRestHandler.getRequestId(requestContext);
+ String requestorId = "Unknown";
+ String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
+ String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
+ currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId, volumeGroupId,
+ serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
+ ServiceInstancesRequest request = requestBuilder.buildVolumeGroupDeleteRequest(vnfInstanceId, volumeGroupId);
+ volumeRestHandler.saveInstanceName(request, currentRequest);
+ volumeRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, volumeGroupId,
+ request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
+ Recipe recipe = vfModuleRestHandler.findVfModuleRecipe(
+ request.getRequestDetails().getModelInfo().getModelCustomizationId(), ModelType.volumeGroup.toString(),
+ Action.deleteInstance.toString());
+ volumeRestHandler
+ .callWorkflowEngine(
+ volumeRestHandler.buildRequestParams(request, volumeRestHandler.getRequestUri(requestContext),
+ requestId, serviceInstanceId, vnfInstanceId, volumeGroupId),
+ recipe.getOrchestrationUri());
+ ServiceInstancesResponse response = volumeRestHandler.createResponse(volumeGroupId, requestId, requestContext);
+ return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/AAIEntityNotFound.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/AAIEntityNotFound.java
new file mode 100644
index 0000000000..2153d9a628
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/AAIEntityNotFound.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception;
+
+public class AAIEntityNotFound extends Exception {
+
+ public AAIEntityNotFound(String errorMessage) {
+ super(errorMessage);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/CloudConfigurationNotFoundException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/CloudConfigurationNotFoundException.java
new file mode 100644
index 0000000000..5135478a3e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/CloudConfigurationNotFoundException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception;
+
+public class CloudConfigurationNotFoundException extends RuntimeException {
+
+ public CloudConfigurationNotFoundException(String errorMessage) {
+ super(errorMessage);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/NoRecipeException.java
index 0c10599a52..db35b5c5cd 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/NoRecipeException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -18,11 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.apihandlerinfra;
+package org.onap.so.apihandlerinfra.infra.rest.exception;
+
+public class NoRecipeException extends Exception {
+
+ public NoRecipeException(String error) {
+ super(error);
+ }
+
+
-/*
- * Enum for Status values returned by API Handler to Tail-F
- */
-public enum ModelType {
- service, vnf, vfModule, volumeGroup, network
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/RequestConflictedException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/RequestConflictedException.java
new file mode 100644
index 0000000000..35cb21945c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/RequestConflictedException.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception;
+
+public class RequestConflictedException extends RuntimeException {
+
+ public RequestConflictedException(String errorMessage) {
+ super(errorMessage);
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/WorkflowEngineConnectionException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/WorkflowEngineConnectionException.java
new file mode 100644
index 0000000000..f9206628a4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/WorkflowEngineConnectionException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception;
+
+public class WorkflowEngineConnectionException extends Exception {
+
+ public WorkflowEngineConnectionException(String error, Throwable t) {
+ super(error, t);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/AAIEntityNotFoundMapper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/AAIEntityNotFoundMapper.java
new file mode 100644
index 0000000000..519578ce6c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/AAIEntityNotFoundMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception.mapper;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class AAIEntityNotFoundMapper implements ExceptionMapper<AAIEntityNotFound> {
+
+ private static final Logger logger = LoggerFactory.getLogger(AAIEntityNotFoundMapper.class);
+
+ @Override
+ public Response toResponse(AAIEntityNotFound e) {
+ logger.error("AAIEntity Not Found", e);
+ RequestError error = new RequestError();
+ ServiceException value = new ServiceException();
+ value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
+ value.setText(e.getMessage());
+ error.setServiceException(value);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/CloudConfigurationNotFoundMapper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/CloudConfigurationNotFoundMapper.java
new file mode 100644
index 0000000000..24bf7434ee
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/CloudConfigurationNotFoundMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception.mapper;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class CloudConfigurationNotFoundMapper implements ExceptionMapper<CloudConfigurationNotFoundException> {
+
+ private static final Logger logger = LoggerFactory.getLogger(CloudConfigurationNotFoundMapper.class);
+
+ @Override
+ public Response toResponse(CloudConfigurationNotFoundException e) {
+ logger.error("Cloud Configuration Not Found", e);
+ RequestError error = new RequestError();
+ ServiceException value = new ServiceException();
+ value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
+ value.setText(e.getMessage());
+ error.setServiceException(value);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/NoRecipeExceptionMapper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/NoRecipeExceptionMapper.java
new file mode 100644
index 0000000000..c807aa2597
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/NoRecipeExceptionMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception.mapper;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class NoRecipeExceptionMapper implements ExceptionMapper<NoRecipeException> {
+
+ private static final Logger logger = LoggerFactory.getLogger(NoRecipeExceptionMapper.class);
+
+ @Override
+ public Response toResponse(NoRecipeException e) {
+ logger.error("No Recipe Found", e);
+ RequestError error = new RequestError();
+ ServiceException value = new ServiceException();
+ value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
+ value.setText(e.getMessage());
+ error.setServiceException(value);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/RequestConflictMapper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/RequestConflictMapper.java
new file mode 100644
index 0000000000..42d07c627b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/RequestConflictMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception.mapper;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class RequestConflictMapper implements ExceptionMapper<RequestConflictedException> {
+
+ private static final Logger logger = LoggerFactory.getLogger(RequestConflictMapper.class);
+
+ @Override
+ public Response toResponse(RequestConflictedException e) {
+ logger.error("Request Conflict Error", e);
+ RequestError error = new RequestError();
+ ServiceException value = new ServiceException();
+ value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
+ value.setText(e.getMessage());
+ error.setServiceException(value);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/WorkflowEngineConnectionMapper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/WorkflowEngineConnectionMapper.java
new file mode 100644
index 0000000000..71e0dacd56
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/exception/mapper/WorkflowEngineConnectionMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.exception.mapper;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class WorkflowEngineConnectionMapper implements ExceptionMapper<WorkflowEngineConnectionException> {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowEngineConnectionMapper.class);
+
+ @Override
+ public Response toResponse(WorkflowEngineConnectionException e) {
+ logger.error("Workflow Engine Connection Error", e);
+ RequestError error = new RequestError();
+ ServiceException value = new ServiceException();
+ value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
+ value.setText(e.getMessage());
+ error.setServiceException(value);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
new file mode 100644
index 0000000000..db84353cd4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import java.util.Optional;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.MsoRequest;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.onap.so.utils.UUIDChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public abstract class AbstractRestHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(AbstractRestHandler.class);
+
+ public static final String conflictFailMessage = "Error: Locked instance - This %s (%s) "
+ + "already has a request being worked with a status of %s (RequestId - %s). The existing request must finish or be cleaned up before proceeding.";
+
+
+ @Autowired
+ protected CatalogDbClient catalogDbClient;
+
+ @Autowired
+ protected RequestsDbClient infraActiveRequestsClient;
+
+ @Autowired
+ protected RequestClientFactory reqClientFactory;
+
+ public String getRequestUri(ContainerRequestContext context) {
+ String requestUri = context.getUriInfo().getPath();
+ String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri);
+ MDC.put(LogConstants.HTTP_URL, httpUrl);
+ requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
+ return requestUri;
+ }
+
+ public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
+ String requestId = null;
+ if (requestContext.getProperty("requestId") != null) {
+ requestId = requestContext.getProperty("requestId").toString();
+ }
+ if (UUIDChecker.isValidUUID(requestId)) {
+ return requestId;
+ } else {
+ ErrorLoggerInfo errorLoggerInfo =
+ new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError)
+ .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException =
+ new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID",
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+
+ public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq)
+ throws ApiException {
+ return duplicateCheck(action, instanceIdMap, startTime, instanceName, requestScope, currentActiveReq);
+ }
+
+ public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
+ InfraActiveRequests dup = null;
+ try {
+ if (!(instanceName == null && requestScope.equals("service") && (action == Action.createInstance
+ || action == Action.activateInstance || action == Action.assignInstance))) {
+ dup = infraActiveRequestsClient.checkInstanceNameDuplicate(instanceIdMap, instanceName, requestScope);
+ }
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo =
+ new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError)
+ .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ RequestDbFailureException requestDbFailureException =
+ new RequestDbFailureException.Builder("check for duplicate instance", e.toString(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage());
+ throw requestDbFailureException;
+ }
+ return dup;
+ }
+
+ public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage)
+ throws RequestDbFailureException {
+ if (aq != null) {
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage(errorMessage);
+ aq.setProgress(100L);
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ aq.setEndTime(endTimeStamp);
+ try {
+ infraActiveRequestsClient.updateInfraActiveRequests(aq);
+ } catch (Exception e) {
+ logger.error("Error updating status", e);
+ }
+ }
+ }
+ }
+
+
+
+ public void callWorkflowEngine(RequestClientParameter requestClientParameter, String orchestrationUri)
+ throws WorkflowEngineConnectionException {
+ RequestClient requestClient = reqClientFactory.getRequestClient(orchestrationUri);
+ try {
+ requestClient.post(requestClientParameter);
+ } catch (IOException e) {
+ logger.error("Error Calling Workflow Engine", e);
+ throw new WorkflowEngineConnectionException("Error Calling Workflow Engine", e);
+ }
+ }
+
+ public Optional<URL> buildSelfLinkUrl(String url, String requestId) {
+ Optional<URL> selfLinkUrl = Optional.empty();
+ String version = "";
+ try {
+ URL aUrl = new URL(url);
+ String aPath = aUrl.getPath();
+ if (aPath.indexOf("/v") == -1) {
+ version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V") + 4);
+ } else {
+ version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v") + 4);
+ }
+ String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId);
+ selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath));
+ } catch (Exception e) {
+ selfLinkUrl = Optional.empty(); // ignore
+ logger.info(e.getMessage());
+ }
+ return selfLinkUrl;
+ }
+
+ /**
+ * @param vfmoduleInstanceId
+ * @param requestId
+ * @param response
+ */
+ public ServiceInstancesResponse createResponse(String instanceId, String requestId,
+ ContainerRequestContext requestContext) {
+ ServiceInstancesResponse response = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId(instanceId);
+ requestReferences.setRequestId(requestId);
+ Optional<URL> optionalUrl = buildSelfLinkUrl(getRequestUri(requestContext), requestId);
+ if (optionalUrl.isPresent()) {
+ requestReferences.setRequestSelfLink(optionalUrl.get());
+ }
+ response.setRequestReferences(requestReferences);
+ return response;
+ }
+
+ public void checkDuplicateRequest(HashMap<String, String> instanceIdMap, ModelType modelType, String instanceName,
+ String requestId) throws RequestConflictedException {
+ InfraActiveRequests conflictedRequest =
+ infraActiveRequestsClient.checkInstanceNameDuplicate(instanceIdMap, instanceName, modelType.toString());
+ if (conflictedRequest != null && !conflictedRequest.getRequestId().equals(requestId)) {
+ throw new RequestConflictedException(String.format(conflictFailMessage, modelType.toString(), instanceName,
+ conflictedRequest.getRequestStatus(), conflictedRequest.getRequestId()));
+ }
+ }
+
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java
new file mode 100644
index 0000000000..ebb5d7e119
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import java.sql.Timestamp;
+import java.util.HashMap;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.db.catalog.beans.NetworkRecipe;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class NetworkRestHandler extends AbstractRestHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(NetworkRestHandler.class);
+
+ public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
+ String networkId, String requestorId, String source, String requestURL) {
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ InfraActiveRequests deleteRequest = new InfraActiveRequests();
+ deleteRequest.setRequestAction(Action.deleteInstance.toString());
+ deleteRequest.setAction(Action.deleteInstance.toString());
+ deleteRequest.setStartTime(startTimeStamp);
+ deleteRequest.setServiceInstanceId(serviceInstanceId);
+ deleteRequest.setNetworkId(networkId);
+ deleteRequest.setRequestId(requestId);
+ deleteRequest.setRequestorId(requestorId);
+ deleteRequest.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ deleteRequest.setSource(source);
+ deleteRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ deleteRequest.setRequestUrl(requestURL);
+ deleteRequest.setRequestScope(ModelType.network.toString());
+ deleteRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ return deleteRequest;
+ }
+
+ public InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
+ String networkId, String requestorId, String source, String requestURL) {
+ InfraActiveRequests request = mapInfraActiveRequestForDelete(requestId, serviceInstanceId, networkId,
+ requestorId, source, requestURL);
+ infraActiveRequestsClient.save(request);
+ return request;
+ }
+
+ public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
+ String requestId, String serviceInstanceId, String networkId) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
+ .setNetworkId(networkId).setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
+ .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
+ .build();
+ }
+
+ public void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest) {
+ try {
+ currentRequest.setNetworkName(request.getRequestDetails().getRequestInfo().getInstanceName());
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ } catch (Exception e) {
+ logger.warn("Could not update instance name", e);
+ }
+ }
+
+ public void checkDuplicateRequest(String serviceInstanceId, String networkInstanceId, String instanceName,
+ String requestId) throws RequestConflictedException {
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("networkInstanceId", networkInstanceId);
+ checkDuplicateRequest(instanceIdMap, ModelType.network, instanceName, requestId);
+ }
+
+ public Recipe findNetworkRecipe(String action) throws NoRecipeException {
+ String modelName = "GR-API-DEFAULT";
+ NetworkRecipe recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action);
+
+ if (recipe == null) {
+ throw new NoRecipeException(String.format("Unable to locate default recipe for, Action: %s, Model Name: %s",
+ action, modelName));
+ }
+ return recipe;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java
new file mode 100644
index 0000000000..7d3091e950
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+
+import java.sql.Timestamp;
+import java.util.HashMap;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class ServiceInstanceRestHandler extends AbstractRestHandler {
+
+ private static final String DEFAULT_VF_MODULE_UUID = "d88da85c-d9e8-4f73-b837-3a72a431622b";
+
+ private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceRestHandler.class);
+
+ public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
+ String requestorId, String source, String requestURL) {
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ InfraActiveRequests deleteRequest = new InfraActiveRequests();
+ deleteRequest.setRequestAction(Action.deleteInstance.toString());
+ deleteRequest.setAction(Action.deleteInstance.toString());
+ deleteRequest.setStartTime(startTimeStamp);
+ deleteRequest.setServiceInstanceId(serviceInstanceId);
+ deleteRequest.setRequestId(requestId);
+ deleteRequest.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ deleteRequest.setRequestorId(requestorId);
+ deleteRequest.setSource(source);
+ deleteRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ deleteRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ deleteRequest.setRequestUrl(requestURL);
+ deleteRequest.setRequestScope(ModelType.service.toString());
+ return deleteRequest;
+ }
+
+ public InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
+ String requestorId, String source, String requestURL) {
+ InfraActiveRequests request =
+ mapInfraActiveRequestForDelete(requestId, serviceInstanceId, requestorId, source, requestURL);
+ infraActiveRequestsClient.save(request);
+ return request;
+ }
+
+ public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
+ String requestId, String serviceInstanceId) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
+ .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
+ .build();
+ }
+
+ public void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest) {
+ try {
+ currentRequest.setServiceInstanceName(request.getRequestDetails().getRequestInfo().getInstanceName());
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ } catch (Exception e) {
+ logger.warn("Could not update instance name", e);
+ }
+ }
+
+ public void checkDuplicateRequest(String serviceInstanceId, String instanceName, String requestId)
+ throws RequestConflictedException {
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ checkDuplicateRequest(instanceIdMap, ModelType.service, instanceName, requestId);
+ }
+
+ public Recipe findServiceRecipe(String modelUUID, String action) throws NoRecipeException {
+ ServiceRecipe recipe = catalogDbClient.findServiceRecipeByActionAndServiceModelUUID(action, modelUUID);
+ if (recipe == null) {
+ recipe = catalogDbClient.findServiceRecipeByActionAndServiceModelUUID(action, DEFAULT_VF_MODULE_UUID);
+ }
+ if (recipe == null) {
+ throw new NoRecipeException(String.format(
+ "Unable to locate custom or default recipe for, Action: %s, Model UUID: %s", action, modelUUID));
+ }
+ return recipe;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java
new file mode 100644
index 0000000000..efd8b12b9a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+
+import java.sql.Timestamp;
+import java.util.HashMap;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class VFModuleRestHandler extends AbstractRestHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(VFModuleRestHandler.class);
+
+ public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String vfModuleId,
+ String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ InfraActiveRequests deleteRequest = new InfraActiveRequests();
+ deleteRequest.setRequestAction(Action.deleteInstance.toString());
+ deleteRequest.setAction(Action.deleteInstance.toString());
+ deleteRequest.setStartTime(startTimeStamp);
+ deleteRequest.setServiceInstanceId(serviceInstanceId);
+ deleteRequest.setVnfId(vnfId);
+ deleteRequest.setVfModuleId(vfModuleId);
+ deleteRequest.setRequestId(requestId);
+ deleteRequest.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ deleteRequest.setRequestorId(requestorId);
+ deleteRequest.setSource(source);
+ deleteRequest.setVfModuleId(vfModuleId);
+ deleteRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ deleteRequest.setRequestUrl(requestURL);
+ deleteRequest.setRequestScope(ModelType.vfModule.toString());
+ deleteRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ return deleteRequest;
+ }
+
+ public InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String vfModuleId,
+ String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
+ InfraActiveRequests request = mapInfraActiveRequestForDelete(requestId, vfModuleId, serviceInstanceId, vnfId,
+ requestorId, source, requestURL);
+ infraActiveRequestsClient.save(request);
+ return request;
+ }
+
+ public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
+ String requestId, String serviceInstanceId, String vnfId, String vfModuleId)
+ throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
+ .setVnfId(vnfId).setVfModuleId(vfModuleId).setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(request))
+ .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
+ .build();
+ }
+
+ public void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest) {
+ try {
+ currentRequest.setVfModuleName(request.getRequestDetails().getRequestInfo().getInstanceName());
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ } catch (Exception e) {
+ logger.warn("Could not update instance name", e);
+ }
+ }
+
+ public void checkDuplicateRequest(String serviceInstanceId, String vnfInstanceId, String vfmoduleInstanceId,
+ String instanceName, String requestId) {
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ checkDuplicateRequest(instanceIdMap, ModelType.vfModule, instanceName, requestId);
+ }
+
+ public Recipe findVfModuleRecipe(String modelCustomizationId, String modelType, String action)
+ throws NoRecipeException {
+ VnfComponentsRecipe recipe =
+ catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
+ modelCustomizationId, modelType, action);
+ if (recipe == null) {
+ recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
+ "GR-API-DEFAULT", modelType, action);
+ }
+ if (recipe == null) {
+ throw new NoRecipeException(String.format(
+ "Unable to locate custom or default recipe for ModelType: %s , Action: %s, CustomizationId: %s",
+ modelType, action, modelCustomizationId));
+ }
+ return recipe;
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java
new file mode 100644
index 0000000000..d98625fe50
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java
@@ -0,0 +1,110 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+
+import java.sql.Timestamp;
+import java.util.HashMap;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.VnfRecipe;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class VnfRestHandler extends AbstractRestHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(VnfRestHandler.class);
+
+ public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String serviceInstanceId, String vnfId,
+ String requestorId, String source, String requestURL) {
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ InfraActiveRequests deleteRequest = new InfraActiveRequests();
+ deleteRequest.setRequestAction(Action.deleteInstance.toString());
+ deleteRequest.setAction(Action.deleteInstance.toString());
+ deleteRequest.setStartTime(startTimeStamp);
+ deleteRequest.setServiceInstanceId(serviceInstanceId);
+ deleteRequest.setVnfId(vnfId);
+ deleteRequest.setRequestId(requestId);
+ deleteRequest.setRequestorId(requestorId);
+ deleteRequest.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ deleteRequest.setSource(source);
+ deleteRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ deleteRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ deleteRequest.setRequestScope(ModelType.vnf.toString());
+ deleteRequest.setRequestUrl(requestURL);
+ return deleteRequest;
+ }
+
+ public InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String serviceInstanceId,
+ String vnfId, String requestorId, String source, String requestURL) {
+ InfraActiveRequests request =
+ mapInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfId, requestorId, source, requestURL);
+ infraActiveRequestsClient.save(request);
+ return request;
+ }
+
+ public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
+ String requestId, String serviceInstanceId, String vnfId) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
+ .setVnfId(vnfId).setALaCarte(true).setRequestDetails(mapper.writeValueAsString(request))
+ .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
+ .build();
+ }
+
+ public void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest) {
+ try {
+ currentRequest.setVnfName(request.getRequestDetails().getRequestInfo().getInstanceName());
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ } catch (Exception e) {
+ logger.warn("Could not update instance name", e);
+ }
+ }
+
+ public void checkDuplicateRequest(String serviceInstanceId, String vnfInstanceId, String instanceName,
+ String requestId) {
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ checkDuplicateRequest(instanceIdMap, ModelType.vnf, instanceName, requestId);
+ }
+
+ public Recipe findVnfModuleRecipe(String modelCustomizationId, String modelType, String action)
+ throws NoRecipeException {
+ VnfRecipe recipe = new VnfRecipe();
+ recipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
+ return recipe;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java
new file mode 100644
index 0000000000..52f7ee9ac4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+
+import java.sql.Timestamp;
+import java.util.HashMap;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class VolumeRestHandler extends AbstractRestHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(VolumeRestHandler.class);
+
+ public InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String volumeGroupId,
+ String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ InfraActiveRequests deleteRequest = new InfraActiveRequests();
+ deleteRequest.setRequestAction(Action.deleteInstance.toString());
+ deleteRequest.setAction(Action.deleteInstance.toString());
+ deleteRequest.setStartTime(startTimeStamp);
+ deleteRequest.setServiceInstanceId(serviceInstanceId);
+ deleteRequest.setVnfId(vnfId);
+ deleteRequest.setVolumeGroupId(volumeGroupId);
+ deleteRequest.setRequestId(requestId);
+ deleteRequest.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ deleteRequest.setRequestorId(requestorId);
+ deleteRequest.setSource(source);
+ deleteRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ deleteRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ deleteRequest.setRequestScope(ModelType.volumeGroup.toString());
+ deleteRequest.setRequestUrl(requestURL);
+ return deleteRequest;
+ }
+
+ public InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String volumeGroupId,
+ String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL) {
+ InfraActiveRequests request = mapInfraActiveRequestForDelete(requestId, volumeGroupId, serviceInstanceId, vnfId,
+ requestorId, source, requestURL);
+ infraActiveRequestsClient.save(request);
+ return request;
+ }
+
+ public RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
+ String requestId, String serviceInstanceId, String vnfId, String volumeGroupId)
+ throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return new RequestClientParameter.Builder().setRequestId(requestId).setServiceInstanceId(serviceInstanceId)
+ .setVnfId(vnfId).setVolumeGroupId(volumeGroupId).setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(request))
+ .setRequestAction(Action.deleteInstance.toString()).setRequestUri(requestURI).setApiVersion("v8")
+ .build();
+ }
+
+ public void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest) {
+ try {
+ currentRequest.setVolumeGroupName(request.getRequestDetails().getRequestInfo().getInstanceName());
+ infraActiveRequestsClient.updateInfraActiveRequests(currentRequest);
+ } catch (Exception e) {
+ logger.warn("Could not update instance name", e);
+ }
+ }
+
+ public void checkDuplicateRequest(String serviceInstanceId, String vnfInstanceId, String volumeGroupId,
+ String instanceName, String requestId) {
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("volumeGroupInstanceId", volumeGroupId);
+ checkDuplicateRequest(instanceIdMap, ModelType.volumeGroup, instanceName, requestId);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
index c80e89e21d..71405b0f63 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
@@ -23,9 +23,9 @@ package org.onap.so.apihandlerinfra.validation;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
-import org.onap.so.apihandlerinfra.ModelType;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.LineOfBusiness;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.Platform;
public class PlatformLOBValidation implements ValidationRule {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
index 60e1274469..584269715a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
@@ -23,8 +23,8 @@ package org.onap.so.apihandlerinfra.validation;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
-import org.onap.so.apihandlerinfra.ModelType;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.OwningEntity;
import org.onap.so.serviceinstancebeans.Project;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index bc10aa744e..86bf8060a7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -24,13 +24,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.StringReader;
-import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Optional;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
@@ -46,13 +44,13 @@ import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
@RunWith(JUnitParamsRunner.class)
public class MsoRequestTest extends BaseTest {
@@ -1062,20 +1060,5 @@ public class MsoRequestTest extends BaseTest {
assertNotNull(result);
}
- @Test
- public void buildSelfLinkUrlTest() throws Exception {
- // v - version
- String incomingUrl = "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances";
- String expectedSelfLink = "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1";
- String requestId = "efce3167-5e45-4666-9d4d-22e23648e5d1";
- this.msoRequest = new MsoRequest();
- Optional<URL> actualSelfLinkUrl = msoRequest.buildSelfLinkUrl(incomingUrl, requestId);
- assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString());
- // V - Version
- String incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances";
- String expectedSelfLinkV =
- "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1";
- Optional<URL> actualSelfLinkUrlV = msoRequest.buildSelfLinkUrl(incomingUrlV, requestId);
- assertEquals(expectedSelfLinkV, actualSelfLinkUrlV.get().toString());
- }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
index dc0cd473c2..62a6f44a63 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
@@ -38,7 +38,6 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
-import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MediaType;
import org.apache.http.HttpStatus;
import org.junit.Before;
@@ -50,6 +49,7 @@ import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index ea43a54e69..b72e5124d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -67,6 +67,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestError;
import org.onap.so.serviceinstancebeans.RequestInfo;
@@ -90,7 +91,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.http.Fault;
import ch.qos.logback.classic.spi.ILoggingEvent;
-
public class ServiceInstancesTest extends BaseTest {
private final ObjectMapper mapper = new ObjectMapper();
@@ -2947,4 +2947,15 @@ public class ServiceInstancesTest extends BaseTest {
Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
assertEquals(Action.replaceInstanceRetainAssignments, action);
}
+ /*
+ * @Test public void buildSelfLinkUrlTest() throws Exception { // v - version String incomingUrl =
+ * "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances"; String expectedSelfLink =
+ * "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1"; String requestId =
+ * "efce3167-5e45-4666-9d4d-22e23648e5d1"; Optional<URL> actualSelfLinkUrl = buildSelfLinkUrl(incomingUrl,
+ * requestId); assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString()); // V - Version String
+ * incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances"; String
+ * expectedSelfLinkV = "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1";
+ * Optional<URL> actualSelfLinkUrlV = buildSelfLinkUrl(incomingUrlV, requestId); assertEquals(expectedSelfLinkV,
+ * actualSelfLinkUrlV.get().toString()); }
+ */
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
new file mode 100644
index 0000000000..3644dd8e7f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.Mockito.doReturn;
+import java.io.File;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class BpmnRequestBuilderTest {
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/infra/";
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ @Spy
+ BpmnRequestBuilder reqBuilder;
+
+ @Mock
+ private RequestsDbClient requestDBClient;
+
+ @Mock
+ private AAIResourcesClient aaiResourcesClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private GraphInventoryCommonObjectMapperProvider provider = new GraphInventoryCommonObjectMapperProvider();
+
+ @Before
+ public void setup() {
+ reqBuilder.setAaiResourcesClient(aaiResourcesClient);
+
+ }
+
+ @Test
+ public void test_buildServiceInstanceDeleteRequest() throws Exception {
+ ServiceInstance service =
+ provider.getMapper().readValue(new File(RESOURCE_PATH + "ServiceInstance.json"), ServiceInstance.class);
+
+ doReturn(service).when(reqBuilder).getServiceInstance("serviceId");
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedServiceRequest.json"), ServiceInstancesRequest.class);
+ expectedRequest.getRequestDetails().getModelInfo().setModelId(null);
+ // bad getter/setter setting multiple fields
+ ServiceInstancesRequest actualRequest = reqBuilder.buildServiceDeleteRequest("serviceId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVnfDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+
+ ServiceInstancesRequest expectedRequest =
+ mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest = reqBuilder.buildVnfDeleteRequest("vnfId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVFModuleDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class);
+
+ doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnfId", "vfModuleId"));
+
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest =
+ reqBuilder.buildVFModuleDeleteRequest("vnfId", "vfModuleId", ModelType.vfModule);
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVolumeGroupDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ VolumeGroup volumeGroup =
+ provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
+
+ doReturn(Optional.of(volumeGroup)).when(aaiResourcesClient).get(VolumeGroup.class, AAIUriFactory
+ .createResourceUri(AAIObjectType.VOLUME_GROUP, "cloudOwner", "regionOne", "volumeGroupId"));
+
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest = reqBuilder.buildVolumeGroupDeleteRequest("vnfId", "volumeGroupId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
new file mode 100644
index 0000000000..d39192cdf0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Optional;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AbstractRestHandlerTest {
+
+ @Spy
+ AbstractRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Test
+ public void test_createResponse() throws MalformedURLException {
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ URL selfLinkURL = new URL("http://localhost:8080/v1");
+ requestReferences.setInstanceId("instanceId");
+ requestReferences.setRequestId("requestId");
+ requestReferences.setRequestSelfLink(selfLinkURL);
+ expectedResponse.setRequestReferences(requestReferences);
+
+ doReturn("http://localhost:8080/v1").when(restHandler).getRequestUri(mockRequestContext);
+ doReturn(Optional.of(selfLinkURL)).when(restHandler).buildSelfLinkUrl("http://localhost:8080/v1", "requestId");
+ ServiceInstancesResponse actualResponse =
+ restHandler.createResponse("instanceId", "requestId", mockRequestContext);
+ assertThat(actualResponse, sameBeanAs(expectedResponse));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java
new file mode 100644
index 0000000000..8ff7517da8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class NetworkRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ NetworkRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "networkId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.network.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("NetworkId should exit in map", "networkId", actualMap.get("networkInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getNetworkName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setNetworkId("networkId").setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "networkId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setNetworkId("networkId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestScope(ModelType.network.toString());
+ expected.setRequestUrl("http://localhost:9090");
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "networkId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java
new file mode 100644
index 0000000000..56d57aa2d5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java
@@ -0,0 +1,189 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ServiceInstanceRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ ServiceInstanceRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_service_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(expected).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ }
+
+ @Test
+ public void test_find_service_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ doReturn(expected).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ Mockito.verify(catalogDbClient, Mockito.times(1)).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ }
+
+ @Test
+ public void test_find_service_recipe_not_found() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ doReturn(null).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ exceptionRule.expect(NoRecipeException.class);
+ exceptionRule.expectMessage(
+ "Unable to locate custom or default recipe for, Action: createInstance, Model UUID: testModelId");
+ restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_checkDuplicateRequest()
+ throws MalformedURLException, NoRecipeException, RequestConflictedException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.service.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("serviceInstanceId", actualMap.get("serviceInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getServiceInstanceName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected =
+ new RequestClientParameter.Builder().setRequestId("requestId").setServiceInstanceId("serviceInstanceId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.service.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java
new file mode 100644
index 0000000000..280ae9c071
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java
@@ -0,0 +1,190 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VfModuleRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VFModuleRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_vf_module_recipe() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ doReturn(expected).when(catalogDbClient)
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_find_vf_module_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
+ "testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
+ doReturn(expected).when(catalogDbClient)
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("GR-API-DEFAULT",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_find_vf_module_recipe_not_found() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ exceptionRule.expect(NoRecipeException.class);
+ exceptionRule.expectMessage(
+ "Unable to locate custom or default recipe for ModelType: vfModule , Action: createInstance, CustomizationId: testModelId");
+ restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "vfModuleId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vfModule.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ assertEquals("VFModuleId should exit in map", "vfModuleId", actualMap.get("vfModuleInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVfModuleName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVfModuleId("vfModuleId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "vfModuleId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setVfModuleId("vfModuleId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.vfModule.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "vfModuleId",
+ "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java
new file mode 100644
index 0000000000..2ea537b6ad
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VnfRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_vnf_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
+ Recipe actual = restHandler.findVnfModuleRecipe("testModelId", ModelType.vnf.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vnf.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVnfName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.vnf.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java
new file mode 100644
index 0000000000..2721f8a14a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.so.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VolumeRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VolumeRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "volumeGroupId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.volumeGroup.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ assertEquals("VolumeGroupId should exit in map", "volumeGroupId", actualMap.get("volumeGroupInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVolumeGroupName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVolumeGroupId("volumeGroupId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "volumeGroupId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setVolumeGroupId("volumeGroupId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestScope(ModelType.volumeGroup.toString());
+ expected.setRequestUrl("http://localhost:9090");
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "volumeGroupId",
+ "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json
new file mode 100644
index 0000000000..3ad3d1efec
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json
@@ -0,0 +1,20 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "modelUuid": "bad955c3-29b2-4a27-932e-28e942cc6480"
+ },
+ "requestInfo": {
+ "instanceName": "Robot_SI_For_VolumeGroup",
+ "suppressRollback": false
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json
new file mode 100644
index 0000000000..9670c3b645
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelCustomizationUuid": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d"
+ },
+ "requestInfo": {
+ "instanceName": "dummy_id",
+ "suppressRollback": false
+ },
+ "cloudConfiguration": {
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "cloudOwner": "cloudOwner",
+ "lcpCloudRegionId": "regionOne"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json
new file mode 100644
index 0000000000..59602f7ac2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json
@@ -0,0 +1,20 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelCustomizationUuid": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
+ "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade"
+ },
+ "requestInfo": {
+ "instanceName": "Robot_VNF_For_Volume_Group",
+ "suppressRollback": false
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json
new file mode 100644
index 0000000000..ec7acf1e41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelCustomizationUuid": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "modelCustomizationId": "e38906fa-717c-49b0-b391-e6ec12b50c4a"
+ },
+ "requestInfo": {
+ "instanceName": "VolumeGroup",
+ "suppressRollback": false
+ },
+ "cloudConfiguration": {
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "cloudOwner": "cloudOwner",
+ "lcpCloudRegionId": "regionOne"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json
new file mode 100644
index 0000000000..7d7a103123
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json
@@ -0,0 +1,35 @@
+{
+ "service-instance-id": "e9fbfab4-d91c-4508-a429-2046c8751371",
+ "service-instance-name": "Robot_SI_For_VolumeGroup",
+ "environment-context": "General_Revenue-Bearing",
+ "model-invariant-id": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
+ "model-version-id": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "resource-version": "1560538276937",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/projects/project/GR_API_OE_MSO_Test200",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "GR_API_OE_MSO_Test200"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v15/business/owning-entities/owning-entity/c3f57fa8-ac7d-11e8-98d0-529269fb1459",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "c3f57fa8-ac7d-11e8-98d0-529269fb1459"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json
new file mode 100644
index 0000000000..cfd9eb3e3c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json
@@ -0,0 +1,37 @@
+{
+ "vf-module-id": "b70060b7-0031-4065-9462-3cd5b753d2db",
+ "vf-module-name": "dummy_id",
+ "heat-stack-id": "dummy_id/stackId",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "automated-assignment": false,
+ "resource-version": "1560538368229",
+ "model-invariant-id": "f7a867f2-596b-4f4a-a128-421e825a6190",
+ "model-version-id": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
+ "model-customization-id": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "module-index": 0,
+ "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data//vf-modules/vf-module/dummy_id/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "volume-group",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/18b220c8-af84-4b82-a8c0-41bbea6328a6",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "volume-group.volume-group-id",
+ "relationship-value": "18b220c8-af84-4b82-a8c0-41bbea6328a6"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json
new file mode 100644
index 0000000000..09f6d81da3
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json
@@ -0,0 +1,131 @@
+{
+ "vnf-id": "829924cc-8932-4875-b0af-d7a02799da9a",
+ "vnf-name": "Robot_VNF_For_Volume_Group",
+ "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0",
+ "service-id": "06f76284-8710-11e6-ae22-56b6b6499611",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Active",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1560538316260",
+ "model-invariant-id": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
+ "model-version-id": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
+ "model-customization-id": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
+ "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v15/business/customers/customer/Robot_Test_Subscriber_ID/service-subscriptions/service-subscription/Robot_Test_Service_Type/service-instances/service-instance/e9fbfab4-d91c-4508-a429-2046c8751371",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Robot_Test_Subscriber_ID"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "Robot_Test_Service_Type"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "e9fbfab4-d91c-4508-a429-2046c8751371"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Robot_SI_For_VolumeGroup"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/platforms/platform/vSAMP12_14-2XXX-Aug18-9001%20-%20Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/lines-of-business/line-of-business/vSAMP12_14-2XXX-Aug18-9001%20-%20LOB",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - LOB"
+ }
+ ]
+ },
+ {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "tenant.tenant-name",
+ "property-value": "tenantName"
+ }
+ ]
+ },
+ {
+ "related-to": "volume-group",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/volumeGroupId",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "volume-group.volume-group-id",
+ "relationship-value": "18b220c8-af84-4b82-a8c0-41bbea6328a6"
+ }
+ ]
+ },
+ {
+ "related-to": "cloud-region",
+ "relationship-label": "org.onap.relationships.inventory.LocatedIn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "LCP"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json
new file mode 100644
index 0000000000..328b82ed55
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json
@@ -0,0 +1,56 @@
+{
+ "volume-group-id": "5e6bca5b-8e14-4bdd-a419-820f68019b19",
+ "volume-group-name": "VolumeGroup",
+ "heat-stack-id": "VolumeGroup/stackId",
+ "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0",
+ "orchestration-status": "Active",
+ "model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "vf-module-model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "resource-version": "1560526466219",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "tenant.tenant-name",
+ "property-value": "tenantName"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/network/generic-vnfs/generic-vnf/82035634-1878-4fd9-ab14-04b819bea24b",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "82035634-1878-4fd9-ab14-04b819bea24b"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Robot_VNF_For_Volume_Group"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
index 8657892c34..8566afe9e1 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
@@ -20,12 +20,16 @@
package org.onap.so.db.request.data.repository;
+import java.util.List;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
+import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-import org.springframework.stereotype.Repository;
@RepositoryRestResource(collectionResourceRel = "archivedInfraRequests", path = "archivedInfraRequests")
public interface ArchivedInfraRequestsRepository extends JpaRepository<ArchivedInfraRequests, String> {
+ List<InfraActiveRequests> findByActionAndRequestStatusAndVfModuleId(String action, String requestStatus,
+ String vfModuleId);
+
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java
index 29be0ddc00..a14699827d 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java
@@ -37,6 +37,9 @@ public interface InfraActiveRequestsRepository
InfraActiveRequests findOneByRequestIdOrClientRequestIdAndRequestType(String requestId, String clientRequestId,
String requestType);
+ List<InfraActiveRequests> findByActionAndRequestStatusAndVfModuleId(String action, String requestStatus,
+ String vfModuleId);
+
InfraActiveRequests findOneByRequestId(String string);
InfraActiveRequests findOneByRequestBody(String requestBody);
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
index 3c4b1fa66b..d8c7c8f971 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
@@ -92,7 +92,8 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
protected static final String OPENV = "operationalEnvironment";
private static final List<String> VALID_COLUMNS =
- Arrays.asList(REQUEST_ID, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, ACTION, REQUEST_STATUS);
+ Arrays.asList(REQUEST_ID, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, ACTION, REQUEST_STATUS,
+ VFMODULE_INSTANCE_ID, VNF_INSTANCE_ID, NETWORK_INSTANCE_ID, VOLUME_GROUP_INSTANCE_ID);
/*
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 1867b85de6..9ab0f3b680 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -73,7 +73,6 @@ public class RequestsDbClient {
private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENV_ID";
private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID";
-
@Value("${mso.adapters.requestDb.endpoint:#{null}}")
protected String endpoint;
@@ -106,6 +105,8 @@ public class RequestsDbClient {
private String requestProcessingDataURI = "/requestProcessingData";
+ private String getInfraActiveRequests = "/infraActiveRequests/v1/getInfraActiveRequests";
+
private static final String findBySoRequestIdAndGroupIdAndName =
"/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndName";
@@ -128,6 +129,7 @@ public class RequestsDbClient {
cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive;
findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_SEARCH + findOneByServiceIdAndOperationIdURI;
requestProcessingDataURI = endpoint + requestProcessingDataURI;
+ getInfraActiveRequests = endpoint + getInfraActiveRequests;
operationalEnvDistributionStatusURI = endpoint + operationalEnvDistributionStatusURI;
findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI =
endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH
@@ -368,6 +370,17 @@ public class RequestsDbClient {
return requestProcessingDataList;
}
+ // From and To are defaulted to ignore start/endtime on query to database
+ public List<InfraActiveRequests> getRequest(final Map<String, String[]> filters) {
+ String url = UriBuilder.fromUri(getUri(getInfraActiveRequests)).queryParam("from", "0")
+ .queryParam("to", "10000000000000").build().toString();
+ HttpHeaders headers = getHttpHeaders();
+ HttpEntity<Map> entity = new HttpEntity<>(filters, headers);
+ return restTemplate
+ .exchange(url, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {})
+ .getBody();
+ }
+
@Component
static class ClassURLMapper {
private static final Map<Class, String> classURLMap = new HashMap<>();