jpl.mipl.mdms.FileService.komodo.fileMgmt
Class FileTransMgr

java.lang.Object
  |
  +--jpl.mipl.mdms.FileService.komodo.fileMgmt.FileTransMgr

public class FileTransMgr
extends Object

File Management class, used to manage and register file transfer events with a database on behalf of a client. Uses the FileTypeInfo class (one per server) to manage filetypes and schedule vft references.

Version:
$Id: FileTransMgr.java,v 1.6 2003/04/15 23:25:19 txh Exp $
Author:
J. Jacobson, G. Turke

Constructor Summary
FileTransMgr(BufferedStreamIO io)
          Constructor
FileTransMgr(BufferedStreamIO io, FileSystem fileSystem, boolean debug)
          Constructor
 
Method Summary
 void addFile()
          Method to add file.
 void addFileType(String fileType, String dir, String comment, String reserved, String threshold, String qaInterval, String checksum, String xml)
          Method to create a new file type
Used to create a file type.
 void addFileTypeToRole(String fileType, String role)
          Method to associate a file type to a defined role.
 void addReference(String vft, String reference, String link, String comment)
          Method to make a reference within the current VFT.
 void addRole(String role, String capabilities)
          Method to create a new role
 void addUser(String name, String passwd, String privilege, boolean vft)
          Method to add new user to the file system
 void addUserToRole(String name, String role)
          Method to associate a user to an existing role
 void addVFT(String vft, String title, boolean notify)
          Method to add a vft
 void addVFTReader(String vft, String userName)
          Method to add user to an existing vft
 void archiveFile(String name, String archive)
          Method to add archive to an existing file
 void cancelReference(String vft, String ref)
          Method to schedule a file reference to be canceled
 void changePassword(String name, String passwd, String oldPasswd)
          Method to change user password
 void commentFile(String name, String comment)
          Method to add comment to an existing file.
 void delFile(String name)
          Method to delete a file from the device associated with the file type, and remove the files record in the DBMS.
 void delFileRef(String vft, String ref)
          Method to schedule the removal of a file reference.
 void delFileType(String fileType)
          Method delete a file type
 void delFileTypeFromRole(String fileType, String role)
          Method to delete file type from existing role
 void delRef(String vft, String reference)
          Method to delete a reference from the current VFT.
 void delRole(String role)
          Method to delete a user role
 void delUser(String name)
          Method to delete a user
 void delUserFromRole(String name, String role)
          Method to delete a user from an existing role
 void delVFT(String vft)
          Method to delete a vft
 void delVFTReader(String vft, String user)
          Method to delete a vft reader
 void dSync(String fileType, String datetime)
          Synchronize file system with database
 void fSync(String fileType, String datetime)
          Method to synchronize database with file system
 void getCapabilities()
          Method to send string version of user capabilities to client.
 void getFile(String name, boolean checksumRequest, boolean registerRequest, boolean accessByVFT, long offset)
          Method to get a file from the device associated with the file type, and ship the file to the client.
 void getFileFromPath(String filePath, boolean checksumRequest)
          Method to get a file from a full path specification.
 void getFileNames(String regexp, char modifier)
          Get file names that match regexp
 void getFileNames(String datetime1, String datetime2)
          Method to query list of file name for the specified time range.
 void getRefFileInfo(String vft, String ref)
          Method to get the necessary information to get a referenced file.
 void getRefFileInfoAt(String vft, String datetime, String ref)
          Get the necessary information to get a referenced file at a point in history.
 void hotboot()
          Method to hotboot the server
 boolean isAdmin()
          Accessor method to return true if the user has admin role
 void lockCurrentFileType(char mode)
          Method to prevent write access to a file type.
 void login(String username, String password)
          Method to check user access against DBMS entry.
 void makeDomainFile()
          Method to make a new domain file with info stored in DB
 void renameFile(String oldName, String newName)
          Method to rename a file of given file type as a transaction.
 void setFileType(String fileType)
          Method to set connection file type and sent file ID to remote client
 void setReference(String vft, String reference, String fileType, String fileName)
          Method to schedule a reference to be set.
 void show(String start, String end)
          Method to send all file names of given file type.
 void showFileTypes(String fileType)
          Method to get list of file types for this server
 void showRefs(String vft, String datetime)
          Method to get reference information for the current vft.
 void showRegExp(String regexp, char modifier)
          Send a list of files filtered by the input regular expression to the client.
 void showRoles(String role)
          Method to show existing roles
 void showRolesForFileType(String fileType, String role)
          Methe to show roles for the current file type
 void showRolesForUser(String name)
          Methodt o show user roles
 void showServerParameters(String name)
          Method to how server parameters.
 void showServers()
          Method to show the list of servers
 void showUsers(String name)
          Method to show user info
 void showUserVFTs(String userName, String vft)
          Method to list user vfts
 boolean showVFT(String vft, String datetime, boolean checkPerms)
          Method to show vft info
 void showVFTReaders(String vft, String userName)
          Method to list vft readers
 void shutDown()
          Method to shutdown server
 void startAddAndRefFile(Result profile, boolean checksumRequest, boolean doReceipt, String vft, String linkDir)
          Method to determine whether the add file with reference will be allowed, link directory available, etc.
 void startAddFile(Result profile, boolean checksumRequest, boolean doReceipt)
          Method to start add file transaction
Notes:
Pass file type string instead of TypeInfo.
 void startReplaceFile(Result profile, boolean checksumRequest, boolean doReceipt)
          Method to start replace file transaction
Notes:
Pass file type string instead of TypeInfo.
 void unlockCurrentFileType(char mode)
          Method to prevent write access to a file type.
 void updateVFT(String vft, String comment)
          Sync-up the file system links for a VFT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransMgr

public FileTransMgr(BufferedStreamIO io)
Constructor

Parameters:
io - the buffered stream io

FileTransMgr

public FileTransMgr(BufferedStreamIO io,
                    FileSystem fileSystem,
                    boolean debug)
Constructor

Parameters:
io - the buffered stream io
debug - flag to enable/disable debug
Method Detail

login

public void login(String username,
                  String password)
           throws IOException,
                  IllegalArgumentException,
                  Exception
Method to check user access against DBMS entry. DMBS contains SHA hash of password, to implement password forwarding.

Parameters:
username - the user login name
password - the user password (plaintext). It will be encrypted by the server
Throws:
IOException - when connection failure
IllegalArgumentException - when invalid connectiont args
Exception - general operation failure

getCapabilities

public void getCapabilities()
                     throws IOException
Method to send string version of user capabilities to client.

Throws:
IOException - when network I/O failure

isAdmin

public boolean isAdmin()
Accessor method to return true if the user has admin role

Returns:
true or false

setFileType

public void setFileType(String fileType)
                 throws IOException
Method to set connection file type and sent file ID to remote client

Parameters:
fileType - the file type to select.
Throws:
IOException - when network failure

startReplaceFile

public void startReplaceFile(Result profile,
                             boolean checksumRequest,
                             boolean doReceipt)
                      throws IOException
Method to start replace file transaction
Notes:
  1. Pass file type string instead of TypeInfo. This allows us to throw an exception if a type gets deleted on a type info reload.
  2. Lock file for replace. If the file does not exist, then switch this replace to an add.

Parameters:
profile - the information about the file to be added.
checksumRequest - flag to enable checksum request
doReceipt - flag to enable receipt request flag
Throws:
IOException - when network I/O failure

startAddAndRefFile

public void startAddAndRefFile(Result profile,
                               boolean checksumRequest,
                               boolean doReceipt,
                               String vft,
                               String linkDir)
                        throws IOException
Method to determine whether the add file with reference will be allowed, link directory available, etc. ACK/NACK client. If allowed, rename the file to be added by appending a timestamp.

Parameters:
profile - the information about the file to be added.
checksumRequest - to enable checksum request flag
doReceipt - to enable receipt request flag
vft - the vft name
linkDir - the directory for reference.
Throws:
IOException - when network I/O failure

startAddFile

public void startAddFile(Result profile,
                         boolean checksumRequest,
                         boolean doReceipt)
                  throws IOException
Method to start add file transaction
Notes:
  1. Pass file type string instead of TypeInfo. This allows us to throw an exception if a type gets deleted on a type info reload.

Parameters:
profile - Information about the file to be added.
checksumRequest - to enable checksum request flag
doReceipt - to enable receipt request flag
Throws:
IOException - when network I/O failure

addFile

public void addFile()
             throws IOException
Method to add file. Transfer file from client to server after startAddFile has been called. StartAddFile will have ACKed or NACKed client. The result will be sent to client.

Throws:
IOException - when network I/O failure

showRegExp

