gov.nasa.pds.vtool
Class VTool

java.lang.Object
  extended by gov.nasa.pds.vtool.VTool
All Implemented Interfaces:
VToolConfigKeys, ToolsFlags, VToolFlags, ToolsLicense, ExitStatusType

public class VTool
extends Object
implements VToolConfigKeys, VToolFlags, ExitStatusType, ToolsLicense

Class to perform automated validation to determine if a given data product is PDS compliant.

This replaces LVTool functionality.

Version:
$Revision: 11676 $
Author:
mcayanan

Field Summary
 
Fields inherited from interface gov.nasa.pds.vtool.config.VToolConfigKeys
ALIASKEY, DICTKEY, FOLLOWKEY, FORCEKEY, IGNOREDIRKEY, IGNOREFILEKEY, INCLUDESKEY, LOGKEY, PROGRESSKEY, RECURSEKEY, REGEXPKEY, REPORTKEY, SHOWLOGKEY, STYLEKEY, TARGETKEY, VERBOSEKEY
 
Fields inherited from interface gov.nasa.pds.vtool.flags.VToolFlags
ALIAS, FOLLOW, IGNOREDIR, IGNOREFILE, INCLUDES, LOCAL, LOG, PARTIAL, PROGRESS, REGEXP, RPTSTYLE, TARGET, VERBOSE, WHATIS_ALIAS, WHATIS_DICT, WHATIS_FOLLOW, WHATIS_IGNOREDIR, WHATIS_IGNOREFILE, WHATIS_INCLUDES, WHATIS_LOCAL, WHATIS_LOG, WHATIS_PARTIAL, WHATIS_PROGRESS, WHATIS_REGEXP, WHATIS_REPORT, WHATIS_RPTSTYLE, WHATIS_TARGET, WHATIS_VERBOSE
 
Fields inherited from interface gov.nasa.pds.vtool.flags.ToolsFlags
ARGNAME, CONFIG, DICT, HELP, LONG, REPORT, SHORT, VERSION, WHATIS_CONFIG, WHATIS_HELP, WHATIS_VERSION
 
Fields inherited from interface gov.nasa.pds.vtool.status.ExitStatusType
APPLICATION_ERROR, ERRORS_FOUND, SKIPPED_FILES, SUCCESS, SYSTEM_ERROR, WARNINGS_FOUND
 
Fields inherited from interface gov.nasa.pds.vtool.license.ToolsLicense
LICENSE
 
Constructor Summary
VTool()
          Default constructor.
 
Method Summary
 List<URL> getDictionaries()
           
static void main(String[] argv)
          Implementation to perform automated PDS validation.
 org.apache.commons.cli.CommandLine parseLine(String[] argv)
          Parses the VTool command-line.
 void printRptFooter()
           
 void printRptHeader()
          Prints report header information such as version of the tool, execution time, and flag settings.
 void queryCmdLine(org.apache.commons.cli.CommandLine cmd)
          Queries the VTool command-line.
 void readConfigFile(URL file)
          Reads a configuration file to set the default behaviors for VTool.
 gov.nasa.pds.tools.dict.Dictionary readDictionaries(List dictionary)
          Parse the dictionary files.
 void setAlias(boolean a)
          Set aliasing flag.
 void setDictionaries(List<String> d)
          Set the dictionary file names passed into VTool .
 void setdirsToSkip(List<String> d)
          Set the flag to ignore specified directories.
 void setfilesToFind(List<String> e)
          Set the patterns flag.
 void setfilesToSkip(List<String> f)
          Set the flag to ignore specified files.
 void setFollowPtrs(boolean f)
          Set the flag that determines whether to follow pointers found in a label.
 void setForcePartial(boolean f)
          Set the flag that determines whether to validate standalone label.
 void setIncludePaths(List<String> i)
          Set the paths to search for files referenced by pointers.
 void setLogFile(File f)
          Set the file name for the machine-readable log.
 void setProgress(boolean p)
          Set the progress reporting flag.
 void setRecursive(boolean r)
          Set the recursive flag.
 void setRptFile(File f)
          Set the file for the human-readable report.
 void setRptStyle(String style)
          Set the output style for the report.
 void setShowLog(boolean l)
          Set the flag to write the log to standard out.
 void setTargets(List<String> t)
          Set the targets flag.
 void setupReport()
          Configures the logger appropriately.
 void setVerbose(short v)
          Set the verbosity level and above to include in the reporting.
 void showHelp()
          Display VTool usage and help information
 void showProgress(URL file)
          Prints out the current directory being validated and represents each file being validated by an asterisk.
 void showVersion()
          Show the version and disclaimer notice for VTool.
 void validateLabel(URL url, gov.nasa.pds.tools.dict.Dictionary dict)
          Validate a label file.
 void validateLabels(List<Target> targets)
          Validate labels, performing only syntactic validation.
 void validateLabels(List<Target> targets, gov.nasa.pds.tools.dict.Dictionary dict)
          Validate labels, performing both syntactic and semantic validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VTool

public VTool()
Default constructor.

Method Detail

showVersion

public void showVersion()
                 throws IOException
Show the version and disclaimer notice for VTool.

Throws:
IOException

showHelp

public void showHelp()
Display VTool usage and help information


parseLine

public org.apache.commons.cli.CommandLine parseLine(String[] argv)
                                             throws ApplicationException
Parses the VTool command-line.

Parameters:
argv - arguments given on the command-line
Throws:
ApplicationException

queryCmdLine

public void queryCmdLine(org.apache.commons.cli.CommandLine cmd)
                  throws ApplicationException,
                         MalformedURLException,
                         SystemException
Queries the VTool command-line.

