SourceJammer 1.3.0 November 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan

org.sourcejammer.project.controller
Class ProjectController

java.lang.Object
  |
  +--org.sourcejammer.project.controller.ProjectController
All Implemented Interfaces:
Archive

public class ProjectController
extends java.lang.Object
implements Archive

ProjectController is responsible for returning objects from the model implementation, and adding and maintaining objects in the model implementation. This class also maintains a cache of the entire project hierarchy of a particular archive. This object does not handle user-level security except to allow checking out and checking in of files. User names and passwords are verified and controlled by the object that calls this object. A ProjectController is created and (hopefully) cached for a single archive.


Field Summary
static long ROOT_PROJECT_ID
           
 
Constructor Summary
ProjectController()
           
 
Method Summary
 long addFile(long projectID, java.lang.String name, java.io.File file, FileProperties props, java.lang.String userName)
          Adds a new file to this archive, at the specified location.
 long addNewVersion(long fileID, java.io.File newVersion, java.lang.String comment, java.lang.String userName)
          Adds a new version to an existing file.
 long addProject(long parentID, java.lang.String name)
          Adds a new project at the specified location (the NodeName object) to this archive.
protected  Label buildLabel(Label label, long parentProjectID, java.lang.String baseSJPath, long skipFile)
          This method recursively calls itself until it has put all of the latest versions of all the file nodes in parent (and in all ProjectNode children of parent) into label.
 void checkInFile(long fileID)
          Set status of specified file to checked in.
 void checkOutFile(long fileID, java.lang.String userName, java.lang.String checkOutLocation)
          Set status of specified file to checked out.
protected  NodeInfo controllerNodeToNodeInfo(ControllerNode nd)
          Builds new NodeInfo object from ControllerNode.
 void copyFile(long fileID, long parentProjectID, long newParentProjectID, java.lang.String userName)
          Copies the specified file from one project to another.
 void copyProject(long projectID, long parentProjectID, long newParentProjectID, java.lang.String userName, java.lang.String newProjectName)
          Copies the specified project and all children from one project to another.
 ArchiveInfoFlex getArchiveInfo()
          Gives subclasses access to archive info object.
 File getFile(long fileID)
          Get File object (info about file).
 java.lang.String getFileDescription(long fileID)
          Gets and returns the description of a file.
 long getFileLatestVersion(long fileID, int requestedEOL)
          Get latest version of file source to temp dir and return temp file ID.
 TextLineReader getFileLatestVersionTLR(long fileID)
          Get latest version of text file source as TextLineReader.
 FileNode getFileNode(long fileID)
          Allows "master control" to look at file info to verify check out, check in, file type, etc.
 FileNode getFileNode(long fileID, boolean readOnly)
          Allows "master control" to look at file info to verify check out, check in, file type, etc.
 Delta getFileVersionDelta(long versionID)
          Get specified delta object for file.
 Label getLabelContentList(long labelID, int versionNumber)
          Returns the Label object (which contains the sourcejammer path and version number for each object in the labeled version) with the specified name.
 NodeList getLabelList()
          Deprecated.  
 java.io.File getLatestVersionSourceFilePointer(long fileID)
          Returns java.io.File object for latest version's source.
 Project getProject(long projectID)
          Get Project object (info about project).
 java.util.Vector getRemovedNodes(long projectID)
          Returns a Vector of NodeInfo objects, one for each node that has been removed (but not permanently deleted) from the parent project.
 Project getRootProject()
          Returns the view Project for the root node of the archive for this ProjectController.
 long getUniqueIDFromPath(long parentID, java.lang.String path)
          Returns unique id based on a path.
 java.lang.String getVersionComment(long versionID)
          Get the comment for the specified version.
 long getVersionFileSizeInBytes(long fileID, int versionNumber)
          Gets the size of the version file in bytes.
 void makeLabeledVersion(java.lang.String name, java.lang.String description, long parentProjectID, java.lang.String userName)
          Create and save a new labeled version with the passed-in name and description and containing all of the latest versions that are children of parent.
 void moveFile(long fileID, long parentProjectID, long newParentProjectID)
          Moves the specified file from one project to another.
 void moveProject(long projectID, long parentProjectID, long newParentProjectID, java.lang.String newProjectName)
          Moves the specified project from one project to another.
 void permanentlyDeleteRemovedNode(long projectID, int index)
          Permanently delete specified removed node.