public void showRegExp(String regexp,
                       char modifier)
                throws IOException
Send a list of files filtered by the input regular expression to the client.

Parameters:
regexp - the regular expression. Handles * and _ meta characters only.
modifier - the command modifier, 'l' means get latest
Throws:
IOException - when network I/O failure

show

public void show(String start,
                 String end)
          throws IOException
Method to send all file names of given file type. Caller sets start/end times if list since or list between. Caller sets these times to null, otherwise.

Parameters:
start - optional start time
end - optional end time
Throws:
IOException - when network I/O failure

getFileNames

public void getFileNames(String datetime1,
                         String datetime2)
                  throws IOException
Method to query list of file name for the specified time range.

Parameters:
datetime1 - the start datetime
datetime2 - the end datetime
Throws:
IOException - when network I/O failure

getFileNames

public void getFileNames(String regexp,
                         char modifier)
                  throws IOException
Get file names that match regexp

Parameters:
regexp - the regular expression
modifier - command modifier, 'l' means get latest
Throws:
IOException - when network I/O failure

getFile

public void getFile(String name,
                    boolean checksumRequest,
                    boolean registerRequest,
                    boolean accessByVFT,
                    long offset)
             throws IOException
Method to get a file from the device associated with the file type, and ship the file to the client. The file is written to a buffered input stream.
Notes:
  1. Pass file type string instead of TypeInfo. This allows us to throw an exception if a type gets deleted on a type info reload.

Parameters:
name - the file name
checksumRequest - flag for client checksum request
registerRequest - flag for client register request
accessByVFT - flag to get read access from current vft.
Throws:
IOException - when network I/O failure

getFileFromPath

public void getFileFromPath(String filePath,
                            boolean checksumRequest)
                     throws IOException
Method to get a file from a full path specification. This path must not include .., and the path's root must match the file types' location. This allows use to controll random file access using the KomodoDB file permissions scheam. Note, checksum is supported, but reqistration is not, since these files are not necessarily registered in KomodoDB.
Notes:
  1. Pass file type string instead of TypeInfo. This allows us to throw an exception if a type gets deleted on a type info reload.

Parameters:
filePath - the full path to the file.
checksumRequest - flag for client checksum request
Throws:
IOException - when network I/O failures

delFile

public void delFile(String name)
             throws IOException
Method to delete a file from the device associated with the file type, and remove the files record in the DBMS.

Parameters:
name - Name of file to be deleted.
Throws:
IOException - when network I/O failure

commentFile

public void commentFile(String name,
                        String comment)
                 throws IOException
Method to add comment to an existing file.

Parameters:
name - the name of file to be deleted.
comment - the comment
Throws:
IOException - when network I/O failure

archiveFile

public void archiveFile(String name,
                        String archive)
                 throws IOException
Method to add archive to an existing file

Parameters:
name - the name of file to be deleted.
archive - the archive
Throws:
IOException - when network I/O failure

renameFile

public void renameFile(String oldName,
                       String newName)
                throws IOException
Method to rename a file of given file type as a transaction.

Parameters:
oldName - the old name of file
newName - the new name of file
Throws:
IOException - when network I/O failure

lockCurrentFileType

public void lockCurrentFileType(char mode)
                         throws IOException
Method to prevent write access to a file type. Users no longer may add or replace files, and, if the fileType file/directory permission action is set, remove write access to all, or remove all write access to all but the file system owner.

Parameters:
mode - 'g' for group, 'o' for owner
Throws:
IOException - when network I/O failure

unlockCurrentFileType

public void unlockCurrentFileType(char mode)
                           throws IOException
Method to prevent write access to a file type. Users no longer may add or replace files, and, if the fileType file/directory permission action is set, remove write access to all, or remove all write access to all but the file system owner.

Parameters:
mode - 'g' for group, 'o' for owner
Throws:
IOException - when network I/O failure

delRef

public void delRef(String vft,
                   String reference)
            throws IOException
Method to delete a reference from the current VFT. Remove any soft-link too.

Parameters:
vft - the vft name
reference - the reference name
Throws:
IOException - when network I/O failure

updateVFT

public void updateVFT(String vft,
                      String comment)
               throws IOException
Sync-up the file system links for a VFT. Locks vft for synch, then creates new links for any changed vft references. If the reference had a previously defined link, then remove the link. If all goes well, then commit the changes to the database. Otherwise log the error, and leave the vft in lockedForSynch. Recovery will require Komodo and VFT administrator manual intervention.

Parameters:
vft - the vft name
comment - optional comment
Throws:
IOException - when network I/O failure

delVFT

public void delVFT(String vft)
            throws IOException
Method to delete a vft

Parameters:
vft - the virtual file type.
Throws:
IOException - when network I/O failure

getRefFileInfo

public void getRefFileInfo(String vft,
                           String ref)
                    throws IOException
Method to get the necessary information to get a referenced file. Writes 'v fileType fileName' to the wire.

Parameters:
vft - the virtual file type containing the reference.
ref - the reference name or null
Throws:
IOException - when network I/O failure

getRefFileInfoAt

public void getRefFileInfoAt(String vft,
                             String datetime,
                             String ref)
                      throws IOException
Get the necessary information to get a referenced file at a point in history. Also ships any references that are not valid at this historical point for deleting unused references. Also works for get vft when getting an earlier version of the vft. Writes 'v fileType filename to the wire.

Parameters:
vft - the virtual file type containing the reference.
datetime - the datetime value
ref - the reference name or null
Throws:
IOException - when network I/O failure

addReference

public void addReference(String vft,
                         String reference,
                         String link,
                         String comment)
                  throws IOException
Method to make a reference within the current VFT.

Parameters:
vft - the vft name
reference - the reference to target file's file type
link - the name of the link
comment - optional comment, may be null
Throws:
IOException - when network I/O failure

addVFT

public void addVFT(String vft,
                   String title,
                   boolean notify)
            throws IOException
Method to add a vft

Parameters:
vft - the virutal file type containing the reference.
title - the title for vft.
notify - if true, send email on update vft.
Throws:
IOException - when network I/O failure

setReference

public void setReference(String vft,
                         String reference,
                         String fileType,
                         String fileName)
                  throws IOException
Method to schedule a reference to be set.

Parameters:
vft - the vft name
reference - the reference name
fileType - the file type
fileName - the file name
Throws:
IOException - when network I/O failure

delFileRef

public void delFileRef(String vft,
                       String ref)
                throws IOException
Method to schedule the removal of a file reference. Takes place at the next VFT update.

Parameters:
vft - the vft name
ref - the reference
Throws:
IOException - whe network I/O failure

cancelReference

public void cancelReference(String vft,
                            String ref)
                     throws IOException
Method to schedule a file reference to be canceled

Parameters:
vft - the virtual file type containing the reference.
ref - the reference.
Throws:
IOException - when network I/O failure

showVFT

public boolean showVFT(String vft,
                       String datetime,
                       boolean checkPerms)
                throws IOException
Method to show vft info

Parameters:
vft - the virtual file type.
datetime - the time string in DBMS format.
checkPerms - if set, don't show the vft if user has no read access.
Returns:
true if vft exists, even if it is not valid for the time specified.
Throws:
IOException - when network I/O failure

showRefs

public void showRefs(String vft,
                     String datetime)
              throws IOException
Method to get reference information for the current vft.

Parameters:
vft - the vft name
datetime - the time filter
Throws:
IOException - when network I/O failure

addFileTypeToRole

public void addFileTypeToRole(String fileType,
                              String role)
                       throws IOException
Method to associate a file type to a defined role.

Parameters:
fileType - the file type
role - the role name
Throws:
IOException - when network I/O failure

addVFTReader

public void addVFTReader(String vft,
                         String userName)
                  throws IOException
Method to add user to an existing vft

Parameters:
vft - the vft name
userName - the user name
Throws:
IOException - when network I/O failure

showVFTReaders

public void showVFTReaders(String vft,
                           String userName)
                    throws IOException
Method to list vft readers

Parameters:
vft - the vft name
userName - the user name
Throws:
IOException - when network I/O failure

addUserToRole

public void addUserToRole(String name,
                          String role)
                   throws IOException
Method to associate a user to an existing role

Parameters:
name - the user name
role - the role name
Throws:
IOException - when network I/O failure

dSync

public void dSync(String fileType,
                  String datetime)
           throws IOException
Synchronize file system with database

Parameters:
fileType - the file type
datetime - the cutoff date
Throws:
IOException - when network I/O failure

fSync

public void fSync(String fileType,
                  String datetime)
           throws IOException
Method to synchronize database with file system

Parameters:
fileType - the file type
datetime - the cutoff date
Throws:
IOException - when network I/O failure

hotboot

public void hotboot()
             throws IOException
Method to hotboot the server

Throws:
IOException - when network I/O failure

makeDomainFile

public void makeDomainFile()
                    throws IOException
Method to make a new domain file with info stored in DB

Throws:
IOException - when network I/O failure

addFileType

public void addFileType(String fileType,
                        String dir,
                        String comment,
                        String reserved,
                        String threshold,
                        String qaInterval,
                        String checksum,
                        String xml)
                 throws IOException
Method to create a new file type
Used to create a file type. Create a directory for the file type. if successful, add the file type to the DBMS fileTypes table.

Parameters:
fileType - the file type name
dir - the physical directory name
comment - the optional comment
reserved - the space reserved for this file type
threshold - the threshold for the file type
qaInterval - the QA release interval
checksum - the checksum flag
xml - if there is an associated xml schema
Throws:
IOException - when network I/O failure

addRole

public void addRole(String role,
                    String capabilities)
             throws IOException
Method to create a new role

Parameters:
role - the new role name
capabilities - the capabilities list
Throws:
IOException - the network I/O failure

addUser

public void addUser(String name,
                    String passwd,
                    String privilege,
                    boolean vft)
             throws IOException
Method to add new user to the file system

Parameters:
name - the user name
passwd - the password
privilege - the user privilege
vft - the vft flag
Throws:
IOException - the network I/O failue

changePassword

public void changePassword(String name,
                           String passwd,
                           String oldPasswd)
                    throws IOException
Method to change user password

Parameters:
name - the user name
passwd - the new password
oldPasswd - the old password
Throws:
IOException - when network I/O failure

delRole

public void delRole(String role)
             throws IOException
Method to delete a user role

Parameters:
role - the role name
Throws:
IOException - when network I/O failure

delFileType

public void delFileType(String fileType)
                 throws IOException
Method delete a file type

Parameters:
fileType - the file type
Throws:
IOException - when network I/O failure

delUser

public void delUser(String name)
             throws IOException
Method to delete a user

Parameters:
name - the user name
Throws:
IOException - when network I/O failure

delVFTReader

public void delVFTReader(String vft,
                         String user)
                  throws IOException
Method to delete a vft reader

Parameters:
vft - the vft name
user - the user name
Throws:
IOException - when network I/O failure

delFileTypeFromRole

public void delFileTypeFromRole(String fileType,
                                String role)
                         throws IOException
Method to delete file type from existing role

Parameters:
fileType - the file type
role - the role name
Throws:
IOException - when network I/O failure

delUserFromRole

public void delUserFromRole(String name,
                            String role)
                     throws IOException
Method to delete a user from an existing role

Parameters:
name - the user name
role - the role name
Throws:
IOException - when network I/O failure

showFileTypes

public void showFileTypes(String fileType)
                   throws IOException
Method to get list of file types for this server

Parameters:
fileType - the file type name
Throws:
IOException - when network I/O failure

showRoles

public void showRoles(String role)
               throws IOException
Method to show existing roles

Parameters:
role - the role name
Throws:
IOException - when network I/O failure

showRolesForFileType

public void showRolesForFileType(String fileType,
                                 String role)
                          throws IOException
Methe to show roles for the current file type

Parameters:
fileType - the file type name
role - the role name
Throws:
IOException - when network I/O failure

showUserVFTs

public void showUserVFTs(String userName,
                         String vft)
                  throws IOException
Method to list user vfts

Parameters:
userName - the user name
vft - the vft name
Throws:
IOException - when network I/O failure

showRolesForUser

public void showRolesForUser(String name)
                      throws IOException
Methodt o show user roles

Parameters:
name - the user name
Throws:
IOException - when network I/O failure

showUsers

public void showUsers(String name)
               throws IOException
Method to show user info

Parameters:
name - the user name
Throws:
IOException - when network I/O failure

showServerParameters

public void showServerParameters(String name)
                          throws IOException
Method to how server parameters. For server connected to echo alphabetized Configuration, for a named server show info stored in the database. Results will display differently for each case.

Parameters:
name - the server name
Throws:
IOException - when network I/O failure

showServers

public void showServers()
                 throws IOException
Method to show the list of servers

Throws:
IOException - when network I/O failure

shutDown

public void shutDown()
              throws IOException
Method to shutdown server

Throws:
IOException - when network I/O failure