net.sourceforge.cruisecontrol.sourcecontrols
Class P4

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

public class P4
extends java.lang.Object
implements SourceControl

This class implements the SourceControlElement methods for a P4 depot. The call to CVS is assumed to work without any setup. This implies that if the authentication type is pserver the call to cvs login should be done prior to calling this class.

P4Element depends on the optional P4 package delivered with Ant v1.3. But since it probably doesn't make much sense using the P4Element without other P4 support it shouldn't be a problem.

P4Element sets the property ${p4element.change} with the latest changelist number or the changelist with the latest date. This should then be passed into p4sync or other p4 commands.

Author:
Niclas Olofsson - isMobile.com, Jason Yip, Tim McCune, J D Glanville, Patrick Conant Copyright (c) 2005 Hewlett-Packard Development Company, L.P., John Lussmyer
See Also:
Serialized Form

Nested Class Summary
protected static class P4.ServerInfoConsumer
           
 
Constructor Summary
P4()
           
 
Method Summary
 Commandline buildChangesCommand(java.util.Date lastBuildTime, java.util.Date now, boolean isWindows)
          p4 -s [-c client] [-p port] [-u user] changes -s submitted [view@lastBuildTime@now]
 Commandline buildDescribeCommand(java.lang.String[] changelistNumbers)
          p4 -s [-c client] [-p port] [-u user] describe -s [change number]
 Commandline buildUserCommand(java.lang.String username)
          p4 -s [-c client] [-p port] [-u user] user -o [username]
protected  long calculateServerTimeOffset()
          Calculate the difference in time between the Perforce server and the CruiseControl server.
 java.util.List getModifications(java.util.Date lastBuild, java.util.Date now)
          Get a List of modifications detailing all the changes between now and the last build.
 java.util.Map getProperties()
          Any properties that have been set in this sourcecontrol.
protected  java.util.List parseChangeDescriptions(java.io.InputStream is)
           
protected  java.lang.String[] parseChangelistNumbers(java.io.InputStream is)
           
 void setClient(java.lang.String p4Client)
           
 void setCorrectForServerTime(boolean flag)
          Indicates whether to correct for time differences between the p4 server and the CruiseControl server.
 void setPasswd(java.lang.String p4Passwd)
           
 void setPort(java.lang.String p4Port)
           
 void setProperty(java.lang.String propertyName)
           
 void setUseP4Email(boolean flag)
          Sets if the Email address for the user should be retrieved from Perforce.
 void setUser(java.lang.String p4User)
           
 void setView(java.lang.String p4View)
           
 void validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P4

public P4()
Method Detail

setPort

public void setPort(java.lang.String p4Port)

setClient

public void setClient(java.lang.String p4Client)

setUser

public void setUser(java.lang.String p4User)

setView

public void setView(java.lang.String p4View)

setPasswd

public void setPasswd(java.lang.String p4Passwd)

setCorrectForServerTime

public void setCorrectForServerTime(boolean flag)
Indicates whether to correct for time differences between the p4 server and the CruiseControl server. Setting the flag to "true" will correct for both time zone differences and for non-synchronized system clocks.


setUseP4Email

public void setUseP4Email(boolean flag)
Sets if the Email address for the user should be retrieved from Perforce.

Parameters:
flag - true to retrieve email addresses from perforce.

setProperty

public void setProperty(java.lang.String propertyName)

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)
Get a List of modifications detailing all the changes between now and the last build. Return this as an element. It is not necessary for sourcecontrols to actually do anything other than returning a chunk of XML data back.

Specified by:
getModifications in interface SourceControl
Parameters:
lastBuild - time of last build
now - time this build started
Returns:
a list of XML elements that contains data about the modifications that took place. If no changes, this method returns an empty list.

parseChangelistNumbers

protected java.lang.String[] parseChangelistNumbers(java.io.InputStream is)
                                             throws java.io.IOException
Throws:
java.io.IOException

parseChangeDescriptions

protected java.util.List parseChangeDescriptions(java.io.InputStream is)
                                          throws java.io.IOException
Throws:
java.io.IOException

buildChangesCommand

public Commandline buildChangesCommand(java.util.Date lastBuildTime,
                                       java.util.Date now,
                                       boolean isWindows)
p4 -s [-c client] [-p port] [-u user] changes -s submitted [view@lastBuildTime@now]


buildDescribeCommand

public Commandline buildDescribeCommand(java.lang.String[] changelistNumbers)
p4 -s [-c client] [-p port] [-u user] describe -s [change number]


buildUserCommand

public Commandline buildUserCommand(java.lang.String username)
p4 -s [-c client] [-p port] [-u user] user -o [username]


calculateServerTimeOffset

protected long calculateServerTimeOffset()
                                  throws java.io.IOException,
                                         java.lang.InterruptedException
Calculate the difference in time between the Perforce server and the CruiseControl server. A negative time difference indicates that the Perforce server time is later than CruiseControl server (e.g. Perforce in New York, CruiseControl in San Francisco). A positive offset indicates that the Perforce server time is before the CruiseControl server.

Throws:
java.io.IOException
java.lang.InterruptedException