0a271c9d87a7df9324b8e24f33d824b69398e78e
[sdc.git] /
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 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
33 public interface ETSIService {
34
35     /**
36      * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1
37      * and contains mandatory Entries in Tosca.meta
38      * @param handler contains csar artifacts
39      * @return true if all condition matched, false otherwise
40      * @throws IOException when TOSCA.meta file is invalid
41      */
42     boolean isSol004WithToscaMetaDirectory(FileContentHandler handler) throws IOException;
43
44     /**
45      * Update file structure. Moves non mano files to the correct folder based on the manifest non mano type.
46      *
47      * @param handler The file handler containing the artifacts to move.
48      * @return A Map with pairs of from and to path of the moved artifacts.
49      */
50     Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler)
51         throws IOException;
52
53     /**
54      * Updates the main descriptor paths referring the artifacts that were moved.
55      *
56      * @param toscaServiceModel The tosca service model containing the main descriptor.
57      * @param fromToMovedArtifactMap A Map representing the from and to artifacts path changes.
58      */
59     void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel,
60                                    final Map<String, Path> fromToMovedArtifactMap);
61
62     /**
63      * Retrieves the manifest file from the CSAR
64      * @param handler contains csar artifacts
65      * @throws IOException when TOSCA.meta file or manifest file is invalid
66      */
67     Manifest getManifest(FileContentHandler handler) throws IOException;
68
69     /**
70      * Determmines the type of resource that the CSAR represents
71      * @param handler contains csar artifacts
72      * @throws IOException when TOSCA.meta file or manifest file is invalid
73      */
74     ResourceTypeEnum getResourceType(FileContentHandler handler) throws IOException;
75
76     /**
77      * Determmines the type of resource that the CSAR represents
78      * @param manifest contains manifest content
79      * @throws IOException when TOSCA.meta file or manifest file is invalid
80      */
81     ResourceTypeEnum getResourceType(Manifest manifest) throws IOException;
82
83     Path getOriginalManifestPath(final FileContentHandler handler) throws IOException;
84 }