Add new SOL004 ETSI Validator
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-software-product-lib / openecomp-sdc-vendor-software-product-api / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / services / impl / etsi / ETSIService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019, Nordix Foundation. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi;
22
23 import java.io.IOException;
24 import java.nio.file.Path;
25 import java.util.Map;
26 import java.util.Optional;
27
28 import org.openecomp.core.utilities.file.FileContentHandler;
29 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
30 import org.openecomp.sdc.tosca.csar.Manifest;
31 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
32
33 import com.vdurmont.semver4j.Semver;
34
35
36 public interface ETSIService {
37
38     /**
39      * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1
40      * and contains mandatory Entries in Tosca.meta
41      * @param handler contains csar artifacts
42      * @return true if all condition matched, false otherwise
43      * @throws IOException when TOSCA.meta file is invalid
44      */
45     boolean isSol004WithToscaMetaDirectory(FileContentHandler handler) throws IOException;
46
47     /**
48      * Update file structure. Moves non mano files to the correct folder based on the manifest non mano type.
49      *
50      * @param handler The file handler containing the artifacts to move.
51      * @return A Map with pairs of from and to path of the moved artifacts.
52      */
53     Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler)
54         throws IOException;
55
56     /**
57      * Updates the main descriptor paths referring the artifacts that were moved.
58      *
59      * @param toscaServiceModel The tosca service model containing the main descriptor.
60      * @param fromToMovedArtifactMap A Map representing the from and to artifacts path changes.
61      */
62     void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel,
63                                    final Map<String, Path> fromToMovedArtifactMap);
64
65     /**
66      * Retrieves the manifest file from the CSAR
67      * @param handler contains csar artifacts
68      * @throws IOException when TOSCA.meta file or manifest file is invalid
69      */
70     Manifest getManifest(FileContentHandler handler) throws IOException;
71
72     /**
73      * Determines the type of resource that the CSAR represents
74      * @param handler contains csar artifacts
75      * @throws IOException when TOSCA.meta file or manifest file is invalid
76      */
77     ResourceTypeEnum getResourceType(FileContentHandler handler) throws IOException;
78
79     /**
80      * Determines the type of resource that the CSAR represents
81      * @param manifest contains manifest content
82      * @throws IOException when TOSCA.meta file or manifest file is invalid
83      */
84     ResourceTypeEnum getResourceType(Manifest manifest) throws IOException;
85
86     Path getOriginalManifestPath(final FileContentHandler handler) throws IOException;
87
88
89     /**
90      * Determines the highest compatible specification version based on ETSI manifest file
91      * @param handler contains csar artifacts
92      * @return Semver representing highest compatible specification version
93      */
94     Semver getHighestCompatibleSpecificationVersion(final FileContentHandler handler);
95
96     /**
97      * Verifies if SOL004 3.3.1 manifest file has onap_cnf_helm non mano entry
98      * @return true if manifest files has onap_cnf_helm non mano entry
99      */
100     boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException;
101 }