protected  Project projectNodeToProject(ProjectNode ndProject)
           
 void rebuildLabel(long labelID, java.lang.String description, long parentProjectID, java.lang.String userName)
           
 void releaseFileNode(FileNode nd)
          Release a file node.
 void removeFile(long parentID, long fileID)
          Remove specified file from specified project.
 void removeProject(long parentID, long projectID)
          Remove specified project from the project hierarchy.
 void renameFile(long parentID, long fileID, java.lang.String newName)
           
 void renameProject(long parentID, long projectID, java.lang.String newName)
           
 void restoreRemovedNode(long parentID, int index)
          Restores a project or file node that was previously removed from the archive.
 void restoreRemovedNode(long parentID, java.lang.String newName, int index)
          Restores a project or file node that was previously removed from the archive.
 java.io.File retrieveVersionDeltaFile(NodeInfo versionNode)
           
 void rollbackToVersion(long fileID, long versionID, java.io.File newLatestVersion)
          Rollback specified file to specified version number.
 void setArchiveInfo(ArchiveInfoFlex info)
          Sets the ArchiveInfo object for this ProjectController.
 void setFileDescription(long fileID, java.lang.String description)
          Changes description of a file.
 void setNodeLibrary(NodeLibrary lib)
          Set the NodeLibrary object for this archive.
 void setVersionComment(long fileID, int version, java.lang.String comment)
          Set the comment of the specified version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_PROJECT_ID

public static final long ROOT_PROJECT_ID
Constructor Detail

ProjectController

public ProjectController()
Method Detail

setArchiveInfo

public void setArchiveInfo(ArchiveInfoFlex info)
                    throws FileAccessException
Sets the ArchiveInfo object for this ProjectController.
Specified by:
setArchiveInfo in interface Archive

setNodeLibrary

public void setNodeLibrary(NodeLibrary lib)
Set the NodeLibrary object for this archive.

getArchiveInfo

public ArchiveInfoFlex getArchiveInfo()
Gives subclasses access to archive info object.
Specified by:
getArchiveInfo in interface Archive

copyFile

public void copyFile(long fileID,
                     long parentProjectID,
                     long newParentProjectID,
                     java.lang.String userName)
              throws NodeExistsException,
                     NodeDoesNotExistException,
                     SecurityException,
                     FileAccessException,
                     FileDoesNotExistException,
                     NoSuchVersionException
Copies the specified file from one project to another. No file history is copied. A new source file is created.
Specified by:
copyFile in interface Archive

moveFile

public void moveFile(long fileID,
                     long parentProjectID,
                     long newParentProjectID)
              throws NodeExistsException,
                     FileAccessException,
                     SecurityException,
                     NoSuchVersionException,
                     NodeDoesNotExistException,
                     FileDoesNotExistException
Moves the specified file from one project to another.
Specified by:
moveFile in interface Archive

moveProject

public void moveProject(long projectID,
                        long parentProjectID,
                        long newParentProjectID,
                        java.lang.String newProjectName)
                 throws NodeExistsException,
                        FileAccessException,
                        SecurityException,
                        NoSuchVersionException,
                        NodeDoesNotExistException,
                        ProjectDoesNotExistException
Moves the specified project from one project to another.
Specified by:
moveProject in interface Archive

copyProject

public void copyProject(long projectID,
                        long parentProjectID,
                        long newParentProjectID,
                        java.lang.String userName,
                        java.lang.String newProjectName)
                 throws NodeExistsException,
                        NodeDoesNotExistException,
                        SecurityException,
                        FileAccessException,
                        FileDoesNotExistException,
                        NoSuchVersionException,
                        ProjectDoesNotExistException
Description copied from interface: Archive
Copies the specified project and all children from one project to another. No file history is copied. A new source for each file is created.
Specified by:
copyProject in interface Archive

getRootProject

public Project getRootProject()
                       throws FileAccessException,
                              SecurityException
