Package gov.nasa.pds.tools.validate.rule
Class RuleContext
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
org.apache.commons.chain.impl.ContextBase
gov.nasa.pds.tools.validate.rule.RuleContext
- All Implemented Interfaces:
Serializable
,Cloneable
,Map
,org.apache.commons.chain.Context
public class RuleContext
extends org.apache.commons.chain.impl.ContextBase
Implements a type-safe context for using validation rules
in commands and chains.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
Field Summary
Fields Modifier and Type Field Description static String
ADDITIONAL_TARGET_KEY
Key used to retrieve additional targets.static String
ALLOW_UNLABELED_FILES_KEY
Key used to tell the tool to allow unlabeled files in a bundle or collection.static String
CATALOG_FILES
The key used to retrieve the catalog files.static String
CATALOG_RESOLVER
The key used to retrieve the XMLCatalogResolver object.static String
CHECK_DATA_KEY
The key used to indicate whether to disable data content validation.static String
CHECKSUM_MANIFEST_KEY
The key used to retrieve a hash map containing the checksum values from a given checksum manifest.static String
CONTEXT_VALIDATION_KEY
The key used to indicate whether to disable context validation.static String
CRAWLER_KEY
The key used to retrieve the crawler.static String
FILE_FILTERS
The key used to set file name filters.static String
FORCE_LABEL_SCHEMA_VALIDATION
The key used to indicate that declared schema and Schematron files in a label should be validated before the label is validate.static String
LISTENER_KEY
The key used to retrieve the definition listener from the execution context.static String
LOCATION_VALIDATOR_KEY
The key used to retrieve the top-level validator for getting singleton utilities.static String
PARENT_TARGET_KEY
The key used to retrieve the parent target from the context.static String
RECURSIVE_VALIDATION
The key used to set whether to validate recursively.static String
REGISTERED_PRODUCTS_KEY
Key used to store a map of registered Product LIDVIDs.static String
REGISTRAR_KEY
The key used to retrieve the validation registrar from the execution context.static String
RULE_KEY
static String
RULE_MANAGER_KEY
The key used to retrieve the rule manager from the context.static String
SKIP_PRODUCT_VALIDATION_KEY
Key used to ignore(skip) product level validation.static String
SPOT_CHECK_DATA_KEY
The key used to indicate how many lines or records to skip during content validation.static String
TARGET_KEY
The key used to retrieve the current validation target from the execution context. -
Constructor Summary
Constructors Constructor Description RuleContext()
-
Method Summary
Modifier and Type Method Description boolean
getAllowUnlabeledFiles()
XMLCatalogResolver
getCatalogResolver()
List<String>
getCatalogs()
boolean
getCheckData()
Map<URL,String>
getChecksumManifest()
<T> T
getContextValue(String key, Class<T> clazz)
Gets a value from the context in a type-safe manner.Crawler
getCrawler()
AdditionalTarget
getExtraTarget()
WildcardOSFilter
getFileFilters()
ExceptionType
getLogLevel()
String
getParentTarget()
Gets the parent target location.ProblemListener
getProblemListener()
Map<String,List<ContextProductReference>>
getRegisteredProducts()
LocationValidator
getRootValidator()
Gets the top-level validator for getting singleton utilities, such as the label validator.ValidationRule
getRule()
ValidationRuleManager
getRuleManager()
Gets the rule manager used to find other rules to apply.boolean
getSkipProductValidation()
int
getSpotCheckData()
URL
getTarget()
TargetRegistrar
getTargetRegistrar()
boolean
getValidateContext()
boolean
isForceLabelSchemaValidation()
Tests whether to force validation of schemas and Schematrons defined in a label file.boolean
isRecursive()
boolean
isRootTarget()
Tests whether this is the root target for the validation.<T> void
putContextValue(String key, T value)
Puts a value into the context in a type-safe manner.void
setAllowUnlabeledFiles(boolean flag)
void
setCatalogResolver(XMLCatalogResolver catalogResolver)
void
setCatalogs(List<String> catalogs)
void
setCheckData(boolean flag)
void
setChecksumManifest(Map<URL,String> manifest)
void
setCrawler(Crawler crawler)
void
setExtraTarget(ArrayList<URL> targets)
void
setFileFilters(WildcardOSFilter filter)
void
setFileFilters(List<String> filters)
void
setForceLabelSchemaValidation(boolean force)
Sets whether to force schema and Schematron validation defined in a label.void
setLogLevel(ExceptionType logLevel)
void
setParentTarget(String parentLocation)
Sets the parent target location.void
setProblemListener(ProblemListener listener)
void
setRecursive(boolean isRecursive)
void
setRegisteredProducts(Map<String,List<ContextProductReference>> products)
void
setRootTarget(boolean flag)
Sets whether this is the root target for the validation.void
setRootValidator(LocationValidator validator)
Sets the top-level validator.void
setRule(ValidationRule rule)
void
setRuleManager(ValidationRuleManager ruleManager)
Sets the rule manager to use for finding new rules.void
setSkipProductValidation(boolean flag)
void
setSpotCheckData(int value)
void
setTarget(URL target)
void
setTargetRegistrar(TargetRegistrar registrar)
void
setValidateContext(boolean flag)
Methods inherited from class org.apache.commons.chain.impl.ContextBase
clear, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Field Details
-
LOCATION_VALIDATOR_KEY
The key used to retrieve the top-level validator for getting singleton utilities.- See Also:
- Constant Field Values
-
FORCE_LABEL_SCHEMA_VALIDATION
The key used to indicate that declared schema and Schematron files in a label should be validated before the label is validate.- See Also:
- Constant Field Values
-
RECURSIVE_VALIDATION
The key used to set whether to validate recursively.- See Also:
- Constant Field Values
-
FILE_FILTERS
The key used to set file name filters.- See Also:
- Constant Field Values
-
TARGET_KEY
The key used to retrieve the current validation target from the execution context.- See Also:
- Constant Field Values
-
ADDITIONAL_TARGET_KEY
Key used to retrieve additional targets.- See Also:
- Constant Field Values
-
LISTENER_KEY
The key used to retrieve the definition listener from the execution context.- See Also:
- Constant Field Values
-
REGISTRAR_KEY
The key used to retrieve the validation registrar from the execution context.- See Also:
- Constant Field Values
-
RULE_MANAGER_KEY
The key used to retrieve the rule manager from the context.- See Also:
- Constant Field Values
-
RULE_KEY
- See Also:
- Constant Field Values
-
PARENT_TARGET_KEY
The key used to retrieve the parent target from the context.- See Also:
- Constant Field Values
-
CRAWLER_KEY
The key used to retrieve the crawler.- See Also:
- Constant Field Values
-
CHECKSUM_MANIFEST_KEY
The key used to retrieve a hash map containing the checksum values from a given checksum manifest.- See Also:
- Constant Field Values
-
CATALOG_FILES
The key used to retrieve the catalog files.- See Also:
- Constant Field Values
-
CATALOG_RESOLVER
The key used to retrieve the XMLCatalogResolver object.- See Also:
- Constant Field Values
-
CHECK_DATA_KEY
The key used to indicate whether to disable data content validation.- See Also:
- Constant Field Values
-
SPOT_CHECK_DATA_KEY
The key used to indicate how many lines or records to skip during content validation.- See Also:
- Constant Field Values
-
ALLOW_UNLABELED_FILES_KEY
Key used to tell the tool to allow unlabeled files in a bundle or collection.- See Also:
- Constant Field Values
-
REGISTERED_PRODUCTS_KEY
Key used to store a map of registered Product LIDVIDs.- See Also:
- Constant Field Values
-
CONTEXT_VALIDATION_KEY
The key used to indicate whether to disable context validation.- See Also:
- Constant Field Values
-
SKIP_PRODUCT_VALIDATION_KEY
Key used to ignore(skip) product level validation.- See Also:
- Constant Field Values
-
-
Constructor Details
-
RuleContext
public RuleContext()
-
-
Method Details
-
getContextValue
Gets a value from the context in a type-safe manner.- Parameters:
key
- the keyclazz
- the expected class- Returns:
- the value, or null if there is no value with that key
-
putContextValue
Puts a value into the context in a type-safe manner.- Parameters:
key
- the keyvalue
- the value
-
getLogLevel
-
setLogLevel
-
getTarget
-
setTarget
-
getExtraTarget
-
setExtraTarget
public void setExtraTarget(ArrayList<URL> targets) throws MalformedURLException, URISyntaxException -
getProblemListener
-
setProblemListener
-
getTargetRegistrar
-
setTargetRegistrar
-
getRuleManager
Gets the rule manager used to find other rules to apply.- Returns:
- the rule manager
-
getRule
-
setRuleManager
Sets the rule manager to use for finding new rules.- Parameters:
ruleManager
- the rule manager
-
setRule
-
getParentTarget
Gets the parent target location.- Returns:
- the parent target location, or null if there is no parent target
-
setParentTarget
Sets the parent target location.- Parameters:
parent
- the parent target location
-
isRootTarget
public boolean isRootTarget()Tests whether this is the root target for the validation.- Returns:
- true, if this context is for the root target
-
setRootTarget
public void setRootTarget(boolean flag)Sets whether this is the root target for the validation.- Parameters:
flag
- true, if this context is for the root target
-
getRootValidator
Gets the top-level validator for getting singleton utilities, such as the label validator.- Returns:
- the top-level validator
-
setRootValidator
Sets the top-level validator.- Parameters:
validator
- the top-level validator
-
isRecursive
public boolean isRecursive() -
setRecursive
public void setRecursive(boolean isRecursive) -
getFileFilters
-
setFileFilters
-
setFileFilters
-
isForceLabelSchemaValidation
public boolean isForceLabelSchemaValidation()Tests whether to force validation of schemas and Schematrons defined in a label file.- Returns:
- true, if declared schema and Schematron files should be validated
-
setForceLabelSchemaValidation
public void setForceLabelSchemaValidation(boolean force)Sets whether to force schema and Schematron validation defined in a label.- Parameters:
force
- true, if declared schema and Schematron files should be validated
-
getCrawler
-
setCrawler
-
setChecksumManifest
-
getChecksumManifest
-
setCatalogs
-
getCatalogs
-
setCatalogResolver
-
getCatalogResolver
-
getCheckData
public boolean getCheckData() -
setCheckData
public void setCheckData(boolean flag) -
getSpotCheckData
public int getSpotCheckData() -
setSpotCheckData
public void setSpotCheckData(int value) -
getAllowUnlabeledFiles
public boolean getAllowUnlabeledFiles() -
setAllowUnlabeledFiles
public void setAllowUnlabeledFiles(boolean flag) -
getRegisteredProducts
-
setRegisteredProducts
-
getValidateContext
public boolean getValidateContext() -
setValidateContext
public void setValidateContext(boolean flag) -
getSkipProductValidation
public boolean getSkipProductValidation() -
setSkipProductValidation
public void setSkipProductValidation(boolean flag)
-