gov.nasa.pds.report.util
Class FileUtil

java.lang.Object
  extended by gov.nasa.pds.report.util.FileUtil

public class FileUtil
extends Object


Constructor Summary
FileUtil()
           
 
Method Summary
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 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

createDirTree

public static void createDirTree(List<Properties> props,
                                 String dirName)
                          throws ReportManagerException
Create a directory tree with the given name directly under the root of the Report Service directory tree.

Parameters:
props - A List of Properties of created from profiles
dirName - The name of the directory that will be placed at the root of the tree being created (i.e. staging, final, backup, or processing)
Throws:
ReportManagerException - If any error occurs during the creation of the tree

getDir

public static File getDir(String dirName,
                          String nodeName,
                          String profileID)
                   throws ReportManagerException
Get a 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]

Parameters:
dirName - The name of the directory (i.e. staging, final, backup, or processing)
nodeName - The name of the node from which the logs come
profileID - The ID of the profile specifying where/how to obtain the logs
Returns:
A File object pointing to the new directory
Throws:
ReportManagerException - If any of the parameters are missing

getProcessingDir

public static File getProcessingDir(String nodeName,
                                    String profileID,
                                    String processName)
                             throws ReportManagerException
Get a File object pointing to the directory in the tree where output for the process with the given name will be placed

Parameters:
nodeName - The name of the node from which the logs come
profileID - The ID of the profile specifying where/how to obtain the logs
processName - The name of the process
Returns:
A File object pointing to the new directory
Throws:
ReportManagerException - If any of the parameters are missing

backupDir

public static void backupDir(Properties p,
                             String from,
                             String to)
                      throws ReportManagerException
Backup a directory in the given source directory structure to a location under the given destination directory structure.

Parameters:
p - The profile specifying the source location
from - The source directory name
to - The destination directory name
Throws:
ReportManagerException - If the profile is incomplete or parameters are missing

cleanupLogs

public static void cleanupLogs(File dir)
Delete all files under the given directory

Parameters:
dir - The directory under which all files will be deleted

cleanupOldLogs

public static void cleanupOldLogs(File dir,
                                  long age)
Delete all files under the given directory that are past a given age

Parameters:
dir - The directory under which all old files will be deleted
age - The maximum age (number of milliseconds passed the Epoch) of files that will be deleted


Copyright © 2010–2015 Planetary Data System. All rights reserved.