All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.nasa.pds.citool.CITool Maven / Gradle / Ivy

Go to download

The Legacy Catalog Tool provides functionality for ingesting PDS3 catalog files into the PDS4 infrastructure including the Registry Service.

There is a newer version: 3.1.0
Show newest version
package gov.nasa.pds.citool;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.AbstractConfiguration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.ConsoleAppender;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import gov.nasa.pds.citool.commandline.options.ConfigKey;
import gov.nasa.pds.citool.commandline.options.Flag;
import gov.nasa.pds.citool.commandline.options.InvalidOptionException;
import gov.nasa.pds.citool.commandline.options.Mode;
import gov.nasa.pds.citool.commandline.options.ToolsPropertiesConfiguration;
import gov.nasa.pds.citool.registry.client.RegistryClientManager;
import gov.nasa.pds.citool.report.CompareReport;
import gov.nasa.pds.citool.report.IngestReport;
import gov.nasa.pds.citool.report.Report;
import gov.nasa.pds.citool.report.ValidateReport;
import gov.nasa.pds.citool.search.DocConfigManager;
import gov.nasa.pds.citool.search.DocGenerator;
import gov.nasa.pds.citool.target.Target;
import gov.nasa.pds.citool.util.ToolInfo;
import gov.nasa.pds.citool.util.Utility;
import gov.nasa.pds.tools.constants.Constants.Severity;

/**
 * Front end class for the Catalog Ingestion Tool.
 *
 * @author mcayanan, hyunlee
 *
 */
public class CITool 
{
	private static final String DEFAULT_REGISTRTY_URL = "http://localhost:8983/solr"; 
	
    private List targets;
    private List dictionaries;
    private List includePaths;
    private Target oldTarget;
    private Target newTarget;
    private File reportFile;
    private Severity severity;
    private boolean traverse;
    private boolean alias;
    private Target target;
    private URL allrefs;
 
    private String registryUrl;
    private String docConfifDir;
    private String outputDir;
        
    private Mode toolMode;
    private Report report;

    private Logger log;
    
    public CITool() 
    {
    	log = Logger.getLogger(this.getClass().getName());
    	
        targets = new ArrayList();
        dictionaries = new ArrayList();
        includePaths = new ArrayList();
        oldTarget = null;
        newTarget = null;
        severity = Severity.WARNING;
        toolMode = null;
        alias = false;
        traverse = true;
        reportFile = null;
        target = null;
        allrefs = null;
        report = null;
    }

    /**
     * Parses the CITool command-line.
     *
     * @param argv arguments given on the command-line
     * @throws ApplicationException
     */
    public CommandLine parseLine(String[] argv) throws Exception {
        CommandLineParser parser = new GnuParser();
        try {
            return parser.parse(Flag.getOptions(), argv);
        }
        catch( ParseException pEx ) {
            throw new Exception("Command line parser failed.\n\n"
                    + "Reason: " + pEx.getMessage());
        }
    }

    
    private void processCommandLine(CommandLine commandLine) throws Exception
    {
        List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy