diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2020-02-25 12:26:14 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-25 12:26:14 +0000 |
commit | 2f497888bfcc70a6982843454e346c46ee02ce78 (patch) | |
tree | 3439f22bc3386abf2fcef7cc7f1351d55c59dd49 /bpmn | |
parent | e00ef64b058fc1dc2c26461a6634b5a08fa1a53f (diff) | |
parent | af8873fed8d913862fb4d43738b4e9808cd3cd92 (diff) |
Merge "Sonar issue - Refactor"
Diffstat (limited to 'bpmn')
7 files changed, 97 insertions, 120 deletions
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 79ccd9216f..00d0fdc01d 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 @@ -6,12 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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. @@ -29,7 +31,6 @@ import java.util.Optional; import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; import org.json.JSONObject; -import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.core.json.JsonUtils; @@ -143,7 +144,7 @@ public class AppcRunTasks { ControllerSelectionReference controllerSelectionReference = catalogDbClient .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString()); - String controllerType = null; + String controllerType; if (controllerSelectionReference != null) { controllerType = controllerSelectionReference.getControllerName(); } else { @@ -191,13 +192,13 @@ public class AppcRunTasks { logger.error("Error Message: {}", appcMessage); logger.error("ERROR CODE: {}", appcCode); logger.trace("End of runAppCommand "); - if (appcCode != null && !appcCode.equals("0")) { + if (appcCode != null && !"0".equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } protected void mapRollbackVariables(BuildingBlockExecution execution, Action action, String appcCode) { - if (appcCode != null && appcCode.equals("0") && action != null) { + if ("0".equals(appcCode) && action != null) { if (action.equals(Action.Lock)) { execution.setVariable(ROLLBACK_VNF_LOCK, true); } else if (action.equals(Action.Unlock)) { @@ -216,7 +217,7 @@ public class AppcRunTasks { private HashMap<String, String> buildPayloadInfo(String vnfName, String aicIdentity, String vnfHostIpAddress, String vmIdList, String vserverIdList, String identityUrl, String vfModuleId) { - HashMap<String, String> payloadInfo = new HashMap<String, String>(); + HashMap<String, String> payloadInfo = new HashMap<>(); payloadInfo.put("vnfName", vnfName); payloadInfo.put("aicIdentity", aicIdentity); payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress); @@ -242,44 +243,39 @@ public class AppcRunTasks { return payload; } - protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException { AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); - if (aaiRW != null && aaiRW.getRelationships() != null && aaiRW.getRelationships().isPresent()) { - Relationships relationships = aaiRW.getRelationships().get(); - if (relationships != null) { - List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); - JSONArray vserverIds = new JSONArray(); - JSONArray vserverSelfLinks = new JSONArray(); - if (vserverUris != null) { - for (AAIResourceUri j : vserverUris) { - if (j != null) { - if (j.getURIKeys() != null) { - String vserverId = j.getURIKeys().get("vserver-id"); - vserverIds.put(vserverId); - } - Optional<Vserver> oVserver = aaiVnfResources.getVserver(j); - if (oVserver.isPresent()) { - Vserver vserver = oVserver.get(); - if (vserver != null) { - String vserverSelfLink = vserver.getVserverSelflink(); - vserverSelfLinks.put(vserverSelfLink); - } - } - } + if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) { + return; + } + Relationships relationships = aaiRW.getRelationships().get(); + List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); + JSONArray vserverIds = new JSONArray(); + JSONArray vserverSelfLinks = new JSONArray(); + if (vserverUris != null) { + for (AAIResourceUri j : vserverUris) { + if (j != null) { + if (j.getURIKeys() != null) { + String vserverId = j.getURIKeys().get("vserver-id"); + vserverIds.put(vserverId); } + aaiVnfResources.getVserver(j).ifPresent((vserver) -> { + String vserverSelfLink = vserver.getVserverSelflink(); + vserverSelfLinks.put(vserverSelfLink); + }); } - - JSONObject vmidsArray = new JSONObject(); - JSONObject vserveridsArray = new JSONObject(); - vmidsArray.put("vmIds", vserverSelfLinks.toString()); - vserveridsArray.put("vserverIds", vserverIds.toString()); - logger.debug("vmidsArray is: {}", vmidsArray.toString()); - logger.debug("vserveridsArray is: {}", vserveridsArray.toString()); - - execution.setVariable("vmIdList", vmidsArray.toString()); - execution.setVariable("vserverIdList", vserveridsArray.toString()); } } + + JSONObject vmidsArray = new JSONObject(); + JSONObject vserveridsArray = new JSONObject(); + vmidsArray.put("vmIds", vserverSelfLinks.toString()); + vserveridsArray.put("vserverIds", vserverIds.toString()); + logger.debug("vmidsArray is: {}", vmidsArray.toString()); + logger.debug("vserveridsArray is: {}", vserveridsArray.toString()); + + execution.setVariable("vmIdList", vmidsArray.toString()); + execution.setVariable("vserverIdList", vserveridsArray.toString()); } } 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 64f0072991..1cde9fb8f6 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 @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -29,11 +31,9 @@ import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.OrchestrationStatusValidationException; import org.onap.so.db.catalog.beans.BuildingBlockDetail; -import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; -import org.onap.so.db.catalog.beans.ResourceType; import org.onap.so.db.catalog.client.CatalogDbClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,8 +52,6 @@ public class OrchestrationStatusValidator { "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)"; private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult"; private static final String ALACARTE = "aLaCarte"; - private static final String MULTI_STAGE_DESIGN_OFF = "false"; - private static final String MULTI_STAGE_DESIGN_ON = "true"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -86,7 +84,7 @@ public class OrchestrationStatusValidator { String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName)); } - OrchestrationStatus orchestrationStatus = null; + OrchestrationStatus orchestrationStatus; switch (buildingBlockDetail.getResourceType()) { case SERVICE: diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 9ee0104a5f..33625882f6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -471,9 +471,7 @@ public class WorkflowAction { List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(type); for (AAIResultWrapper vnfcResultWrapper : vnfcResultWrappers) { Optional<T> vnfcOp = vnfcResultWrapper.asBean(resultClass); - if (vnfcOp.isPresent()) { - vnfcs.add(vnfcOp.get()); - } + vnfcOp.ifPresent(vnfcs::add); } } return vnfcs; @@ -493,9 +491,7 @@ public class WorkflowAction { this.getResultWrappersFromRelationships(relationships, type); for (AAIResultWrapper configurationResultWrapper : configurationResultWrappers) { Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass); - if (configurationOp.isPresent()) { - configurations.add(configurationOp.get()); - } + configurationOp.ifPresent(configurations::add); } } return configurations; @@ -574,8 +570,6 @@ public class WorkflowAction { protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) throws Exception { - List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>(); - String vnfId = dataObj.getWorkflowResourceIds().getVnfId(); String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); @@ -639,19 +633,15 @@ public class WorkflowAction { if (!relationshipsOp.isPresent()) { logger.debug("No relationships were found for Configuration in AAI"); return null; - } else { - Relationships relationships = relationshipsOp.get(); - List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC); - if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) { - logger.debug("Too many vnfcs or no vnfc found that are related to configuration"); - } - Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class); - if (vnfcOp.isPresent()) { - return vnfcOp.get().getVnfcName(); - } else { - return null; - } } + Relationships relationships = relationshipsOp.get(); + List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC); + if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) { + logger.debug("Too many vnfcs or no vnfc found that are related to configuration"); + } + Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class); + return vnfcOp.map(Vnfc::getVnfcName).orElse(null); + } protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) { @@ -816,7 +806,7 @@ public class WorkflowAction { vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); if (existingAAIVrfConfiguration != null) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); + aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); } resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); @@ -964,12 +954,11 @@ public class WorkflowAction { resourceCounter.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); if (serviceInstanceMSO.getVnfs() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId())); + aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); if (vnf.getVfModules() != null) { for (VfModule vfModule : vnf.getVfModules()) { - aaiResourceIds.add( - new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); + aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false); resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); resourceCounter.add(resource); @@ -978,8 +967,7 @@ public class WorkflowAction { if (vnf.getVolumeGroups() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf .getVolumeGroups()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, - volumeGroup.getVolumeGroupId())); + aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); resourceCounter .add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); } @@ -989,14 +977,14 @@ public class WorkflowAction { if (serviceInstanceMSO.getNetworks() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO .getNetworks()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, network.getNetworkId())); + aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId())); resourceCounter.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false)); } } if (serviceInstanceMSO.getCollection() != null) { logger.debug("found networkcollection"); - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, - serviceInstanceMSO.getCollection().getId())); + aaiResourceIds + .add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId(), false)); } @@ -1008,8 +996,7 @@ public class WorkflowAction { for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) { if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, - config.getConfigurationId())); + aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId())); resourceCounter.add( new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false)); break; @@ -1035,12 +1022,11 @@ public class WorkflowAction { if (serviceInstanceMSO.getVnfs() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { if (vnf.getVnfId().equals(vnfId)) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId())); + aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); if (vnf.getVfModules() != null) { for (VfModule vfModule : vnf.getVfModules()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, - vfModule.getVfModuleId())); + aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); resourceCounter .add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false)); findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), @@ -1050,8 +1036,8 @@ public class WorkflowAction { if (vnf.getVolumeGroups() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf .getVolumeGroups()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, - volumeGroup.getVolumeGroupId())); + aaiResourceIds + .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); resourceCounter.add( new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); } @@ -1081,8 +1067,7 @@ public class WorkflowAction { Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get()); if (config.isPresent()) { - aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, - config.get().getConfigurationId())); + aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId())); resourceCounter.add( new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false)); } @@ -1256,7 +1241,7 @@ public class WorkflowAction { Pattern patt = Pattern.compile("[vV]\\d+.*?(?:(?:/(?<type>" + SUPPORTEDTYPES + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?(?:/resume)?)?$"); Matcher m = patt.matcher(uri); - Boolean generated = false; + boolean generated = false; if (m.find()) { logger.debug("found match on {} : {} ", uri, m); @@ -1366,7 +1351,7 @@ public class WorkflowAction { } else if (ebb.getBuildingBlock().getBpmnFlowName().equals(CREATENETWORKBB) || ebb.getBuildingBlock().getBpmnFlowName().equals(ACTIVATENETWORKBB)) { continue; - } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) { + } else if (!"".equals(ebb.getBuildingBlock().getBpmnFlowName())) { sortedOrchFlows.add(ebb); } } @@ -1557,9 +1542,7 @@ public class WorkflowAction { if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) { List<OrchestrationFlow> macroQueryFlows = catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName()); - for (OrchestrationFlow macroFlow : macroQueryFlows) { - listToExecute.add(macroFlow); - } + listToExecute.addAll(macroQueryFlows); } else { listToExecute.add(flow); } @@ -1582,7 +1565,7 @@ public class WorkflowAction { public void handleRuntimeException(DelegateExecution execution) { StringBuilder wfeExpMsg = new StringBuilder("Runtime error "); - String runtimeErrorMessage = null; + String runtimeErrorMessage; try { String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg"); if (javaExpMsg != null && !javaExpMsg.isEmpty()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index d78fa69680..3f81e432e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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. @@ -52,6 +54,7 @@ import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.beans.Subnet; +import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -65,8 +68,7 @@ public class NetworkAdapterObjectMapper { public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, - Map<String, String> userInput, String cloudRegionPo, Customer customer) - throws UnsupportedEncodingException { + Map<String, String> userInput, String cloudRegionPo, Customer customer) { CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); // set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId() @@ -119,7 +121,7 @@ public class NetworkAdapterObjectMapper { } public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, - ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException { + ServiceInstance serviceInstance, L3Network l3Network) { DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); deleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); @@ -150,14 +152,14 @@ public class NetworkAdapterObjectMapper { /** * Access method to build Rollback Network Request - * + * * @return * @throws UnsupportedEncodingException */ public RollbackNetworkRequest createNetworkRollbackRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, - CreateNetworkResponse createNetworkResponse) throws UnsupportedEncodingException { + CreateNetworkResponse createNetworkResponse) { RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest(); rollbackNetworkRequest = setCommonRollbackRequestFields(rollbackNetworkRequest, requestContext); @@ -171,7 +173,7 @@ public class NetworkAdapterObjectMapper { public UpdateNetworkRequest createNetworkUpdateRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, - Map<String, String> userInput, Customer customer) throws UnsupportedEncodingException { + Map<String, String> userInput, Customer customer) { UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); updateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); @@ -198,11 +200,10 @@ public class NetworkAdapterObjectMapper { } private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request, - RequestContext requestContext) throws UnsupportedEncodingException { + RequestContext requestContext) { request.setSkipAAI(true); String messageId = requestContext.getMsoRequestId(); request.setMessageId(messageId); - // request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); return request; } @@ -240,7 +241,7 @@ public class NetworkAdapterObjectMapper { return UUID.randomUUID().toString(); } - protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException { + protected String createCallbackUrl(String messageType, String correlator) { String endpoint = this.getEndpoint(); while (endpoint.endsWith("/")) { @@ -256,14 +257,14 @@ public class NetworkAdapterObjectMapper { /** * Use BB L3Network object to build subnets list of type org.onap.so.openstack.beans.Subnet - * + * * @param L3Network * @return List<org.onap.so.openstack.beans.Subnet> */ protected List<Subnet> buildOpenstackSubnetList(L3Network l3Network) { List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets(); - List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>(); + List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<>(); // create mapper from onap Subnet to openstack bean Subnet if (modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class, org.onap.so.openstack.beans.Subnet.class) == null) { @@ -292,7 +293,7 @@ public class NetworkAdapterObjectMapper { .setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask())); List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes(); List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>(); - org.onap.so.openstack.beans.HostRoute openstackHostRoute = null; + org.onap.so.openstack.beans.HostRoute openstackHostRoute; // TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) { openstackHostRoute = new org.onap.so.openstack.beans.HostRoute(); @@ -319,10 +320,9 @@ public class NetworkAdapterObjectMapper { private ProviderVlanNetwork buildProviderVlanNetwork(L3Network l3Network) { ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork(); providerVlanNetwork.setPhysicalNetworkName(l3Network.getPhysicalNetworkName()); - List<Integer> vlans = new ArrayList<Integer>(); - List<org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment> segmentationAssignments = - l3Network.getSegmentationAssignments(); - for (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment assignment : segmentationAssignments) { + List<Integer> vlans = new ArrayList<>(); + List<SegmentationAssignment> segmentationAssignments = l3Network.getSegmentationAssignments(); + for (SegmentationAssignment assignment : segmentationAssignments) { vlans.add(Integer.valueOf(assignment.getSegmentationId())); } providerVlanNetwork.setVlans(vlans); @@ -401,7 +401,7 @@ public class NetworkAdapterObjectMapper { private Map<String, String> addSharedAndExternal(Map<String, String> userInput, L3Network l3Network) { if (userInput == null) - userInput = new HashMap<String, String>(); + userInput = new HashMap<>(); if (!userInput.containsKey("shared")) { userInput.put("shared", Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString()); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java index 3d3058da0b..362f64d720 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -24,7 +26,7 @@ import java.util.HashMap; public class NamingRequestObject { - private HashMap<String, String> namingRequestMap = new HashMap<String, String>(); + private HashMap<String, String> namingRequestMap = new HashMap<>(); public HashMap<String, String> getNamingRequestObjectMap() { return this.namingRequestMap; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index fc1528526c..9b104f3250 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -37,14 +39,11 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class AAIServiceInstanceResources { - private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources.class); @Autowired private InjectionHelper injectionHelper; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java index 5513122560..dba1693e5d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -33,14 +35,11 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.namingservice.NamingClient; import org.onap.so.client.namingservice.NamingRequestObject; import org.onap.so.client.namingservice.NamingRequestObjectBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class NamingServiceResources { - private static final Logger logger = LoggerFactory.getLogger(NamingServiceResources.class); private static final String NAMING_TYPE = "instanceGroup"; @Autowired @@ -53,14 +52,14 @@ public class NamingServiceResources { throws BadResponseException, IOException { Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName, NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName()); - List<Element> elements = new ArrayList<Element>(); + List<Element> elements = new ArrayList<>(); elements.add(element); return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements))); } public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException, IOException { Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId()); - List<Deleteelement> deleteElements = new ArrayList<Deleteelement>(); + List<Deleteelement> deleteElements = new ArrayList<>(); deleteElements.add(deleteElement); return (namingClient .deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements))); @@ -70,8 +69,8 @@ public class NamingServiceResources { throws BadResponseException, IOException { HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap(); Element element = new Element(); - nsRequestObject.forEach((k, v) -> element.put(k, v)); - List<Element> elements = new ArrayList<Element>(); + nsRequestObject.forEach(element::put); + List<Element> elements = new ArrayList<>(); elements.add(element); return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements))); } @@ -81,7 +80,7 @@ public class NamingServiceResources { HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap(); Deleteelement delElement = new Deleteelement(); nsRequestObject.forEach((k, v) -> delElement.setExternalKey(v)); - List<Deleteelement> delElements = new ArrayList<Deleteelement>(); + List<Deleteelement> delElements = new ArrayList<>(); delElements.add(delElement); return (namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(delElements))); } |