summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java74
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java72
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java70
11 files changed, 168 insertions, 139 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index a472268a3..a82dfab75 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -30,7 +30,6 @@ import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.CloudOwnerServiceImpl;
@@ -54,10 +53,6 @@ public class MsoConfig {
MsoProperties.MSO_SERVER_URL),httpsAuthClient);
}
- @Bean
- public MockedWorkflowsRestClient mockedWorkflowsClient(ObjectMapper unirestObjectMapper){
- return new MockedWorkflowsRestClient(new SyncRestClient(unirestObjectMapper), "http://vid-simulator:1080/");
- }
@Bean
public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
index a6ad92321..1d0ff95bc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
@@ -62,10 +62,6 @@ public class WorkflowsController extends VidRestrictedBaseController {
return externalWorkflowsService.getWorkflows(vnfModelId);
}
- @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET)
- SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) {
- return externalWorkflowsService.getWorkflowParameterDefinitions(id);
- }
@RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
index b88c3f6f6..00cc7b943 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
@@ -20,9 +20,18 @@
package org.onap.vid.model
+import com.google.common.collect.Lists
+
+enum class WorkflowSource(val source: String) {
+ SDC("sdc"), NATIVE("native")
+}
+
data class SOWorkflow constructor(
- val id: Long,
- val name: String) {
+ val id: String,
+ val name: String,
+ val source: WorkflowSource,
+ val workflowInputParameters: List<WorkflowInputParameter>
+) {
fun clone(): SOWorkflow {
return copy()
}
@@ -79,3 +88,50 @@ data class LocalWorkflowParameterDefinitions constructor(
}
}
+
+data class ArtifactInfo constructor(
+ val artifactType: String,
+ val artifactUuid: String,
+ val artifactName: String,
+ val artifactVersion: String,
+ val artifactDescription: String? = null,
+ val workflowName: String,
+ val operationName: String? = null,
+ val workflowSource: String,
+ val workflowResourceTarget: String
+)
+
+data class ActivitySequenceItem constructor(
+ val name: String,
+ val description: String
+)
+
+data class WorkflowInputParameter constructor(
+ val label: String,
+ val inputType: String,
+ val required: Boolean,
+ val validation: List<InputParameterValidation>? = Lists.newArrayList(),
+ val soFieldName: String,
+ val soPayloadLocation: String?,
+ val description: String?
+
+)
+
+data class InputParameterValidation constructor(
+ val maxLength: String?,
+ val allowableChars: String?
+)
+
+data class WorkflowSpecification constructor(
+ val artifactInfo: ArtifactInfo,
+ val activitySequence: List<ActivitySequenceItem>? = Lists.newArrayList(),
+ val workflowInputParameters: List<WorkflowInputParameter>
+)
+
+data class WorkflowSpecificationWrapper constructor(
+ val workflowSpecification: WorkflowSpecification
+)
+
+data class SOWorkflowList constructor(
+ val workflowSpecificationList: List<WorkflowSpecificationWrapper>? = Lists.newArrayList()
+)
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index 1ff30f03c..3b2cdb1bf 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright 2019 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.vid.mso;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
@@ -138,4 +140,5 @@ public interface MsoBusinessLogic {
MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails);
+ SOWorkflowList getWorkflowListByModelId(String modelVersionId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index ad07eacae..64c405a39 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -8,9 +8,9 @@
* 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.
@@ -26,26 +26,44 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.changeManagement.UIWorkflowsRequest;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
-import org.onap.vid.controller.ControllersUtils;
import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
-import org.onap.vid.mso.model.*;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
+import org.onap.vid.mso.model.RequestInfo;
+import org.onap.vid.mso.model.RequestParameters;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
-import org.onap.vid.mso.rest.*;
+import org.onap.vid.mso.rest.RelatedInstance;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.RequestList;
+import org.onap.vid.mso.rest.RequestWrapper;
+import org.onap.vid.mso.rest.Task;
+import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.togglz.core.manager.FeatureManager;
import javax.ws.rs.BadRequestException;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -54,8 +72,16 @@ import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.upperCase;
import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
-import static org.onap.vid.controller.MsoController.*;
-import static org.onap.vid.mso.MsoProperties.*;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.WORKFLOW_ID;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS;
import static org.onap.vid.properties.Features.FLAG_UNASSIGN_SERVICE;
import static org.onap.vid.utils.Logging.debugRequestDetails;
@@ -97,7 +123,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
this.featureManager = featureManager;
}
- public static String validateEndpointPath(String endpointEnvVariable) {
+ public static String validateEndpointPath(String endpointEnvVariable) {
String endpoint = SystemProperties.getProperty(endpointEnvVariable);
if (endpoint == null || endpoint.isEmpty()) {
throw new GenericUncheckedException(endpointEnvVariable + " env variable is not defined");
@@ -404,7 +430,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
}
- private List<Task> deserializeManualTasksJson(String manualTasksJson) {
+ private List<Task> deserializeManualTasksJson(String manualTasksJson) {
logInvocationInDebug("deserializeManualTasksJson");
ObjectMapper mapper = new ObjectMapper();
@@ -558,6 +584,20 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
return new MsoResponseWrapper2<>(msoClientInterface.post(path, new RequestDetailsWrapper<>(requestDetails), RequestReferencesContainer.class));
}
+ @Override
+ public SOWorkflowList getWorkflowListByModelId(String modelVersionId) {
+ logInvocationInDebug("getWorkflowListByModelId");
+ String pathTemplate = validateEndpointPath(MSO_REST_API_WORKFLOW_SPECIFICATIONS);
+ String path = pathTemplate.replaceFirst("<model_version_id>", modelVersionId);
+
+ HttpResponse<SOWorkflowList> workflowListByModelId = msoClientInterface.getWorkflowListByModelId(path);
+ if (!isSuccessful(workflowListByModelId)) {
+ logger.error(EELFLoggerDelegate.errorLogger, workflowListByModelId.getStatusText());
+ throw new WorkflowListException(String.format("Get worklflow list for id: %s failed due to %s", modelVersionId, workflowListByModelId.getStatusText()));
+ }
+ return workflowListByModelId.getBody();
+ }
+
@Override
public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
@@ -842,6 +882,18 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
}
+ private boolean isSuccessful(HttpResponse<SOWorkflowList> workflowListByModelId) {
+ int status = workflowListByModelId.getStatus();
+ return HttpStatus.OK.value() == status || HttpStatus.ACCEPTED.value() == status;
+ }
+
+ static class WorkflowListException extends RuntimeException{
+
+ WorkflowListException(String message) {
+ super(message);
+ }
+ }
+
enum RequestType {
CREATE_INSTANCE("createInstance"),
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 904ba13e4..9befc0f90 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -22,6 +22,7 @@ package org.onap.vid.mso;
import io.joshworks.restclient.http.HttpResponse;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.mso.rest.RequestDetails;
@@ -114,6 +115,8 @@ public interface MsoInterface {
MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
+ HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint);
+
MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail requestDetails,String invokeWorkflowsPath, Map<String, String> extraHeaders);
<T> HttpResponse<T> get(String path, Class<T> responseClass);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
index 47cb95f2f..4e6258c16 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
@@ -125,4 +125,6 @@ public class MsoProperties extends SystemProperties {
/** The Constant MSO_REST_API_SERVICE_INSTANCE_ASSIGN */
public static final String MSO_REST_API_SERVICE_INSTANCE_ASSIGN = "mso.restapi.serviceInstanceAssign";
+
+ public static final String MSO_REST_API_WORKFLOW_SPECIFICATIONS= "mso.restapi.changeManagement.workflowSpecifications";
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
deleted file mode 100644
index 54ee6464f..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.mso.rest;
-
-import java.util.Collections;
-import org.jetbrains.annotations.NotNull;
-import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-
-public class MockedWorkflowsRestClient {
-
- private SyncRestClient syncRestClient;
- private String baseUrl;
-
- public MockedWorkflowsRestClient(SyncRestClient syncRestClient, String baseUrl) {
- this.syncRestClient = syncRestClient;
- this.baseUrl = baseUrl;
- }
-
- public MsoResponseWrapper2<SOWorkflows> getWorkflows(String vnfName) {
- // Temporary skip vnfName and call mocked service
- return new MsoResponseWrapper2<>(syncRestClient
- .get(getWorkflowsUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflows.class));
- }
-
- public MsoResponseWrapper2<SOWorkflowParameterDefinitions> getWorkflowParameterDefinitions(Long workflowId) {
- return new MsoResponseWrapper2<>(syncRestClient
- .get((workflowId <= 3 && workflowId > 0) ? getParametersUrl(workflowId) : getParametersUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflowParameterDefinitions.class));
- }
-
- @NotNull
- private String getWorkflowsUrl() {
- return baseUrl + "so/workflows";
- }
-
-
- @NotNull
- private String getParametersUrl() {
- return baseUrl + "so/workflow-parameters";
- }
-
- @NotNull
- private String getParametersUrl(Long workflowId) {
- return baseUrl + "so/workflow-parameters/" + workflowId;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index ff7acffcf..0c05b80e2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -21,6 +21,7 @@
package org.onap.vid.mso.rest;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import java.text.DateFormat;
@@ -40,6 +41,7 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
@@ -473,6 +475,12 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
+ public HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint){
+ String path = baseUrl + endpoint;
+
+ return client.get(path, commonHeaders, Maps.newHashMap(), SOWorkflowList.class);
+ }
+
private MsoResponseWrapper createInstance(Object request, String path) {
String methodName = "createInstance";
logger.debug(methodName + START);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
index 2eae52f4f..4620eed34 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia 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.
@@ -22,10 +22,8 @@ package org.onap.vid.services;
import java.util.List;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
+
public interface ExternalWorkflowsService {
List<SOWorkflow> getWorkflows(String vnfModelId);
-
- SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
index e03b5463a..0648b6ac9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia 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.
@@ -20,60 +20,48 @@
package org.onap.vid.services;
-import java.util.List;
+import org.onap.vid.model.ArtifactInfo;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
+import org.onap.vid.model.SOWorkflowList;
+import org.onap.vid.model.WorkflowSource;
+import org.onap.vid.model.WorkflowSpecification;
+import org.onap.vid.mso.MsoBusinessLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
@Service
public class ExternalWorkflowsServiceImpl implements ExternalWorkflowsService {
- private MockedWorkflowsRestClient mockedWorkflowsRestClient;
+ private MsoBusinessLogic msoService;
@Autowired
- public ExternalWorkflowsServiceImpl(MockedWorkflowsRestClient mockedWorkflowsRestClient) {
- this.mockedWorkflowsRestClient = mockedWorkflowsRestClient;
+ public ExternalWorkflowsServiceImpl(MsoBusinessLogic msoService) {
+ this.msoService = msoService;
}
@Override
public List<SOWorkflow> getWorkflows(String vnfModelId) {
- MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfModelId);
- validateSOResponse(msoResponse, SOWorkflows.class);
- return convertMsoResponseToWorkflowList(msoResponse);
- }
+ SOWorkflowList workflowListByModelId = msoService.getWorkflowListByModelId(vnfModelId);
+ List<SOWorkflow> soWorkflows = new ArrayList<>();
+ Objects.requireNonNull(workflowListByModelId
+ .getWorkflowSpecificationList())
+ .forEach(
+ workflow -> soWorkflows.add(convertWorkflow(workflow.getWorkflowSpecification()))
+ );
- @Override
- public SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId) {
- MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponse = mockedWorkflowsRestClient.getWorkflowParameterDefinitions(workflowId);
- validateSOResponse(msoResponse, SOWorkflowParameterDefinitions.class);
- return (SOWorkflowParameterDefinitions) msoResponse.getEntity();
+ return soWorkflows;
}
- private List<SOWorkflow> convertMsoResponseToWorkflowList(MsoResponseWrapper2<SOWorkflows> msoResponse) {
- SOWorkflows soWorkflows = (SOWorkflows) msoResponse.getEntity();
- return soWorkflows.getWorkflows();
- }
+ private SOWorkflow convertWorkflow(WorkflowSpecification workflow) {
+ ArtifactInfo artifactInfo = workflow.getArtifactInfo();
- private void validateSOResponse(MsoResponseWrapper2 response, Class<?> expectedResponseClass){
- if (response.getStatus() >= 400 || !expectedResponseClass.isInstance(response.getEntity())) {
- throw new BadResponseFromMso(response);
- }
+ return new SOWorkflow(artifactInfo.getArtifactUuid(),
+ artifactInfo.getWorkflowName(),
+ WorkflowSource.valueOf(artifactInfo.getWorkflowSource().toUpperCase()),
+ workflow.getWorkflowInputParameters());
}
-
- public static class BadResponseFromMso extends RuntimeException {
- private final MsoResponseWrapper2<?> msoResponse;
-
- BadResponseFromMso(MsoResponseWrapper2<?> msoResponse) {
- this.msoResponse = msoResponse;
- }
-
- public MsoResponseWrapper2<?> getMsoResponse() {
- return msoResponse;
- }
- }
-
}