@Plugin(name="Delete", category="Core", printObject=true) public class DeleteAction extends AbstractPathAction
LOGGER
Modifier and Type | Method and Description |
---|---|
static DeleteAction |
createDeleteAction(String basePath,
boolean followLinks,
int maxDepth,
boolean testMode,
PathSorter sorterParameter,
PathCondition[] pathConditions,
ScriptCondition scriptCondition,
Configuration config)
Create a DeleteAction.
|
protected FileVisitor<Path> |
createFileVisitor(Path visitorBaseDir,
List<PathCondition> conditions)
Creates a new
FileVisitor<Path> to pass to the Files.walkFileTree(Path, Set, int, FileVisitor)
method when the AbstractPathAction.execute() method is invoked. |
protected void |
delete(Path path)
Deletes the specified file.
|
boolean |
execute()
Performs action.
|
boolean |
execute(FileVisitor<Path> visitor) |
boolean |
isTestMode()
Returns
true if files are not deleted even when all conditions accept a path, false otherwise. |
getBasePath, getBasePathString, getMaxDepth, getOptions, getPathConditions, getStrSubstitutor, isFollowSymbolicLinks, toString
close, isComplete, isInterrupted, reportException, run
public boolean execute() throws IOException
AbstractAction
execute
in interface Action
execute
in class AbstractPathAction
IOException
- if IO error.protected void delete(Path path) throws IOException
path
- the file to deleteIOException
- if a problem occurred deleting the filepublic boolean execute(FileVisitor<Path> visitor) throws IOException
execute
in class AbstractPathAction
IOException
public boolean isTestMode()
true
if files are not deleted even when all conditions accept a path, false
otherwise.true
if files are not deleted even when all conditions accept a path, false
otherwiseprotected FileVisitor<Path> createFileVisitor(Path visitorBaseDir, List<PathCondition> conditions)
AbstractPathAction
FileVisitor<Path>
to pass to the Files.walkFileTree(Path, Set, int, FileVisitor)
method when the AbstractPathAction.execute()
method is invoked.
The visitor is responsible for processing the files it encounters that are accepted by all filters.
createFileVisitor
in class AbstractPathAction
visitorBaseDir
- base dir from where to start scanning for files to processconditions
- filters that determine if a file should be processedFileVisitor<Path>
@PluginFactory public static DeleteAction createDeleteAction(@PluginAttribute(value="basePath") String basePath, @PluginAttribute(value="followLinks") boolean followLinks, @PluginAttribute(value="maxDepth",defaultInt=1) int maxDepth, @PluginAttribute(value="testMode") boolean testMode, @PluginElement(value="PathSorter") PathSorter sorterParameter, @PluginElement(value="PathConditions") PathCondition[] pathConditions, @PluginElement(value="ScriptCondition") ScriptCondition scriptCondition, @PluginConfiguration Configuration config)
basePath
- base path from where to start scanning for files to delete.followLinks
- whether to follow symbolic links. Default is false.maxDepth
- The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0
means that only the starting file is visited, unless denied by the security manager. A value of
MAX_VALUE may be used to indicate that all levels should be visited.testMode
- if true, files are not deleted but instead a message is printed to the status logger
at INFO level. Users can use this to do a dry run to test if their configuration works as expected.
Default is false.PathSorter
- a plugin implementing the PathSorter
interfacePathConditions
- an array of path conditions (if more than one, they all need to accept a path before it is
deleted).config
- The Configuration.Copyright © 1999-2019 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.