Example usage for java.io File isDirectory

List of usage examples for java.io File isDirectory

Introduction

In this page you can find the example usage for java.io File isDirectory.

Prototype

public boolean isDirectory() 

Source Link

Document

Tests whether the file denoted by this abstract pathname is a directory.

Usage

From source file:gov.nasa.jpl.mudrod.ontology.process.LocalOntology.java

public static void main(String[] args) throws Exception {

    // boolean options
    Option helpOpt = new Option("h", "help", false, "show this help message");
    // argument options
    Option ontDirOpt = OptionBuilder.hasArg(true).withArgName(ONT_DIR)
            .withDescription("A directory containing .owl files.").isRequired(false).create();

    // create the options
    Options options = new Options();
    options.addOption(helpOpt);// w  ww.  j a va  2s .  com
    options.addOption(ontDirOpt);

    String ontDir;
    CommandLineParser parser = new GnuParser();
    try {
        CommandLine line = parser.parse(options, args);

        if (line.hasOption(ONT_DIR)) {
            ontDir = line.getOptionValue(ONT_DIR).replace("\\", "/");
        } else {
            ontDir = LocalOntology.class.getClassLoader().getResource("ontology").getFile();
        }
        if (!ontDir.endsWith("/")) {
            ontDir += "/";
        }
    } catch (Exception e) {
        LOG.error("Error whilst processing main method of LocalOntology.", e);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LocalOntology: 'ontDir' argument is mandatory. ", options, true);
        return;
    }
    File fileDir = new File(ontDir);
    //Fail if the input is not a directory.
    if (fileDir.isDirectory()) {
        List<String> owlFiles = new ArrayList<>();
        for (File owlFile : fileDir.listFiles()) {
            owlFiles.add(owlFile.toString());
        }
        MudrodEngine mEngine = new MudrodEngine();
        Properties props = mEngine.loadConfig();
        Ontology ontology = new OntologyFactory(props).getOntology();
        //convert to correct iput for ontology loading.
        String[] owlArray = new String[owlFiles.size()];
        owlArray = owlFiles.toArray(owlArray);
        ontology.load(owlArray);

        String[] terms = new String[] { "Glacier ice" };
        //Demonstrate that we can do basic ontology heirarchy navigation and log output.
        for (Iterator<OntClass> i = getParser().rootClasses(getModel()); i.hasNext();) {

            //print Ontology Class Hierarchy
            OntClass c = i.next();
            renderHierarchy(System.out, c, new LinkedList<>(), 0);

            for (Iterator<OntClass> subClass = c.listSubClasses(true); subClass.hasNext();) {
                OntClass sub = subClass.next();
                //This means that the search term is present as an OntClass
                if (terms[0].equalsIgnoreCase(sub.getLabel(null))) {
                    //Add the search term(s) above to the term cache.
                    for (int j = 0; j < terms.length; j++) {
                        addSearchTerm(terms[j], sub);
                    }

                    //Query the ontology and return subclasses of the search term(s)
                    for (int k = 0; k < terms.length; k++) {
                        Iterator<String> iter = ontology.subclasses(terms[k]);
                        while (iter.hasNext()) {
                            LOG.info("Subclasses >> " + iter.next());
                        }
                    }

                    //print any synonymic relationships to demonstrate that we can 
                    //undertake synonym-based query expansion
                    for (int l = 0; l < terms.length; l++) {
                        Iterator<String> iter = ontology.synonyms(terms[l]);
                        while (iter.hasNext()) {
                            LOG.info("Synonym >> " + iter.next());
                        }
                    }
                }
            }
        }

        mEngine.end();
    }

}

From source file:org.ala.util.XmlReportUtil.java

