public class FileUtil extends Object
Constructor and Description |
---|
FileUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
backupDir(Properties p,
String from,
String to)
Backup a directory in the given source directory structure to a
location under the given destination directory structure.
|
static void |
cleanupLogs(File dir)
Delete all files under the given directory
|
static void |
cleanupOldLogs(File dir,
long age)
Delete all files under the given directory that are past a given age
|
static void |
createDirTree(List<Properties> props,
String dirName)
Create a directory tree with the given name directly under the root of
the Report Service directory tree.
|
static File |
getDir(String dirName,
String nodeName,
String profileID)
Get a
File object pointing to the directory under the
root directory and create all directories and sub-directories as needed. |
static List<File> |
getFileList(File dir)
|
static List<String> |
getFilenameList(String path)
Get a
List of file names in the given directory. |
static void |
getFilesFromDirTree(File dir,
File dest)
Copy all files found within the given directory or its sub-directories
to the given location.
|
static File |
getProcessingDir(String nodeName,
String profileID,
String processName)
Get a
File object pointing to the directory in the tree where
output for the process with the given name will be placed |
public static void createDirTree(List<Properties> props, String dirName) throws ReportManagerException
props
- A List
of Properties of created
from profilesdirName
- The name of the directory that will be
placed at the root of the tree being
created (i.e. staging, final, backup,
or processing)ReportManagerException
- If any error occurs during the creation
of the treepublic static File getDir(String dirName, String nodeName, String profileID) throws ReportManagerException
File
object pointing to the directory under the
root directory and create all directories and sub-directories as needed.
The path to the directory will be
DIR_ROOT/[dirname]/[node name]/[profile ID]dirName
- The name of the directory (i.e. staging,
final, backup, or processing)nodeName
- The name of the node from which the
logs comeprofileID
- The ID of the profile specifying
where/how to obtain the logsFile
object pointing to the
new directoryReportManagerException
- If any of the parameters are missingpublic static File getProcessingDir(String nodeName, String profileID, String processName) throws ReportManagerException
File
object pointing to the directory in the tree where
output for the process with the given name will be placednodeName
- The name of the node from which the
logs comeprofileID
- The ID of the profile specifying
where/how to obtain the logsprocessName
- The name of the processFile
object pointing to the
new directoryReportManagerException
- If any of the parameters are missingpublic static void backupDir(Properties p, String from, String to) throws ReportManagerException
p
- The profile specifying the source
locationfrom
- The source directory nameto
- The destination directory nameReportManagerException
- If the profile is incomplete or
parameters are missingpublic static void cleanupLogs(File dir)
dir
- The directory under which all files will be deletedpublic static void cleanupOldLogs(File dir, long age)
dir
- The directory under which all old files will be deletedage
- The maximum age (number of milliseconds passed the Epoch)
of files that will be deletedpublic static List<String> getFilenameList(String path) throws ReportManagerException
List
of file names in the given directory.path
- A String of the path to the directory.ReportManagerException
- If the path is null or if the directory
there is invalid.public static List<File> getFileList(File dir) throws ReportManagerException
dir
- A File
object indicating the
directory.ReportManagerException
- If the provided directory is null or
invalid.public static void getFilesFromDirTree(File dir, File dest) throws ReportManagerException
dir
- The directory (a File
) in which to search.dest
- The directory into which files are copied.ReportManagerException
- If the provided parameters are invalid
or if an error occurs while copying.Copyright © 2010–2018 Planetary Data System. All rights reserved.