public class HiCat_File_Verify
extends java.lang.Object
The main method of this class retrieves records from a database table containing an identification field and verifies the existance of the file stored in the pathname field. If the file does not exist, a line of output indicating the record containing the missing file is either written to the terminal or a log file (if logging is specified).
The permissions of a file are checked also to ensure that that the file is accessible (world read permission are set).
In addition, if a PATHNAMES_MAP group has been defined in the configuration file, this program can optionally convert the path stored in the database to the logical path defined in the the PATHNAMES_MAP group.
Configuration File
A PVL configuration file (default: DEFAULT_CONFIGURATION_FILE
) should contain the connection parameters needed
to establish a connection to the database.
In addition, the configuration file contains additional parameters that can for tuning what records get checked. Each database to be checked should have a GROUP = DATABASE_NAME grouping set up. This gouping can contain additional table level parameters that can be used to tune how a give table within the database is queried.
Modifier and Type | Field and Description |
---|---|
java.lang.String |
Base_Pathname
The base path used to check if the file path is already in logical form
|
java.lang.String |
Catalog
The name of the catalog (database) to use to run the queries on.
|
static java.lang.String |
DEFAULT_CONFIGURATION_FILENAME
The name of the default configuration file.
|
static int |
EXIT_CONFIGURATION_ERROR
Exit status: Configuration Error
|
static int |
EXIT_DATABASE_ERROR
Exit status: Database Error
|
static int |
EXIT_FILE_PERMISSIONS_ERRORS
Exit status: File permissions errors
|
static int |
EXIT_INVALID_COMMAND_LINE_SYNTAX
Exit status: Invalid command line syntax
|
static int |
EXIT_MISSING_AND_PERMISSIONS
Exit status: Missing files and permissions errors
|
static int |
EXIT_MISSING_FILES
Exit status: Missing files.
|
static int |
EXIT_SUCCESS
Exit status: Success
|
java.util.Vector |
Field_List
A vector of strings containing the name of the database record
id column and the name of the file column.
|
java.lang.String |
File_Field
The name of the column in the database table containing the file
information.
|
static java.lang.String |
ID |
java.io.PrintWriter |
Log
An object to write logging information to.
|
static java.lang.String |
Logfile_Base_Name
The base log file name.
|
static java.lang.String |
Logfile_extension
The extension to be appended to the end of the log file name.
|
PIRL.Configuration.Configuration |
Pathnames_Map
A configuration containing a Pathnames_Map group that can be used to
update file paths.
|
java.lang.String |
Record_Identifier
The name of the identification column that should be used as a record
identifier.
|
java.lang.String |
Table_Name
The name of the table being operated on.
|
PIRL.Database.Database |
The_Database
The database object.
|
Constructor and Description |
---|
HiCat_File_Verify(java.util.Vector Files,
PIRL.Configuration.Configuration Pathnames_Map,
PIRL.Database.Database The_Database,
java.lang.String Table_Name,
java.lang.String Base_Pathname,
java.util.Vector Field_List,
java.io.PrintWriter Log)
Construct a file verify and object and initialize all the resources
required by the various methods.
|
Modifier and Type | Method and Description |
---|---|
void |
Fix_Paths(boolean update)
Set to true if paths that are not in a logical form should be
converted to a logical form.
|
static void |
main(java.lang.String[] arguments)
Check filenames stored in a database for existance and convert the paths
to logical paths if enabled.
|
int |
Missing_Files()
Get the number of missing files found.
|
int |
Non_Logical_Paths()
The number of paths not in logical form that were not updated.
|
int |
Unreadable_Files()
Get the number of unreadable files found.
|
void |
Update_Path(java.lang.String Id,
PIRL.Utilities.File file)
Update the path of a file stored in the database to a logical path.
|
int |
Updated_Paths()
The number of paths updated in the database.
|
static void |
Usage()
Prints command line usage syntax.
|
void |
Verify_Files()
Verifies the existence of the files containted within the Files Vector
created at the time of construction.
|
public static final java.lang.String ID
public static final java.lang.String DEFAULT_CONFIGURATION_FILENAME
public static final java.lang.String Logfile_Base_Name
public static final java.lang.String Logfile_extension
public java.lang.String Base_Pathname
public PIRL.Configuration.Configuration Pathnames_Map
public java.io.PrintWriter Log
public PIRL.Database.Database The_Database
public java.util.Vector Field_List
public java.lang.String Table_Name
public java.lang.String Record_Identifier
public java.lang.String File_Field
public java.lang.String Catalog
public static final int EXIT_SUCCESS
public static final int EXIT_MISSING_FILES
public static final int EXIT_FILE_PERMISSIONS_ERRORS
public static final int EXIT_MISSING_AND_PERMISSIONS
public static final int EXIT_CONFIGURATION_ERROR
public static final int EXIT_DATABASE_ERROR
public static final int EXIT_INVALID_COMMAND_LINE_SYNTAX
public HiCat_File_Verify(java.util.Vector Files, PIRL.Configuration.Configuration Pathnames_Map, PIRL.Database.Database The_Database, java.lang.String Table_Name, java.lang.String Base_Pathname, java.util.Vector Field_List, java.io.PrintWriter Log) throws java.sql.SQLException
Files
- A vector containing a list of record Ids and filenames retrieved
from a database. Each element of the vector should be another vector. The first
element of the vector should the the record Id, the second element should be
the file.Pathnames_Map
- A configuration containing a Pathnames_Map group to be
used for mapping canonical paths to a logical paths.The_Database
- The database object the original files were retrieved from.Table_Name
- The name of the table containing the list of files.Base_Pathname
- The Base_Pathname used to determine if a file is already
in logical form.Field_List
- a two element vector. The first element is the column name
of the record identifier column, the second is the column name of the file
column.Log
- - PrintWriter object to be used for logging.java.sql.SQLException
public void Verify_Files()
On the first pass, the entire list of input files are checked for existance,
and to ensure that the paths stored in the database are in a logical form. If
the Fix_Paths(boolean)
method has set to true, then any paths found
that are not in a logical form and can be matched to a logical path defined
in the Configuration will have their paths stored in the database updated to
the matching logical path.
On the second pass, any files that were found to be missing will be checked a second time. Only files missing on the first pass will be checked a second time. This second pass is required since it is possible that a file might have been moved during the time it took for the first pass to run. Only if a file comes up missing after both passes will it be logged as missing.
Update_Path(String, File)
,
File
public void Update_Path(java.lang.String Id, PIRL.Utilities.File file) throws java.sql.SQLException
Fix_Paths()
method has
been passed a boolean true argument first. Otherwise, the NonLogical_Paths
counter is incremented everytime a non-logical path is seen.Id
- The record identifier to be used as a key for updating the proper
recordfile
- The test file.java.sql.SQLException
- if a bad parameters is passed to the prepared statement.public void Fix_Paths(boolean update)
public int Missing_Files()
Verify_Files()
method.public int Unreadable_Files()
Verify_Files()
method.public int Updated_Paths()
Verify_Files
method. This will always be zero unless
updates are enabled (the -Update command line option)Usage()
public int Non_Logical_Paths()
Usage()
public static void main(java.lang.String[] arguments)
Command line syntax is described in the Usage()
method.
Each file field of each record retrieved from the database will be checked for existance, if the file does not exist, notification will be sent to the controling terminal or a log file if logging is enabled.
Exit Status Values
0 - Success
1 - One or more missing files
2 - File permissions errors
3 - Both missing files and permissions errors found
4 - Configuration Error
5 - Database Error
6 - Invalid Command Line Syntax
arguments
- Array of command line argument strings.public static void Usage()
Usage: HiCat_File_VerifyOptions - [-Configuration ] (default: HiCat_File_Verify.conf) [-Database ] [-Id ] [-File ] [-Log-to-file] [-Table ] [-Update] (update paths that are not in logical form, default: false) [-Where ] [-Help]
Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona