diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java')
4 files changed, 74 insertions, 52 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 0fd38badad..bfa77212c4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -34,14 +34,36 @@ import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.javatuples.Pair; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -52,12 +74,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -1044,7 +1060,8 @@ public class BBInputSetup implements JavaDelegate { protected ServiceSubscription getServiceSubscriptionFromURI(String resourceId, Customer customer) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String subscriptionServiceType = uriKeys.get("service-type"); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI = bbInputSetupUtils.getAAIServiceSubscription(customer.getGlobalCustomerId(), subscriptionServiceType); if (serviceSubscriptionAAI != null) { @@ -1056,7 +1073,7 @@ public class BBInputSetup implements JavaDelegate { protected Customer getCustomerFromURI(String resourceId) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String globalCustomerId = uriKeys.get("global-customer-id"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); org.onap.aai.domain.yang.Customer customerAAI = this.bbInputSetupUtils.getAAICustomer(globalCustomerId); if (customerAAI != null) { return mapperLayer.mapAAICustomer(customerAAI); @@ -1085,8 +1102,9 @@ public class BBInputSetup implements JavaDelegate { if (customer == null) { Map<String, String> uriKeys = bbInputSetupUtils .getURIKeysFromServiceInstance(parameter.getServiceInstance().getServiceInstanceId()); - String globalCustomerId = uriKeys.get("global-customer-id"); - String subscriptionServiceType = uriKeys.get("service-type"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); customer = mapCustomer(globalCustomerId, subscriptionServiceType); } outputBB.setServiceInstance(parameter.getServiceInstance()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java index c05557a317..c6a921abb5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -20,8 +20,9 @@ package org.onap.so.client.appc; -import java.util.HashMap; +import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.appc.client.lcm.model.Action; import org.onap.appc.client.lcm.model.Status; @@ -40,10 +41,11 @@ public class ApplicationControllerAction { protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); private String errorCode = "1002"; private String errorMessage = "Unable to reach App C Servers"; + private static final String PAYLOAD_NOT_PRESENT_ERROR_MSG = "Payload is not present for "; private static Logger logger = LoggerFactory.getLogger(ApplicationControllerAction.class); public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional<String> payload, - HashMap<String, String> payloadInfo, String controllerType) { + Map<String, String> payloadInfo, String controllerType) { Status appCStatus = null; try { String vnfName = payloadInfo.getOrDefault("vnfName", ""); @@ -96,20 +98,8 @@ public class ApplicationControllerAction { logger.warn("vserverIds null in AppCClient"); break; } - String vmId = ""; - String vserverId = ""; - ObjectMapper mapper = new ObjectMapper(); - List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {}); - List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {}); - int i = 0; - while (i < vmIdJsonList.size()) { - vmId = vmIdJsonList.get(i); - vserverId = vserverIdJsonList.get(i); - Optional<String> vserverIdString = Optional.of(vserverId); - appCStatus = - snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType); - i++; - } + appCStatus = getSnapshotActionAppcStatus(msoRequestId, vnfId, controllerType, identityUrl, vmIds, + vserverIds); break; case ConfigModify: case ConfigScaleOut: @@ -140,29 +130,44 @@ public class ApplicationControllerAction { logger.error("Error building Appc request: {}", e.getMessage(), e); errorCode = "1002"; errorMessage = e.getMessage(); - } catch (NoSuchMethodError e) { - logger.error("Error building Appc request: {}", e.getMessage(), e); - errorMessage = e.getMessage(); } catch (Exception e) { logger.error("Error building Appc request: {}", e.getMessage(), e); errorMessage = e.getMessage(); } } + private Status getSnapshotActionAppcStatus(String msoRequestId, String vnfId, String controllerType, + String identityUrl, String vmIds, String vserverIds) + throws IOException, ApplicationControllerOrchestratorException { + Status appcStatus = null; + String vmId = ""; + String vserverId = ""; + ObjectMapper mapper = new ObjectMapper(); + List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {}); + List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {}); + int i = 0; + while (i < vmIdJsonList.size()) { + vmId = vmIdJsonList.get(i); + vserverId = vserverIdJsonList.get(i); + Optional<String> vserverIdString = Optional.of(vserverId); + appcStatus = snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType); + i++; + } + return appcStatus; + } + private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + action.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + action.toString()); } return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.QuiesceTraffic.toString()); } payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, Optional.empty(), payload, controllerType); @@ -170,19 +175,18 @@ public class ApplicationControllerAction { private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + action.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + action.toString()); } payload = PayloadClient.upgradeFormat(payload, vnfName); return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } private Status distributeTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + Action.DistributeTraffic.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.DistributeTraffic.toString()); } payload = PayloadClient.distributeTrafficFormat(payload, vnfName); return client.vnfCommand(Action.DistributeTraffic, msoRequestId, vnfId, Optional.empty(), payload, @@ -191,10 +195,10 @@ public class ApplicationControllerAction { private Status distributeTrafficCheckAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { throw new IllegalArgumentException( - "Payload is not present for " + Action.DistributeTrafficCheck.toString()); + PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.DistributeTrafficCheck.toString()); } payload = PayloadClient.distributeTrafficCheckFormat(payload, vnfName); return client.vnfCommand(Action.DistributeTrafficCheck, msoRequestId, vnfId, Optional.empty(), payload, diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 79e957155d..948c9326d8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -80,7 +80,7 @@ public class ExceptionBuilder { } logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -113,7 +113,7 @@ public class ExceptionBuilder { } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -144,7 +144,7 @@ public class ExceptionBuilder { } } logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -176,7 +176,7 @@ public class ExceptionBuilder { } } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -260,7 +260,7 @@ public class ExceptionBuilder { public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { logger.debug("Processing Audit Results"); - String auditListString = (String) execution.getVariable("auditInventoryResult"); + String auditListString = execution.getVariable("auditInventoryResult"); String processKey = getProcessKey(execution.getDelegateExecution()); if (auditListString != null) { StringBuilder errorMessage = new StringBuilder(); @@ -304,6 +304,7 @@ public class ExceptionBuilder { } catch (IOException | BBObjectNotFoundException e) { errorMessage = errorMessage.append("process objects in AAI. "); + logger.error("Exception occurred in processAuditException", e); } if (flowShouldContinue) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java index c2283f1627..692d581b0d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -33,11 +33,10 @@ public class AAIPropertiesImpl implements AAIProperties { public static final String MSO_MSO_KEY = "mso.msoKey"; public static final String AAI_AUTH = "aai.auth"; public static final String AAI_ENDPOINT = "aai.endpoint"; - private UrnPropertiesReader reader; @Override public URL getEndpoint() throws MalformedURLException { - return new URL(reader.getVariable(AAI_ENDPOINT)); + return new URL(UrnPropertiesReader.getVariable(AAI_ENDPOINT)); } @Override @@ -52,11 +51,11 @@ public class AAIPropertiesImpl implements AAIProperties { @Override public String getAuth() { - return reader.getVariable(AAI_AUTH); + return UrnPropertiesReader.getVariable(AAI_AUTH); } @Override public String getKey() { - return reader.getVariable(MSO_MSO_KEY); + return UrnPropertiesReader.getVariable(MSO_MSO_KEY); } } |