diff options
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java')
19 files changed, 117 insertions, 118 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java index 0dcadfd4d8..0901f077d2 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java @@ -31,10 +31,11 @@ import org.springframework.web.bind.annotation.ResponseStatus; public class NsRequestProcessingException extends RuntimeException { private static final long serialVersionUID = 66862444537194516L; - private InlineResponse400 problemDetails; + private final InlineResponse400 problemDetails; public NsRequestProcessingException(final String message) { super(message); + problemDetails = null; } public NsRequestProcessingException(final String message, final InlineResponse400 problemDetails) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java index 75dd7107a7..749e85e3db 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java @@ -25,7 +25,7 @@ import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model. import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; -import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptorParser; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser.NetworkServiceDescriptorParser; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,9 +66,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting NS package model for: {}", nsdId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting NS package model for: " + nsdId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } @@ -82,9 +81,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting VNF package model for: {}", vnfPkgId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting VNF package model for: " + vnfPkgId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } @@ -101,9 +99,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting NS package content for: {}", nsdId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting NS package content for: " + nsdId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 8c6ea92428..7adf87adf4 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -69,11 +69,11 @@ import org.springframework.web.client.RestTemplate; @Configuration public class EtsiCatalogServiceProviderConfiguration { - public static final String ETSI_CATALOG_REST_TEMPLATE_BEAN = "etsiCatalogRestTemplate"; + private static final Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProviderConfiguration.class); public static final String ETSI_CATALOG_SERVICE_PROVIDER_BEAN = "etsiCatalogServiceProvider"; - private final static Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProviderConfiguration.class); + public static final String ETSI_CATALOG_REST_TEMPLATE_BEAN = "etsiCatalogRestTemplate"; private final HttpClientConnectionConfiguration clientConnectionConfiguration; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java index e3c159c7b0..54f6ad6543 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -33,8 +33,6 @@ public class EtsiCatalogUrlProvider { @Value("${etsi-catalog-manager.base.endpoint}") private String etsiCatalogManagerEndpoint; - public EtsiCatalogUrlProvider() {} - public String getNsPackageUrl(final String nsdId) { return etsiCatalogManagerEndpoint + "/nsd/v1/ns_descriptors/" + nsdId; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java index fe710ec00b..6776d8ba0b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java @@ -73,20 +73,20 @@ public class Sol003AdapterConfiguration { @Value("${rest.http.client.configuration.ssl.trustStorePassword:#{null}}") private String trustStorePassword; - @Value("so.adapters.sol003-adapter.auth:Basic dm5mbTpwYXNzd29yZDEk") + @Value("${so.adapters.sol003-adapter.auth:Basic dm5mbTpwYXNzd29yZDEk}") private String sol003AdapterBasicAuth; @Autowired private GsonProvider gsonProvider; - @Autowired - private HttpComponentsClientConfiguration httpComponentsClientConfiguration; - @Bean @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) - public RestTemplate sol003AdapterRestTemplate() { + public RestTemplate sol003AdapterRestTemplate( + @Autowired final HttpComponentsClientConfiguration httpComponentsClientConfiguration) { + final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory(); + final RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory)); restTemplate.getInterceptors().add(new SOSpringClientFilter()); @@ -114,7 +114,7 @@ public class Sol003AdapterConfiguration { final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); - } catch (Exception exception) { + } catch (final Exception exception) { logger.error("Error reading truststore, TLS connection to VNFM will fail.", exception); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java index a0798f6e55..df3a0c2e31 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN; import java.util.Optional; +import org.apache.commons.lang3.StringUtils; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; @@ -76,7 +77,7 @@ public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServicePro final CreateVnfResponse createVnfResponse = response.getBody(); - if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) { + if (StringUtils.isBlank(createVnfResponse.getJobId())) { LOGGER.error("Received invalid instantiation response: {}", response); return Optional.empty(); } @@ -134,7 +135,7 @@ public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServicePro } final DeleteVnfResponse deleteVnfResponse = response.getBody(); - if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) { + if (StringUtils.isBlank(deleteVnfResponse.getJobId())) { LOGGER.error("Received invalid terminate response: {}", response); return Optional.empty(); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java index 58ca2507bd..cfe5b94859 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Arrays; import java.util.Objects; /** @@ -82,7 +83,7 @@ public class FileEntry { @Override public int hashCode() { - return Objects.hash(isDirectory, filePath, fileContent); + return Objects.hash(isDirectory, filePath) + Arrays.hashCode(fileContent); } @Override @@ -90,7 +91,7 @@ public class FileEntry { if (obj instanceof FileEntry) { final FileEntry other = (FileEntry) obj; return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath) - && Objects.equals(fileContent, other.fileContent); + && Arrays.equals(fileContent, other.fileContent); } return false; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java index 9df5262302..2a37922e9b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; /** * @author Waqas Ikram (waqas.ikram@est.tech) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java index 33737f4c17..cc92234750 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -31,6 +31,10 @@ import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -79,7 +83,7 @@ public class NetworkServiceDescriptorParser { final Map<String, Object> nodeTemplates = getNodeTemplates(topologyTemplates); final Optional<NetworkServiceDescriptor> nsdOptional = - getNetworkServiceDescriptor(topologyTemplates);; + getNetworkServiceDescriptor(topologyTemplates); if (nsdOptional.isPresent()) { final NetworkServiceDescriptor networkServiceDescriptor = nsdOptional.get(); networkServiceDescriptor.setVnfs(getVirtualNetworkFunctions(nodeTemplates)); @@ -91,10 +95,10 @@ public class NetworkServiceDescriptorParser { } + logger.error("Unable to find {} file in {}", TOSCA_META_PATH_FILE_NAME, files); } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); } - logger.error("Unable to parser nsd zip content"); return Optional.empty(); } @@ -104,7 +108,7 @@ public class NetworkServiceDescriptorParser { final Map<String, Object> substitutionMappings = (Map<String, Object>) topologyTemplates.get(SUBSTITUTION_MAPPINGS); final Object nodeType = substitutionMappings.get(NODE_TYPE); - if (substitutionMappings != null && nodeType != null && NS_NODE_TYPE.equals(nodeType)) { + if (substitutionMappings != null && NS_NODE_TYPE.equals(nodeType)) { final NetworkServiceDescriptor networkServiceDescriptor = new NetworkServiceDescriptor(); networkServiceDescriptor.setType(nodeType.toString()); networkServiceDescriptor.setProperties((Map<String, Object>) substitutionMappings.get(PROPERTIES)); @@ -191,7 +195,7 @@ public class NetworkServiceDescriptorParser { } return files; } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); return Collections.emptyMap(); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java index fe23f5ef8d..746416c8e4 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java @@ -17,12 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.List; import java.util.Optional; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -39,7 +42,7 @@ public class ToscaMetadataParser { public Optional<ToscaMetadata> parse(final FileEntry toscaMetaFile) { try { final ToscaMetadata toscaMetadata = new ToscaMetadata(); - final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), "utf-8"); + final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), UTF_8); for (final String line : lines) { final String trimmedLine = line.trim(); if (!trimmedLine.isEmpty() && trimmedLine.contains(ATTRIBUTE_VALUE_SEPARATOR)) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java index ac8f782a99..eab6974252 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; import org.springframework.stereotype.Service; import org.yaml.snakeyaml.Yaml; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java index 5e5e51cee0..49118494cf 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java @@ -164,7 +164,7 @@ public class JobExecutorService { final LocalDateTime currentDateTime = LocalDateTime.now(); final NsLcmOpOcc newNsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.INSTANTIATE) .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime) - .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false) + .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInvocation(false) .isCancelPending(false).operationParams(gson.toJson(instantiateNsRequest)); databaseServiceProvider.addNSLcmOpOcc(newNsLcmOpOcc); logger.info("New NSLcmOpOcc created in database :\n{}", newNsLcmOpOcc); @@ -209,7 +209,7 @@ public class JobExecutorService { final LocalDateTime currentDateTime = LocalDateTime.now(); final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.TERMINATE) .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime) - .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false) + .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInvocation(false) .isCancelPending(false).operationParams(gson.toJson(terminateNsRequest)); databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); logger.info("New NSLcmOpOcc created in database :\n{}", nsLcmOpOcc); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java index d23e81201c..e94b3de81e 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java @@ -48,10 +48,20 @@ public abstract class AbstractNetworkServiceTask { private final Logger logger = LoggerFactory.getLogger(getClass()); protected final DatabaseServiceProvider databaseServiceProvider; - public AbstractNetworkServiceTask(final DatabaseServiceProvider jobServiceProvider) { + protected AbstractNetworkServiceTask(final DatabaseServiceProvider jobServiceProvider) { this.databaseServiceProvider = jobServiceProvider; } + public void addJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, + final String description) { + final NfvoJobStatus nfvoJobStatus = + new NfvoJobStatus().status(jobStatus).description(description).updatedTime(LocalDateTime.now()); + logger.info("Adding NfvoJobStatus {}", nfvoJobStatus); + final NfvoJob nfvoJob = getNfvoJob(execution); + nfvoJob.nfvoJobStatus(nfvoJobStatus); + databaseServiceProvider.addJob(nfvoJob); + } + public void setJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, final String description) { logger.info("Setting Job Status to {}", jobStatus); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java index bfeaf49daa..600792acc0 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java @@ -47,6 +47,7 @@ import org.springframework.stereotype.Component; */ @Component public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { + private static final String CREATE_INSTANTIATE_REQUEST_PARAM_NAME = "request"; private static final Logger logger = LoggerFactory.getLogger(CreateInstantiateVnfTask.class); private static final String NF_INST_ID_PARAM_NAME = "NF_INST_ID"; public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; @@ -64,10 +65,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void checkIfNfInstanceExistsInDb(final DelegateExecution execution) { logger.info("Executing checkIfNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + request.getNsInstId() + " and " + request.getVnfName()); if (!databaseServiceProvider.isNsInstExists(request.getNsInstId(), request.getVnfName())) { abortOperation(execution, @@ -79,10 +81,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createNfInstanceInDb(final DelegateExecution execution) { logger.info("Executing createNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); final Optional<NfvoNsInst> optional = databaseServiceProvider.getNfvoNsInst(request.getNsInstId()); @@ -104,9 +107,10 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createGenericVnfInAai(final DelegateExecution execution) { logger.info("Executing createGenericVnfInAai"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); @@ -140,10 +144,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing invokeCreateInstantiationRequest"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for creating and instantiating VNF: " + request.getVnfName()); final CreateVnfRequest vnfRequest = new CreateVnfRequest(); @@ -165,7 +170,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf instantiation response: {}", vnfResponse); execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + request.getVnfName() + " CreaetVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeCreateInstantiationRequest ..."); } catch (final Exception exception) { @@ -180,8 +185,9 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToInstantiated"); updateNfInstanceStatus(execution, State.INSTANTIATED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); - setJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); + addJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + " will set status to " + State.INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -192,8 +198,9 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToActive"); updateNfInstanceStatus(execution, State.FAILED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); - setJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); + addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -202,14 +209,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) { final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); - final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId); - if (!optional.isPresent()) { + if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java index 1d9e09e74b..a6d35e301e 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java @@ -240,12 +240,20 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); - final String nsPackageId = nfvoNsInst.getNsPackageId(); - final NsdInfo nsdInfo = getNsdInfo(execution, nsPackageId); final Map<String, String> vnfdIdToVnfPkgIdMapping = new HashMap<>(); try { + final Optional<NsdInfo> nsdInfoOptional = + etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); + + if (nsdInfoOptional.isEmpty()) { + final String message = "Unable to find NS package using NS package id: " + nsPackageId; + logger.error(message); + abortOperation(execution, message); + } + + final NsdInfo nsdInfo = nsdInfoOptional.get(); for (final String vnfPkgId : nsdInfo.getVnfPkgIds()) { final Optional<VnfPkgInfo> optional = etsiCatalogPackageManagementServiceProvider.getVnfPkgInfo(vnfPkgId); @@ -290,34 +298,8 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { setJobStatusToError(execution, "Instantiate NS workflow process failed"); } - private NsdInfo getNsdInfo(final DelegateExecution execution, final String nsPackageId) { - try { - final Optional<NsdInfo> optional = - etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); - - if (optional.isPresent()) { - final NsdInfo packageModel = optional.get(); - logger.info("NS Package exists {}", packageModel); - return packageModel; - } - - } catch (final EtsiCatalogManagerRequestFailureException failureException) { - final String message = - "Unexpected exception occured while getting ns package using nsPackageId: " + nsPackageId; - logger.error(message, failureException); - - abortOperation(execution, message); - } - - final String message = "Unable to find NS package using NS package id: " + nsPackageId; - logger.error(message); - abortOperation(execution, message); - return null; - - } - private Optional<Tenant> getTenant(final Map<String, String> additionalParams) { - final String vimId = (String) additionalParams.get("vim_id"); + final String vimId = additionalParams.get("vim_id"); if (vimId != null) { final String[] splitString = vimId.split("_"); if (splitString.length == 3) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java index e4dc3d5e07..001c369801 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java @@ -37,7 +37,7 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterNodeTask.class); private final AaiServiceProvider aaiServiceProvider; - public MonitorSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, + protected MonitorSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, final AaiServiceProvider aaiServiceProvider) { super(databaseServiceProvider); this.aaiServiceProvider = aaiServiceProvider; @@ -56,7 +56,7 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId); final Optional<GenericVnf> aaiGenericVnfOptional = aaiServiceProvider.getGenericVnf(vnfId); - if (!aaiGenericVnfOptional.isPresent()) { + if (aaiGenericVnfOptional.isEmpty()) { abortOperation(execution, "Unable to find generic vnf in A&AI using vnfId" + vnfId); } final GenericVnf genericVnf = aaiGenericVnfOptional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java index 2baa2845a5..c0d1df8c50 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java @@ -109,9 +109,8 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); if (nfInstances != null) { - nfInstances.stream().forEach(instance -> { - logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName()); - }); + nfInstances.stream().forEach( + instance -> logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName())); } } @@ -120,16 +119,14 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { logger.info("Getting NfvoNfInstList using nsInstId: {}", nsInstId); final List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); - if (nfvoNfInstList.size() == 0) { + if (nfvoNfInstList == null || nfvoNfInstList.isEmpty()) { final String message = "Unable to find NF Instances in database using id: " + nsInstId; abortOperation(execution, message); } final List<String> vnfIdsList = new ArrayList<>(); - nfvoNfInstList.stream().forEach(nfvoNfInst -> { - vnfIdsList.add(nfvoNfInst.getNfInstId()); - }); + nfvoNfInstList.stream().forEach(nfvoNfInst -> vnfIdsList.add(nfvoNfInst.getNfInstId())); return vnfIdsList; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java index 15eee22dd2..049a6f38b0 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java @@ -19,6 +19,13 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; @@ -31,13 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; /** * @author Andrew Lamb (andrew.a.lamb@est.tech) @@ -63,7 +63,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("vnfId: {}", vnfId); execution.setVariable(NF_INST_ID_PARAM_NAME, vnfId); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if VNF Instance with id: " + vnfId + " exists in database."); if (!databaseServiceProvider.isNfInstExists(vnfId)) { abortOperation(execution, @@ -78,7 +78,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); final Optional<DeleteVnfResponse> optional = sol003AdapterServiceProvider.invokeTerminationRequest(vnfId); @@ -92,7 +92,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf delete response: {}", vnfResponse); execution.setVariable(DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + vnfId + " DeleteVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeTerminateRequest ..."); } catch (final Exception exception) { @@ -108,7 +108,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); aaiServiceProvider.deleteGenericVnf(vnfId); } catch (final Exception exception) { @@ -124,10 +124,10 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing deleteNfInstanceFromDb"); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); databaseServiceProvider.deleteNfvoNfInst(vnfId); - setJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); logger.info("Finished executing deleteNfInstanceFromDb ..."); } @@ -136,7 +136,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.TERMINATING); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Terminating VNF with vnfId: " + vnfId + " will set status to " + State.TERMINATING); logger.info("Finished executing updateNfInstanceStatusToTerminating ..."); @@ -148,7 +148,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.NOT_INSTANTIATED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Successfully terminated VNF with vnfId: " + vnfId + " will set status to " + State.NOT_INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -160,7 +160,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.FAILED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, ERROR, + addJobStatus(execution, ERROR, "Failed to terminate VNF with vnfId: " + vnfId + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToFailed ..."); @@ -174,9 +174,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java index 34959ee0f0..9f21d2b449 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; /** @@ -45,14 +46,14 @@ public class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { @Override public LocalDateTime read(final JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - final String dateTime = in.nextString(); - return LocalDateTime.parse(dateTime, FORMATTER); + if (JsonToken.NULL == in.peek()) { + in.nextNull(); + return null; + } + final String dateTime = in.nextString(); + return LocalDateTime.parse(dateTime, FORMATTER); + } } |