Package gov.nasa.pds.validate
Class ValidateLauncher
- java.lang.Object
-
- gov.nasa.pds.validate.ValidateLauncher
-
public class ValidateLauncher extends Object
Wrapper class for the Validate Tool. Class handles command-line parsing and querying, in addition to reporting setup.- Author:
- mcayanan
-
-
Constructor Summary
Constructors Constructor Description ValidateLauncher()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
displayHelp()
Displays tool usage.void
displayVersion()
Displays the current version and disclaimer notice.boolean
doValidation(Map<URL,String> checksumManifest)
Performs validation.void
flushValidators()
Flush ValidatorFactory cache (set to null).String
getLabelExtension()
File
getNonRegisteredProductsFile()
File
getRegisteredProductsFile()
static void
main(String[] args)
Main class that launches the Validate Tool.org.apache.commons.cli.CommandLine
parse(String[] args)
Parse the command-line argumentsvoid
printReportFooter()
Print the report footer.int
processMain(String[] args)
Wrapper method for the main class that returns valid exitCode for execution.void
query(File configuration)
Query the configuration file.void
query(org.apache.commons.cli.CommandLine line)
Query the command-line and process the command-line option flags set.void
setAdditionalPaths(List<String> additionalPaths)
Set additional paths to be specified when attempting referential integrity validation (pds4.bundle or pds4.collection rules)void
setAllowUnlabeledFiles(boolean flag)
void
setCatalogs(List<String> catalogs)
Set the catalogs.void
setCheckInbetweenFields(boolean flag)
void
setChecksumManifest(String manifest)
Set the checksum manifest.void
setCompleteDescriptions(boolean b)
void
setContentValidation(boolean flag)
Sets the flag that enables/disables data content validation.void
setContextMismatchAsWarn(boolean value)
void
setContextReferenceCheck(boolean flag)
void
setEveryN(int value)
void
setForce(boolean value)
void
setLabelExtension(String labelExtension)
Set the label extension to crawl for within the target space.void
setManifestBasePath(String path)
Set the base path to look up relative file references in a given checksum manifest file.void
setMaxErrors(long value)
void
setNonRegisteredProducts(boolean nonRegisteredProducts)
void
setNonRegisteredProductsFile(File nonRegisteredProductsFile)
void
setPDFErrorDir(String dir)
void
setRegExps(List<String> patterns)
Sets the list of file patterns to look for if traversing a directory.void
setRegisteredProductsFile(File registeredProductsFile)
void
setReportStyle(String style)
Set the output style for the report.void
setSchemas(List<String> schemas)
Set the schemas.void
setSchematrons(List<String> schematrons)
Set the schematrons.void
setSeverity(int level)
Sets the severity level for the report.void
setSkipProductValidation(boolean flag)
void
setSpotCheckData(int value)
void
setTargets(List<String> targets)
Set the target.void
setTraverse(boolean value)
Sets the flag to enable/disable directory recursion.void
setUpdateRegisteredProducts(boolean updateRegisteredProducts)
void
setupReport()
Setup the report.void
setValidateContext(boolean flag)
Sets the flag that enables/disables context validation.void
setValidationRule(String value)
Sets the validation rule name to use.
-
-
-
Constructor Detail
-
ValidateLauncher
public ValidateLauncher() throws TransformerConfigurationException
Constructor.
-
-
Method Detail
-
parse
public org.apache.commons.cli.CommandLine parse(String[] args) throws org.apache.commons.cli.ParseException
Parse the command-line arguments- Parameters:
args
- The command-line arguments- Returns:
- A class representation of the command-line arguments
- Throws:
org.apache.commons.cli.ParseException
- If an error occurred during parsing.
-
query
public void query(org.apache.commons.cli.CommandLine line) throws Exception
Query the command-line and process the command-line option flags set.- Parameters:
line
- A CommandLine object containing the flags that were set.- Throws:
Exception
- If an error occurred while processing the command-line options.
-
query
public void query(File configuration) throws org.apache.commons.configuration.ConfigurationException
Query the configuration file.- Parameters:
configuration
- A configuration file.- Throws:
org.apache.commons.configuration.ConfigurationException
- If an error occurred while querying the configuration file.
-
setAdditionalPaths
public void setAdditionalPaths(List<String> additionalPaths) throws MalformedURLException
Set additional paths to be specified when attempting referential integrity validation (pds4.bundle or pds4.collection rules)- Parameters:
additionalPaths
- A list of paths.- Throws:
MalformedURLException
-
setTargets
public void setTargets(List<String> targets) throws MalformedURLException
Set the target.- Parameters:
targets
- A list of targets.- Throws:
MalformedURLException
-
setChecksumManifest
public void setChecksumManifest(String manifest) throws MalformedURLException
Set the checksum manifest.- Parameters:
manifest
- A checksum manifest file.- Throws:
MalformedURLException
-
setManifestBasePath
public void setManifestBasePath(String path) throws MalformedURLException
Set the base path to look up relative file references in a given checksum manifest file.- Parameters:
path
- A path.- Throws:
MalformedURLException
-
setSchemas
public void setSchemas(List<String> schemas) throws MalformedURLException
Set the schemas.- Parameters:
schemas
- A list of schemas.- Throws:
MalformedURLException
-
setSchematrons
public void setSchematrons(List<String> schematrons) throws MalformedURLException
Set the schematrons.- Parameters:
schematrons
- A list of schematrons.- Throws:
MalformedURLException
-
setCatalogs
public void setCatalogs(List<String> catalogs)
Set the catalogs.- Parameters:
catalogs
- A list of catalogs.
-
setReportStyle
public void setReportStyle(String style) throws Exception
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:
Exception
-
setTraverse
public void setTraverse(boolean value)
Sets the flag to enable/disable directory recursion.- Parameters:
value
- A boolean value.
-
setSeverity
public void setSeverity(int level)
Sets the severity level for the report.- Parameters:
level
- An interger value.
-
setRegExps
public void setRegExps(List<String> patterns)
Sets the list of file patterns to look for if traversing a directory.- Parameters:
patterns
- A list of file patterns.
-
setForce
public void setForce(boolean value)
-
setValidationRule
public void setValidationRule(String value)
Sets the validation rule name to use.- Parameters:
value
- the validation rule name
-
setContentValidation
public void setContentValidation(boolean flag)
Sets the flag that enables/disables data content validation.- Parameters:
flag
- True or False.
-
setContextReferenceCheck
public void setContextReferenceCheck(boolean flag)
-
setCheckInbetweenFields
public void setCheckInbetweenFields(boolean flag)
-
setSkipProductValidation
public void setSkipProductValidation(boolean flag)
-
setMaxErrors
public void setMaxErrors(long value)
-
setEveryN
public void setEveryN(int value)
-
setContextMismatchAsWarn
public void setContextMismatchAsWarn(boolean value)
-
setCompleteDescriptions
public void setCompleteDescriptions(boolean b)
-
setPDFErrorDir
public void setPDFErrorDir(String dir)
-
setSpotCheckData
public void setSpotCheckData(int value)
-
setAllowUnlabeledFiles
public void setAllowUnlabeledFiles(boolean flag)
-
setUpdateRegisteredProducts
public void setUpdateRegisteredProducts(boolean updateRegisteredProducts)
-
setNonRegisteredProducts
public void setNonRegisteredProducts(boolean nonRegisteredProducts)
-
getRegisteredProductsFile
public File getRegisteredProductsFile()
-
setRegisteredProductsFile
public void setRegisteredProductsFile(File registeredProductsFile)
-
getNonRegisteredProductsFile
public File getNonRegisteredProductsFile()
-
setNonRegisteredProductsFile
public void setNonRegisteredProductsFile(File nonRegisteredProductsFile)
-
setValidateContext
public void setValidateContext(boolean flag)
Sets the flag that enables/disables context validation.- Parameters:
flag
- True or False.
-
displayHelp
public void displayHelp()
Displays tool usage.
-
displayVersion
public void displayVersion() throws IOException
Displays the current version and disclaimer notice.- Throws:
IOException
- If there was an error that occurred while getting the tool information.
-
setupReport
public void setupReport() throws IOException
Setup the report.- Throws:
IOException
- If an error occurred while setting up the report.
-
doValidation
public boolean doValidation(Map<URL,String> checksumManifest) throws Exception
Performs validation.- Parameters:
checksumManifest
-- Returns:
- boolean true - success false - fail
- Throws:
Exception
-
printReportFooter
public void printReportFooter()
Print the report footer.
-
processMain
public int processMain(String[] args) throws Exception
Wrapper method for the main class that returns valid exitCode for execution.- Parameters:
args
- list of command-line arguments.- Throws:
Exception
-
flushValidators
public void flushValidators()
Flush ValidatorFactory cache (set to null). The ValidatorFactory will cache schemas and other validation data between runs, which can cause issues, specifically when using varying dictionaries and catalog files.
-
main
public static void main(String[] args) throws TransformerConfigurationException
Main class that launches the Validate Tool.- Parameters:
args
- A list of command-line arguments.- Throws:
TransformerConfigurationException
-
getLabelExtension
public String getLabelExtension()
-
setLabelExtension
public void setLabelExtension(String labelExtension)
Set the label extension to crawl for within the target space. NOTE: This should be executed prior to running the doValidation or it will not be appropriately added to validation pipeline execution context.- Parameters:
labelExtension
-
-
-