00120759d631dcbc34c62954683e654f93765536
[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
17 package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
18
19 import org.openecomp.core.utilities.file.FileContentHandler;
20 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
21 import org.openecomp.sdc.datatypes.error.ErrorMessage;
22 import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
23 import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
24 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
25 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
26 import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
27 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
28 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
29 import org.openecomp.sdc.versioning.dao.types.Version;
30
31 import java.io.ByteArrayInputStream;
32 import java.io.IOException;
33 import java.io.InputStream;
34 import java.nio.ByteBuffer;
35 import java.util.List;
36 import java.util.Map;
37 import java.util.Optional;
38
39 public interface CandidateService {
40   Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload,
41                                                       String fileSuffix);
42
43   Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData);
44
45   OrchestrationTemplateCandidateData createCandidateDataEntity(
46       CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
47       AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
48
49   void updateCandidateUploadData(String vspId, Version version,
50                                  OrchestrationTemplateCandidateData uploadData);
51
52   Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
53                                                                                   Version version);
54
55   void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
56                                                              FilesDataStructure fileDataStructure);
57
58   OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
59                                                                        Version version);
60
61   OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
62                                                                        Version version);
63
64   byte[] getZipData(ByteBuffer contentData) throws IOException;
65
66   void deleteOrchestrationTemplateCandidate(String vspId, Version version);
67
68   Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
69                                                                   OrchestrationTemplateCandidateData candidateDataEntity,
70                                                                   String manifest,
71                                                                   OnboardingTypesEnum type,
72                                                                   Map<String, List<ErrorMessage>> uploadErrors);
73
74   byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
75                               OnboardingTypesEnum type) throws IOException;
76
77   Optional<ManifestContent> createManifest(VspDetails vspDetails,
78                                            FileContentHandler fileContentHandler,
79                                            AnalyzedZipHeatFiles analyzedZipHeatFiles);
80
81   String createManifest(VspDetails vspDetails, FilesDataStructure structure);
82
83   Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
84
85   void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
86 }