public static void main(String[] args) {

    XmlReportUtil xmlReportUtil = new XmlReportUtil();

    if (args.length == 0) {
        try {/*w  w w .j ava 2s .c  o  m*/
            xmlReportUtil.generateReport(UID);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }
    } else if (args.length == 1) {
        try {
            xmlReportUtil.generateReport(args[0]);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }
    } else if (args.length == 2) {
        try {
            File outputDir = new File(args[1]);

            if (outputDir.isDirectory()) {
                xmlReportUtil.generateReport(args[0], args[1]);
            } else {
                System.out.println(args[1] + " is not a Directory!");
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }
    }
    System.exit(0);
}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.LuceneIndexer.java

public static void main(String[] args) {
    Options options = new Options();

    options.addOption(CommonParams.ROOT_DIR_PARAM, null, true, CommonParams.ROOT_DIR_DESC);
    options.addOption(CommonParams.SUB_DIR_TYPE_PARAM, null, true, CommonParams.SUB_DIR_TYPE_DESC);
    options.addOption(CommonParams.MAX_NUM_REC_PARAM, null, true, CommonParams.MAX_NUM_REC_DESC);
    options.addOption(CommonParams.SOLR_FILE_NAME_PARAM, null, true, CommonParams.SOLR_FILE_NAME_DESC);
    options.addOption(CommonParams.OUT_INDEX_PARAM, null, true, CommonParams.OUT_MINDEX_DESC);

    CommandLineParser parser = new org.apache.commons.cli.GnuParser();

    try {//from w  ww  . j  a  va2s .c om
        CommandLine cmd = parser.parse(options, args);

        String rootDir = null;

        rootDir = cmd.getOptionValue(CommonParams.ROOT_DIR_PARAM);

        if (null == rootDir)
            Usage("Specify: " + CommonParams.ROOT_DIR_DESC, options);

        String outputDirName = cmd.getOptionValue(CommonParams.OUT_INDEX_PARAM);

        if (null == outputDirName)
            Usage("Specify: " + CommonParams.OUT_MINDEX_DESC, options);

        String subDirTypeList = cmd.getOptionValue(CommonParams.SUB_DIR_TYPE_PARAM);

        if (null == subDirTypeList || subDirTypeList.isEmpty())
            Usage("Specify: " + CommonParams.SUB_DIR_TYPE_DESC, options);

        String solrFileName = cmd.getOptionValue(CommonParams.SOLR_FILE_NAME_PARAM);
        if (null == solrFileName)
            Usage("Specify: " + CommonParams.SOLR_FILE_NAME_DESC, options);

        int maxNumRec = Integer.MAX_VALUE;

        String tmp = cmd.getOptionValue(CommonParams.MAX_NUM_REC_PARAM);

        if (tmp != null) {
            try {
                maxNumRec = Integer.parseInt(tmp);
                if (maxNumRec <= 0) {
                    Usage("The maximum number of records should be a positive integer", options);
                }
            } catch (NumberFormatException e) {
                Usage("The maximum number of records should be a positive integer", options);
            }
        }

        File outputDir = new File(outputDirName);
        if (!outputDir.exists()) {
            if (!outputDir.mkdirs()) {
                System.out.println("couldn't create " + outputDir.getAbsolutePath());
                System.exit(1);
            }
        }
        if (!outputDir.isDirectory()) {
            System.out.println(outputDir.getAbsolutePath() + " is not a directory!");
            System.exit(1);
        }
        if (!outputDir.canWrite()) {
            System.out.println("Can't write to " + outputDir.getAbsolutePath());
            System.exit(1);
        }

        String subDirs[] = subDirTypeList.split(",");

        int docNum = 0;

        // No English analyzer here, all language-related processing is done already,
        // here we simply white-space tokenize and index tokens verbatim.
        Analyzer analyzer = new WhitespaceAnalyzer();
        FSDirectory indexDir = FSDirectory.open(outputDir);
        IndexWriterConfig indexConf = new IndexWriterConfig(analyzer.getVersion(), analyzer);

        System.out.println("Creating a new Lucene index, maximum # of docs to process: " + maxNumRec);
        indexConf.setOpenMode(OpenMode.CREATE);
        IndexWriter indexWriter = new IndexWriter(indexDir, indexConf);

        for (int subDirId = 0; subDirId < subDirs.length && docNum < maxNumRec; ++subDirId) {
            String inputFileName = rootDir + "/" + subDirs[subDirId] + "/" + solrFileName;

            System.out.println("Input file name: " + inputFileName);

            BufferedReader inpText = new BufferedReader(
                    new InputStreamReader(CompressUtils.createInputStream(inputFileName)));
            String docText = XmlHelper.readNextXMLIndexEntry(inpText);

            for (; docText != null && docNum < maxNumRec; docText = XmlHelper.readNextXMLIndexEntry(inpText)) {
                ++docNum;
                Map<String, String> docFields = null;

                Document luceneDoc = new Document();

                try {
                    docFields = XmlHelper.parseXMLIndexEntry(docText);
                } catch (Exception e) {
                    System.err.println(String.format("Parsing error, offending DOC #%d:\n%s", docNum, docText));
                    System.exit(1);
                }

                String id = docFields.get(UtilConst.TAG_DOCNO);

                if (id == null) {
                    System.err.println(String.format("No ID tag '%s', offending DOC #%d:\n%s",
                            UtilConst.TAG_DOCNO, docNum, docText));
                }

                luceneDoc.add(new StringField(UtilConst.TAG_DOCNO, id, Field.Store.YES));

                for (Map.Entry<String, String> e : docFields.entrySet())
                    if (!e.getKey().equals(UtilConst.TAG_DOCNO)) {
                        luceneDoc.add(new TextField(e.getKey(), e.getValue(), Field.Store.YES));
                    }
                indexWriter.addDocument(luceneDoc);
                if (docNum % 1000 == 0)
                    System.out.println("Indexed " + docNum + " docs");
            }
            System.out.println("Indexed " + docNum + " docs");
        }

        indexWriter.commit();
        indexWriter.close();

    } catch (ParseException e) {
        Usage("Cannot parse arguments", options);
    } catch (Exception e) {
        System.err.println("Terminating due to an exception: " + e);
        System.exit(1);
    }

}

From source file:iaj.linkit.App.java

/**
 * Application entry method.//from   w  w w  .ja v  a  2s.co m
 *
 * @param args Command line arguments.
 */
public static void main(final String[] args) {
    final Configuration config = new Configuration();
    final CmdLineParser parser = new CmdLineParser(config);

    try {
        parser.parseArgument(args);

        final File f = (config.getPaths().size() > 0) ? new File(config.getPaths().get(0)).getCanonicalFile()
                : new File(DIR_CURRENT).getCanonicalFile();
        if (!f.exists()) {
            System.err.println("No such path: " + f.getCanonicalFile());
            System.exit(1);
        } else if (!f.canRead()) {
            System.err.println("Can't read path.");
            System.exit(1);
        } else if (f.isDirectory()) {
            handleFiles(config.isRecursive(), f.listFiles());
        } else {
            handleFiles(config.isRecursive(), f);
        }

    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (final CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println("lu [options...] [paths...]"); //$NON-NLS-1$
        parser.printUsage(System.err);
        System.exit(1);
    }
}

From source file:com.act.lcms.db.analysis.IonSearchAnalysis.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*from ww w . java2s .  c o m*/
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        return;
    }

    File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY));
    if (!lcmsDir.isDirectory()) {
        System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath());
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    Double fontScale = null;
    if (cl.hasOption("font-scale")) {
        try {
            fontScale = Double.parseDouble(cl.getOptionValue("font-scale"));
        } catch (IllegalArgumentException e) {
            System.err.format("Argument for font-scale must be a floating point number.\n");
            System.exit(1);
        }
    }

    try (DB db = DB.openDBFromCLI(cl)) {
        Set<String> includeIons = null;
        if (cl.hasOption("include-ions")) {
            String[] ionNames = cl.getOptionValues("include-ions");
            includeIons = new HashSet<>(Arrays.asList(ionNames));
            System.out.format("Including ions in search: %s\n", StringUtils.join(includeIons, ", "));
        }
        Set<String> excludeIons = null;
        if (cl.hasOption("exclude-ions")) {
            String[] ionNames = cl.getOptionValues("exclude-ions");
            excludeIons = new HashSet<>(Arrays.asList(ionNames));
            System.out.format("Excluding ions from search: %s\n", StringUtils.join(excludeIons, ", "));
        }

        Set<Integer> takeSamplesFromPlateIds = null;
        if (cl.hasOption(OPTION_FILTER_BY_PLATE_BARCODE)) {
            String[] plateBarcodes = cl.getOptionValues(OPTION_FILTER_BY_PLATE_BARCODE);
            System.out.format("Considering only sample wells in plates: %s\n",
                    StringUtils.join(plateBarcodes, ", "));
            takeSamplesFromPlateIds = new HashSet<>(plateBarcodes.length);
            for (String plateBarcode : plateBarcodes) {
                Plate p = Plate.getPlateByBarcode(db, plateBarcode);
                if (p == null) {
                    System.err.format("WARNING: unable to find plate in DB with barcode %s\n", plateBarcode);
                } else {
                    takeSamplesFromPlateIds.add(p.getId());
                }
            }
            // Allow filtering on barcode even if we couldn't find any in the DB.
        }

        System.out.format("Loading/updating LCMS scan files into DB\n");
        ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir);

        System.out.format("Processing LCMS scans\n");
        Pair<List<LCMSWell>, Set<Integer>> positiveWellsAndPlateIds = Utils.extractWellsAndPlateIds(db,
                cl.getOptionValues(OPTION_STRAINS), cl.getOptionValues(OPTION_CONSTRUCTS),
                takeSamplesFromPlateIds, false);
        List<LCMSWell> positiveWells = positiveWellsAndPlateIds.getLeft();
        if (positiveWells.size() == 0) {
            throw new RuntimeException("Found no LCMS wells for specified strains/constructs");
        }
        // Only take negative samples from the plates where we found the positive samples.
        Pair<List<LCMSWell>, Set<Integer>> negativeWellsAndPlateIds = Utils.extractWellsAndPlateIds(db,
                cl.getOptionValues(OPTION_NEGATIVE_STRAINS), cl.getOptionValues(OPTION_NEGATIVE_CONSTRUCTS),
                positiveWellsAndPlateIds.getRight(), true);
        List<LCMSWell> negativeWells = negativeWellsAndPlateIds.getLeft();
        if (negativeWells == null || negativeWells.size() == 0) {
            System.err.format("WARNING: no valid negative samples found in same plates as positive samples\n");
        }

        // Extract the reference MZ that will be used in the LCMS trace processing.
        List<Pair<String, Double>> searchMZs = null;
        Set<CuratedChemical> standardChemicals = null;
        List<ChemicalAssociatedWithPathway> pathwayChems = null;
        if (cl.hasOption(OPTION_SEARCH_MZ)) {
            // Assume mz can be an FP number of a chemical name.
            String massStr = cl.getOptionValue(OPTION_SEARCH_MZ);
            Pair<String, Double> searchMZ = Utils.extractMassFromString(db, massStr);
            if (searchMZ != null) {
                searchMZs = Collections.singletonList(searchMZ);
            }
            standardChemicals = Utils.extractTargetsForWells(db, positiveWells);
        } else {
            CuratedChemical targetChemical = Utils.requireOneTarget(db, positiveWells);
            if (targetChemical == null) {
                throw new RuntimeException(
                        "Unable to find a curated chemical entry for specified strains'/constructs' targets.  "
                                + "Please specify a chemical name or m/z explicitly or update the curated chemicals list in the DB.");
            }
            System.out.format("Using reference M/Z for positive target %s (%f)\n", targetChemical.getName(),
                    targetChemical.getMass());
            searchMZs = Collections.singletonList(Pair.of(targetChemical.getName(), targetChemical.getMass()));
            standardChemicals = Collections.singleton(targetChemical);
        }

        // Look up the standard by name, or use the target if none is specified.
        List<StandardWell> standardWells = null;
        if (cl.hasOption(OPTION_NO_STANDARD)) {
            System.err.format("WARNING: skipping standard comparison (no-standard option specified)\n");
            standardWells = new ArrayList<>(0);
        } else if (cl.hasOption(OPTION_STANDARD_WELLS)) {
            String[] standardCoordinates = cl.getOptionValues(OPTION_STANDARD_WELLS);
            standardWells = new ArrayList<>(standardCoordinates.length);
            Plate standardPlate = Plate.getPlateByBarcode(db, cl.getOptionValue(OPTION_STANDARD_PLATE_BARCODE));
            List<String> foundCoordinates = new ArrayList<>(standardCoordinates.length);
            for (String stringCoords : standardCoordinates) {
                Pair<Integer, Integer> coords = Utils.parsePlateCoordinates(stringCoords);
                StandardWell well = StandardWell.getInstance().getStandardWellsByPlateIdAndCoordinates(db,
                        standardPlate.getId(), coords.getLeft(), coords.getRight());
                if (well == null) {
                    System.err.format("Unable to find standard well at %s [%s]\n", standardPlate.getBarcode(),
                            stringCoords);
                    continue;
                }
                standardWells.add(well);
                foundCoordinates.add(stringCoords);
            }
            System.out.format("Using explicitly specified standard wells %s [%s]\n", standardPlate.getBarcode(),
                    StringUtils.join(foundCoordinates, ", "));
        } else if (cl.hasOption(OPTION_STANDARD_NAME)) {
            String standardName = cl.getOptionValue(OPTION_STANDARD_NAME);
            System.out.format("Using explicitly specified standard %s\n", standardName);
            standardWells = Collections.singletonList(Utils.extractStandardWellFromPlate(db,
                    cl.getOptionValue(OPTION_STANDARD_PLATE_BARCODE), standardName));
        } else if (standardChemicals != null && standardChemicals.size() > 0) {
            // Default to using the target chemical(s) as a standard if none is specified.
            standardWells = new ArrayList<>(standardChemicals.size());
            for (CuratedChemical c : standardChemicals) {
                String standardName = c.getName();
                System.out.format("Searching for well containing standard %s\n", standardName);
                standardWells.add(Utils.extractStandardWellFromPlate(db,
                        cl.getOptionValue(OPTION_STANDARD_PLATE_BARCODE), standardName));
            }
        }

        boolean useFineGrainedMZ = cl.hasOption("fine-grained-mz");
        boolean useSNR = cl.hasOption(OPTION_USE_SNR);

        /* Process the standard, positive, and negative wells, producing ScanData containers that will allow them to be
         * iterated over for graph writing. */
        HashMap<Integer, Plate> plateCache = new HashMap<>();
        Pair<List<ScanData<StandardWell>>, Double> allStandardScans = AnalysisHelper.processScans(db, lcmsDir,
                searchMZs, ScanData.KIND.STANDARD, plateCache, standardWells, useFineGrainedMZ, includeIons,
                excludeIons, useSNR);
        Pair<List<ScanData<LCMSWell>>, Double> allPositiveScans = AnalysisHelper.processScans(db, lcmsDir,
                searchMZs, ScanData.KIND.POS_SAMPLE, plateCache, positiveWells, useFineGrainedMZ, includeIons,
                excludeIons, useSNR);
        Pair<List<ScanData<LCMSWell>>, Double> allNegativeScans = AnalysisHelper.processScans(db, lcmsDir,
                searchMZs, ScanData.KIND.NEG_CONTROL, plateCache, negativeWells, useFineGrainedMZ, includeIons,
                excludeIons, useSNR);

        String fmt = "pdf";
        String outImg = cl.getOptionValue(OPTION_OUTPUT_PREFIX) + "." + fmt;
        String outData = cl.getOptionValue(OPTION_OUTPUT_PREFIX) + ".data";
        System.err.format("Writing combined scan data to %s and graphs to %s\n", outData, outImg);

        produceLCMSSearchPlots(lcmsDir, outData, outImg, allStandardScans, allPositiveScans, allNegativeScans,
                fontScale, useFineGrainedMZ, cl.hasOption(OPTION_USE_HEATMAP), useSNR);
    }
}

