Create plugin point for csar generation
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / tosca / DefaultCsarGenerator.java
1 /*
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2023 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 package org.openecomp.sdc.be.tosca;
21
22 import fj.data.Either;
23 import java.io.IOException;
24 import java.util.zip.ZipOutputStream;
25 import org.openecomp.sdc.be.model.Component;
26 import org.openecomp.sdc.be.plugins.CsarZipGenerator;
27 import org.openecomp.sdc.exception.ResponseFormat;
28
29 /**
30  * Generates a Network Service CSAR based on a SERVICE component and wraps it in a SDC CSAR entry.
31  */
32 @org.springframework.stereotype.Component("defaultCsarGenerator")
33 public class DefaultCsarGenerator implements CsarZipGenerator {
34
35     private static final String DEFINITIONS_PATH = "Definitions/";
36     private final CommonCsarGenerator commonCsarGenerator;
37
38     public DefaultCsarGenerator(final CommonCsarGenerator commonCsarGenerator) {
39         this.commonCsarGenerator = commonCsarGenerator;
40     }
41
42     @Override
43     public Either<ZipOutputStream, ResponseFormat> generateCsarZip(Component component,
44                                                                    boolean getFromCS,
45                                                                    ZipOutputStream zip,
46                                                                    boolean isInCertificationRequest,
47                                                                    boolean isAsdPackage) throws IOException {
48         return commonCsarGenerator.generateCsarZip(component, getFromCS, zip, isInCertificationRequest, isAsdPackage, DEFINITIONS_PATH, true, false);
49     }
50
51     @Override
52     public String getModel() {
53         return null;
54     }
55
56 }