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