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 org.openecomp.sdc.asdctool.configuration.VrfObjectFixConfiguration;
24 import org.openecomp.sdc.asdctool.impl.VrfObjectFixHandler;
25 import org.openecomp.sdc.be.config.ConfigurationManager;
26 import org.openecomp.sdc.common.api.ConfigurationSource;
27 import org.openecomp.sdc.common.impl.ExternalConfiguration;
28 import org.openecomp.sdc.common.impl.FSConfigurationSource;
29 import org.openecomp.sdc.common.log.wrappers.Logger;
30 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
32 import java.util.Arrays;
34 public class VrfObjectFixMenu {
36 private static final Logger log = Logger.getLogger(VrfObjectFixMenu.class);
38 private VrfObjectFixMenu(){}
40 public static void main(String[] args) {
41 if (isNotValidArguments(args)) {
42 log.debug("#main - The invalid array of the arguments have been received: {}", Arrays.toString(args));
43 log.debug("#main - Usage: <configuration dir> <'detect'/'fix'> <output folder path>");
47 VrfObjectFixHandler vrfObjectFixHandler = getVrfObjectFixHandler();
48 if (vrfObjectFixHandler.handle(args[1], args.length == 3 ? args[2] : null)) {
49 log.info("#main - The {} operation of the corrupted VRFObject Node Types has been finished successfully", args[1]);
51 log.info("#main - The {} operation of the corrupted VRFObject Node Types has been failed", args[1]);
57 private static VrfObjectFixHandler getVrfObjectFixHandler() {
58 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VrfObjectFixConfiguration.class);
59 return context.getBean(VrfObjectFixHandler.class);
62 private static boolean isNotValidArguments(String[] args) {
63 return args == null || args.length < 2;
67 private static void initConfig(String configDir) {
68 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), configDir);
69 new ConfigurationManager(configurationSource);