Returns the view Project for the root node of the archive for this ProjectController.
Specified by:
getRootProject in interface Archive

addProject

public long addProject(long parentID,
                       java.lang.String name)
                throws FileAccessException,
                       ProjectDoesNotExistException,
                       NodeExistsException,
                       SecurityException
Adds a new project at the specified location (the NodeName object) to this archive.
Specified by:
addProject in interface Archive
Returns:
unique ID of new project.

addFile

public long addFile(long projectID,
                    java.lang.String name,
                    java.io.File file,
                    FileProperties props,
                    java.lang.String userName)
             throws FileAccessException,
                    ProjectDoesNotExistException,
                    FileAlreadyExistsException,
                    SecurityException,
                    TextFileException
Adds a new file to this archive, at the specified location. Note: fileType means binary or text. Returns new version unique ID.
Specified by:
addFile in interface Archive

getFileDescription

public java.lang.String getFileDescription(long fileID)
                                    throws FileAccessException,
                                           FileDoesNotExistException,
                                           SecurityException
Gets and returns the description of a file.
Specified by:
getFileDescription in interface Archive

setFileDescription

public void setFileDescription(long fileID,
                               java.lang.String description)
                        throws FileAccessException,
                               FileDoesNotExistException,
                               SecurityException
Changes description of a file.
Specified by:
setFileDescription in interface Archive

addNewVersion

public long addNewVersion(long fileID,
                          java.io.File newVersion,
                          java.lang.String comment,
                          java.lang.String userName)
                   throws FileAccessException,
                          FileDoesNotExistException,
                          TextFileException,
                          SecurityException,
                          EndOfSourceException,
                          InvalidSourceException,
                          WrongFileTypeException
Adds a new version to an existing file. Returns newest version id.
Specified by:
addNewVersion in interface Archive

getProject

public Project getProject(long projectID)
                   throws FileAccessException,
                          ProjectDoesNotExistException,
                          SecurityException
Get Project object (info about project).
Specified by:
getProject in interface Archive

getFile

public File getFile(long fileID)
             throws FileAccessException,
                    FileDoesNotExistException,
                    SecurityException
Get File object (info about file).
Specified by:
getFile in interface Archive

getLatestVersionSourceFilePointer

public java.io.File getLatestVersionSourceFilePointer(long fileID)
                                               throws FileAccessException,
                                                      FileDoesNotExistException,
                                                      SecurityException
Returns java.io.File object for latest version's source.
Specified by:
getLatestVersionSourceFilePointer in interface Archive

getFileLatestVersion

public long getFileLatestVersion(long fileID,
                                 int requestedEOL)
                          throws FileAccessException,
                                 FileDoesNotExistException,
                                 TextFileException,
                                 SecurityException
Get latest version of file source to temp dir and return temp file ID.
Specified by:
getFileLatestVersion in interface Archive

getFileLatestVersionTLR

public TextLineReader getFileLatestVersionTLR(long fileID)
                                       throws FileAccessException,
                                              FileDoesNotExistException,
                                              TextFileException,
                                              SecurityException
Get latest version of text file source as TextLineReader.
Specified by:
getFileLatestVersionTLR in interface Archive

getFileVersionDelta

public Delta getFileVersionDelta(long versionID)
                          throws FileAccessException,
                                 NoSuchVersionException,
                                 WrongFileTypeException
Get specified delta object for file.
Specified by:
getFileVersionDelta in interface Archive

removeProject

public void removeProject(long parentID,
                          long projectID)
                   throws FileAccessException,
                          ProjectDoesNotExistException,
                          SecurityException
Remove specified project from the project hierarchy.
Specified by:
removeProject in interface Archive

removeFile

public void removeFile(long parentID,
                       long fileID)
                throws FileAccessException,
                       ProjectDoesNotExistException,
                       FileDoesNotExistException,
                       SecurityException
Remove specified file from specified project.
Specified by:
removeFile in interface Archive

rollbackToVersion

public void rollbackToVersion(long fileID,
                              long versionID,
                              java.io.File newLatestVersion)
                       throws FileAccessException,
                              FileDoesNotExistException,
                              NoSuchVersionException,
                              SecurityException,
                              TextFileException