From source file:edu.kit.dama.util.release.GenerateSourceRelease.java

public static void main(String[] args) throws Exception {

    if (args.length != 3) {
        System.err.println("Usage: GenerateSourceRelease TYPE SOURCE DESTINATION");
        System.err.println("");
        System.err.println("TYPE\tThe release type. Must be one of KITDM, GENERIC_CLIENT or BARE_DEMO");
        System.err.println("SOURCE\tThe source folder containing all sources for the selected release type.");
        System.err.println("DESTINATION\tThe destination folder where all sources of the release are placed.");
        System.exit(1);//  w w w  .  j av  a  2s .  c o  m
    }

    String releaseType = args[0];
    RELEASE_TYPE type = RELEASE_TYPE.KITDM;
    try {
        type = RELEASE_TYPE.valueOf(releaseType);
    } catch (IllegalArgumentException ex) {
        System.err.println(
                "Invalid release type. Valid relase types arguments are KITDM, GENERIC_CLIENT or BARE_DEMO");
        System.exit(1);
    }

    String source = args[1];
    String destination = args[2];
    File sourceFile = new File(source);
    File destinationFile = new File(destination);

    if ((sourceFile.exists() && !sourceFile.isDirectory())
            || (destinationFile.exists() && !destinationFile.isDirectory())) {
        System.err.println("Either source or destination are no directories.");
        System.exit(1);
    }

    if (!sourceFile.exists() || !sourceFile.canRead()) {
        System.err.println("Source either does not exist or is not readable.");
        System.exit(1);
    }

    if ((destinationFile.exists() && !sourceFile.canWrite())
            || (!destinationFile.exists() && !destinationFile.mkdirs())) {
        System.err.println("Destination is either not writable or cannot be created.");
        System.exit(1);
    }

    ReleaseConfiguration config = null;
    switch (type) {
    case KITDM:
        config = getKITDMSourceReleaseConfig(source, destination);
        break;
    case GENERIC_CLIENT:
        config = getGenericRepoClientSourceReleaseConfig(source, destination);
        break;
    case BARE_DEMO:
        config = getBaReDemoSourceReleaseConfig(source, destination);
        break;

    }

    generateSourceRelease(config);

    System.out.println("Generating Release finished.");
    System.out.println("Please manually check pom.xml:");
    System.out.println(" - Remove profiles");
    System.out.println(" - Update links to SCM, ciManagement and internal repositories");
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxDb2LUWLoaderCLI.CFAsteriskSaxDb2LUWLoaderCLI.java

public static void main(String args[]) {
    final String S_ProcName = "CFAsteriskSaxDb2LUWLoaderCLI.main() ";
    initConsoleLog();//from w ww  .  j a  v a2s  . c o  m
    int numArgs = args.length;
    if (numArgs >= 2) {
        String homeDirName = System.getProperty("HOME");
        if (homeDirName == null) {
            homeDirName = System.getProperty("user.home");
            if (homeDirName == null) {
                log.message(S_ProcName + "ERROR: Home directory not set");
                return;
            }
        }
        File homeDir = new File(homeDirName);
        if (!homeDir.exists()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
            return;
        }
        if (!homeDir.isDirectory()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
            return;
        }
        CFAsteriskConfigurationFile cFAsteriskConfig = new CFAsteriskConfigurationFile();
        String cFAsteriskConfigFileName = homeDir.getPath() + File.separator + ".cfasteriskdb2luwrc";
        cFAsteriskConfig.setFileName(cFAsteriskConfigFileName);
        File cFAsteriskConfigFile = new File(cFAsteriskConfigFileName);
        if (!cFAsteriskConfigFile.exists()) {
            cFAsteriskConfig.setDbServer("127.0.0.1");
            cFAsteriskConfig.setDbPort(5432);
            cFAsteriskConfig.setDbDatabase("CFAst24");
            cFAsteriskConfig.setDbUserName("luw");
            cFAsteriskConfig.setDbPassword("edit-me-please");
            cFAsteriskConfig.save();
            log.message(S_ProcName + "INFO: Created configuration file " + cFAsteriskConfigFileName
                    + ", please edit configuration and restart.");
            return;
        }
        if (!cFAsteriskConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed configuration file " + cFAsteriskConfigFileName
                    + " is not a file.");
            return;
        }
        if (!cFAsteriskConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read configuration file "
                    + cFAsteriskConfigFileName);
            return;
        }
        cFAsteriskConfig.load();
        boolean fastExit = false;
        CFAsteriskClientConfigurationFile cFDbTestClientConfig = new CFAsteriskClientConfigurationFile();
        String cFDbTestClientConfigFileName = homeDir.getPath() + File.separator + ".cfdbtestclientrc";
        cFDbTestClientConfig.setFileName(cFDbTestClientConfigFileName);
        File cFDbTestClientConfigFile = new File(cFDbTestClientConfigFileName);
        if (!cFDbTestClientConfigFile.exists()) {
            String cFDbTestKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
            cFDbTestClientConfig.setKeyStore(cFDbTestKeyStoreFileName);
            InetAddress localHost;
            try {
                localHost = InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                localHost = null;
            }
            if (localHost == null) {
                log.message(S_ProcName + "ERROR: LocalHost is null");
                return;
            }
            String hostName = localHost.getHostName();
            if ((hostName == null) || (hostName.length() <= 0)) {
                log.message("ERROR: LocalHost.HostName is null or empty");
                return;
            }
            String userName = System.getProperty("user.name");
            if ((userName == null) || (userName.length() <= 0)) {
                log.message("ERROR: user.name is null or empty");
                return;
            }
            String deviceName = hostName.replaceAll("[^\\w]", "_").toLowerCase() + "-"
                    + userName.replaceAll("[^\\w]", "_").toLowerCase();
            cFDbTestClientConfig.setDeviceName(deviceName);
            cFDbTestClientConfig.save();
            log.message(S_ProcName + "INFO: Created CFAsterisk client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed client configuration file " + cFDbTestClientConfigFileName
                    + " is not a file.");
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        cFDbTestClientConfig.load();

        if (fastExit) {
            return;
        }

        // Configure logging
        Properties sysProps = System.getProperties();
        sysProps.setProperty("log4j.rootCategory", "WARN");
        sysProps.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

        Logger httpLogger = Logger.getLogger("org.apache.http");
        httpLogger.setLevel(Level.WARN);

        ICFAsteriskSchema cFAsteriskSchema = new CFAsteriskDb2LUWSchema();
        cFAsteriskSchema.setConfigurationFile(cFAsteriskConfig);
        ICFAsteriskSchemaObj cFAsteriskSchemaObj = new CFAsteriskSchemaObj();
        cFAsteriskSchemaObj.setBackingStore(cFAsteriskSchema);
        CFAsteriskSaxLoaderCLI cli = new CFAsteriskSaxDb2LUWLoaderCLI();
        CFAsteriskSaxLoader loader = cli.getSaxLoader();
        loader.setSchemaObj(cFAsteriskSchemaObj);
        cFAsteriskSchema.connect();
        String url = args[1];
        if (numArgs >= 5) {
            cli.setClusterName(args[2]);
            cli.setTenantName(args[3]);
            cli.setSecUserName(args[4]);
        } else {
            cli.setClusterName("default");
            cli.setTenantName("system");
            cli.setSecUserName("system");
        }
        loader.setUseCluster(cli.getClusterObj());
        loader.setUseTenant(cli.getTenantObj());
        try {
            cFAsteriskSchema.beginTransaction();
            cFAsteriskSchemaObj.setSecCluster(cli.getClusterObj());
            cFAsteriskSchemaObj.setSecTenant(cli.getTenantObj());
            cFAsteriskSchemaObj.setSecUser(cli.getSecUserObj());
            cFAsteriskSchemaObj.setSecSession(cli.getSecSessionObj());
            CFSecurityAuthorization auth = new CFSecurityAuthorization();
            auth.setSecCluster(cFAsteriskSchemaObj.getSecCluster());
            auth.setSecTenant(cFAsteriskSchemaObj.getSecTenant());
            auth.setSecSession(cFAsteriskSchemaObj.getSecSession());
            cFAsteriskSchemaObj.setAuthorization(auth);
            applyLoaderOptions(loader, args[0]);
            if (numArgs >= 5) {
                cli.evaluateRemainingArgs(args, 5);
            } else {
                cli.evaluateRemainingArgs(args, 2);
            }
            loader.parseFile(url);
            cFAsteriskSchema.commit();
            cFAsteriskSchema.disconnect(true);
        } catch (Exception e) {
            log.message(S_ProcName + "EXCEPTION: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } catch (Error e) {
            log.message(S_ProcName + "ERROR: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } finally {
            if (cFAsteriskSchema.isConnected()) {
                cFAsteriskSchema.rollback();
                cFAsteriskSchema.disconnect(false);
            }
        }
    } else {
        log.message(S_ProcName
                + "ERROR: Expected at least two argument specifying the loader options and the name of the XML file to parse.  The first argument may be empty.");
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxMSSqlLoaderCLI.CFAsteriskSaxMSSqlLoaderCLI.java

public static void main(String args[]) {
    final String S_ProcName = "CFAsteriskSaxMSSqlLoaderCLI.main() ";
    initConsoleLog();/*from  w  w w.j  a  v a  2 s .c o m*/
    int numArgs = args.length;
    if (numArgs >= 2) {
        String homeDirName = System.getProperty("HOME");
        if (homeDirName == null) {
            homeDirName = System.getProperty("user.home");
            if (homeDirName == null) {
                log.message(S_ProcName + "ERROR: Home directory not set");
                return;
            }
        }
        File homeDir = new File(homeDirName);
        if (!homeDir.exists()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
            return;
        }
        if (!homeDir.isDirectory()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
            return;
        }
        CFAsteriskConfigurationFile cFAsteriskConfig = new CFAsteriskConfigurationFile();
        String cFAsteriskConfigFileName = homeDir.getPath() + File.separator + ".cfasteriskmssqlrc";
        cFAsteriskConfig.setFileName(cFAsteriskConfigFileName);
        File cFAsteriskConfigFile = new File(cFAsteriskConfigFileName);
        if (!cFAsteriskConfigFile.exists()) {
            cFAsteriskConfig.setDbServer("127.0.0.1");
            cFAsteriskConfig.setDbPort(1433);
            cFAsteriskConfig.setDbDatabase("CFAst24");
            cFAsteriskConfig.setDbUserName("sa");
            cFAsteriskConfig.setDbPassword("edit-me-please");
            cFAsteriskConfig.save();
            log.message(S_ProcName + "INFO: Created configuration file " + cFAsteriskConfigFileName
                    + ", please edit configuration and restart.");
            return;
        }
        if (!cFAsteriskConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed configuration file " + cFAsteriskConfigFileName
                    + " is not a file.");
            return;
        }
        if (!cFAsteriskConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read configuration file "
                    + cFAsteriskConfigFileName);
            return;
        }
        cFAsteriskConfig.load();
        boolean fastExit = false;
        CFAsteriskClientConfigurationFile cFDbTestClientConfig = new CFAsteriskClientConfigurationFile();
        String cFDbTestClientConfigFileName = homeDir.getPath() + File.separator + ".cfdbtestclientrc";
        cFDbTestClientConfig.setFileName(cFDbTestClientConfigFileName);
        File cFDbTestClientConfigFile = new File(cFDbTestClientConfigFileName);
        if (!cFDbTestClientConfigFile.exists()) {
            String cFDbTestKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
            cFDbTestClientConfig.setKeyStore(cFDbTestKeyStoreFileName);
            InetAddress localHost;
            try {
                localHost = InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                localHost = null;
            }
            if (localHost == null) {
                log.message(S_ProcName + "ERROR: LocalHost is null");
                return;
            }
            String hostName = localHost.getHostName();
            if ((hostName == null) || (hostName.length() <= 0)) {
                log.message("ERROR: LocalHost.HostName is null or empty");
                return;
            }
            String userName = System.getProperty("user.name");
            if ((userName == null) || (userName.length() <= 0)) {
                log.message("ERROR: user.name is null or empty");
                return;
            }
            String deviceName = hostName.replaceAll("[^\\w]", "_").toLowerCase() + "-"
                    + userName.replaceAll("[^\\w]", "_").toLowerCase();
            cFDbTestClientConfig.setDeviceName(deviceName);
            cFDbTestClientConfig.save();
            log.message(S_ProcName + "INFO: Created CFAsterisk client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed client configuration file " + cFDbTestClientConfigFileName
                    + " is not a file.");
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        cFDbTestClientConfig.load();

        if (fastExit) {
            return;
        }

        // Configure logging
        Properties sysProps = System.getProperties();
        sysProps.setProperty("log4j.rootCategory", "WARN");
        sysProps.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

        Logger httpLogger = Logger.getLogger("org.apache.http");
        httpLogger.setLevel(Level.WARN);

        ICFAsteriskSchema cFAsteriskSchema = new CFAsteriskMSSqlSchema();
        cFAsteriskSchema.setConfigurationFile(cFAsteriskConfig);
        ICFAsteriskSchemaObj cFAsteriskSchemaObj = new CFAsteriskSchemaObj();
        cFAsteriskSchemaObj.setBackingStore(cFAsteriskSchema);
        CFAsteriskSaxLoaderCLI cli = new CFAsteriskSaxMSSqlLoaderCLI();
        CFAsteriskSaxLoader loader = cli.getSaxLoader();
        loader.setSchemaObj(cFAsteriskSchemaObj);
        cFAsteriskSchema.connect();
        String url = args[1];
        if (numArgs >= 5) {
            cli.setClusterName(args[2]);
            cli.setTenantName(args[3]);
            cli.setSecUserName(args[4]);
        } else {
            cli.setClusterName("default");
            cli.setTenantName("system");
            cli.setSecUserName("system");
        }
        loader.setUseCluster(cli.getClusterObj());
        loader.setUseTenant(cli.getTenantObj());
        try {
            cFAsteriskSchema.beginTransaction();
            cFAsteriskSchemaObj.setSecCluster(cli.getClusterObj());
            cFAsteriskSchemaObj.setSecTenant(cli.getTenantObj());
            cFAsteriskSchemaObj.setSecUser(cli.getSecUserObj());
            cFAsteriskSchemaObj.setSecSession(cli.getSecSessionObj());
            CFSecurityAuthorization auth = new CFSecurityAuthorization();
            auth.setSecCluster(cFAsteriskSchemaObj.getSecCluster());
            auth.setSecTenant(cFAsteriskSchemaObj.getSecTenant());
            auth.setSecSession(cFAsteriskSchemaObj.getSecSession());
            cFAsteriskSchemaObj.setAuthorization(auth);
            applyLoaderOptions(loader, args[0]);
            if (numArgs >= 5) {
                cli.evaluateRemainingArgs(args, 5);
            } else {
                cli.evaluateRemainingArgs(args, 2);
            }
            loader.parseFile(url);
            cFAsteriskSchema.commit();
            cFAsteriskSchema.disconnect(true);
        } catch (Exception e) {
            log.message(S_ProcName + "EXCEPTION: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } catch (Error e) {
            log.message(S_ProcName + "ERROR: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } finally {
            if (cFAsteriskSchema.isConnected()) {
                cFAsteriskSchema.rollback();
                cFAsteriskSchema.disconnect(false);
            }
        }
    } else {
        log.message(S_ProcName
                + "ERROR: Expected at least two argument specifying the loader options and the name of the XML file to parse.  The first argument may be empty.");
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxMySqlLoaderCLI.CFAsteriskSaxMySqlLoaderCLI.java

public static void main(String args[]) {
    final String S_ProcName = "CFAsteriskSaxMySqlLoaderCLI.main() ";
    initConsoleLog();/*from  w  ww . ja v a2  s . c o m*/
    int numArgs = args.length;
    if (numArgs >= 2) {
        String homeDirName = System.getProperty("HOME");
        if (homeDirName == null) {
            homeDirName = System.getProperty("user.home");
            if (homeDirName == null) {
                log.message(S_ProcName + "ERROR: Home directory not set");
                return;
            }
        }
        File homeDir = new File(homeDirName);
        if (!homeDir.exists()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
            return;
        }
        if (!homeDir.isDirectory()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
            return;
        }
        CFAsteriskConfigurationFile cFAsteriskConfig = new CFAsteriskConfigurationFile();
        String cFAsteriskConfigFileName = homeDir.getPath() + File.separator + ".cfasteriskmysqlrc";
        cFAsteriskConfig.setFileName(cFAsteriskConfigFileName);
        File cFAsteriskConfigFile = new File(cFAsteriskConfigFileName);
        if (!cFAsteriskConfigFile.exists()) {
            cFAsteriskConfig.setDbServer("127.0.0.1");
            cFAsteriskConfig.setDbPort(3306);
            cFAsteriskConfig.setDbDatabase("CFAst24");
            cFAsteriskConfig.setDbUserName("root");
            cFAsteriskConfig.setDbPassword("edit-me-please");
            cFAsteriskConfig.save();
            log.message(S_ProcName + "INFO: Created configuration file " + cFAsteriskConfigFileName
                    + ", please edit configuration and restart.");
            return;
        }
        if (!cFAsteriskConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed configuration file " + cFAsteriskConfigFileName
                    + " is not a file.");
            return;
        }
        if (!cFAsteriskConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read configuration file "
                    + cFAsteriskConfigFileName);
            return;
        }
        cFAsteriskConfig.load();
        boolean fastExit = false;
        CFAsteriskClientConfigurationFile cFDbTestClientConfig = new CFAsteriskClientConfigurationFile();
        String cFDbTestClientConfigFileName = homeDir.getPath() + File.separator + ".cfdbtestclientrc";
        cFDbTestClientConfig.setFileName(cFDbTestClientConfigFileName);
        File cFDbTestClientConfigFile = new File(cFDbTestClientConfigFileName);
        if (!cFDbTestClientConfigFile.exists()) {
            String cFDbTestKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
            cFDbTestClientConfig.setKeyStore(cFDbTestKeyStoreFileName);
            InetAddress localHost;
            try {
                localHost = InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                localHost = null;
            }
            if (localHost == null) {
                log.message(S_ProcName + "ERROR: LocalHost is null");
                return;
            }
            String hostName = localHost.getHostName();
            if ((hostName == null) || (hostName.length() <= 0)) {
                log.message("ERROR: LocalHost.HostName is null or empty");
                return;
            }
            String userName = System.getProperty("user.name");
            if ((userName == null) || (userName.length() <= 0)) {
                log.message("ERROR: user.name is null or empty");
                return;
            }
            String deviceName = hostName.replaceAll("[^\\w]", "_").toLowerCase() + "-"
                    + userName.replaceAll("[^\\w]", "_").toLowerCase();
            cFDbTestClientConfig.setDeviceName(deviceName);
            cFDbTestClientConfig.save();
            log.message(S_ProcName + "INFO: Created CFAsterisk client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed client configuration file " + cFDbTestClientConfigFileName
                    + " is not a file.");
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        cFDbTestClientConfig.load();

        if (fastExit) {
            return;
        }

        // Configure logging
        Properties sysProps = System.getProperties();
        sysProps.setProperty("log4j.rootCategory", "WARN");
        sysProps.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

        Logger httpLogger = Logger.getLogger("org.apache.http");
        httpLogger.setLevel(Level.WARN);

        ICFAsteriskSchema cFAsteriskSchema = new CFAsteriskMySqlSchema();
        cFAsteriskSchema.setConfigurationFile(cFAsteriskConfig);
        ICFAsteriskSchemaObj cFAsteriskSchemaObj = new CFAsteriskSchemaObj();
        cFAsteriskSchemaObj.setBackingStore(cFAsteriskSchema);
        CFAsteriskSaxLoaderCLI cli = new CFAsteriskSaxMySqlLoaderCLI();
        CFAsteriskSaxLoader loader = cli.getSaxLoader();
        loader.setSchemaObj(cFAsteriskSchemaObj);
        cFAsteriskSchema.connect();
        String url = args[1];
        if (numArgs >= 5) {
            cli.setClusterName(args[2]);
            cli.setTenantName(args[3]);
            cli.setSecUserName(args[4]);
        } else {
            cli.setClusterName("default");
            cli.setTenantName("system");
            cli.setSecUserName("system");
        }
        loader.setUseCluster(cli.getClusterObj());
        loader.setUseTenant(cli.getTenantObj());
        try {
            cFAsteriskSchema.beginTransaction();
            cFAsteriskSchemaObj.setSecCluster(cli.getClusterObj());
            cFAsteriskSchemaObj.setSecTenant(cli.getTenantObj());
            cFAsteriskSchemaObj.setSecUser(cli.getSecUserObj());
            cFAsteriskSchemaObj.setSecSession(cli.getSecSessionObj());
            CFSecurityAuthorization auth = new CFSecurityAuthorization();
            auth.setSecCluster(cFAsteriskSchemaObj.getSecCluster());
            auth.setSecTenant(cFAsteriskSchemaObj.getSecTenant());
            auth.setSecSession(cFAsteriskSchemaObj.getSecSession());
            cFAsteriskSchemaObj.setAuthorization(auth);
            applyLoaderOptions(loader, args[0]);
            if (numArgs >= 5) {
                cli.evaluateRemainingArgs(args, 5);
            } else {
                cli.evaluateRemainingArgs(args, 2);
            }
            loader.parseFile(url);
            cFAsteriskSchema.commit();
            cFAsteriskSchema.disconnect(true);
        } catch (Exception e) {
            log.message(S_ProcName + "EXCEPTION: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } catch (Error e) {
            log.message(S_ProcName + "ERROR: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } finally {
            if (cFAsteriskSchema.isConnected()) {
                cFAsteriskSchema.rollback();
                cFAsteriskSchema.disconnect(false);
            }
        }
    } else {
        log.message(S_ProcName
                + "ERROR: Expected at least two argument specifying the loader options and the name of the XML file to parse.  The first argument may be empty.");
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxOracleLoaderCLI.CFAsteriskSaxOracleLoaderCLI.java

public static void main(String args[]) {
    final String S_ProcName = "CFAsteriskSaxOracleLoaderCLI.main() ";
    initConsoleLog();/*  w w w.  j a v  a 2 s  .c  o m*/
    int numArgs = args.length;
    if (numArgs >= 2) {
        String homeDirName = System.getProperty("HOME");
        if (homeDirName == null) {
            homeDirName = System.getProperty("user.home");
            if (homeDirName == null) {
                log.message(S_ProcName + "ERROR: Home directory not set");
                return;
            }
        }
        File homeDir = new File(homeDirName);
        if (!homeDir.exists()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
            return;
        }
        if (!homeDir.isDirectory()) {
            log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
            return;
        }
        CFAsteriskConfigurationFile cFAsteriskConfig = new CFAsteriskConfigurationFile();
        String cFAsteriskConfigFileName = homeDir.getPath() + File.separator + ".cfasteriskoraclerc";
        cFAsteriskConfig.setFileName(cFAsteriskConfigFileName);
        File cFAsteriskConfigFile = new File(cFAsteriskConfigFileName);
        if (!cFAsteriskConfigFile.exists()) {
            cFAsteriskConfig.setDbServer("127.0.0.1");
            cFAsteriskConfig.setDbPort(1526);
            cFAsteriskConfig.setDbDatabase("CFAst24");
            cFAsteriskConfig.setDbUserName("system");
            cFAsteriskConfig.setDbPassword("edit-me-please");
            cFAsteriskConfig.save();
            log.message(S_ProcName + "INFO: Created configuration file " + cFAsteriskConfigFileName
                    + ", please edit configuration and restart.");
            return;
        }
        if (!cFAsteriskConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed configuration file " + cFAsteriskConfigFileName
                    + " is not a file.");
            return;
        }
        if (!cFAsteriskConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read configuration file "
                    + cFAsteriskConfigFileName);
            return;
        }
        cFAsteriskConfig.load();
        boolean fastExit = false;
        CFAsteriskClientConfigurationFile cFDbTestClientConfig = new CFAsteriskClientConfigurationFile();
        String cFDbTestClientConfigFileName = homeDir.getPath() + File.separator + ".cfdbtestclientrc";
        cFDbTestClientConfig.setFileName(cFDbTestClientConfigFileName);
        File cFDbTestClientConfigFile = new File(cFDbTestClientConfigFileName);
        if (!cFDbTestClientConfigFile.exists()) {
            String cFDbTestKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
            cFDbTestClientConfig.setKeyStore(cFDbTestKeyStoreFileName);
            InetAddress localHost;
            try {
                localHost = InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                localHost = null;
            }
            if (localHost == null) {
                log.message(S_ProcName + "ERROR: LocalHost is null");
                return;
            }
            String hostName = localHost.getHostName();
            if ((hostName == null) || (hostName.length() <= 0)) {
                log.message("ERROR: LocalHost.HostName is null or empty");
                return;
            }
            String userName = System.getProperty("user.name");
            if ((userName == null) || (userName.length() <= 0)) {
                log.message("ERROR: user.name is null or empty");
                return;
            }
            String deviceName = hostName.replaceAll("[^\\w]", "_").toLowerCase() + "-"
                    + userName.replaceAll("[^\\w]", "_").toLowerCase();
            cFDbTestClientConfig.setDeviceName(deviceName);
            cFDbTestClientConfig.save();
            log.message(S_ProcName + "INFO: Created CFAsterisk client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.isFile()) {
            log.message(S_ProcName + "ERROR: Proposed client configuration file " + cFDbTestClientConfigFileName
                    + " is not a file.");
            fastExit = true;
        }
        if (!cFDbTestClientConfigFile.canRead()) {
            log.message(S_ProcName + "ERROR: Permission denied attempting to read client configuration file "
                    + cFDbTestClientConfigFileName);
            fastExit = true;
        }
        cFDbTestClientConfig.load();

        if (fastExit) {
            return;
        }

        // Configure logging
        Properties sysProps = System.getProperties();
        sysProps.setProperty("log4j.rootCategory", "WARN");
        sysProps.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

        Logger httpLogger = Logger.getLogger("org.apache.http");
        httpLogger.setLevel(Level.WARN);

        ICFAsteriskSchema cFAsteriskSchema = new CFAsteriskOracleSchema();
        cFAsteriskSchema.setConfigurationFile(cFAsteriskConfig);
        ICFAsteriskSchemaObj cFAsteriskSchemaObj = new CFAsteriskSchemaObj();
        cFAsteriskSchemaObj.setBackingStore(cFAsteriskSchema);
        CFAsteriskSaxLoaderCLI cli = new CFAsteriskSaxOracleLoaderCLI();
        CFAsteriskSaxLoader loader = cli.getSaxLoader();
        loader.setSchemaObj(cFAsteriskSchemaObj);
        cFAsteriskSchema.connect();
        String url = args[1];
        if (numArgs >= 5) {
            cli.setClusterName(args[2]);
            cli.setTenantName(args[3]);
            cli.setSecUserName(args[4]);
        } else {
            cli.setClusterName("default");
            cli.setTenantName("system");
            cli.setSecUserName("system");
        }
        loader.setUseCluster(cli.getClusterObj());
        loader.setUseTenant(cli.getTenantObj());
        try {
            cFAsteriskSchema.beginTransaction();
            cFAsteriskSchemaObj.setSecCluster(cli.getClusterObj());
            cFAsteriskSchemaObj.setSecTenant(cli.getTenantObj());
            cFAsteriskSchemaObj.setSecUser(cli.getSecUserObj());
            cFAsteriskSchemaObj.setSecSession(cli.getSecSessionObj());
            CFSecurityAuthorization auth = new CFSecurityAuthorization();
            auth.setSecCluster(cFAsteriskSchemaObj.getSecCluster());
            auth.setSecTenant(cFAsteriskSchemaObj.getSecTenant());
            auth.setSecSession(cFAsteriskSchemaObj.getSecSession());
            cFAsteriskSchemaObj.setAuthorization(auth);
            applyLoaderOptions(loader, args[0]);
            if (numArgs >= 5) {
                cli.evaluateRemainingArgs(args, 5);
            } else {
                cli.evaluateRemainingArgs(args, 2);
            }
            loader.parseFile(url);
            cFAsteriskSchema.commit();
            cFAsteriskSchema.disconnect(true);
        } catch (Exception e) {
            log.message(S_ProcName + "EXCEPTION: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } catch (Error e) {
            log.message(S_ProcName + "ERROR: Could not parse XML file \"" + url + "\": " + e.getMessage());
            e.printStackTrace(System.out);
        } finally {
            if (cFAsteriskSchema.isConnected()) {
                cFAsteriskSchema.rollback();
                cFAsteriskSchema.disconnect(false);
            }
        }
    } else {
        log.message(S_ProcName
                + "ERROR: Expected at least two argument specifying the loader options and the name of the XML file to parse.  The first argument may be empty.");
    }
}