diff options
Diffstat (limited to 'vid-app-common/src/main/java')
21 files changed, 259 insertions, 39 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java new file mode 100644 index 000000000..dd6923569 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.vid.changeManagement; + +import java.util.List; +import java.util.Map; + +public class RequestParameters { + + private List<Map<String,String>> userParams; + + + public List<Map<String, String>> getUserParams() { + return userParams; + } + + public void setUserParams(List<Map<String, String>> userParams) { + this.userParams = userParams; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java new file mode 100644 index 000000000..97eee3045 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.vid.changeManagement; + +public class UIWorkflowsRequest { + + private WorkflowRequestDetail requestDetails; + + + public WorkflowRequestDetail getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(WorkflowRequestDetail requestDetails) { + this.requestDetails = requestDetails; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java new file mode 100644 index 000000000..2ebebdd68 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.vid.changeManagement; + +import org.onap.vid.mso.model.CloudConfiguration; + +public class WorkflowRequestDetail { + + + private CloudConfiguration cloudConfiguration; + + private RequestParameters requestParameters; + + + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + + public RequestParameters getRequestParameters() { + return requestParameters; + } + + public void setRequestParameters(RequestParameters requestParameters) { + this.requestParameters = requestParameters; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java index 124b6cfcb..1acf84f05 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java @@ -55,6 +55,7 @@ import org.onap.vid.roles.Role; import org.onap.vid.roles.RoleProvider; import org.onap.vid.roles.RoleValidator; import org.onap.vid.services.AaiService; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.onap.vid.utils.Unchecked; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -100,9 +101,10 @@ public class AaiController extends RestrictedBaseController { private AaiService aaiService; @Autowired private RoleProvider roleProvider; - @Autowired private AAIRestInterface aaiRestInterface; + @Autowired + private SystemPropertiesWrapper systemPropertiesWrapper; /** * Welcome method. @@ -144,7 +146,7 @@ public class AaiController extends RestrictedBaseController { @RequestMapping(value = {"/getuserID"}, method = RequestMethod.GET) public ResponseEntity<String> getUserID(HttpServletRequest request) { - String userId = ControllersUtils.extractUserId(request); + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request); return new ResponseEntity<>(userId, HttpStatus.OK); } diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java index a204d3a9a..081e3c640 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java @@ -31,6 +31,7 @@ import org.onap.vid.model.serviceInstantiation.ServiceInstantiation; import org.onap.vid.mso.MsoResponseWrapper2; import org.onap.vid.services.AsyncInstantiationBusinessLogic; import org.onap.vid.services.AuditService; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -48,6 +49,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController { public static final String ASYNC_INSTANTIATION = "asyncInstantiation"; protected final AsyncInstantiationBusinessLogic asyncInstantiationBL; + private final SystemPropertiesWrapper systemPropertiesWrapper; protected ObjectMapper objectMapper = new ObjectMapper(); @@ -55,8 +57,9 @@ public class AsyncInstantiationController extends VidRestrictedBaseController { protected AuditService auditService; @Autowired - public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL) { + public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL, SystemPropertiesWrapper systemPropertiesWrapper) { this.asyncInstantiationBL = asyncInstantiationBL; + this.systemPropertiesWrapper = systemPropertiesWrapper; } @ExceptionHandler(OperationNotAllowedException.class) @@ -84,7 +87,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController { catch (Exception e) { LOGGER.error(EELFLoggerDelegate.errorLogger, "failed to log incoming ServiceInstantiation request ", e); } - String userId = ControllersUtils.extractUserId(httpServletRequest); + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(httpServletRequest); List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, userId); return new MsoResponseWrapper2(200, uuids); diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java index 7139b29fb..befbe0320 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java @@ -3,13 +3,14 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. 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,35 +21,26 @@ package org.onap.vid.controller; +import static org.onap.vid.utils.Logging.getMethodCallerName; + +import java.util.Optional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.WebApplicationException; import org.apache.commons.lang3.exception.ExceptionUtils; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.model.ExceptionResponse; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.http.ResponseEntity; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.WebApplicationException; - -import static org.onap.vid.utils.Logging.getMethodCallerName; +public final class ControllersUtils { -public class ControllersUtils { + private final SystemPropertiesWrapper systemPropertiesWrapper; - - public static String extractUserId(HttpServletRequest request) { - String userId = ""; - HttpSession session = request.getSession(); - if (session != null) { - User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); - if (user != null) { - //userId = user.getHrid(); - userId = user.getLoginId(); - if (userId == null) - userId = user.getOrgUserId(); - } - } - return userId; + public ControllersUtils(SystemPropertiesWrapper systemPropertiesWrapper) { + this.systemPropertiesWrapper = systemPropertiesWrapper; } public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) { @@ -62,4 +54,12 @@ public class ControllersUtils { return ResponseEntity.status(e.getResponse().getStatus()).body(ControllersUtils.handleException(e, logger)); } + public String extractUserId(HttpServletRequest request) { + Optional<User> user = Optional.ofNullable(request.getSession()) + .map((HttpSession he) -> (User) he + .getAttribute(systemPropertiesWrapper.getProperty(SystemProperties.USER_ATTRIBUTE_NAME))); + + return user.map(User::getLoginId).isPresent() + ? user.map(User::getLoginId).orElse("") : user.map(User::getOrgUserId).orElse(""); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java index 290400432..00f9db246 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java @@ -74,6 +74,7 @@ public class MsoController extends RestrictedBaseController { * The Constant VNF_INSTANCE_ID. */ public static final String VNF_INSTANCE_ID = "<vnf_instance_id>"; + public static final String WORKFLOW_ID = "<workflow_UUID>"; public static final String START_LOG = " start"; private final MsoBusinessLogic msoBusinessLogic; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java index fe94dfd80..a6778ad0c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java @@ -37,6 +37,7 @@ import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo; import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails; import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.MissingServletRequestParameterException; @@ -60,20 +61,22 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle private final MsoInterface restMso; private final MsoBusinessLogic msoBusinessLogic; + private final SystemPropertiesWrapper systemPropertiesWrapper; private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("from String \"(.*)\": value not"); @Autowired - public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoInterface msoClientInterface) { + public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoInterface msoClientInterface, SystemPropertiesWrapper systemPropertiesWrapper) { this.restMso = msoClientInterface; this.msoBusinessLogic = msoBusinessLogic; + this.systemPropertiesWrapper = systemPropertiesWrapper; } @RequestMapping(value = "/create", method = RequestMethod.POST) public MsoResponseWrapper2 createOperationalEnvironment(HttpServletRequest request, @RequestBody OperationalEnvironmentCreateBody operationalEnvironment) { debugStart(operationalEnvironment); - String userId = ControllersUtils.extractUserId(request); + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request); RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = msoBusinessLogic.convertParametersToRequestDetails(operationalEnvironment, userId); String path = msoBusinessLogic.getOperationalEnvironmentCreationPath(); @@ -94,7 +97,7 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle throw new BadManifestException("Manifest structure is wrong"); } - String userId = ControllersUtils.extractUserId(request); + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request); OperationalEnvironmentActivateInfo activateInfo = new OperationalEnvironmentActivateInfo(activateRequest, userId, operationalEnvironmentId); debugStart(activateInfo); @@ -115,7 +118,7 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment"); - String userId = ControllersUtils.extractUserId(request); + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request); OperationalEnvironmentDeactivateInfo deactivateInfo = new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId); debugStart(deactivateInfo); diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java index 987bffa34..543aa9432 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java @@ -24,6 +24,7 @@ package org.onap.vid.controller; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.module.kotlin.KotlinModule; import io.joshworks.restclient.http.mapper.ObjectMapper; +import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.*; import org.onap.vid.aai.model.PortDetailsTranslator; import org.onap.vid.aai.util.*; @@ -163,7 +164,7 @@ public class WebConfig { } @Bean - public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper){ + public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper, SystemProperties systemProperties){ return new AaiOverTLSClient(new SyncRestClient(unirestObjectMapper), new AaiOverTLSPropertySupplier()); } 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 a94481b9e..a6ad92321 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 @@ -21,18 +21,26 @@ package org.onap.vid.controller; import java.util.List; +import java.util.UUID; + +import org.onap.vid.changeManagement.UIWorkflowsRequest; import org.onap.vid.model.LocalWorkflowParameterDefinitions; import org.onap.vid.model.SOWorkflow; import org.onap.vid.model.SOWorkflowParameterDefinitions; +import org.onap.vid.mso.MsoResponseWrapper; +import org.onap.vid.services.ChangeManagementService; import org.onap.vid.services.ExternalWorkflowsService; import org.onap.vid.services.LocalWorkflowsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; + @RestController @RequestMapping(WorkflowsController.WORKFLOWS_MANAGEMENT) public class WorkflowsController extends VidRestrictedBaseController { @@ -40,16 +48,18 @@ public class WorkflowsController extends VidRestrictedBaseController { private ExternalWorkflowsService externalWorkflowsService; private LocalWorkflowsService localWorkflowsService; + private ChangeManagementService changeManagementService; @Autowired - public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService) { + public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService,ChangeManagementService changeManagementService) { this.externalWorkflowsService = externalWorkflowsService; this.localWorkflowsService = localWorkflowsService; + this.changeManagementService = changeManagementService; } @RequestMapping(value = "workflows", method = RequestMethod.GET) - public List<SOWorkflow> getWorkflows(@RequestParam(value = "vnfName") String vnfName){ - return externalWorkflowsService.getWorkflows(vnfName); + public List<SOWorkflow> getWorkflows(@RequestParam(value = "vnfModelId") String vnfModelId){ + return externalWorkflowsService.getWorkflows(vnfModelId); } @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET) @@ -62,5 +72,10 @@ public class WorkflowsController extends VidRestrictedBaseController { return localWorkflowsService.getWorkflowParameterDefinitions(name); } + @RequestMapping(value = "{serviceInstanceId}/{vnfInstanceId}/{workflow_UUID}", method = RequestMethod.POST) + public MsoResponseWrapper getWorkflowFromUI(HttpServletRequest request, @PathVariable("serviceInstanceId") UUID serviceInstanceId, @PathVariable("vnfInstanceId") UUID vnfInstanceId, @PathVariable("workflow_UUID") UUID workflow_UUID, @RequestBody UIWorkflowsRequest requestBody) { + return changeManagementService.invokeVnfWorkflow(request,requestBody.getRequestDetails(), serviceInstanceId, vnfInstanceId, workflow_UUID); + } + } 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 633acbcb8..1ff30f03c 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 @@ -21,6 +21,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.SoftDeleteRequest; import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; @@ -31,6 +32,7 @@ import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.mso.rest.Task; import java.util.List; +import java.util.UUID; public interface MsoBusinessLogic { @@ -51,6 +53,8 @@ public interface MsoBusinessLogic { MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); + MsoResponseWrapper invokeVnfWorkflow(WorkflowRequestDetail request, String userId, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID); + MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId); MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus); 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 ec1c5479f..ad07eacae 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 @@ -30,6 +30,9 @@ 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; @@ -181,6 +184,27 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override + public MsoResponseWrapper invokeVnfWorkflow(WorkflowRequestDetail request, String userId, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID) { + logInvocationInDebug("invokeVnfWorkflow"); + + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_WORKFLOW_INSTANCE); + + String final_endpoint = endpoint + .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId.toString()) + .replaceFirst(WORKFLOW_ID, workflow_UUID.toString()) + .replaceFirst(VNF_INSTANCE_ID, vnfInstanceId.toString()); + + Map<String,String> extraHeaders = new HashMap<>(); + + UUID requestId = UUID.randomUUID(); + extraHeaders.put("X-ONAP-RequestID",requestId.toString()); + extraHeaders.put("X-ONAP-PartnerName","VID"); + extraHeaders.put("X-RequestorID",userId); + + return msoClientInterface.invokeWorkflow(request,final_endpoint,extraHeaders); + } + + @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) { logInvocationInDebug("createConfigurationInstance"); 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 31063c62b..904ba13e4 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,8 +22,11 @@ package org.onap.vid.mso; import io.joshworks.restclient.http.HttpResponse; import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.changeManagement.WorkflowRequestDetail; import org.onap.vid.mso.rest.RequestDetails; +import java.util.Map; + /** * Created by pickjonathan on 21/06/2017. */ @@ -111,6 +114,8 @@ public interface MsoInterface { MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath); + MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail requestDetails,String invokeWorkflowsPath, Map<String, String> extraHeaders); + <T> HttpResponse<T> get(String path, Class<T> responseClass); <T> HttpResponse<T> post(String path, RequestDetailsWrapper<?> requestDetailsWrapper, 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 3dc1ddcd3..47cb95f2f 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 @@ -97,6 +97,9 @@ public class MsoProperties extends SystemProperties { public static final String MSO_REST_API_VF_MODULE_SCALE_OUT = "mso.restapi.vf.module.scaleout"; + /** The Constant MSO_REST_API_WORKFLOW_INSTANCE. */ + public static final String MSO_REST_API_WORKFLOW_INSTANCE = "mso.restapi.workflow.invoke"; + /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */ public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; 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 8dac0ce1b..ff7acffcf 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 @@ -22,6 +22,7 @@ package org.onap.vid.mso.rest; import com.google.common.collect.ImmutableMap; import io.joshworks.restclient.http.HttpResponse; +import io.joshworks.restclient.http.JsonNode; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -36,6 +37,7 @@ import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.changeManagement.MsoRequestDetails; 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.mso.MsoInterface; @@ -444,6 +446,20 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf } @Override + public MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail workflowRequestDetail, String invokeWorkflowsPath, Map<String, String> extraHeaders) { + String path = baseUrl + invokeWorkflowsPath; + Map<String, String> finalHeader = new HashMap<>(); + + finalHeader.putAll(commonHeaders); + finalHeader.putAll(extraHeaders); + + RequestDetailsWrapper<WorkflowRequestDetail> requestDetailsWrapper = new RequestDetailsWrapper<>(workflowRequestDetail); + + HttpResponse<JsonNode> response = client.post(path, finalHeader, requestDetailsWrapper); + return MsoUtil.wrapResponse(response); + } + + @Override public <T> HttpResponse<T> get(String endpoint, Class<T> responseClass) { String path = baseUrl + endpoint; return client.get(path, commonHeaders, new HashMap<>(), responseClass); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt index 311b0fbbe..7d2a41a6a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt @@ -32,12 +32,15 @@ data class Task( var errorMessage: String?, var buildingBlockName: String?, var buildingBlockStep: String?, + var description: String?, + var timeout: String?, var validResponses: List<String>? ) { // i.e. "default constructor", no params constructor() : this( null, null, null, null, null, null, null, null, - null, null, null, null + null, null, null, + null, null, null ) } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java index 142bf73ec..83757f2fb 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java @@ -320,6 +320,8 @@ public class AaiServiceImpl implements AaiService { return aaiClient.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel); } + + @Override public AaiResponse getServices(RoleValidator roleValidator) { AaiResponse<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices(); diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java index 0047396d1..603e1f7be 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java @@ -23,13 +23,16 @@ package org.onap.vid.services; import com.fasterxml.jackson.databind.node.ArrayNode; import org.apache.commons.lang3.tuple.Pair; import org.onap.vid.changeManagement.*; +import org.onap.vid.mso.MsoResponseWrapper; import org.onap.vid.mso.RestObjectWithRequestInfo; import org.onap.vid.mso.rest.Request; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.util.Collection; import java.util.List; +import java.util.UUID; public interface ChangeManagementService { Collection<Request> getMSOChangeManagements(); @@ -49,4 +52,6 @@ public interface ChangeManagementService { VnfWorkflowRelationAllResponse getAllVnfWorkflowRelations(); String uploadConfigUpdateFile(MultipartFile file); + MsoResponseWrapper invokeVnfWorkflow(HttpServletRequest request, WorkflowRequestDetail requestBody, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID); + } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java index a20164c9e..fc5a85c04 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java @@ -30,17 +30,20 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.changeManagement.*; +import org.onap.vid.controller.ControllersUtils; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.exceptions.NotFoundException; import org.onap.vid.model.VNFDao; import org.onap.vid.model.VidWorkflow; import org.onap.vid.mso.MsoBusinessLogic; +import org.onap.vid.mso.MsoResponseWrapper; import org.onap.vid.mso.MsoResponseWrapperInterface; import org.onap.vid.mso.RestObject; import org.onap.vid.mso.RestObjectWithRequestInfo; import org.onap.vid.mso.rest.Request; import org.onap.vid.scheduler.SchedulerProperties; import org.onap.vid.scheduler.SchedulerRestInterfaceIfc; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -48,6 +51,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.BadRequestException; import java.io.IOException; import java.util.*; @@ -64,16 +68,18 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { private MsoBusinessLogic msoBusinessLogic; private final SchedulerRestInterfaceIfc restClient; private final CloudOwnerService cloudOwnerService; + private final SystemPropertiesWrapper systemPropertiesWrapper; @Autowired private CsvService csvService; @Autowired - public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService) { + public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService, SystemPropertiesWrapper systemPropertiesWrapper) { this.dataAccessService = dataAccessService; this.msoBusinessLogic = msoBusinessLogic; this.restClient = schedulerRestInterface; this.cloudOwnerService = cloudOwnerService; + this.systemPropertiesWrapper = systemPropertiesWrapper; } @Override @@ -327,6 +333,12 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { return json.toString(); } + @Override + public MsoResponseWrapper invokeVnfWorkflow(HttpServletRequest request,WorkflowRequestDetail requestBody, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID) { + String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request); + return msoBusinessLogic.invokeVnfWorkflow(requestBody, userId, serviceInstanceId, vnfInstanceId, workflow_UUID); + } + private boolean validateJsonOutput(org.json.JSONObject json) { if (!json.has(PRIMARY_KEY) || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS)) return false; 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 da909a54d..2eae52f4f 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 @@ -25,7 +25,7 @@ import org.onap.vid.model.SOWorkflow; import org.onap.vid.model.SOWorkflowParameterDefinitions; public interface ExternalWorkflowsService { - List<SOWorkflow> getWorkflows(String vnfName); + 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 1da03f0ac..e03b5463a 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 @@ -40,8 +40,8 @@ public class ExternalWorkflowsServiceImpl implements ExternalWorkflowsService { } @Override - public List<SOWorkflow> getWorkflows(String vnfName) { - MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfName); + public List<SOWorkflow> getWorkflows(String vnfModelId) { + MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfModelId); validateSOResponse(msoResponse, SOWorkflows.class); return convertMsoResponseToWorkflowList(msoResponse); } |