Rollback specified file to specified version number. This method just removes the versions from the cache.
Specified by:
rollbackToVersion in interface Archive

retrieveVersionDeltaFile

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

setVersionComment

public void setVersionComment(long fileID,
                              int version,
                              java.lang.String comment)
                       throws FileAccessException,
                              FileDoesNotExistException,
                              NoSuchVersionException,
                              SecurityException
Set the comment of the specified version.
Specified by:
setVersionComment in interface Archive

getVersionFileSizeInBytes

public long getVersionFileSizeInBytes(long fileID,
                                      int versionNumber)
                               throws FileAccessException,
                                      FileDoesNotExistException,
                                      NoSuchVersionException,
                                      SecurityException
Gets the size of the version file in bytes.
Specified by:
getVersionFileSizeInBytes in interface Archive

getVersionComment

public java.lang.String getVersionComment(long versionID)
                                   throws FileAccessException,
                                          ProjectDoesNotExistException,
                                          FileDoesNotExistException,
                                          NoSuchVersionException
Get the comment for the specified version.
Specified by:
getVersionComment in interface Archive

checkOutFile

public void checkOutFile(long fileID,
                         java.lang.String userName,
                         java.lang.String checkOutLocation)
                  throws FileAccessException,
                         FileDoesNotExistException,
                         CheckOutException,
                         SecurityException
Set status of specified file to checked out. Does not return the file. Does guarantee that no other method will check out the file until it is checked in.
Specified by:
checkOutFile in interface Archive

checkInFile

public void checkInFile(long fileID)
                 throws FileAccessException,
                        FileDoesNotExistException,
                        CheckInException,
                        SecurityException
Set status of specified file to checked in. Does not add the new file version to model implementation. Does not guarantee that user checking in file is the same user who checked it out. Does guaranted that file will not be checked in if it has already been checked it.
Specified by:
checkInFile in interface Archive

getUniqueIDFromPath

public long getUniqueIDFromPath(long parentID,
                                java.lang.String path)
                         throws FileAccessException,
                                ProjectDoesNotExistException,
                                NodeDoesNotExistException,
                                SecurityException
Description copied from interface: Archive
Returns unique id based on a path.
Specified by:
getUniqueIDFromPath in interface Archive

getFileNode

public FileNode getFileNode(long fileID)
                     throws FileDoesNotExistException,
                            FileAccessException,
                            SecurityException
Allows "master control" to look at file info to verify check out, check in, file type, etc. MCP MUST release the file when done with it.
Specified by:
getFileNode in interface Archive

getFileNode

public FileNode getFileNode(long fileID,
                            boolean readOnly)
                     throws FileDoesNotExistException,
                            FileAccessException,
                            SecurityException
Allows "master control" to look at file info to verify check out, check in, file type, etc. MCP MUST release the file when done with it.
Specified by:
getFileNode in interface Archive

releaseFileNode

public void releaseFileNode(FileNode nd)
                     throws FileAccessException
Release a file node.
Specified by:
releaseFileNode in interface Archive

restoreRemovedNode

public void restoreRemovedNode(long parentID,
                               int index)
                        throws FileAccessException,
                               ProjectDoesNotExistException,
                               FileDoesNotExistException,
                               NodeDoesNotExistException,
                               NodeExistsException,
                               SecurityException
Description copied from interface: Archive
Restores a project or file node that was previously removed from the archive.
Specified by:
restoreRemovedNode in interface Archive
Following copied from interface: org.sourcejammer.project.controller.Archive
Parameters:
parent - -- NodeName of the project from which the node was removed.
index - -- Index value of the removed node in the removed nodes list (see getRemovedNodes()).

restoreRemovedNode

public void restoreRemovedNode(long parentID,
                               java.lang.String newName,
                               int index)
                        throws FileAccessException,
                               ProjectDoesNotExistException,
                               FileDoesNotExistException,
                               NodeDoesNotExistException,
                               NodeExistsException,
                               SecurityException
Restores a project or file node that was previously removed from the archive.
Specified by:
restoreRemovedNode in interface Archive
Parameters:
parentID - -- ID of the project from which the node was removed.
newName - -- a new name for the removed node.
index - -- Index value of the removed node in the removed nodes list (see getRemovedNodes()).