Throws:
ApplicationException
MalformedURLException
SystemException

setAlias

public void setAlias(boolean a)
Set aliasing flag.

Parameters:
a - 'false' if aliasing should be turned off, 'true' otherwise

getDictionaries

public List<URL> getDictionaries()

setDictionaries

public void setDictionaries(List<String> d)
                     throws ApplicationException
Set the dictionary file names passed into VTool .

Parameters:
d - a List object of dictionary files
Throws:
ApplicationException

setFollowPtrs

public void setFollowPtrs(boolean f)
Set the flag that determines whether to follow pointers found in a label.

Parameters:
f - 'true' to follow, 'false' otherwise

setForcePartial

public void setForcePartial(boolean f)
Set the flag that determines whether to validate standalone label. fragments

Parameters:
f - 'true' to enable, 'false' otherwise

setIncludePaths

public void setIncludePaths(List<String> i)
Set the paths to search for files referenced by pointers.

Default is to always look first in the same directory as the label, then search specified directories.

Parameters:
i - List of paths

setdirsToSkip

public void setdirsToSkip(List<String> d)
Set the flag to ignore specified directories.

Parameters:
d - a text file containing a list of directories and/or directory patterns to ignore during validation. The names must be listed one name per line.

setfilesToSkip

public void setfilesToSkip(List<String> f)
Set the flag to ignore specified files.

Parameters:
f - a list of files/file patterns to ignore during validation.

setLogFile

public void setLogFile(File f)
Set the file name for the machine-readable log.

Parameters:
f - file name of the log

setShowLog

public void setShowLog(boolean l)
Set the flag to write the log to standard out.

Parameters:
l -

setRptFile

public void setRptFile(File f)
Set the file for the human-readable report.

Parameters:
f - file name

setRptStyle

public void setRptStyle(String style)
                 throws ApplicationException
Set the output style for the report.

Parameters:
style - 'sum' for a summary report, 'min' for a minimal report, and 'full' for a full report
Throws:
ApplicationException

setProgress

public void setProgress(boolean p)
Set the progress reporting flag.

Parameters:
p -

setfilesToFind

public void setfilesToFind(List<String> e)
Set the patterns flag.

Parameters:
e - a List of patterns to be matched when searching for files to validate in a directory

setRecursive

public void setRecursive(boolean r)
Set the recursive flag.

Parameters:
r - 'true' to recursively traverse down a directory and all its sub-directories, 'false' otherwise

setTargets

public void setTargets(List<String> t)
Set the targets flag.

Parameters:
t - a List of files, URLs, and/or directories to be validated

setVerbose

public void setVerbose(short v)
                throws ApplicationException
Set the verbosity level and above to include in the reporting.

Parameters:
v - '1' for info, '2' for warnings, and '3' for errors
Throws:
ApplicationException

readConfigFile

public void readConfigFile(URL file)
                    throws ApplicationException
Reads a configuration file to set the default behaviors for VTool.

Flags set on the command-line will override flags set in the configuration file

Parameters:
file - a file containing keyword/value statements
Throws:
ApplicationException

printRptHeader

public void printRptHeader()
                    throws SystemException,
                           IOException
Prints report header information such as version of the tool, execution time, and flag settings.

Throws:
SystemException
IOException

setupReport

public void setupReport()
                 throws ApplicationException,
                        SystemException
Configures the logger appropriately.

If a log file was specified on the command-line, the log will be written to that file. If the log flag was specified with no file spec, then the log will be written to standard out. Otherwise, the log will be written to memory (ByteArrayOutputStream).

Throws:
SystemException
ApplicationException

readDictionaries

public gov.nasa.pds.tools.dict.Dictionary readDictionaries(List dictionary)
                                                    throws ApplicationException,
                                                           URISyntaxException
Parse the dictionary files.

Parameters:
dictionary - a list of dictionary URLs
Returns:
a Dictionary object that includes all the dictionary information from all the dictionary files passed in.
Throws:
ApplicationException
URISyntaxException

validateLabels

public void validateLabels(List<Target> targets)
                    throws Exception
Validate labels, performing only syntactic validation.

Parameters:
targets -
Throws:
Exception

validateLabels

public void validateLabels(List<Target> targets,
                           gov.nasa.pds.tools.dict.Dictionary dict)
                    throws Exception
Validate labels, performing both syntactic and semantic validation. If the target is a directory, this method will validate all labels found within the directory and its sub-directories. If recursion is turned OFF, then sub-directories will not be looked into.

Parameters:
targets - a list of files, directories, and/or URLs.
dict - the dictionary file.
Throws:
Exception

validateLabel

public void validateLabel(URL url,
                          gov.nasa.pds.tools.dict.Dictionary dict)
                   throws ApplicationException,
                          SystemException
Validate a label file.

Parameters:
url - The URL of the file to be validated
dict - a Dictionary object needed for semantic validation. If null, only syntactic validation will be performed.
Throws:
ApplicationException
SystemException

showProgress

public void showProgress(URL file)
                  throws SystemException
Prints out the current directory being validated and represents each file being validated by an asterisk. This is used when progress reporting is enabled.

Parameters:
file - The URL being validated
Throws:
SystemException

main

public static void main(String[] argv)
Implementation to perform automated PDS validation.

The main calls the following methods (in this order):

To setup the flags and parse the command-line options:

To setup the logger and log the report header information:

To perform validation:

To create the final report:

Reporting is not generated if the log flag was specified with no file spec and the report file flag was not specified

VTool returns an appropriate exit status based on validation results.

Parameters:
argv - Arguments passed on the command-line

printRptFooter

public void printRptFooter()


Copyright © 2005-2013 Planetary Data System. All Rights Reserved.