1 package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
3 import com.fasterxml.jackson.core.JsonProcessingException;
4 import org.camunda.bpm.engine.delegate.DelegateExecution;
5 import org.javatuples.Pair;
6 import org.onap.aai.domain.yang.Relationship;
7 import org.onap.aai.domain.yang.ServiceInstance;
8 import org.onap.aai.domain.yang.VpnBinding;
9 import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
10 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
11 import org.onap.aaiclient.client.aai.entities.Relationships;
12 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
13 import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
14 import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException;
15 import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
16 import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
17 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
18 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
19 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
20 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
21 import org.onap.so.client.exception.ExceptionBuilder;
22 import org.onap.so.client.orchestration.AAIConfigurationResources;
23 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
24 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
25 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
26 import org.onap.so.db.catalog.beans.InstanceGroup;
27 import org.onap.so.db.catalog.client.CatalogDbClient;
28 import org.onap.so.serviceinstancebeans.ModelType;
29 import org.onap.so.serviceinstancebeans.RelatedInstance;
30 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.stereotype.Component;
34 import java.io.IOException;
35 import java.util.ArrayList;
36 import java.util.List;
38 import java.util.Optional;
39 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
40 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
41 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
42 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
43 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
44 import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
48 public class ServiceEBBLoader {
50 private static final Logger logger = LoggerFactory.getLogger(ServiceEBBLoader.class);
52 private final UserParamsServiceTraversal userParamsServiceTraversal;
53 private final CatalogDbClient catalogDbClient;
54 private final VrfValidation vrfValidation;
55 private final AAIConfigurationResources aaiConfigurationResources;
56 private final WorkflowActionExtractResourcesAAI workflowActionUtils;
57 private final BBInputSetupUtils bbInputSetupUtils;
58 private final BBInputSetup bbInputSetup;
59 private final ExceptionBuilder exceptionBuilder;
61 public ServiceEBBLoader(UserParamsServiceTraversal userParamsServiceTraversal, CatalogDbClient catalogDbClient,
62 VrfValidation vrfValidation, AAIConfigurationResources aaiConfigurationResources,
63 WorkflowActionExtractResourcesAAI workflowActionUtils, BBInputSetupUtils bbInputSetupUtils,
64 BBInputSetup bbInputSetup, ExceptionBuilder exceptionBuilder) {
65 this.userParamsServiceTraversal = userParamsServiceTraversal;
66 this.catalogDbClient = catalogDbClient;
67 this.vrfValidation = vrfValidation;
68 this.aaiConfigurationResources = aaiConfigurationResources;
69 this.workflowActionUtils = workflowActionUtils;
70 this.bbInputSetupUtils = bbInputSetupUtils;
71 this.bbInputSetup = bbInputSetup;
72 this.exceptionBuilder = exceptionBuilder;
75 public List<Resource> getResourceListForService(ServiceInstancesRequest sIRequest, String requestAction,
76 DelegateExecution execution, String serviceInstanceId, String resourceId,
77 List<Pair<WorkflowType, String>> aaiResourceIds) throws IOException, VrfBondingServiceException {
78 boolean containsService = false;
79 List<Resource> resourceList = new ArrayList<>();
80 List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
81 if (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
82 // SERVICE-MACRO-ASSIGN will always get user params with a
85 if (userParams != null) {
86 containsService = isContainsService(sIRequest);
87 if (containsService) {
88 resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
89 serviceInstanceId, requestAction);
92 buildAndThrowException(execution,
93 "Service-Macro-Assign request details must contain user params with a service");
95 } else if (requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
96 // SERVICE-MACRO-CREATE will get user params with a service,
97 // a service with a network, a service with a
98 // network collection, OR an empty service.
99 // If user params is just a service or null and macro
100 // queries the SI and finds a VNF, macro fails.
102 if (userParams != null) {
103 containsService = isContainsService(sIRequest);
105 if (containsService) {
106 resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
107 serviceInstanceId, requestAction);
109 if (!foundRelated(resourceList)) {
110 traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
112 } else if (("activateInstance".equalsIgnoreCase(requestAction)
113 || "unassignInstance".equalsIgnoreCase(requestAction)
114 || "deleteInstance".equalsIgnoreCase(requestAction)
115 || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
116 // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
117 // SERVICE-MACRO-DELETE
118 // Will never get user params with service, macro will have
119 // to query the SI in AAI to find related instances.
120 traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
121 } else if ("deactivateInstance".equalsIgnoreCase(requestAction)) {
122 resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
127 private boolean isContainsService(ServiceInstancesRequest sIRequest) {
128 boolean containsService;
129 List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
130 containsService = userParams.stream().anyMatch(param -> param.containsKey(USER_PARAM_SERVICE));
131 return containsService;
134 public void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest,
135 List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds)
136 throws JsonProcessingException, VrfBondingServiceException {
137 String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId();
138 org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID);
140 if (service == null) {
141 buildAndThrowException(execution, "Could not find the service model in catalog db.");
143 resourceList.add(new Resource(WorkflowType.SERVICE, service.getModelUUID(), false));
144 RelatedInstance relatedVpnBinding =
145 bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.vpnBinding);
146 RelatedInstance relatedLocalNetwork =
147 bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.network);
149 if (relatedVpnBinding != null && relatedLocalNetwork != null) {
150 traverseVrfConfiguration(aaiResourceIds, resourceList, service, relatedVpnBinding, relatedLocalNetwork);
152 traverseNetworkCollection(execution, resourceList, service);
157 public boolean foundRelated(List<Resource> resourceList) {
158 return (containsWorkflowType(resourceList, WorkflowType.VNF)
159 || containsWorkflowType(resourceList, WorkflowType.PNF)
160 || containsWorkflowType(resourceList, WorkflowType.NETWORK)
161 || containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION));
164 public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId,
165 List<Pair<WorkflowType, String>> aaiResourceIds) {
167 ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
168 org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
169 bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
170 resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
171 traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO);
172 traverseServiceInstanceMSOPnfs(resourceList, aaiResourceIds, serviceInstanceMSO);
173 if (serviceInstanceMSO.getNetworks() != null) {
174 for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
176 aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
177 resourceList.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false));
180 if (serviceInstanceMSO.getCollection() != null) {
181 logger.debug("found networkcollection");
183 .add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
184 resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
185 serviceInstanceMSO.getCollection().getId(), false));
187 if (serviceInstanceMSO.getConfigurations() != null) {
188 for (Configuration config : serviceInstanceMSO.getConfigurations()) {
189 Optional<org.onap.aai.domain.yang.Configuration> aaiConfig =
190 aaiConfigurationResources.getConfiguration(config.getConfigurationId());
191 if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
192 for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
193 if (relationship.getRelatedTo().contains("vnfc")
194 || relationship.getRelatedTo().contains("vpn-binding")) {
195 aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
197 new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false));
204 } catch (Exception ex) {
205 logger.error("Exception in traverseAAIService", ex);
206 buildAndThrowException(execution,
207 "Could not find existing Service Instance or related Instances to execute the request on.");
211 private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList,
212 List<Pair<WorkflowType, String>> aaiResourceIds,
213 org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
214 if (serviceInstanceMSO.getVnfs() == null) {
217 for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
218 aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
219 resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
220 traverseVnfModules(resourceList, aaiResourceIds, vnf);
221 if (vnf.getVolumeGroups() != null) {
222 for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
223 aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
224 resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
230 private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList,
231 List<Pair<WorkflowType, String>> aaiResourceIds,
232 org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
233 if (serviceInstanceMSO.getPnfs() == null) {
236 for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) {
237 aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId()));
238 resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false));
242 protected void traverseVrfConfiguration(List<Pair<WorkflowType, String>> aaiResourceIds,
243 List<Resource> resourceList, org.onap.so.db.catalog.beans.Service service,
244 RelatedInstance relatedVpnBinding, RelatedInstance relatedLocalNetwork)
245 throws VrfBondingServiceException, JsonProcessingException {
246 org.onap.aai.domain.yang.L3Network aaiLocalNetwork =
247 bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId());
248 vrfValidation.vrfServiceValidation(service);
249 vrfValidation.vrfCatalogDbChecks(service);
250 vrfValidation.aaiVpnBindingValidation(relatedVpnBinding.getInstanceId(),
251 bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId()));
252 vrfValidation.aaiNetworkValidation(relatedLocalNetwork.getInstanceId(), aaiLocalNetwork);
253 vrfValidation.aaiSubnetValidation(aaiLocalNetwork);
254 vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork);
255 vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork);
256 String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork);
257 if (existingAAIVrfConfiguration != null) {
258 aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration));
260 resourceList.add(new Resource(WorkflowType.CONFIGURATION,
261 service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false));
265 protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceList,
266 org.onap.so.db.catalog.beans.Service service) {
267 if (isVnfCustomizationsInTheService(service)) {
268 buildAndThrowException(execution,
269 "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows");
271 if (isPnfCustomizationsInTheService(service)) {
272 buildAndThrowException(execution,
273 "Cannot orchestrate Service-Macro-Create without user params with a pnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows");
275 List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
276 if (customizations.isEmpty()) {
277 logger.debug("No Collections found. CollectionResourceCustomization list is empty.");
279 CollectionResourceCustomization collectionResourceCustomization =
280 findCatalogNetworkCollection(execution, service);
281 traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization);
283 traverseNetworkCollectionCustomization(resourceList, service);
286 private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList,
287 CollectionResourceCustomization collectionResourceCustomization) {
288 if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, collectionResourceCustomization))
291 org.onap.so.db.catalog.beans.InstanceGroup instanceGroup =
292 collectionResourceCustomization.getCollectionResource().getInstanceGroup();
293 CollectionResourceInstanceGroupCustomization collectionInstCust = null;
294 if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) {
295 for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup
296 .getCollectionInstanceGroupCustomizations()) {
297 if (collectionInstanceGroupTemp.getModelCustomizationUUID()
298 .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
299 collectionInstCust = collectionInstanceGroupTemp;
303 if (interfaceNetworkQuantityIsAvailableInCollection(collectionInstCust)) {
304 minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
307 logger.debug("minNetworks: {}", minNetworks);
308 CollectionNetworkResourceCustomization collectionNetworkResourceCust =
309 getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup);
310 for (int i = 0; i < minNetworks; i++) {
311 if (collectionNetworkResourceCust != null) {
312 Resource resource = new Resource(WorkflowType.VIRTUAL_LINK,
313 collectionNetworkResourceCust.getModelCustomizationUUID(), false);
314 resource.setVirtualLinkKey(Integer.toString(i));
315 resourceList.add(resource);
320 private CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomization(
321 CollectionResourceCustomization collectionResourceCustomization, InstanceGroup instanceGroup) {
322 CollectionNetworkResourceCustomization collectionNetworkResourceCust = null;
323 for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup
324 .getCollectionNetworkResourceCustomizations()) {
325 if (collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID()
326 .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
327 collectionNetworkResourceCust = collectionNetworkTemp;
331 return collectionNetworkResourceCust;
334 private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList,
335 CollectionResourceCustomization collectionResourceCustomization) {
336 if (collectionResourceCustomization == null) {
337 logger.debug("No Network Collection Customization found");
340 resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
341 collectionResourceCustomization.getModelCustomizationUUID(), false));
342 logger.debug("Found a network collection");
343 if (collectionResourceCustomization.getCollectionResource() == null) {
344 logger.debug("No Network Collection found. collectionResource is null");
347 if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() == null) {
348 logger.debug("No Instance Group found for network collection.");
351 String toscaNodeType =
352 collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType();
353 if (!toscaNodeTypeHasNetworkCollection(toscaNodeType)) {
354 logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", toscaNodeType);
360 private boolean interfaceNetworkQuantityIsAvailableInCollection(
361 CollectionResourceInstanceGroupCustomization collectionInstCust) {
362 return collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null;
365 private boolean toscaNodeTypeHasNetworkCollection(String toscaNodeType) {
366 return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION);
369 private void traverseNetworkCollectionCustomization(List<Resource> resourceList,
370 org.onap.so.db.catalog.beans.Service service) {
371 if (isNetworkCollectionInTheResourceList(resourceList)) {
374 if (service.getNetworkCustomizations() == null) {
375 logger.debug("No networks were found on this service model");
378 for (int i = 0; i < service.getNetworkCustomizations().size(); i++) {
379 resourceList.add(new Resource(WorkflowType.NETWORK,
380 service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false));
384 private boolean isVnfCustomizationsInTheService(org.onap.so.db.catalog.beans.Service service) {
385 return !(service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty());
388 private boolean isPnfCustomizationsInTheService(org.onap.so.db.catalog.beans.Service service) {
389 return !(service.getPnfCustomizations() == null || service.getPnfCustomizations().isEmpty());
392 private void traverseVnfModules(List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds,
393 org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) {
394 if (vnf.getVfModules() == null) {
397 for (VfModule vfModule : vnf.getVfModules()) {
398 aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
399 Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false);
400 resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean());
401 resourceList.add(resource);
406 protected String getExistingAAIVrfConfiguration(RelatedInstance relatedVpnBinding,
407 org.onap.aai.domain.yang.L3Network aaiLocalNetwork)
408 throws JsonProcessingException, VrfBondingServiceException {
409 Optional<Relationships> relationshipsOp = new AAIResultWrapper(
410 new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiLocalNetwork)).getRelationships();
411 if (relationshipsOp.isPresent()) {
412 List<AAIResultWrapper> configurationsRelatedToLocalNetwork =
413 relationshipsOp.get().getByType(AAIFluentTypeBuilder.Types.CONFIGURATION);
414 if (configurationsRelatedToLocalNetwork.size() > 1) {
415 throw new VrfBondingServiceException(
416 "Network: " + aaiLocalNetwork.getNetworkId() + " has more than 1 configuration related to it");
418 if (configurationsRelatedToLocalNetwork.size() == 1) {
419 AAIResultWrapper configWrapper = configurationsRelatedToLocalNetwork.get(0);
420 Optional<Configuration> relatedConfiguration = configWrapper.asBean(Configuration.class);
421 if (relatedConfiguration.isPresent() && vrfConfigurationAlreadyExists(relatedVpnBinding,
422 relatedConfiguration.get(), configWrapper)) {
423 return relatedConfiguration.get().getConfigurationId();
430 protected boolean vrfConfigurationAlreadyExists(RelatedInstance relatedVpnBinding, Configuration vrfConfiguration,
431 AAIResultWrapper configWrapper) throws VrfBondingServiceException {
432 if ("VRF-ENTRY".equalsIgnoreCase(vrfConfiguration.getConfigurationType())) {
433 Optional<Relationships> relationshipsConfigOp = configWrapper.getRelationships();
434 if (relationshipsConfigOp.isPresent()) {
435 Optional<VpnBinding> relatedInfraVpnBindingOp =
436 workflowActionUtils.extractRelationshipsVpnBinding(relationshipsConfigOp.get());
437 if (relatedInfraVpnBindingOp.isPresent()) {
438 VpnBinding relatedInfraVpnBinding = relatedInfraVpnBindingOp.get();
439 if (!relatedInfraVpnBinding.getVpnId().equalsIgnoreCase(relatedVpnBinding.getInstanceId())) {
440 throw new VrfBondingServiceException("Configuration: " + vrfConfiguration.getConfigurationId()
441 + " is not connected to the same vpn binding id provided in request: "
442 + relatedVpnBinding.getInstanceId());
452 public boolean containsWorkflowType(List<Resource> resourceList, WorkflowType workflowType) {
453 return resourceList.stream().anyMatch(resource -> resource.getResourceType().equals(workflowType));
456 public boolean isNetworkCollectionInTheResourceList(List<Resource> resourceList) {
457 return resourceList.stream().anyMatch(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType());
460 public CollectionResourceCustomization findCatalogNetworkCollection(DelegateExecution execution,
461 org.onap.so.db.catalog.beans.Service service) {
462 CollectionResourceCustomization networkCollection = null;
464 for (CollectionResourceCustomization collectionCust : service.getCollectionResourceCustomizations()) {
465 if (catalogDbClient.getNetworkCollectionResourceCustomizationByID(
466 collectionCust.getModelCustomizationUUID()) != null) {
467 networkCollection = collectionCust;
473 } else if (count > 1) {
474 buildAndThrowException(execution,
475 "Found multiple Network Collections in the Service model, only one per Service is supported.");
477 return networkCollection;
480 protected void buildAndThrowException(DelegateExecution execution, String msg) {
482 execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
483 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);