renameFile

public void renameFile(long parentID,
                       long fileID,
                       java.lang.String newName)
                throws FileAccessException,
                       ProjectDoesNotExistException,
                       FileDoesNotExistException,
                       NodeExistsException,
                       SecurityException
Specified by:
renameFile in interface Archive

renameProject

public void renameProject(long parentID,
                          long projectID,
                          java.lang.String newName)
                   throws FileAccessException,
                          ProjectDoesNotExistException,
                          NodeExistsException,
                          SecurityException
Specified by:
renameProject in interface Archive

permanentlyDeleteRemovedNode

public void permanentlyDeleteRemovedNode(long projectID,
                                         int index)
                                  throws FileAccessException,
                                         ProjectDoesNotExistException,
                                         NodeDoesNotExistException,
                                         SecurityException
Permanently delete specified removed node.
Specified by:
permanentlyDeleteRemovedNode in interface Archive

getRemovedNodes

public java.util.Vector getRemovedNodes(long projectID)
                                 throws FileAccessException,
                                        ProjectDoesNotExistException,
                                        SecurityException
Returns a Vector of NodeInfo objects, one for each node that has been removed (but not permanently deleted) from the parent project.
Specified by:
getRemovedNodes in interface Archive
Parameters:
parent - -- project NodeName to return a list of removed nodes for.

makeLabeledVersion

public void makeLabeledVersion(java.lang.String name,
                               java.lang.String description,
                               long parentProjectID,
                               java.lang.String userName)
                        throws NodeExistsException,
                               FileAccessException,
                               ProjectDoesNotExistException,
                               NoSuchVersionException,
                               FileDoesNotExistException,
                               FileAlreadyExistsException,
                               TextFileException,
                               SecurityException
Create and save a new labeled version with the passed-in name and description and containing all of the latest versions that are children of parent.
Specified by:
makeLabeledVersion in interface Archive

rebuildLabel

public void rebuildLabel(long labelID,
                         java.lang.String description,
                         long parentProjectID,
                         java.lang.String userName)
                  throws NodeExistsException,
                         FileAccessException,
                         NodeDoesNotExistException,
                         ProjectDoesNotExistException,
                         NoSuchVersionException,
                         FileDoesNotExistException,
                         FileAlreadyExistsException,
                         TextFileException,
                         SecurityException,
                         WrongFileTypeException,
                         EndOfSourceException,
                         InvalidSourceException
Specified by:
rebuildLabel in interface Archive

getLabelList

public NodeList getLabelList()
Deprecated.  

Returns NodeList of all LabelInfo objects in this archive.
Specified by:
getLabelList in interface Archive

getLabelContentList

public Label getLabelContentList(long labelID,
                                 int versionNumber)
                          throws NodeDoesNotExistException,
                                 FileAccessException,
                                 FileDoesNotExistException,
                                 SecurityException,
                                 EndOfSourceException,
                                 InvalidSourceException,
                                 WrongFileTypeException,
                                 NoSuchVersionException,
                                 TextFileException,
                                 ProjectDoesNotExistException
Returns the Label object (which contains the sourcejammer path and version number for each object in the labeled version) with the specified name.
Specified by:
getLabelContentList in interface Archive

projectNodeToProject

protected Project projectNodeToProject(ProjectNode ndProject)
                                throws SecurityException,
                                       ProjectDoesNotExistException,
                                       FileAccessException,
                                       FileDoesNotExistException,
                                       NodeExistsException

buildLabel

protected Label buildLabel(Label label,
                           long parentProjectID,
                           java.lang.String baseSJPath,
                           long skipFile)
                    throws NoSuchVersionException,
                           SecurityException,
                           FileAccessException,
                           ProjectDoesNotExistException,
                           FileDoesNotExistException
This method recursively calls itself until it has put all of the latest versions of all the file nodes in parent (and in all ProjectNode children of parent) into label.

controllerNodeToNodeInfo

protected NodeInfo controllerNodeToNodeInfo(ControllerNode nd)
                                     throws NoSuchVersionException
Builds new NodeInfo object from ControllerNode.

SourceJammer 1.3.0 November 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan