org.sourcejammer.client.filesys
Class SourceVersionChecker

java.lang.Object
  |
  +--org.sourcejammer.client.filesys.SourceVersionChecker

public class SourceVersionChecker
extends java.lang.Object

Title: $FileName: SourceVersionChecker.java$

Version:
$VerNum: 2$

$Description: $ $KeyWordsOff: $

The function of this class is to act as the go-between for retreiving source files from the server and saving them to the local file system and also for retreiving files from the local filesystem and sending them to the server.

This class uses the file source.jam to track what has been stored in the directory it is responsible for. The source.jam file contains information about the version number and archive that each relavent file originates from. If the version number and archive match and the file, the file does not need to be retrieved again from the server.
Author:
$AuthorName: Rob MacGrogan$

Field Summary
static java.lang.String LOCAL_FILE_INFO_FILE_NAME
           
private  java.io.File mflTargetDirectory
           
private  java.util.Hashtable mhshSourceInfo
           
private  java.lang.String msArchiveName
           
private  java.lang.String msServerURL
           
static java.lang.String OLD_FILE_INFO_FILE_NAME
           
 
Constructor Summary
SourceVersionChecker(java.io.File flTargetDirectory, java.lang.String serverURL, java.lang.String archiveName)
           
 
Method Summary
private  StoredFileInfoBean buildStoredInfoBeanForCurrentFile(java.lang.String sFileName)
          Builds a new StoredFileInfoBean (except for the Version #) from the current file in the directory.
private  java.io.File getSourceFile()
           
private  java.util.Hashtable getSourceJamHasttable()
           
 StoredFileInfoBean getStoredFileInfo(java.lang.String sFileName)
          Returns the StoredFileInfoBean for the specified file in the directory served by this SourceVersionChecker.
 boolean isFileCurrent(java.lang.String sFileName, long lSourceVersionUniqueID)
          Returns true if the specified version of the specified file is the version of that file currently stored in the directory for this SourceVersionChecker.
 boolean isStoredFileInfoAccurate(java.lang.String sFileName)
          Returns true if the file info in the source.jam file matches the actual file in the directory.
private  void makeNewSourceJamIfNull()
           
private  void reloadSourceJamHashtable()
           
 boolean saveFile(java.lang.String sName, long lSourceVersionUniqueID, byte[] byFile, boolean setToReadOnly, org.sourcejammer.util.RepeatingResponse repeating)
          Save the file (byte array) to the target directory for this SourceVersionChecker, using the name specified.
 boolean saveFile(java.lang.String sName, long lSourceVersionUniqueID, long lTempFileId, boolean setToReadOnly, org.sourcejammer.util.RepeatingResponse repeating)
          Save the file (byte array) to the target directory for this SourceVersionChecker, using the name specified.
private  void saveSourceJamFile()
           
private  void updateFileInfo(StoredFileInfoBean bn)
          Save the info about the particular file to the source.jam file.
 void updateLocalInfo(java.lang.String sFileName, long lSourceVersionID)
          Updates the source.jam file for the target directory for this SourceVersionChecker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OLD_FILE_INFO_FILE_NAME

public static final java.lang.String OLD_FILE_INFO_FILE_NAME
See Also:
Constant Field Values

LOCAL_FILE_INFO_FILE_NAME

public static final java.lang.String LOCAL_FILE_INFO_FILE_NAME
See Also:
Constant Field Values

mflTargetDirectory

private java.io.File mflTargetDirectory

mhshSourceInfo

private java.util.Hashtable mhshSourceInfo

msServerURL

private java.lang.String msServerURL

msArchiveName

private java.lang.String msArchiveName
Constructor Detail

SourceVersionChecker

public SourceVersionChecker(java.io.File flTargetDirectory,
                            java.lang.String serverURL,
                            java.lang.String archiveName)
                     throws java.io.IOException
Parameters:
flTargetDirectory - -- the directory that this SourceVersionChecker is responsible for.
serverURL - -- URL for the SJ server that the client is connected to.
archiveName - -- name of the SJ archive the client is connected to.
Method Detail

saveFile

public boolean saveFile(java.lang.String sName,
                        long lSourceVersionUniqueID,
                        byte[] byFile,
                        boolean setToReadOnly,
                        org.sourcejammer.util.RepeatingResponse repeating)
                 throws java.io.IOException
Save the file (byte array) to the target directory for this SourceVersionChecker, using the name specified.

Parameters:
sName - -- name to use in saving the file.
lSourceVersionUniqueID - -- unique ID of the VERSION of the file being saved.
byFile - -- the file as a byte array.
setToReadOnly - -- if true, the file will be set to read-only after it is saved.
Returns:
true if the file was saved successfully. False otherwise.
java.io.IOException

saveFile

public boolean saveFile(java.lang.String sName,
                        long lSourceVersionUniqueID,
                        long lTempFileId,
                        boolean setToReadOnly,
                        org.sourcejammer.util.RepeatingResponse repeating)
                 throws java.io.IOException
Save the file (byte array) to the target directory for this SourceVersionChecker, using the name specified.

Parameters:
sName - -- name to use in saving the file.
lSourceVersionUniqueID - -- unique ID of the VERSION of the file being saved.
lTempFileId - -- id of temp file to be saved to parent directory.
setToReadOnly - -- if true, the file will be set to read-only after it is saved.
Returns:
true if the file was saved successfully. False otherwise.
java.io.IOException

getStoredFileInfo

public StoredFileInfoBean getStoredFileInfo(java.lang.String sFileName)
                                     throws java.io.IOException
Returns the StoredFileInfoBean for the specified file in the directory served by this SourceVersionChecker. The StoredFileInfoBean will contain identifying information about version of this file that is stored in this directory. This information may or may not be current. Call isStoredFileInfoAccurate() to check.

java.io.IOException

updateLocalInfo

public void updateLocalInfo(java.lang.String sFileName,
                            long lSourceVersionID)
                     throws java.io.IOException
Updates the source.jam file for the target directory for this SourceVersionChecker. Sets the version ID of the specified file.

Parameters:
sFileName - -- name of the file whose version id is to be updated.
lSourceVersionID - -- version id of the specified file.
java.io.IOException

isStoredFileInfoAccurate

public boolean isStoredFileInfoAccurate(java.lang.String sFileName)
                                 throws java.io.IOException
Returns true if the file info in the source.jam file matches the actual file in the directory.

java.io.IOException

isFileCurrent

public boolean isFileCurrent(java.lang.String sFileName,
                             long lSourceVersionUniqueID)
                      throws java.io.IOException
Returns true if the specified version of the specified file is the version of that file currently stored in the directory for this SourceVersionChecker.

java.io.IOException

buildStoredInfoBeanForCurrentFile

private StoredFileInfoBean buildStoredInfoBeanForCurrentFile(java.lang.String sFileName)
                                                      throws java.io.IOException
Builds a new StoredFileInfoBean (except for the Version #) from the current file in the directory.

java.io.IOException

updateFileInfo

private void updateFileInfo(StoredFileInfoBean bn)
                     throws java.io.IOException
Save the info about the particular file to the source.jam file.

java.io.IOException

saveSourceJamFile

private void saveSourceJamFile()
                        throws java.io.IOException
java.io.IOException

getSourceJamHasttable

private java.util.Hashtable getSourceJamHasttable()

makeNewSourceJamIfNull

private void makeNewSourceJamIfNull()

reloadSourceJamHashtable

private void reloadSourceJamHashtable()
                               throws java.io.IOException
java.io.IOException

getSourceFile

private java.io.File getSourceFile()


Copyright 2003 Soucejammer project.