Added oparent to sdc main
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / main / CsarGeneratorTool.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.asdctool.main;
22
23 import java.util.Scanner;
24
25 import org.openecomp.sdc.asdctool.configuration.ConfigurationUploader;
26 import org.openecomp.sdc.asdctool.configuration.CsarGeneratorConfiguration;
27 import org.openecomp.sdc.asdctool.impl.internal.tool.CsarGenerator;
28 import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
29 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
30
31 public class CsarGeneratorTool extends SdcInternalTool {
32
33     public static void main(String[] args) {
34         if (args == null) {
35             ConsoleWriter.dataLine("Usage: <configuration dir> ");
36             System.exit(1);
37         }
38         String appConfigDir = args[0];
39
40         disableConsole();
41
42         ConfigurationUploader.uploadConfigurationFiles(appConfigDir);
43         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(CsarGeneratorConfiguration.class);
44         CsarGenerator csarGenerator = context.getBean(CsarGenerator.class);
45         ConsoleWriter.dataLine("STARTED... ");
46
47         String input = "";
48         Scanner scanner = new Scanner(System.in);
49         do {
50             ConsoleWriter.dataLine("Enter next service UUID  or exit: ");
51             input = scanner.nextLine();
52             if (!input.equals("exit")) {
53                 if (!input.isEmpty()) {
54                     ConsoleWriter.dataLine("Your UUID is ", input);
55                     csarGenerator.generateCsar(input, scanner);
56                 } else {
57                     ConsoleWriter.dataLine("Your UUID is empty. Try again.");
58                 }
59             }
60         } while (!input.equals("exit"));
61         csarGenerator.closeAll();
62         ConsoleWriter.dataLine("CsarGeneratorTool exit...");
63         System.exit(0);
64     }
65 }