2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.asdctool.main;
23 import java.util.Scanner;
25 import org.openecomp.sdc.asdctool.configuration.ConfigurationUploader;
26 import org.openecomp.sdc.asdctool.configuration.InternalToolConfiguration;
27 import org.openecomp.sdc.asdctool.impl.internal.tool.DeleteComponentHandler;
28 import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
29 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
31 public class DeleteComponentTool extends SdcInternalTool{
32 private static final String PSW = "ItIsTimeToDelete";
34 public static void main(String[] args) {
35 if (args == null || args.length < 2) {
36 ConsoleWriter.dataLine("Usage: <configuration dir> <password>");
39 String appConfigDir = args[0];
40 String password = args[1];
42 if ( !PSW.equals(password) ){
43 ConsoleWriter.dataLine("Wrong password");
48 ConsoleWriter.dataLine("STARTED... ");
50 ConfigurationUploader.uploadConfigurationFiles(appConfigDir);
51 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(InternalToolConfiguration.class);
52 DeleteComponentHandler deleteComponentHandler = context.getBean(DeleteComponentHandler.class);
56 Scanner scanner = new Scanner(System.in);
58 ConsoleWriter.dataLine("Enter next component unique id or exit: ");
59 input = scanner.nextLine();
60 if (!input.equals("exit")) {
61 if (!input.isEmpty()) {
62 ConsoleWriter.dataLine("Your id is " ,input);
63 deleteComponentHandler.deleteComponent(input, scanner);
65 ConsoleWriter.dataLine("Your id is empty. Try again.");
68 } while (!input.equals("exit"));
69 deleteComponentHandler.closeAll();
70 ConsoleWriter.dataLine("DeleteComponentTool exit...");