1 /**============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 ================================================================================
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ============LICENSE_END=========================================================
21 package org.onap.blueprintgenerator.models.blueprint;
23 import com.fasterxml.jackson.annotation.JsonInclude;
24 import com.fasterxml.jackson.annotation.JsonInclude.Include;
25 import com.fasterxml.jackson.databind.ObjectMapper;
26 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
27 import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
29 import java.io.IOException;
30 import java.util.ArrayList;
35 @JsonInclude(value=Include.NON_NULL)
36 public class Imports {
38 private ArrayList<String> imports;
40 public static ArrayList<String> createOnapImports() {
41 ArrayList<String> imps = new ArrayList<>();
42 imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
43 imps.add("plugin:k8splugin?version=3.4.2");
44 imps.add("plugin:dcaepolicyplugin?version=2.4.0");
48 public static ArrayList<String> createDmaapImports(){
49 ArrayList<String> imps = new ArrayList<>();
50 imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
51 imps.add("plugin:k8splugin?version=3.4.2");
52 imps.add("plugin:dmaap?version=1.5.0");
56 public static ArrayList<String> createImportsFromFile(String path) {
57 ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
58 File importPath = new File(path);
60 Imports imports = importMapper.readValue(importPath, Imports.class);
61 imports.getImports().removeIf(String::isBlank);
62 return imports.getImports();
63 } catch (IOException e) {
64 throw new RuntimeException(e);