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=========================================================
20 package org.openecomp.sdc.asdctool.main;
22 import java.util.Arrays;
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 public class VrfObjectFixMenu {
34 private static final Logger log = Logger.getLogger(VrfObjectFixMenu.class);
36 private VrfObjectFixMenu() {
39 public static void main(String[] args) {
40 if (isNotValidArguments(args)) {
41 log.debug("#main - The invalid array of the arguments have been received: {}", Arrays.toString(args));
42 log.debug("#main - Usage: <configuration dir> <'detect'/'fix'> <output folder path>");
46 VrfObjectFixHandler vrfObjectFixHandler = getVrfObjectFixHandler();
47 if (vrfObjectFixHandler.handle(args[1], args.length == 3 ? args[2] : null)) {
48 log.info("#main - The {} operation of the corrupted VRFObject Node Types has been finished successfully", args[1]);
50 log.info("#main - The {} operation of the corrupted VRFObject Node Types has been failed", args[1]);
56 private static VrfObjectFixHandler getVrfObjectFixHandler() {
57 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VrfObjectFixConfiguration.class);
58 return context.getBean(VrfObjectFixHandler.class);
61 private static boolean isNotValidArguments(String[] args) {
62 return args == null || args.length < 2;
65 private static void initConfig(String configDir) {
66 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), configDir);
67 new ConfigurationManager(configurationSource);