diff options
Diffstat (limited to 'vid-app-common/src/main/java/org')
39 files changed, 750 insertions, 479 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java index 3938b164c..a62076073 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java @@ -48,6 +48,14 @@ public class AaiGetVnfResponse { this.additionalProperties.put(name, value); } + public List<VnfResult> getResults() { + return results; + } + + public void setResults(List<VnfResult> results) { + this.results = results; + } + @Override public String toString() { return MoreObjects.toStringHelper(this) diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java index 6059eec74..d03362ba8 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java @@ -34,7 +34,7 @@ public class SubscriberListWithFilterData { public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){ List<Subscriber> subscribers = subscriberList != null ? subscriberList.customer : new ArrayList<>(); - List<SubscriberWithFilter> subscribersWithFilter = new ArrayList<>(); + customer = new ArrayList<>(); for (Subscriber subscriber :subscribers){ SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter(); subscriberWithFilter.setIsPermitted(roleValidator.isSubscriberPermitted(subscriber.globalCustomerId)); @@ -42,10 +42,9 @@ public class SubscriberListWithFilterData { subscriberWithFilter.resourceVersion = subscriber.resourceVersion; subscriberWithFilter.subscriberName = subscriber.subscriberName; subscriberWithFilter.globalCustomerId = subscriber.globalCustomerId; - subscribersWithFilter.add(subscriberWithFilter); + customer.add(subscriberWithFilter); } - this.customer = subscribersWithFilter; - } + } public List<SubscriberWithFilter> customer; } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java index c30570d22..d6eb0526f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java @@ -27,20 +27,17 @@ import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class RelationshipList { - + + public List<Relationship> relationship; + @JsonProperty("relationship") public List<Relationship> getRelationship() { return relationship; } - + @JsonProperty("relationship") public void setRelationship(List<Relationship> relationship) { this.relationship = relationship; } - public List<Relationship> relationship; - - - - } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java index 677602be1..6cbd8cdbf 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_NULL) @@ -83,4 +84,22 @@ public class VnfResult { public void setJsonAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + VnfResult vnfResult = (VnfResult) o; + return Objects.equals(id, vnfResult.id) && + Objects.equals(nodeType, vnfResult.nodeType) && + Objects.equals(url, vnfResult.url) && + Objects.equals(properties, vnfResult.properties) && + Objects.equals(relatedTo, vnfResult.relatedTo) && + Objects.equals(additionalProperties, vnfResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, nodeType, url, properties, relatedTo, additionalProperties); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java index 8f53fcdbf..92d8de757 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java @@ -133,7 +133,7 @@ public class AAIRestInterface { * * @param baseURL the base URL */ - public void SetRestSrvrBaseURL(String baseURL) + public void setRestSrvrBaseURL(String baseURL) { if (baseURL == null) { logger.info(EELFLoggerDelegate.errorLogger, "REST Server base URL cannot be null."); 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 a8e1e2b02..3aff7fea7 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 @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,19 @@ package org.onap.vid.controller; +import static org.onap.vid.utils.Logging.getMethodName; + import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.onap.portalsdk.core.controller.RestrictedBaseController; @@ -41,30 +54,21 @@ 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; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +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 org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.ModelAndView; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -import static org.onap.vid.utils.Logging.getMethodName; - /** * Controller to handle a&ai requests. */ @@ -72,33 +76,25 @@ import static org.onap.vid.utils.Logging.getMethodName; @RestController public class AaiController extends RestrictedBaseController { - /** - * The from app id. - */ - private String fromAppId = "VidAaiController"; - /** - * The logger. - */ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class); - /** - * The model. - */ - private Map<String, Object> model = new HashMap<>(); - /** - * The servlet context. - */ - @Autowired - private ServletContext servletContext; - /** - * aai service - */ - @Autowired + private static final String FROM_APP_ID = "VidAaiController"; + private AaiService aaiService; - @Autowired + private AAIRestInterface aaiRestInterface; private RoleProvider roleProvider; + private SystemPropertiesWrapper systemPropertiesWrapper; @Autowired - private AAIRestInterface aaiRestInterface; + public AaiController(AaiService aaiService, + AAIRestInterface aaiRestInterface, + RoleProvider roleProvider, + SystemPropertiesWrapper systemPropertiesWrapper) { + + this.aaiService = aaiService; + this.aaiRestInterface = aaiRestInterface; + this.roleProvider = roleProvider; + this.systemPropertiesWrapper = systemPropertiesWrapper; + } /** * Welcome method. @@ -140,7 +136,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); } @@ -153,7 +149,7 @@ public class AaiController extends RestrictedBaseController { */ @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> doGetServices(HttpServletRequest request) throws IOException { - RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request)); + RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request)); AaiResponse subscriberList = aaiService.getServices(roleValidator); return aaiResponseToResponseEntity(subscriberList); @@ -277,7 +273,7 @@ public class AaiController extends RestrictedBaseController { public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity<String> responseEntity; - RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request)); + RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request)); SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator); if (subscriberList.getHttpCode() == 200) { responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK); @@ -340,7 +336,7 @@ public class AaiController extends RestrictedBaseController { ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator); String httpMessage = subscriberData.getT() != null ? objectMapper.writeValueAsString(subscriberData.getT()) : @@ -369,7 +365,7 @@ public class AaiController extends RestrictedBaseController { ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects); @@ -531,7 +527,7 @@ public class AaiController extends RestrictedBaseController { try { ObjectMapper objectMapper = new ObjectMapper(); List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator); if (response.getHttpCode() == 200) { responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK); @@ -618,7 +614,7 @@ public class AaiController extends RestrictedBaseController { try { - resp = aaiRestInterface.RestGet(fromAppId, transId, Unchecked.toURI(uri), xml).getResponse(); + resp = aaiRestInterface.RestGet(FROM_APP_ID, transId, Unchecked.toURI(uri), xml).getResponse(); } catch (WebApplicationException e) { final String message = e.getResponse().readEntity(String.class); @@ -647,7 +643,7 @@ public class AaiController extends RestrictedBaseController { Response resp = null; try { - resp = aaiRestInterface.RestPost(fromAppId, uri, payload, xml); + resp = aaiRestInterface.RestPost(FROM_APP_ID, uri, payload, xml); } catch (Exception e) { LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + e.toString()); 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/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java index a472268a3..8d5fbbdbb 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,10 +30,10 @@ 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; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.togglz.core.manager.FeatureManager; @@ -48,16 +48,12 @@ public class MsoConfig { } @Bean - public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){ + public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemPropertiesWrapper){ // Satisfy both interfaces -- MsoInterface and RestMsoImplementation return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty( - MsoProperties.MSO_SERVER_URL),httpsAuthClient); + MsoProperties.MSO_SERVER_URL),httpsAuthClient, systemPropertiesWrapper); } - @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/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..e00c2d7a5 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.*; @@ -41,11 +42,18 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.togglz.core.manager.FeatureManager; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + import javax.servlet.ServletContext; import java.io.File; import java.io.IOException; +@EnableSwagger2 @Configuration public class WebConfig { @@ -163,7 +171,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()); } @@ -192,4 +200,12 @@ public class WebConfig { } + @Bean + public Docket api(){ + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.onap.vid.controller.open")) + .paths(PathSelectors.any()) + .build(); + } } 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..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 @@ -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,27 +48,30 @@ 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) - SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) { - return externalWorkflowsService.getWorkflowParameterDefinitions(id); - } @RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET) LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) { 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/controller/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/HealthCheckController.java index 04d5babcc..92e1a1802 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/HealthCheckController.java @@ -18,11 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import org.onap.portalsdk.core.controller.UnRestrictedBaseController; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.controller.HealthStatus; import org.onap.vid.dao.FnAppDoaImpl; import org.onap.vid.model.GitRepositoryState; import org.springframework.beans.factory.annotation.Autowired; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/MaintenanceController.java index dfba4e31a..d1004401a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/MaintenanceController.java @@ -1,4 +1,4 @@ -package org.onap.vid.controller; +package org.onap.vid.controller.open; /*- * ============LICENSE_START======================================================= diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/RoleGeneratorController.java index 107142d7f..7b57df2c7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/RoleGeneratorController.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import static org.springframework.http.HttpStatus.OK; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/VersionController.java index aa15f0fa3..0a4d6f5ac 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/VersionController.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import com.fasterxml.jackson.core.type.TypeReference; 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 633acbcb8..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. @@ -21,7 +22,9 @@ 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; @@ -31,6 +34,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 +55,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); @@ -134,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 ec1c5479f..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,23 +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.WorkflowRequestDetail; 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; @@ -51,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; @@ -94,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"); @@ -181,6 +210,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"); @@ -380,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(); @@ -534,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) { @@ -818,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 31063c62b..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,8 +22,12 @@ 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; +import java.util.Map; + /** * Created by pickjonathan on 21/06/2017. */ @@ -111,6 +115,10 @@ 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); <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..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 @@ -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"; @@ -122,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/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java index e14ac0e11..17af75200 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java @@ -26,7 +26,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpException; import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; @@ -34,6 +33,7 @@ import org.onap.vid.client.HttpBasicClient; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.mso.rest.RestInterface; import org.onap.vid.utils.Logging; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; @@ -64,6 +64,7 @@ public class RestMsoImplementation implements RestInterface { protected HttpsAuthClient httpsAuthClient; + protected SystemPropertiesWrapper systemProperties; private static final String START_LOG = " start"; private static final String APPLICATION_JSON = "application/json"; @@ -80,8 +81,9 @@ public class RestMsoImplementation implements RestInterface { */ @Autowired - protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){ + protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties){ this.httpsAuthClient=httpsAuthClient; + this.systemProperties = systemProperties; } @SuppressWarnings("Duplicates") @@ -89,9 +91,9 @@ public class RestMsoImplementation implements RestInterface { { final String methodname = "initRestClient()"; - final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME); - final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD); - final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL); + final String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME); + final String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD); + final String mso_url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL); final String decrypted_password = Password.deobfuscate(password); String authString = username + ":" + decrypted_password; @@ -140,7 +142,7 @@ public class RestMsoImplementation implements RestInterface { try { restObject.set(t); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); @@ -179,7 +181,7 @@ public class RestMsoImplementation implements RestInterface { final String methodName = getMethodName(); logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz); - String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " sending request to url= " + url); MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); @@ -216,7 +218,7 @@ public class RestMsoImplementation implements RestInterface { try { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r); cres = client.target(url) .request() @@ -281,7 +283,7 @@ public class RestMsoImplementation implements RestInterface { public Invocation.Builder prepareClient(String path, String methodName) { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + " sending request to url= " + url); // Change the content length return client.target(url) @@ -307,7 +309,7 @@ public class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); userId.ifPresent(id->commonHeaders.put("X-RequestorID", Collections.singletonList(id))); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, httpMethod, url, payload); // Change the content length final Invocation.Builder restBuilder = client.target(url) @@ -369,7 +371,7 @@ public class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r); // Change the content length final Response cres = client.target(url) 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 b47981ecf..6a498fc01 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,7 +21,16 @@ 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; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; import org.apache.commons.codec.binary.Base64; import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -29,18 +38,19 @@ 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.*; +import org.onap.vid.model.SOWorkflowList; +import org.onap.vid.mso.MsoInterface; +import org.onap.vid.mso.MsoProperties; +import org.onap.vid.mso.MsoResponseWrapper; +import org.onap.vid.mso.MsoResponseWrapperInterface; +import org.onap.vid.mso.MsoUtil; +import org.onap.vid.mso.RestMsoImplementation; +import org.onap.vid.mso.RestObject; import org.onap.vid.utils.Logging; - -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import org.onap.vid.utils.SystemPropertiesWrapper; /** @@ -62,8 +72,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf */ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class); - public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) { - super(authClient); + public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper) { + super(authClient,systemPropertiesWrapper); this.client = client; this.baseUrl = baseUrl; this.commonHeaders = initCommonHeaders(); @@ -220,13 +230,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf return MsoUtil.wrapResponse(response); } - public MsoResponseWrapper getManualTasks(String endpoint) { - String path = baseUrl + endpoint; - - HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class); - return MsoUtil.wrapResponse(response); - } - + @Override public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) { String methodName = "getManualTasksByRequestId"; logger.debug(methodName + START); @@ -234,9 +238,10 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf try { String path = baseUrl + endpoint; - MsoResponseWrapper w =getManualTasks(path); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); + HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class); + MsoResponseWrapper w = MsoUtil.wrapResponse(response); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { @@ -444,6 +449,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); @@ -457,6 +476,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); @@ -501,8 +526,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf } private Map<String, String> initCommonHeaders() { - String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME); - String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD); + String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME); + String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD); String decrypted_password = Password.deobfuscate(password); String authString = username + ":" + decrypted_password; @@ -514,7 +539,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf map.put(HttpHeaders.AUTHORIZATION, "Basic " + authStringEnc); map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - map.put(X_FROM_APP_ID, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); + map.put(X_FROM_APP_ID, systemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId()); return ImmutableMap.copyOf(map); } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java deleted file mode 100644 index 1956d8a95..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java +++ /dev/null @@ -1,136 +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.List; - -public class Task { - - private String taskId; - private String type; - private String nfRole; - private String subscriptionServiceType; - private String originalRequestId; - private String originalRequestorId; - private String errorSource; - private String errorCode; - private String errorMessage; - private String buildingBlockName; - private String buildingBlockStep; - private List<String> validResponses; - - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getNfRole() { - return nfRole; - } - - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - - public String getSubscriptionServiceType() { - return subscriptionServiceType; - } - - public void setSubscriptionServiceType(String subscriptionServiceType) { - this.subscriptionServiceType = subscriptionServiceType; - } - - public String getOriginalRequestId() { - return originalRequestId; - } - - public void setOriginalRequestId(String originalRequestId) { - this.originalRequestId = originalRequestId; - } - - public String getOriginalRequestorId() { - return originalRequestorId; - } - - public void setOriginalRequestorId(String originalRequestorId) { - this.originalRequestorId = originalRequestorId; - } - - public String getErrorSource() { - return errorSource; - } - - public void setErrorSource(String errorSource) { - this.errorSource = errorSource; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getBuildingBlockName() { - return buildingBlockName; - } - - public void setBuildingBlockName(String buildingBlockName) { - this.buildingBlockName = buildingBlockName; - } - - public String getBuildingBlockStep() { - return buildingBlockStep; - } - - public void setBuildingBlockStep(String buildingBlockStep) { - this.buildingBlockStep = buildingBlockStep; - } - - public List<String> getValidResponses() { - return validResponses; - } - - public void setValidResponses(List<String> validResponses) { - this.validResponses = validResponses; - } -} 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 new file mode 100644 index 000000000..7d2a41a6a --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt @@ -0,0 +1,46 @@ +/*- + * ============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 + +data class Task( + var taskId: String?, + var type: String?, + var nfRole: String?, + var subscriptionServiceType: String?, + var originalRequestId: String?, + var originalRequestorId: String?, + var errorSource: String?, + var errorCode: String?, + 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 + ) +} diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java new file mode 100644 index 000000000..4e5340fc2 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.roles; + +public class AlwaysValidRoleValidator implements RoleValidator { + + AlwaysValidRoleValidator() { + // package visibility, only for RoleValidator's factory + } + + @Override + public boolean isSubscriberPermitted(String subscriberName) { + return true; + } + + @Override + public boolean isServicePermitted(String subscriberName, String serviceType) { + return true; + } + + @Override + public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { + return true; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java index d3d2b80e2..6c0fd3f52 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java @@ -24,6 +24,14 @@ package org.onap.vid.roles; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.joshworks.restclient.http.HttpResponse; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.web.support.UserUtils; import org.onap.vid.aai.exceptions.RoleParsingException; @@ -34,11 +42,6 @@ import org.onap.vid.services.AaiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - /** * Created by Oren on 7/1/17. @@ -159,7 +162,7 @@ public class RoleProvider { } public RoleValidator getUserRolesValidator(HttpServletRequest request) { - return new RoleValidator(getUserRoles(request)); + return RoleValidator.by(getUserRoles(request)); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java index 315e22dd7..d37477610 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java @@ -3,13 +3,14 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 - 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,70 +21,24 @@ package org.onap.vid.roles; -import org.onap.vid.mso.rest.RequestDetails; - import java.util.List; -import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.onap.portalsdk.core.util.SystemProperties; -/** - * Created by Oren on 7/12/17. - */ -public class RoleValidator { +public interface RoleValidator { - private boolean disableRoles = true; - private List<Role> userRoles; + static RoleValidator by(List<Role> roles) { + boolean disableRoles = + StringUtils.equals(SystemProperties.getProperty("role_management_activated"), "false"); - public RoleValidator(List<Role> roles) { - this.userRoles = roles; + return disableRoles + ? new AlwaysValidRoleValidator() + : new RoleValidatorByRoles(roles); } - public boolean isSubscriberPermitted(String subscriberName) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(subscriberName)) - return true; - } - return false; - } - - public boolean isServicePermitted(String subscriberName, String serviceType) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) - return true; - } - return false; - } + boolean isSubscriberPermitted(String subscriberName); - public boolean isMsoRequestValid(RequestDetails mso_request) { - if (this.disableRoles) return true; + boolean isServicePermitted(String subscriberName, String serviceType); - try { - String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); - String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType"); - return isServicePermitted(globalSubscriberIdRequested, serviceType); - } catch (Exception e) { - //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso - return true; - } - } - - public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(globalCustomerId) - && role.getServiceType().equals(serviceType) - && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) { - return true; - } - } - return false; - } - - void enableRoles() { - this.disableRoles = false; - } + boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName); } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java new file mode 100644 index 000000000..ad5b519c4 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java @@ -0,0 +1,80 @@ +/*- + * ============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.roles; + +import java.util.List; +import java.util.Map; +import org.onap.vid.mso.rest.RequestDetails; + +public class RoleValidatorByRoles implements RoleValidator { + + private final List<Role> userRoles; + + RoleValidatorByRoles(List<Role> roles) { + this.userRoles = roles; + } + + @Override + public boolean isSubscriberPermitted(String subscriberName) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName)) { + return true; + } + } + return false; + } + + @Override + public boolean isServicePermitted(String subscriberName, String serviceType) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) { + return true; + } + } + return false; + } + + @Override + public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(globalCustomerId) + && role.getServiceType().equals(serviceType) + && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) { + return true; + } + } + return false; + } + + boolean isMsoRequestValid(RequestDetails msoRequest) { + try { + String globalSubscriberIdRequested = (String) ((Map) ((Map) msoRequest.getAdditionalProperties() + .get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); + String serviceType = (String) ((Map) ((Map) msoRequest.getAdditionalProperties().get("requestDetails")) + .get("requestParameters")).get("subscriptionServiceType"); + return isServicePermitted(globalSubscriberIdRequested, serviceType); + } catch (Exception e) { + //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso + return true; + } + } + +} 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..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 vnfName); - SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId); +public interface ExternalWorkflowsService { + List<SOWorkflow> getWorkflows(String vnfModelId); } 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..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 vnfName) { - MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfName); - validateSOResponse(msoResponse, SOWorkflows.class); - return convertMsoResponseToWorkflowList(msoResponse); - } + public List<SOWorkflow> getWorkflows(String vnfModelId) { + 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; - } - } - } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java index 097b05e58..cbc79e86f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java @@ -20,6 +20,7 @@ package org.onap.vid.services; +import java.util.List; import org.onap.vid.model.Workflow; import org.springframework.stereotype.Service; @@ -31,29 +32,27 @@ import java.util.stream.Collectors; @Service public class WorkflowServiceImpl implements WorkflowService { //TODO: Add the list of workflows hard coded or from DB. - private ArrayList<Workflow> workflows = new ArrayList<>(Arrays.asList( + private List<Workflow> workflows = Arrays.asList( new Workflow(0, "Upgrade", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3", "VNF4"))), new Workflow(1, "Clean", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3"))), new Workflow(2, "Reinstall", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF4"))), new Workflow(3, "Dump", new ArrayList<>(Arrays.asList("VNF1", "VNF3", "VNF4"))), new Workflow(4, "Flush", new ArrayList<>(Arrays.asList("VNF2", "VNF3", "VNF4"))) - )); + ); @Override public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) { - Collection<String> result = workflows.stream() + return workflows.stream() .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames)) - .map(workflow -> workflow.getWorkflowName()) + .map(Workflow::getWorkflowName) .distinct() .collect(Collectors.toList()); - - return result; } @Override public Collection<String> getAllWorkflows() { return workflows.stream() - .map(workflow -> workflow.getWorkflowName()) + .map(Workflow::getWorkflowName) .distinct() .collect(Collectors.toList()); } |