[SDC-29] Amdocs OnBoard 1707 initial commit.
[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 / filedatastructuremodule / CandidateService.java
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.sdc.datatypes.error.ErrorMessage;
25 import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
26 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
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
45   Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData);
46
47   OrchestrationTemplateCandidateData createCandidateDataEntity(
48           CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
49
50   void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, String
51       itemId);
52
53   Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
54                                Version activeVersion);
55
56   void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version activeVersion,
57         FilesDataStructure fileDataStructure);
58
59   OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
60                                                                        Version activeVersion);
61
62   Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
63                                                                   OrchestrationTemplateCandidateData candidateDataEntity,
64                                                                   String manifest, Map<String, List<ErrorMessage>> uploadErrors);
65
66   byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId)
67       throws IOException;
68
69   Optional<ManifestContent> createManifest(VspDetails vspDetails,
70                                            FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
71
72   String createManifest(VspDetails vspDetails, FilesDataStructure structure);
73
74   Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
75 }