//package at.gv.egovernment.moa.id.commons.config;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//
//import javax.xml.bind.JAXBException;
//
//import at.gv.egovernment.moa.id.commons.config.cli.MOAIDConfCLI;
//import at.gv.egovernment.moa.id.commons.config.cli.MigrateConfigurationParams;
//
///**
// * CLI tool which is able to perform the following tasks:
// *
// * - transform a MoaID 2 XML configuration XML file to a MoaID 3 property file
// *
// * - read a property file and transfer it's content to a database
// * - write the content of a database to a property file
// *
// */
//public class MigrateConfiguration {
//
// public static void main(String[] args) {
//
// MOAIDConfCLI cli = new MOAIDConfCLI();
// MigrateConfigurationParams parsedParameters = cli.parse(args);
//
// // consider settings of force switch
// boolean isOverwriteData = parsedParameters.isOverwriteData();
// ConfigurationUtil configUtil = new ConfigurationUtil(isOverwriteData);
//
// if (!parsedParameters.isInputDB() && (parsedParameters.getInputTarget() != null)) {
// // read input from file
// workWithInputFromFile(parsedParameters.getInputTarget(), parsedParameters, configUtil);
//
// } else if (parsedParameters.getInputDBConfig() != null) {
// // read input from database
// workWithImputFromDB(parsedParameters, configUtil);
//
// } else {
// System.exit(1);
// }
// }
//
// /**
// * Handle the case where input from a file is read.
// *
// * @param inputFileUrl
// * the url of the input file.
// * @param parsedParameters
// * the command line parameters.
// * @param configUtil
// * the class for working with the configuration.
// */
// private static void workWithInputFromFile(String inputFileUrl, MigrateConfigurationParams parsedParameters,
// ConfigurationUtil configUtil) {
// File inFile = new File(inputFileUrl);
// try (FileInputStream inStream = new FileInputStream(inFile);) {
//
// if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
// // input from file and output to a file is desired
// File outFile = new File(parsedParameters.getOutputFile());
// configUtil.readFromXMLFileConvertToPropertyFile(inStream, outFile);
//
// } else if (parsedParameters.getOutputDBConfig() != null) {
// // input from file and output to a database is desired
// configUtil.readFromFileWriteToDB(inStream, parsedParameters.getOutputDBConfig());
// }
// } catch (JAXBException e) {
// System.out.println("MOA-ID XML configuration can not be loaded from given file.");
// System.exit(1);
// } catch (FileNotFoundException e) {
// System.out.println("Could not find the input file.");
// System.exit(1);
// } catch (IOException e) {
// System.out.println("Could not read from the input file.");
// System.exit(1);
// }
// }
//
// /**
// * Handle the case where input is read from a database.
// *
// * @param parsedParameters
// * the command line parameters.
// * @param configUtil
// * the class for working with the configuration.
// */
// private static void workWithImputFromDB(MigrateConfigurationParams parsedParameters, ConfigurationUtil configUtil) {
// if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
// // input from database and output to a file is desired
// File outFile = new File(parsedParameters.getOutputFile());
// String inputDBConfigFilePath = parsedParameters.getInputDBConfig();
// configUtil.readFromDBWriteToFile(inputDBConfigFilePath, outFile);
//
// } else if (parsedParameters.getOutputDBConfig() != null) {
// // input from database and output to a database is desired
// // configUtil.readFromDBWriteToDB(inDBConfigFilePath,
// // outDBConfigFilePath);
// }
// }
//}