SourceJammer 1.2.0.1 May 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan

org.sourcejammer.project.model.filesys
Class NodeLibraryFS

java.lang.Object
  |
  +--org.sourcejammer.project.model.filesys.NodeLibraryFS
All Implemented Interfaces:
NodeLibrary

public class NodeLibraryFS
extends java.lang.Object
implements NodeLibrary

Class that handles locking and unlocking of project, file, and version nodes.


Inner Class Summary
static class NodeLibraryFS.NodeType
           
 
Constructor Summary
NodeLibraryFS(ArchiveInfoFS info)
           
 
Method Summary
 void deleteNode(ControllerNode node)
           
 FileNode getFileNode(long nodeID)
          Retrieves and locks a File node on the file system.
 FileNode getFileNode(long nodeID, boolean readOnly)
          Retrieve or construct a FileNode based on it's node id.
 FileNode getNewFileNodeFromModel()
          Subclasses should implement this to return a new FileNode object.
 LabelInfo getNewLabelInfoFromModel()
           
 ProjectNode getNewProjectFromModel()
          Subclasses should implement this to return a new ProjectNode object.
 long getNextVersionNodeID()
          Returns next unique ID for a version.
 java.lang.String getProjectChildName(ProjectChild child)
          Return the name of a project child object.
 ProjectNode getProjectNode(long nodeID)
          Retrieve or construct a ProjectNode based on it's node id.
 java.io.File getSourceFilePointer(NodeInfo versionNode)
           
 long lockNode(ControllerNode nd)
          Locks the node and returns the key.
 long lockNode(ControllerNode nd, long lTimeOutValue)
          Locks the node and returns the key used to lock it.
 void releaseNode(ControllerNode nd)
          Releases the node after use.
 void removeVersion(FileNode ndFile, long fileKey, long versionID)
          Remove all files assocaited with version from file system.
 Label retrieveLabel(LabelInfo labelInfo)
           
 NodeList retrieveLabelList()
          Loads all the labels for this archive as a NodeList.
 java.lang.String retrieveVersionComment(long versionID)
           
 Delta retrieveVersionDelta(NodeInfo versionNode)
           
 java.io.File retrieveVersionDeltaFile(NodeInfo versionNode)
           
 byte[] retrieveVersionFull(NodeInfo versionNode)
           
 TextLineReader retrieveVersionTextLineReader(NodeInfo versionNode)
          When implemented, this method returns the full source of the specified VersionNode as a TextLineReader.
 void storeLabel(LabelInfo labelInfo, Label label, NodeList allLabels)
          Subclasses should implement to store the labeled version info.
 void storeVersionComment(FileNode ndFile, long fileKey, long versionID, java.lang.String comment)
           
 void storeVersionDelta(FileNode ndFile, long fileKey, long versionID, java.io.File file)
          Subclasses should implement to store file delta in the model implementation.
 void storeVersionFull(FileNode ndFile, long fileKey, long versionID, java.io.File file)
          Subclasses should implement to store version file in the model implementation.
 void storeVersionTextDiff(FileNode ndFile, long fileKey, long versionID, TextDiff file)
           
protected  void unlockNode(ControllerNode nd)
           
protected  void unlockNode(long nodeID, java.lang.String nodeType, long key)
          Unlocks the node with the specified ID and type, using the key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeLibraryFS

public NodeLibraryFS(ArchiveInfoFS info)
Method Detail

unlockNode

protected void unlockNode(long nodeID,
                          java.lang.String nodeType,
                          long key)
                   throws ObjectLockingException
Unlocks the node with the specified ID and type, using the key.
Parameters:
nodeID - -- unique id of the node.
noteType - -- String from NodeTypes inner class. param key -- key returned when the node was locked.
Throws:
ObjectLockingException - if the node is not locked, or if the key is inaccurate.

getProjectNode

public ProjectNode getProjectNode(long nodeID)
                           throws FileAccessException,
                                  ProjectDoesNotExistException,
                                  SecurityException
Description copied from interface: NodeLibrary
Retrieve or construct a ProjectNode based on it's node id.
Specified by:
getProjectNode in interface NodeLibrary

getProjectChildName

public java.lang.String getProjectChildName(ProjectChild child)
                                     throws FileAccessException,
                                            NodeDoesNotExistException
Return the name of a project child object. First checks cache. Then checks filesystem. Does not add child Node to cache.
Specified by:
getProjectChildName in interface NodeLibrary

getFileNode

public FileNode getFileNode(long nodeID)
                     throws FileAccessException,
                            FileDoesNotExistException,
                            SecurityException
Retrieves and locks a File node on the file system.
Specified by:
getFileNode in interface NodeLibrary

getFileNode

public FileNode getFileNode(long nodeID,
                            boolean readOnly)
                     throws FileAccessException,
                            FileDoesNotExistException,
                            SecurityException
Retrieve or construct a FileNode based on it's node id.
Specified by:
getFileNode in interface NodeLibrary
Parameters:
nodeID - -- unique id of the FileNode to retrieve.
readOnly - -- if true, the FileNode will not be lock-able and should probably be a clone of any FileNode stored in the cache.

releaseNode

public void releaseNode(ControllerNode nd)
                 throws FileAccessException
Description copied from interface: NodeLibrary
Releases the node after use.
Specified by:
releaseNode in interface NodeLibrary

unlockNode

