com.altair.hwm.fileserver.server
Class HWMFileServer

java.lang.Object
  extended by com.altair.hwm.fileserver.server.HWMFileServer

public class HWMFileServer
extends java.lang.Object

Title: HWMFileServer

Description: This class initializes the file server and the database connection pool. It also provides some functions that will be required by more than one class

Company: Altair Engineering, Inc.


Constructor Summary
HWMFileServer()
          Constructor
 
Method Summary
 java.lang.String AddFileToSystem(java.sql.Connection cxn, java.lang.String strFName, java.io.InputStream in)
          Copies the contents from input stream into the new file with name = strFName.
 java.lang.String GetBaseDir()
          Gets the base directory.
 java.lang.String GetCurrentDir(java.sql.Connection cxn)
          Gets the current directory to use.
 HWMDBCxnPool GetCxnPool()
          Returns the database cxn pool
 java.sql.ResultSet GetFileInfo(java.sql.Connection cxn, int nFileID)
          Gets the information from the file table about the file with given id.
 java.sql.ResultSet GetRevisionInfo(java.sql.Connection cxn, int nFileID, java.lang.String strRevision)
          Gets the information from the revision table about the revision
 java.sql.ResultSet GetRevisions(java.sql.Connection cxn, int nFileID)
          Gets the revisions for a file (ordered such that the first row in the result set contains the most recent revision and the last row the earliest available revision)
 java.sql.ResultSet GetVersionInfo(java.sql.Connection cxn, int nRevID, int nVersion)
          Gets the information from the version table about the version
 java.sql.ResultSet GetVersions(java.sql.Connection cxn, int nRevID)
          Gets the versions for a revision of a file (ordered such that the first row in the result set contains the most recent version and the last row the earliest available version)
 boolean HasRevisions(java.sql.Connection cxn, int nRevID)
          Returns a flag indicating if the given revision id has more recent revisions.
 boolean HasVersions(java.sql.Connection cxn, int nRevID, int nVersion)
          Returns a flag indicating if the given version has more recent versions under the same revision id.
 void Init(java.lang.String strCfgFile)
          Initialize the file server.
 void OnExit()
          Called when the file server is exiting
 void RemoveEntries(java.sql.Connection cxn, int nFileID, int nRevID, int nVerID)
          Remove any IDS if above 0
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HWMFileServer

public HWMFileServer()
Constructor

Method Detail

Init

public void Init(java.lang.String strCfgFile)
          throws java.lang.Exception
Initialize the file server. a> Reads the cfg file to find the base dir where the files should be placed, the database info class to use, the database to connect, user name and password b> Create the cxn pool class

Parameters:
strCfgFile - The config file for the fileserver
Throws:
java.lang.Exception

GetCxnPool

public HWMDBCxnPool GetCxnPool()
Returns the database cxn pool

Returns:
HWMDBCxnPool The database cxn pool class

GetBaseDir

public java.lang.String GetBaseDir()
                            throws java.lang.Exception
Gets the base directory.

Returns:
String The directory under which sub-dirs are created and files are placed
Throws:
java.lang.Exception

GetCurrentDir

public java.lang.String GetCurrentDir(java.sql.Connection cxn)
                               throws java.lang.Exception
Gets the current directory to use. If the number of files exceed a limit, a new directory is created.

Parameters:
cxn - The connection to database
Returns:
String The directory under which files can be placed
Throws:
java.lang.Exception

AddFileToSystem

public java.lang.String AddFileToSystem(java.sql.Connection cxn,
                                        java.lang.String strFName,
                                        java.io.InputStream in)
                                 throws java.lang.Exception
Copies the contents from input stream into the new file with name = strFName. It places the file into the first available sub directory. It also updates the admin table in the database

Parameters:
cxn - The connection to the database
strFName - The file name to store the file as
in - The input streamto read from
Returns:
String The directory under which file is placed
Throws:
java.lang.Exception

GetFileInfo

public java.sql.ResultSet GetFileInfo(java.sql.Connection cxn,
                                      int nFileID)
                               throws java.lang.Exception
Gets the information from the file table about the file with given id.

Parameters:
cxn - The connection to the database.
nFileID - The id of the file whose information should be retrieved.
Returns:
ResultSet The file information.
Throws:
java.lang.Exception

GetRevisions

public java.sql.ResultSet GetRevisions(java.sql.Connection cxn,
                                       int nFileID)
                                throws java.lang.Exception
Gets the revisions for a file (ordered such that the first row in the result set contains the most recent revision and the last row the earliest available revision)

Parameters:
cxn - The connection to the database.
nFileID - The id for the file whose revisions are to be retrieved.
Returns:
ResultSet The first row in the result set will be the most recent and the last row will be the first revision
Throws:
java.lang.Exception

GetRevisionInfo

public java.sql.ResultSet GetRevisionInfo(java.sql.Connection cxn,
                                          int nFileID,
                                          java.lang.String strRevision)
                                   throws java.lang.Exception
Gets the information from the revision table about the revision

Parameters:
nFileID - The id of the file whose revision information should be retrieved.
strRevision - The revision name of the file whose revision information should be retrieved.
Returns:
ResultSet The file information.
Throws:
java.lang.Exception

HasRevisions

public boolean HasRevisions(java.sql.Connection cxn,
                            int nRevID)
                     throws java.lang.Exception
Returns a flag indicating if the given revision id has more recent revisions.

Parameters:
cxn - The connection to the database.
nRevID - The revision id of the file.
Returns:
boolean If there are more recent revisions, then true, else false
Throws:
java.lang.Exception

GetVersions

public java.sql.ResultSet GetVersions(java.sql.Connection cxn,
                                      int nRevID)
                               throws java.lang.Exception
Gets the versions for a revision of a file (ordered such that the first row in the result set contains the most recent version and the last row the earliest available version)

Parameters:
cxn - The connection to the database.
nRevID - The revision id for the file whose versions are to be retrieved.
Returns:
ResultSet The first row in the result set will be the most recent and the last row will be the eraliest version
Throws:
java.lang.Exception

GetVersionInfo

public java.sql.ResultSet GetVersionInfo(java.sql.Connection cxn,
                                         int nRevID,
                                         int nVersion)
                                  throws java.lang.Exception
Gets the information from the version table about the version

Parameters:
nRevID - The revision id of the file whose version information should be retrieved.
nVersion - The version of the file whose version information should be retrieved.
Returns:
ResultSet The file information.
Throws:
java.lang.Exception

HasVersions

public boolean HasVersions(java.sql.Connection cxn,
                           int nRevID,
                           int nVersion)
                    throws java.lang.Exception
Returns a flag indicating if the given version has more recent versions under the same revision id.

Parameters:
cxn - The connection to the database.
nRevID - The revision id of the file.
nVersion - The version for the file.
Returns:
boolean If there are more recent versions, then true, else false
Throws:
java.lang.Exception

RemoveEntries

public void RemoveEntries(java.sql.Connection cxn,
                          int nFileID,
                          int nRevID,
                          int nVerID)
Remove any IDS if above 0

Parameters:
cxn - The connection
nFileID - The file id to remove
nRevID - The revision id to remove
nVerID - The version id to remove

OnExit

public void OnExit()
Called when the file server is exiting