diff options
Diffstat (limited to 'bpmn')
12 files changed, 178 insertions, 95 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index dd993bca51..078317885c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -20,9 +20,8 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import java.util.HashMap; +import java.util.Map; import java.util.Objects; -import java.util.Optional; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -35,8 +34,7 @@ public class DmaapClientTestImpl implements DmaapClient { private Runnable informConsumer; @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, - Optional<HashMap<String, String>> updateInfo) { + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo) { this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 2ababac7e3..a55f32aaaa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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,14 +21,12 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; +import java.util.Map; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.camunda.bpm.engine.runtime.Execution; -import org.onap.aai.domain.yang.v13.Metadatum; import org.onap.so.bpmn.common.recipe.ResourceInput; import org.onap.so.bpmn.common.resource.ResourceRequestBuilder; -import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +38,7 @@ import java.util.Optional; @Component public class InformDmaapClient implements JavaDelegate { - private Logger logger = LoggerFactory.getLogger(getClass()); + private static final Logger LOGGER = LoggerFactory.getLogger(InformDmaapClient.class); private DmaapClient dmaapClient; @Override @@ -47,25 +46,34 @@ public class InformDmaapClient implements JavaDelegate { String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID); RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); String processBusinessKey = execution.getProcessBusinessKey(); - HashMap<String, String> updateInfo = createUpdateInfo(execution); - updateInfo.put("pnfCorrelationId", pnfCorrelationId); - dmaapClient - .registerForUpdate(pnfCorrelationId, - () -> runtimeService.createMessageCorrelation("WorkflowMessage") - .processInstanceBusinessKey(processBusinessKey).correlateWithResult(), - Optional.of(updateInfo)); + dmaapClient.registerForUpdate(pnfCorrelationId, + () -> runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(processBusinessKey).correlateWithResult(), + createUpdateInfoMap(execution)); } - private HashMap<String, String> createUpdateInfo(DelegateExecution execution) { - HashMap<String, String> map = new HashMap(); - - ResourceInput resourceInputObj = ResourceRequestBuilder + private Map<String, String> createUpdateInfoMap(DelegateExecution execution) { + Map<String, String> updateInfoMap = new HashMap<>(); + updateInfoMap.put("pnfCorrelationId", + (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID)); + getResourceInput(execution).ifPresent(resourceInput -> { + updateInfoMap.put("globalSubscriberID", resourceInput.getGlobalSubscriberId()); + updateInfoMap.put("serviceType", resourceInput.getServiceType()); + updateInfoMap.put("serviceInstanceId", resourceInput.getServiceInstanceId()); + }); + return updateInfoMap; + } - .getJsonObject((String) execution.getVariable("resourceInput"), ResourceInput.class); - map.put("globalSubscriberID", resourceInputObj.getGlobalSubscriberId()); - map.put("serviceType", resourceInputObj.getServiceType()); - map.put("serviceInstanceId", resourceInputObj.getServiceInstanceId()); - return map; + private Optional<ResourceInput> getResourceInput(DelegateExecution execution) { + ResourceInput resourceInput = null; + if (execution.getVariable("resourceInput") != null) { + resourceInput = ResourceRequestBuilder.getJsonObject((String) execution.getVariable("resourceInput"), + ResourceInput.class); + } else { + LOGGER.warn("resourceInput value is null for correlation id: {}", + execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID)); + } + return Optional.ofNullable(resourceInput); } @Autowired diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java index d513684659..bafb749e15 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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,13 +21,11 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; -import java.util.HashMap; -import java.util.Optional; +import java.util.Map; public interface DmaapClient { - void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, - Optional<HashMap<String, String>> updateInfo); + void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo); Runnable unregister(String pnfCorrelationId); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 48061db887..02303a6b23 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -54,8 +54,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private int topicListenerDelayInSeconds; private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; - - public volatile List<HashMap<String, String>> updateInfoMap; + private volatile List<Map<String, String>> listOfUpdateInfoMap; @Autowired public PnfEventReadyDmaapClient(Environment env) { @@ -68,18 +67,15 @@ public class PnfEventReadyDmaapClient implements DmaapClient { .port(env.getProperty("pnf.dmaap.port", Integer.class)).path(env.getProperty("pnf.dmaap.topicName")) .path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId")) .build()); - updateInfoMap = new ArrayList<>(); + listOfUpdateInfoMap = new ArrayList<>(); } @Override public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, - Optional<HashMap<String, String>> updateInfo) { + Map<String, String> updateInfo) { logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); - HashMap<String, String> map = updateInfo.get(); - if (map != null && map.size() > 0) { - synchronized (updateInfoMap) { - updateInfoMap.add(map); - } + synchronized (listOfUpdateInfoMap) { + listOfUpdateInfoMap.add(updateInfo); } pnfCorrelationIdToThreadMap.put(pnfCorrelationId, informConsumer); if (!dmaapThreadListenerIsRunning) { @@ -91,14 +87,14 @@ public class PnfEventReadyDmaapClient implements DmaapClient { public synchronized Runnable unregister(String pnfCorrelationId) { logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); - synchronized (updateInfoMap) { - for (int i = updateInfoMap.size() - 1; i >= 0; i--) { - if (!updateInfoMap.get(i).containsKey("pnfCorrelationId")) + synchronized (listOfUpdateInfoMap) { + for (int i = listOfUpdateInfoMap.size() - 1; i >= 0; i--) { + if (!listOfUpdateInfoMap.get(i).containsKey("pnfCorrelationId")) continue; - String id = updateInfoMap.get(i).get("pnfCorrelationId"); + String id = listOfUpdateInfoMap.get(i).get("pnfCorrelationId"); if (id != pnfCorrelationId) continue; - updateInfoMap.remove(i); + listOfUpdateInfoMap.remove(i); } } if (pnfCorrelationIdToThreadMap.isEmpty()) { @@ -174,8 +170,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient { String customerId = null; String serviceType = null; String serId = null; - synchronized (updateInfoMap) { - for (HashMap<String, String> map : updateInfoMap) { + synchronized (listOfUpdateInfoMap) { + for (Map<String, String> map : listOfUpdateInfoMap) { if (!map.containsKey("pnfCorrelationId")) continue; if (pnfCorrelationId != map.get("pnfCorrelationId")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index 2634f03d4b..598582bfd8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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,10 +21,9 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; +import java.util.Map; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; -import java.util.HashMap; import java.util.Objects; -import java.util.Optional; public class DmaapClientTestImpl implements DmaapClient { @@ -31,8 +31,7 @@ public class DmaapClientTestImpl implements DmaapClient { private Runnable informConsumer; @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, - Optional<HashMap<String, String>> updateInfo) { + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo) { this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 127d21c0ed..3bf9720036 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -60,6 +60,7 @@ public class AppcRunTasks { public static final String ROLLBACK_VNF_STOP = "rollbackVnfStop"; public static final String ROLLBACK_VNF_LOCK = "rollbackVnfLock"; public static final String ROLLBACK_QUIESCE_TRAFFIC = "rollbackQuiesceTraffic"; + public static final String CONTROLLER_TYPE_DEFAULT = "APPC"; @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -139,7 +140,12 @@ public class AppcRunTasks { ControllerSelectionReference controllerSelectionReference = catalogDbClient .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString()); - String controllerType = controllerSelectionReference.getControllerName(); + String controllerType = null; + if (controllerSelectionReference != null) { + controllerType = controllerSelectionReference.getControllerName(); + } else { + controllerType = CONTROLLER_TYPE_DEFAULT; + } String vfModuleId = null; VfModule vfModule = null; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 8822bc39dd..64f0072991 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -153,16 +153,6 @@ public class OrchestrationStatusValidator { .getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction()); - if (aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) - && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) - && OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) { - org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = - extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution, - previousOrchestrationStatusValidationResult, genericVnf, - orchestrationStatusStateTransitionDirective); - } - if (orchestrationStatusStateTransitionDirective .getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) { throw new OrchestrationStatusValidationException( @@ -187,23 +177,4 @@ public class OrchestrationStatusValidator { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e); } } - - private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate( - BuildingBlockExecution execution, - OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult, - org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf, - OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) { - if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult - .equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) { - String multiStageDesign = MULTI_STAGE_DESIGN_OFF; - if (genericVnf.getModelInfoGenericVnf() != null) { - multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign(); - } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - } - } - return orchestrationStatusStateTransitionDirective; - } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java index e24e86285c..9af2128f63 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java @@ -7,9 +7,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. @@ -33,11 +33,16 @@ import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse; import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest; import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.client.adapter.rest.AdapterRestClient; +import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class VnfAdapterClientImpl implements VnfAdapterClient { + private static final Logger logger = LoggerFactory.getLogger(VnfAdapterClientImpl.class); + private static final String VF_MODULES = "/vf-modules/"; private VnfAdapterRestProperties props; @@ -57,6 +62,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req, CreateVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in createVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -69,6 +75,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req, RollbackVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in rollbackVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -80,6 +87,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) .delete(req, DeleteVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in deleteVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -91,6 +99,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) .put(req, UpdateVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in updateVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -122,6 +131,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON).get(QueryVfModuleResponse.class).get(); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in queryVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java index 2af4d5f1fa..c5e8bf7416 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java @@ -7,9 +7,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. @@ -34,11 +34,15 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.client.RestClient; import org.onap.so.client.adapter.rest.AdapterRestClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { + private static final Logger logger = LoggerFactory.getLogger(VnfVolumeAdapterClientImpl.class); + private final VnfVolumeAdapterRestProperties props; public VnfVolumeAdapterClientImpl() { @@ -50,6 +54,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in createVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -60,6 +65,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in deleteVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -71,6 +77,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req, RollbackVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in rollbackVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -81,6 +88,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in updateVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -94,6 +102,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { requestId, serviceInstanceId); return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get(); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in queryVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java index 6daed56675..6278d48e03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java @@ -23,10 +23,10 @@ package org.onap.so.client.adapter.vnf.mapper; import java.io.Serializable; public class AttributeNameValue implements Serializable { - private final static long serialVersionUID = -5215028275587848311L; + private static final long serialVersionUID = -5215028275587848311L; private String attributeName; - private Object attributeValue; + private transient Object attributeValue; public AttributeNameValue(String attributeName, Object attributeValue) { this.attributeName = attributeName; @@ -51,7 +51,7 @@ public class AttributeNameValue implements Serializable { @Override public String toString() { - return new StringBuilder().append("{\"attribute_name\": \"").append(attributeName.toString()) + return new StringBuilder().append("{\"attribute_name\": \"").append(attributeName) .append("\", \"attribute_value\": \"").append(attributeValue.toString()).append("\"}").toString(); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 5c69987a54..8c13c9be97 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -33,7 +33,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; @@ -76,10 +75,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.onap.so.entity.MsoRequest; import org.onap.so.jsonpath.JsonPathUtil; import org.onap.so.openstack.utils.MsoMulticloudUtils; -import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -481,7 +480,7 @@ public class VnfAdapterVfModuleObjectMapper { } } sbInterfaceRoutePrefixes.append("]"); - if (interfaceRoutePrefixesList.size() > 0) { + if (!interfaceRoutePrefixesList.isEmpty()) { paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes", sbInterfaceRoutePrefixes.toString()); } @@ -508,7 +507,7 @@ public class VnfAdapterVfModuleObjectMapper { sriovFilterBuf.append(heatVlanFilterValue); } } - if (heatVlanFiltersList.size() > 0) { + if (!heatVlanFiltersList.isEmpty()) { paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString()); } } @@ -540,7 +539,7 @@ public class VnfAdapterVfModuleObjectMapper { String ipVersion = ipAddress.getIpVersion(); for (int b = 0; b < ipsList.size(); b++) { String ipAddressValue = ipsList.get(b); - if (ipVersion.equals("ipv4")) { + if ("ipv4".equals(ipVersion)) { if (b != ipsList.size() - 1) { sbIpv4Ips.append(ipAddressValue + ","); } else { @@ -548,7 +547,7 @@ public class VnfAdapterVfModuleObjectMapper { } paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue); - } else if (ipVersion.equals("ipv6")) { + } else if ("ipv6".equals(ipVersion)) { if (b != ipsList.size() - 1) { sbIpv6Ips.append(ipAddressValue + ","); } else { @@ -897,6 +896,7 @@ public class VnfAdapterVfModuleObjectMapper { try { json = mapper.writeValueAsString(obj); } catch (JsonProcessingException e) { + logger.error("JsonProcessingException in convertToString", e); json = "{}"; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index b371e3a48a..ffe48876c4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -50,7 +51,6 @@ import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.springframework.beans.factory.annotation.Autowired; -@Ignore public class OrchestrationStatusValidatorTest extends BaseTaskTest { @InjectMocks protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); @@ -72,6 +72,13 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = + new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); @@ -115,6 +122,13 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))) + .thenReturn(configuration); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -134,6 +148,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.getVariable("orchestrationStatusValidationResult")); } + @Ignore @Test public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception { expectedException.expect(BpmnError.class); @@ -147,6 +162,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); } + @Ignore @Test public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception { expectedException.expect(BpmnError.class); @@ -178,6 +194,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); } + @Ignore @Test public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception { expectedException.expect(BpmnError.class); @@ -228,8 +245,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); - assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, - execution.getVariable("orchestrationStatusValidationResult")); + assertNull(execution.getVariable("orchestrationStatusValidationResult")); } @Test @@ -247,6 +263,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); buildingBlockDetail.setId(1); @@ -257,7 +279,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); orchestrationStatusStateTransitionDirective.setId(1); orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); @@ -288,6 +310,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); buildingBlockDetail.setId(1); @@ -338,6 +366,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -380,6 +414,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -422,6 +462,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -464,6 +510,12 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); orchestrationStatusStateTransitionDirective @@ -482,4 +534,39 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); } + + @Test + public void continueValidationActivatedTest() throws Exception { + String flowToBeCalled = "DeactivateVnfBB"; + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName(flowToBeCalled); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); + buildingBlockDetail.setTargetAction(OrchestrationAction.DEACTIVATE); + when(catalogDbClient.getBuildingBlockDetail(flowToBeCalled)).thenReturn(buildingBlockDetail); + + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); + orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); + orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.DEACTIVATE); + doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) + .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ACTIVATED, + OrchestrationAction.DEACTIVATE); + + execution.setVariable("aLaCarte", true); + execution.setVariable("flowToBeCalled", flowToBeCalled); + orchestrationStatusValidator.validateOrchestrationStatus(execution); + + assertEquals(OrchestrationStatusValidationDirective.CONTINUE, + execution.getVariable("orchestrationStatusValidationResult")); + } } |