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.migration.main;
23 import org.apache.commons.cli.Option;
24 import org.apache.commons.cli.Options;
25 import org.openecomp.sdc.asdctool.cli.CLIToolData;
26 import org.openecomp.sdc.asdctool.cli.SpringCLITool;
27 import org.openecomp.sdc.asdctool.migration.config.MigrationSpringConfig;
28 import org.openecomp.sdc.asdctool.migration.core.SdcMigrationTool;
29 import org.openecomp.sdc.common.log.wrappers.Logger;
30 import org.springframework.context.support.AbstractApplicationContext;
32 public class MigrationMenu extends SpringCLITool {
34 private static final Logger LOGGER = Logger.getLogger(MigrationMenu.class);
36 public static void main(String[] args) {
37 MigrationMenu migrationMenu = new MigrationMenu();
38 CLIToolData cliToolData = migrationMenu.init(args);
39 boolean enforceAll = cliToolData.getCommandLine().hasOption("e");
40 migrationMenu.doMigrate(enforceAll, cliToolData.getSpringApplicationContext());
43 private void doMigrate(boolean enforceAll, AbstractApplicationContext context) {
44 SdcMigrationTool migrationTool = context.getBean(SdcMigrationTool.class);
45 boolean migrate = migrationTool.migrate(enforceAll);
47 LOGGER.info("migration completed successfully");
50 LOGGER.error("migration failed");
56 protected Options buildCmdLineOptions() {
57 Options options = super.buildCmdLineOptions();
58 Option enforceAll = buildEnforceAllOption();
59 options.addOption(enforceAll);
64 protected String commandName() {
65 return "sdc-migration";
68 private static Option buildEnforceAllOption() {
69 return Option.builder("e")
70 .longOpt("enforceAll")
71 .desc("enforce running all migration steps for current version")
76 protected Class<?> getSpringConfigurationClass() {
77 return MigrationSpringConfig.class;