Catalog alignment
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / main / DeleteComponentTool.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 org.openecomp.sdc.asdctool.configuration.ConfigurationUploader;
24 import org.openecomp.sdc.asdctool.configuration.InternalToolConfiguration;
25 import org.openecomp.sdc.asdctool.impl.internal.tool.DeleteComponentHandler;
26 import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
27 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
28
29 import java.util.Scanner;
30
31 public class DeleteComponentTool extends SdcInternalTool{
32     private static final String PSW = "ItIsTimeToDelete";
33
34     public static void main(String[] args) {
35         if (args == null || args.length < 2) {
36             ConsoleWriter.dataLine("Usage: <configuration dir> <password>");
37             System.exit(1);
38         }
39         String appConfigDir = args[0];
40         String password = args[1];
41         
42         disableConsole();
43         ConsoleWriter.dataLine("STARTED... ");
44
45         ConfigurationUploader.uploadConfigurationFiles(appConfigDir);
46         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(InternalToolConfiguration.class);
47         DeleteComponentHandler deleteComponentHandler = context.getBean(DeleteComponentHandler.class);
48
49
50         String input = "";
51         Scanner scanner = new Scanner(System.in);
52         do {
53             ConsoleWriter.dataLine("Enter next component unique id or exit: ");
54             input = scanner.nextLine();
55             if (!input.equals("exit")) {
56                 if (!input.isEmpty()) {
57                     ConsoleWriter.dataLine("Your id is " ,input);
58                     deleteComponentHandler.deleteComponent(input, scanner);
59                 }else{
60                     ConsoleWriter.dataLine("Your id is empty. Try again.");
61                 }
62             }
63         } while (!input.equals("exit"));
64         deleteComponentHandler.closeAll();
65         ConsoleWriter.dataLine("DeleteComponentTool exit...");
66         System.exit(0);
67     }
68
69
70 }