Identify SOL004 packages
[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 package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi;
21
22 import com.vdurmont.semver4j.Semver;
23 import java.io.IOException;
24 import java.nio.file.Path;
25 import java.util.Map;
26 import java.util.Optional;
27 import org.openecomp.core.utilities.file.FileContentHandler;
28 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
29 import org.openecomp.sdc.tosca.csar.Manifest;
30 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
31
32 public interface ETSIService {
33
34     /**
35      * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1 and contains mandatory Entries in Tosca.meta
36      *
37      * @param handler contains csar artifacts
38      * @return true if all condition matched, false otherwise
39      * @throws IOException when TOSCA.meta file is invalid
40      */
41     boolean hasEtsiSol261Metadata(FileContentHandler handler) throws IOException;
42
43     /**
44      * Checks if the package is a ETSI package.
45      *
46      * @param fileContentHandler the CSAR file handler
47      * @return {@code true} if the package is a ETSI package, {@code false} otherwise.
48      * @throws IOException when it was not able to parse the TOSCA.meta file
49      */
50     boolean isEtsiPackage(final FileContentHandler fileContentHandler) throws IOException;
51
52     /**
53      * Update file structure. Moves non mano files to the correct folder based on the manifest non mano type.
54      *
55      * @param handler The file handler containing the artifacts to move.
56      * @return A Map with pairs of from and to path of the moved artifacts.
57      */
58     Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler) throws IOException;
59
60     /**
61      * Updates the main descriptor paths referring the artifacts that were moved.
62      *
63      * @param toscaServiceModel      The tosca service model containing the main descriptor.
64      * @param fromToMovedArtifactMap A Map representing the from and to artifacts path changes.
65      */
66     void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, final Map<String, Path> fromToMovedArtifactMap);
67
68     /**
69      * Retrieves the manifest file from the CSAR
70      *
71      * @param handler contains csar artifacts
72      * @throws IOException when TOSCA.meta file or manifest file is invalid
73      */
74     Manifest getManifest(FileContentHandler handler) throws IOException;
75
76     /**
77      * Determines the type of resource that the CSAR represents
78      *
79      * @param handler contains csar artifacts
80      * @throws IOException when TOSCA.meta file or manifest file is invalid
81      */
82     ResourceTypeEnum getResourceType(FileContentHandler handler) throws IOException;
83
84     /**
85      * Determines the type of resource that the CSAR represents
86      *
87      * @param manifest contains manifest content
88      * @throws IOException when TOSCA.meta file or manifest file is invalid
89      */
90     ResourceTypeEnum getResourceType(Manifest manifest) throws IOException;
91
92     Path getOriginalManifestPath(final FileContentHandler handler) throws IOException;
93
94     /**
95      * Determines the highest compatible specification version based on ETSI manifest file
96      *
97      * @param handler contains csar artifacts
98      * @return Semver representing highest compatible specification version
99      */
100     Semver getHighestCompatibleSpecificationVersion(final FileContentHandler handler);
101
102     /**
103      * Verifies if SOL004 3.3.1 manifest file has onap_cnf_helm non mano entry
104      *
105      * @return true if manifest files has onap_cnf_helm non mano entry
106      */
107     boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException;
108
109 }