org.jmonks.dms.versioncontrol.ri
Class DefaultFileEntry

java.lang.Object
  extended byorg.jmonks.dms.versioncontrol.ri.DefaultRepositoryEntry
      extended byorg.jmonks.dms.versioncontrol.ri.DefaultFileEntry
All Implemented Interfaces:
java.lang.Comparable, FileEntry, RepositoryEntry

public class DefaultFileEntry
extends DefaultRepositoryEntry
implements FileEntry

Author:
Suresh Pragada This class saves the configuration in "entryID.vc" file in the following format.
 123.vc
#############################################################################
entry.id=123
entry.name=foo.txt
version.count=1
entry.type=1
checkout=false
1.version.author=Suresh Pragada
1.version.description=This is the first version.
1.version.date=12032005193456

Orignal version of the files will be stored as filename(entry.name)_versionNumber.


Field Summary
protected  java.lang.String absoluteFileName
          Holds the absolute path of absoluteFileName.
static java.lang.String DATE_FORMAT
           
static java.lang.String ENTRY_CHECKOUT_KEY_NAME
           
static java.lang.String ENTRY_VERSION_AUTHOR_KEY_NAME
           
static java.lang.String ENTRY_VERSION_COUNT_KEY_NAME
           
static java.lang.String ENTRY_VERSION_DATE_KEY_NAME
           
static java.lang.String ENTRY_VERSION_DESCRIPTION_KEY_NAME
           
static int INITIAL_VERSION_NUMBER
           
protected  boolean isCheckOut
           
private static org.apache.log4j.Logger logger
           
protected  int versionCount
           
 
Fields inherited from class org.jmonks.dms.versioncontrol.ri.DefaultRepositoryEntry
absoluteConfigFilePath, deletedDate, ENTRY_DELETE_KEY_NAME, ENTRY_DELETED_DATE_KEY_NAME, ENTRY_ID_KEY_NAME, ENTRY_NAME_KEY_NAME, ENTRY_PARENT_ENTRY_ID_KEY_NAME, ENTRY_TYPE_DIRECTORY, ENTRY_TYPE_FILE, ENTRY_TYPE_KEY_NAME, entryID, entryName, isDeleted, parentEntryID
 
Constructor Summary
(package private) DefaultFileEntry(java.io.File configFile, java.util.ResourceBundle configBundle)
          Creates a new instance of DefaultFileEntry from configuration file.
(package private) DefaultFileEntry(java.lang.Object parent, java.lang.String fileName, java.lang.String parentPath, java.lang.String authorName, java.lang.String description, java.util.Date versionDate, java.io.InputStream inputStream)
          Creates a new instance of DefaultFileEntry to create a File Entry.
 
Method Summary
 boolean cancelCheckOut()
          Cancels the reservation made to edit the file.
 FileVersion checkin(java.lang.String authorName, java.util.Date versionDate, java.lang.String description, java.io.InputStream inputStream)
          Checks in the file as a latest version of the file.
 boolean checkOut()
          Reserves the file for edit.
(package private)  java.lang.String getAbsoluteFileName()
           
 java.util.List getAllVersions()
          Returns the list, which contains all the versions of the File Entry.
 FileVersion getVersion(int versionNumber)
          Gets the requested version of file File Entry as an FileVersion object.
 int getVersionCount()
          Returns the number of versions exists for this entry.
 boolean isCheckedOut()
          Tells whether the file has been checked out for edit or not.
 boolean remove()
          This process actually permanently delete the entry from repository.
 java.lang.String toString()
           
private  boolean updateConfigFile(int versionNumber, java.lang.String authorName, java.lang.String versionDate, java.lang.String description)
          Adds the neewer version configuration information and updates the version count in the configuration file.
private  boolean updateConfigFileForCheckOut(boolean checkOut)
          Flips the checkout flag in configuration file.
 
Methods inherited from class org.jmonks.dms.versioncontrol.ri.DefaultRepositoryEntry
cancelDelete, compareTo, delete, getDeletedDate, getEntryID, getEntryName, getEntryType, getParentEntryID, getParentRepositoryEntry, getRepositoryEntry, isDeleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jmonks.dms.versioncontrol.api.RepositoryEntry
cancelDelete, delete, getDeletedDate, getEntryID, getEntryName, getEntryType, getParentEntryID, getParentRepositoryEntry, isDeleted
 

Field Detail

versionCount

protected int versionCount

isCheckOut

protected boolean isCheckOut

absoluteFileName

protected java.lang.String absoluteFileName
Holds the absolute path of absoluteFileName. absoluteFileName="c:\repository\xyz\pqr.txt"


ENTRY_VERSION_COUNT_KEY_NAME

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

ENTRY_CHECKOUT_KEY_NAME

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

ENTRY_VERSION_AUTHOR_KEY_NAME

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

ENTRY_VERSION_DATE_KEY_NAME

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

ENTRY_VERSION_DESCRIPTION_KEY_NAME

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

DATE_FORMAT

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

INITIAL_VERSION_NUMBER

public static final int INITIAL_VERSION_NUMBER
See Also:
Constant Field Values

logger

private static final org.apache.log4j.Logger logger
Constructor Detail

DefaultFileEntry

DefaultFileEntry(java.io.File configFile,
                 java.util.ResourceBundle configBundle)
Creates a new instance of DefaultFileEntry from configuration file.

Parameters:
configFile - Configuration file of the file entry.
configBundle - Resource bundle of the config file.

DefaultFileEntry

DefaultFileEntry(java.lang.Object parent,
                 java.lang.String fileName,
                 java.lang.String parentPath,
                 java.lang.String authorName,
                 java.lang.String description,
                 java.util.Date versionDate,
                 java.io.InputStream inputStream)
Creates a new instance of DefaultFileEntry to create a File Entry.

Parameters:
fileName - Entry name
parentPath - where the file needs to be created.
authorName - Author name of the first version.
description - Description of the first version.
versionDate - Create date of the first version.
inputStream - InputStream of the first version.
Method Detail

getVersion

public FileVersion getVersion(int versionNumber)
Description copied from interface: FileEntry
Gets the requested version of file File Entry as an FileVersion object.

Specified by:
getVersion in interface FileEntry
Parameters:
versionNumber - Required version of the file. The first version of the file start with 1. So, this should be in between the 1 and total number of versions.
Returns:
Returns the FileVersion object of that particular version.
See Also:
FileEntry.getVersion(int)

getAllVersions

public java.util.List getAllVersions()
Description copied from interface: FileEntry
Returns the list, which contains all the versions of the File Entry. This list will contains the FileVersion objects.

Specified by:
getAllVersions in interface FileEntry
Returns:
Returns the list contains all the file versions.
See Also:
org.jmonks.dms.versioncontrol.api.FileEntry#getAllVersions(java.util.List)

checkin

public FileVersion checkin(java.lang.String authorName,
                           java.util.Date versionDate,
                           java.lang.String description,
                           java.io.InputStream inputStream)
Description copied from interface: FileEntry
Checks in the file as a latest version of the file. It does require all the metadata to construct the next version. The file which needs to be checked-in should be provided as an java.io.InputStream.

Specified by:
checkin in interface FileEntry
Parameters:
authorName - Author name to be stored in meta info of this version.
versionDate - Version created date to be stored in meta info of this version.
description - Description to be stored in meta info of this version.
inputStream - InputStream of the information needs to be checked-in as the latest version.
Returns:
Returns the checked-in FileVersion object. This is the latest version.
See Also:
FileEntry.checkin(java.lang.String,java.util.Date,java.lang.String,java.io.InputStream)

updateConfigFile

private boolean updateConfigFile(int versionNumber,
                                 java.lang.String authorName,
                                 java.lang.String versionDate,
                                 java.lang.String description)
Adds the neewer version configuration information and updates the version count in the configuration file.

Parameters:
versionNumber - Version info to add.
authorName - Author name of the first version.
description - Description of the first version.
versionDate - Create date of the first version.

checkOut

public boolean checkOut()
Description copied from interface: FileEntry
Reserves the file for edit.

Specified by:
checkOut in interface FileEntry
See Also:
FileEntry.checkOut()

cancelCheckOut

public boolean cancelCheckOut()
Description copied from interface: FileEntry
Cancels the reservation made to edit the file.

Specified by:
cancelCheckOut in interface FileEntry
Returns:
Returns true if reservation has been cancelled, false, otherwise.
See Also:
FileEntry.cancelCheckOut()

updateConfigFileForCheckOut

private boolean updateConfigFileForCheckOut(boolean checkOut)
Flips the checkout flag in configuration file.

Returns:
Returns true if successfully updated, false otherwise.

getVersionCount

public int getVersionCount()
Description copied from interface: FileEntry
Returns the number of versions exists for this entry.

Specified by:
getVersionCount in interface FileEntry
Returns:
Returns the no of version exists.
See Also:
FileEntry.getVersionCount()

isCheckedOut

public boolean isCheckedOut()
Description copied from interface: FileEntry
Tells whether the file has been checked out for edit or not.

Specified by:
isCheckedOut in interface FileEntry
Returns:
Returns true if file has been checked out for edit, false, otherwise.
See Also:
FileEntry.isCheckedOut()

getAbsoluteFileName

java.lang.String getAbsoluteFileName()

remove

public boolean remove()
Description copied from interface: RepositoryEntry
This process actually permanently delete the entry from repository. After this operation entry will not be available in the repository.

Specified by:
remove in interface RepositoryEntry
Returns:
Returns true if entry got deleted permanently, false otherwise.
See Also:
RepositoryEntry.remove()

toString

public java.lang.String toString()
Overrides:
toString in class DefaultRepositoryEntry
See Also:
Object.toString()