diff options
author | andre.schmid <andre.schmid@est.tech> | 2019-10-10 17:39:03 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-11-20 17:23:14 +0000 |
commit | a80a2e20ab5414c35a948fd58613df33d3bee3d3 (patch) | |
tree | d1cb11b1543c45f3f77762a0ce8b5f27de2f3590 /catalog-be/src/main | |
parent | 13af621442b4c74d9e63ede8e42dbae48aaa64c9 (diff) |
Validate non-mano software information artifact
Change-Id: Ie9fabd6af821b830e211ff1068fb287357fd38ee
Issue-ID: SDC-2619
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main')
4 files changed, 3 insertions, 205 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareInformation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareInformation.java deleted file mode 100644 index 8595fc9698..0000000000 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareInformation.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.be.components.csar; - -import java.util.LinkedHashSet; -import java.util.Set; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -/** - * Represents the Pnf software information non-mano yaml - */ -@Getter -@Setter -public class PnfSoftwareInformation { - - private String description; - private String provider; - private String version; - @Setter(AccessLevel.NONE) - private Set<PnfSoftwareVersion> softwareVersionSet = new LinkedHashSet<>(); - - /** - * Adds a {@link PnfSoftwareVersion} instance to the software version set - * @param softwareVersion the pnf software version to add - */ - public void addToSoftwareVersionSet(final PnfSoftwareVersion softwareVersion) { - softwareVersionSet.add(softwareVersion); - } - - public Set<PnfSoftwareVersion> getSoftwareVersionSet() { - return new LinkedHashSet<>(softwareVersionSet); - } - - /** - * Stores the software information yaml field names. - */ - @AllArgsConstructor - @Getter - public enum PnfSoftwareInformationField { - DESCRIPTION("description"), - PROVIDER("provider"), - VERSION("version"), - PNF_SOFTWARE_INFORMATION("pnf_software_information"); - - private final String fieldName; - - } -} diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareVersion.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareVersion.java deleted file mode 100644 index 0dc4679e53..0000000000 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/PnfSoftwareVersion.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.be.components.csar; - -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -@AllArgsConstructor -@EqualsAndHashCode -@Getter -public class PnfSoftwareVersion { - - private final String version; - private final String description; - - /** - * Stores the pnf software version yaml fields. - */ - @Getter - @AllArgsConstructor - public enum PnfSoftwareVersionField { - DESCRIPTION("description"), - PNF_SOFTWARE_VERSION("pnf_software_version"); - - private final String fieldName; - } -}
\ No newline at end of file diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/SoftwareInformationArtifactYamlParser.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/SoftwareInformationArtifactYamlParser.java deleted file mode 100644 index ec34e21945..0000000000 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/SoftwareInformationArtifactYamlParser.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.be.components.csar; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.apache.commons.collections.CollectionUtils; -import org.onap.sdc.tosca.services.YamlUtil; -import org.openecomp.sdc.be.components.csar.PnfSoftwareInformation.PnfSoftwareInformationField; -import org.openecomp.sdc.be.components.csar.PnfSoftwareVersion.PnfSoftwareVersionField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.error.YAMLException; - -/** - * Handles the parsing of the non-mano software information file. - */ -public class SoftwareInformationArtifactYamlParser { - private static final Logger LOGGER = LoggerFactory.getLogger(SoftwareInformationArtifactYamlParser.class); - - private SoftwareInformationArtifactYamlParser() { - - } - - /** - * Parses the non-mano software information yaml file. - * - * @param softwareInformationYamlFileBytes the file byte array - * @return an {@code Optional<PnfSoftwareInformation>} if the file was successful parsed, otherwise {@code - * Optional.empty()} - */ - @SuppressWarnings("unchecked") - public static Optional<PnfSoftwareInformation> parse(final byte[] softwareInformationYamlFileBytes) { - final Map<String, Object> softwareVersionYamlObject; - try (final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(softwareInformationYamlFileBytes)) { - final Object yaml = YamlUtil.read(byteArrayInputStream); - if (!(yaml instanceof Map)) { - return Optional.empty(); - } - - softwareVersionYamlObject = (Map<String, Object>) yaml; // unchecked warning suppressed - } catch (final IOException | YAMLException e) { - LOGGER.warn("Could not parse the software information yaml file", e); - return Optional.empty(); - } - - final PnfSoftwareInformation pnfSoftwareInformation = new PnfSoftwareInformation(); - pnfSoftwareInformation.setDescription( - (String) softwareVersionYamlObject.get(PnfSoftwareInformationField.DESCRIPTION.getFieldName())); - pnfSoftwareInformation.setProvider( - (String) softwareVersionYamlObject.get(PnfSoftwareInformationField.PROVIDER.getFieldName())); - pnfSoftwareInformation.setVersion( - (String) softwareVersionYamlObject.get(PnfSoftwareInformationField.VERSION.getFieldName())); - final List<Map<String, String>> pnfSoftwareInformationYaml = (List<Map<String, String>>) softwareVersionYamlObject - .get(PnfSoftwareInformationField.PNF_SOFTWARE_INFORMATION.getFieldName()); // unchecked warning suppressed - - if (CollectionUtils.isNotEmpty(pnfSoftwareInformationYaml)) { - pnfSoftwareInformationYaml.forEach(stringStringMap -> { - final String description = stringStringMap.get(PnfSoftwareVersionField.DESCRIPTION.getFieldName()); - final String version = stringStringMap.get(PnfSoftwareVersionField.PNF_SOFTWARE_VERSION.getFieldName()); - pnfSoftwareInformation.addToSoftwareVersionSet(new PnfSoftwareVersion(version, description)); - }); - } - - return Optional.of(pnfSoftwareInformation); - } - - -} diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java index 9355921252..3129befb8c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java @@ -26,9 +26,9 @@ import java.util.List; import java.util.Optional; import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.be.components.csar.CsarInfo; -import org.openecomp.sdc.be.components.csar.PnfSoftwareInformation; -import org.openecomp.sdc.be.components.csar.PnfSoftwareVersion; -import org.openecomp.sdc.be.components.csar.SoftwareInformationArtifactYamlParser; +import org.openecomp.sdc.be.csar.pnf.PnfSoftwareInformation; +import org.openecomp.sdc.be.csar.pnf.PnfSoftwareVersion; +import org.openecomp.sdc.be.csar.pnf.SoftwareInformationArtifactYamlParser; import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; |