d33533a7d0c930e2dc1a827fa090b4cf5798f4e5
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Modifications copyright (c) 2021 Nokia
17  */
18
19 package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
20
21 import org.openecomp.core.utilities.file.FileContentHandler;
22 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
23 import org.openecomp.sdc.datatypes.error.ErrorMessage;
24 import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
25 import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
26 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
27 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
28 import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
29 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
30 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
31 import org.openecomp.sdc.versioning.dao.types.Version;
32
33 import java.io.ByteArrayInputStream;
34 import java.io.IOException;
35 import java.io.InputStream;
36 import java.nio.ByteBuffer;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.Optional;
40
41 public interface CandidateService {
42   Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload,
43                                                       String fileSuffix);
44
45   Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData);
46
47   OrchestrationTemplateCandidateData createCandidateDataEntity(
48       CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
49       AnalyzedZipHeatFiles analyzedZipHeatFiles);
50
51   void updateCandidateUploadData(String vspId, Version version,
52                                  OrchestrationTemplateCandidateData uploadData);
53
54   Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
55                                                                                   Version version);
56
57   void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
58                                                              FilesDataStructure fileDataStructure);
59
60   Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId,
61                                                                                  Version version);
62
63   Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId,
64                                                                                      Version version);
65
66   byte[] getZipData(ByteBuffer contentData) throws IOException;
67
68   void deleteOrchestrationTemplateCandidate(String vspId, Version version);
69
70   Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
71                                                                   OrchestrationTemplateCandidateData candidateDataEntity,
72                                                                   String manifest,
73                                                                   OnboardingTypesEnum type,
74                                                                   Map<String, List<ErrorMessage>> uploadErrors);
75
76   byte[] replaceManifestInZip(ByteBuffer contentData, String manifest,
77                               OnboardingTypesEnum type) throws IOException;
78
79   Optional<ManifestContent> createManifest(VspDetails vspDetails,
80                                            FileContentHandler fileContentHandler,
81                                            AnalyzedZipHeatFiles analyzedZipHeatFiles);
82
83   String createManifest(VspDetails vspDetails, FilesDataStructure structure);
84
85   String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
86
87   Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
88
89   void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
90 }