protected void unlockNode(ControllerNode nd)
                   throws FileAccessException

storeLabel

public void storeLabel(LabelInfo labelInfo,
                       Label label,
                       NodeList allLabels)
                throws FileAccessException
Subclasses should implement to store the labeled version info.
Specified by:
storeLabel in interface NodeLibrary

storeVersionFull

public void storeVersionFull(FileNode ndFile,
                             long fileKey,
                             long versionID,
                             java.io.File file)
                      throws FileAccessException
Subclasses should implement to store version file in the model implementation. FileNode must be locked and passed key must "fit" the FileNode, or SecurityException is thrown.
Specified by:
storeVersionFull in interface NodeLibrary

storeVersionDelta

public void storeVersionDelta(FileNode ndFile,
                              long fileKey,
                              long versionID,
                              java.io.File file)
                       throws FileAccessException
Subclasses should implement to store file delta in the model implementation. FileNode must be locked and passed key must "fit" the FileNode, or SecurityException is thrown.
Specified by:
storeVersionDelta in interface NodeLibrary

storeVersionTextDiff

public void storeVersionTextDiff(FileNode ndFile,
                                 long fileKey,
                                 long versionID,
                                 TextDiff file)
                          throws FileAccessException
Specified by:
storeVersionTextDiff in interface NodeLibrary

getNewProjectFromModel

public ProjectNode getNewProjectFromModel()
                                   throws FileAccessException
Subclasses should implement this to return a new ProjectNode object. Unique ID for new project will be already be set in returned Node.
Specified by:
getNewProjectFromModel in interface NodeLibrary

getNewFileNodeFromModel

public FileNode getNewFileNodeFromModel()
                                 throws FileAccessException
Subclasses should implement this to return a new FileNode object. Unique Id for file will already be set in returned Node.
Specified by:
getNewFileNodeFromModel in interface NodeLibrary

getNextVersionNodeID

public long getNextVersionNodeID()
                          throws FileAccessException
Returns next unique ID for a version.
Specified by:
getNextVersionNodeID in interface NodeLibrary

getNewLabelInfoFromModel

public LabelInfo getNewLabelInfoFromModel()
                                   throws FileAccessException
Specified by:
getNewLabelInfoFromModel in interface NodeLibrary

storeVersionComment

public void storeVersionComment(FileNode ndFile,
                                long fileKey,
                                long versionID,
                                java.lang.String comment)
                         throws FileAccessException
Specified by:
storeVersionComment in interface NodeLibrary

retrieveVersionComment

public java.lang.String retrieveVersionComment(long versionID)
                                        throws FileAccessException
Specified by:
retrieveVersionComment in interface NodeLibrary

getSourceFilePointer

public java.io.File getSourceFilePointer(NodeInfo versionNode)
Specified by:
getSourceFilePointer in interface NodeLibrary

retrieveVersionFull

public byte[] retrieveVersionFull(NodeInfo versionNode)
                           throws FileAccessException,
                                  WrongFileTypeException
Specified by:
retrieveVersionFull in interface NodeLibrary

retrieveVersionTextLineReader

public TextLineReader retrieveVersionTextLineReader(NodeInfo versionNode)
                                             throws FileAccessException,
                                                    WrongFileTypeException,
                                                    SourceJammerVersionException
When implemented, this method returns the full source of the specified VersionNode as a TextLineReader. This method should only be called for files stored as Text. Implementing classes should throw WrongFileType if the underlying file is not text.
Specified by:
retrieveVersionTextLineReader in interface NodeLibrary

retrieveVersionDeltaFile

public java.io.File retrieveVersionDeltaFile(NodeInfo versionNode)
                                      throws FileAccessException,
                                             WrongFileTypeException
Specified by:
retrieveVersionDeltaFile in interface NodeLibrary

retrieveVersionDelta

public Delta retrieveVersionDelta(NodeInfo versionNode)
                           throws FileAccessException,
                                  WrongFileTypeException
Specified by:
retrieveVersionDelta in interface NodeLibrary

retrieveLabel

public Label retrieveLabel(LabelInfo labelInfo)
                    throws FileAccessException
Specified by:
retrieveLabel in interface NodeLibrary

lockNode

public long lockNode(ControllerNode nd)
              throws SecurityException
Locks the node and returns the key. Times out after default number of milliseconds.
Specified by:
lockNode in interface NodeLibrary

lockNode

public long lockNode(ControllerNode nd,
                     long lTimeOutValue)
              throws SecurityException
Locks the node and returns the key used to lock it. Calling routines MUST remember to UNLOCK the node when they are done with it. Method waits for node to unlock for lTimeOutValue milliseconds.
Specified by:
lockNode in interface NodeLibrary

retrieveLabelList

public NodeList retrieveLabelList()
                           throws FileAccessException
Loads all the labels for this archive as a NodeList.
Specified by:
retrieveLabelList in interface NodeLibrary

deleteNode

public void deleteNode(ControllerNode node)
                throws FileAccessException,
                       NodeDoesNotExistException,
                       SecurityException
Specified by:
deleteNode in interface NodeLibrary

removeVersion

public void removeVersion(FileNode ndFile,
                          long fileKey,
                          long versionID)
                   throws FileAccessException,
                          NoSuchVersionException
Remove all files assocaited with version from file system.
Specified by:
removeVersion in interface NodeLibrary

SourceJammer 1.2.0.1 May 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan