net.sourceforge.cruisecontrol.sourcecontrols
Class VssJournal

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.sourcecontrols.VssJournal
All Implemented Interfaces:
java.io.Serializable, SourceControl

public class VssJournal
extends java.lang.Object
implements SourceControl

This class handles all VSS-related aspects of determining the modifications since the last good build. This class uses Source Safe Journal files. Unlike the history files that are generated by executing ss.exe history, journal files must be setup by the Source Safe administrator before the point that logging of modifications is to occur. This code has been tested against Visual Source Safe v6.0 build 8383.

Author:
Eli Tucker, alden almagro, Jason Yip, Arun Aggarwal, Jonny Boman, Simon Brandhof
See Also:
Serialized Form

Constructor Summary
VssJournal()
           
 
Method Summary
 java.util.List getModifications(java.util.Date lastBuild, java.util.Date now)
          Do the work...
 java.util.Map getProperties()
          Any properties that have been set in this sourcecontrol.
protected  Modification handleEntry(java.util.List historyEntry)
          Parse individual VSS history entry
protected  boolean isBeforeLastBuild(java.util.Date date)
          Determines if the date given is before the last build for this VssJournalElement.
protected  boolean isInSsDir(java.lang.String path)
          Determines if the given folder is in the ssdir specified for this VssJournalElement.
 java.util.Date parseDate(java.lang.String nameAndDateLine)
          Parse date/time from VSS file history The nameAndDateLine will look like User: Etucker Date: 6/26/01 Time: 11:53a Sometimes also this User: Aaggarwa Date: 6/29/:1 Time: 3:40p Note the ":" instead of a "0" May give additional DateFormats through the vssjournaldateformat tag.
 java.lang.String parseUser(java.lang.String userLine)
          Parse username from VSS file history
 void setDateFormat(java.lang.String format)
          Sets the date format to use for parsing VSS journal.
 void setJournalFile(java.lang.String journalFile)
          Full path to journal file.
protected  void setLastBuildDate(java.util.Date lastBuild)
          Sets the _lastBuild date.
 void setProperty(java.lang.String property)
          Choose a property to be set if the project has modifications if we have a change that only requires repackaging, i.e. jsp, we don't need to recompile everything, just rejar.
 void setPropertyOnDelete(java.lang.String propertyOnDelete)
          Set the name of the property to be set if some files were deleted or renamed from VSS on this project.
 void setSsDir(java.lang.String s)
          Set the project to get history from
 void setTimeFormat(java.lang.String format)
          Sets the time format to use for parsing VSS journal.
 java.lang.String substringFromLastSlash(java.lang.String input)
          Returns the substring of the given string from the last "/" character.
 java.lang.String substringToLastSlash(java.lang.String input)
          Returns the substring of the given string from the beginning to the last "/" character or till the end of the string if no slash character exists.
 void validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VssJournal

public VssJournal()
Method Detail

setSsDir

public void setSsDir(java.lang.String s)
Set the project to get history from


setJournalFile

public void setJournalFile(java.lang.String journalFile)
Full path to journal file. Example: c:/vssdata/journal/journal.txt

Parameters:
journalFile -

setProperty

public void setProperty(java.lang.String property)
Choose a property to be set if the project has modifications if we have a change that only requires repackaging, i.e. jsp, we don't need to recompile everything, just rejar.

Parameters:
property -

setPropertyOnDelete

public void setPropertyOnDelete(java.lang.String propertyOnDelete)
Set the name of the property to be set if some files were deleted or renamed from VSS on this project.

Parameters:
propertyOnDelete - the name of the property to set

setDateFormat

public void setDateFormat(java.lang.String format)
Sets the date format to use for parsing VSS journal. The default date format is MM/dd/yy. If your VSS server is set to a different region, you may wish to use a format such as dd/MM/yy.

See Also:
SimpleDateFormat

setTimeFormat

public void setTimeFormat(java.lang.String format)
Sets the time format to use for parsing VSS journal. The default time format is hh:mma . If your VSS server is set to a different region, you may wish to use a format such as HH:mm .

See Also:
SimpleDateFormat

setLastBuildDate

protected void setLastBuildDate(java.util.Date lastBuild)
Sets the _lastBuild date. Protected so it can be used by tests.


getProperties

public java.util.Map getProperties()
Description copied from interface: SourceControl
Any properties that have been set in this sourcecontrol. Will be passed onto the Builder, which may then pass the properties to the underlying build implementation. For example, the Ant builder will define these properties so that the underlying Ant script can use them.

Specified by:
getProperties in interface SourceControl

validate

public void validate()
              throws CruiseControlException
Specified by:
validate in interface SourceControl
Throws:
CruiseControlException

getModifications

public java.util.List getModifications(java.util.Date lastBuild,
                                       java.util.Date now)
Do the work... I'm writing to a file since VSS will start wrapping lines if I read directly from the stream.

Specified by:
getModifications in interface SourceControl
Parameters:
lastBuild -
now -
Returns:
List of Modification objects

handleEntry

protected Modification handleEntry(java.util.List historyEntry)
Parse individual VSS history entry

Parameters:
historyEntry -

parseDate

public java.util.Date parseDate(java.lang.String nameAndDateLine)
Parse date/time from VSS file history The nameAndDateLine will look like User: Etucker Date: 6/26/01 Time: 11:53a Sometimes also this User: Aaggarwa Date: 6/29/:1 Time: 3:40p Note the ":" instead of a "0" May give additional DateFormats through the vssjournaldateformat tag. E.g.

Parameters:
nameAndDateLine -
Returns:
Date

parseUser

public java.lang.String parseUser(java.lang.String userLine)
Parse username from VSS file history

Parameters:
userLine -
Returns:
the user name who made the modification

substringFromLastSlash

public java.lang.String substringFromLastSlash(java.lang.String input)
Returns the substring of the given string from the last "/" character. UNLESS the last slash character is the last character or the string does not contain a slash. In that case, return the whole string.


substringToLastSlash

public java.lang.String substringToLastSlash(java.lang.String input)
Returns the substring of the given string from the beginning to the last "/" character or till the end of the string if no slash character exists.


isInSsDir

protected boolean isInSsDir(java.lang.String path)
Determines if the given folder is in the ssdir specified for this VssJournalElement.


isBeforeLastBuild

protected boolean isBeforeLastBuild(java.util.Date date)
Determines if the date given is before the last build for this VssJournalElement.