@Plugin(name="ScriptCondition", category="Core", printObject=true) public class ScriptCondition extends java.lang.Object
DeleteAction
where a user-provided script selects the files to delete from a provided
list. The specified script may be a Script
, a ScriptFile
or a ScriptRef
.Modifier and Type | Field and Description |
---|---|
private Configuration |
configuration |
private static Logger |
LOGGER |
private AbstractScript |
script |
Constructor and Description |
---|
ScriptCondition(AbstractScript script,
Configuration configuration)
Constructs a new ScriptCondition.
|
Modifier and Type | Method and Description |
---|---|
static ScriptCondition |
createCondition(AbstractScript script,
Configuration configuration)
Creates the ScriptCondition.
|
java.util.List<PathWithAttributes> |
selectFilesToDelete(java.nio.file.Path basePath,
java.util.List<PathWithAttributes> candidates)
Executes the script
|
private static Logger LOGGER
private final AbstractScript script
private final Configuration configuration
public ScriptCondition(AbstractScript script, Configuration configuration)
script
- the script that can select files to deleteconfiguration
- configuration containing the StrSubstitutor passed to the scriptpublic java.util.List<PathWithAttributes> selectFilesToDelete(java.nio.file.Path basePath, java.util.List<PathWithAttributes> candidates)
baseDir
- candidates
- @PluginFactory public static ScriptCondition createCondition(@PluginElement(value="Script") AbstractScript script, @PluginConfiguration Configuration configuration)
script
- The script to run. This may be a Script
, a ScriptFile
or a ScriptRef
. The
script must return a List<PathWithAttributes>
. When the script is executed, it is provided the
following bindings:
Delete
action started scanning for
files to delete. Can be used to relativize the paths in the pathList.java.util.List
containing PathWithAttribute
objects. (The script is
free to modify and return this list.)StrSubstitutor
that can be used to look up variables embedded in the base
dir or other properties
StatusLogger
that can be used to log events during script execution
configuration
- the configuration