com.atlassian.bamboo.repository.perforce
Class PerforceManager

java.lang.Object
  extended by com.atlassian.bamboo.repository.perforce.PerforceManager

public class PerforceManager
extends java.lang.Object

This class is designed to be the interface between the perforce library and the repository. TODO Please note that there have been some issues with the legacy perforce api so please only use the tek42 api.


Field Summary
protected static org.apache.commons.lang.time.FastDateFormat dateFormat
           
 
Constructor Summary
PerforceManager()
           
 
Method Summary
 CapabilitySet addDefaultPerforceExe(CapabilitySet capabilitySet)
          Extracts the default perforce executable from the system properties and creates a capability
 void clearCache()
           
 java.util.List<Commit> getChangeLogEntries(com.tek42.perforce.Depot perforceDepot, java.util.List<java.lang.Integer> changeNumbers)
          Retrieves a list of Bamboo Commit Files based on list of change numbers
 java.util.List<java.lang.Integer> getChangeNumbersFromRevision(com.tek42.perforce.Depot perforceDepot, java.lang.String clientViewDepot, int lastRevisionInBamboo)
           
 java.util.List<java.lang.Integer> getChangeNumsBetweenRevisions(com.tek42.perforce.Depot perforceDepot, java.lang.String depot, int firstRevision, int secondRevision)
          Retrieves a list of change log numbers between two revision numbers for the depot.
 java.lang.String getClientRoot(com.tek42.perforce.Depot perforceDepot)
          Retrieves the workspace root as defined in the client configuration
protected  java.lang.String getDepotFromView(com.tek42.perforce.Depot perforceDepot, java.lang.String depotView)
          Takes in the client view of a depot (right hand side of the view map) and returns the actual depot (left hand side of the view map) If it fails it will return the client view, chances are what you are doing will still work with this.
 java.util.Map<java.lang.String,java.lang.String> getDepotViewCache()
           
 java.lang.String getFileNameForUrl(java.lang.String fileName, java.lang.String depot, java.lang.String clientName)
           
 java.lang.String getHostFromInfo(com.tek42.perforce.Depot perforceDepot)
          parses output of perforce indo command to extract out the address of the perforce server
 int getLatestChangeNumber(com.tek42.perforce.Depot perforceDepot, java.lang.String depot, int latestRevisionInBamboo)
          retrieves the latest change list number on the perforce server for comparison to the one stored in Bamboo
 java.lang.String getWorkingDir(java.lang.String client, java.lang.String clientRoot, java.lang.String depot)
          Extracts the directory from the depot(client view) and source code directory which will contain the build files
 void setupSync(com.tek42.perforce.Depot perforceDepot, java.io.File sourceDirectory)
          Sets the directory for perforce to check the code out to.
 void syncToHead(com.tek42.perforce.Depot perforceDepot, java.lang.String depot, boolean forceSync)
          Syncs the source code to head
 void syncToRevision(com.tek42.perforce.Depot perforceDepot, java.lang.String depot, int revisionNumber, boolean forceSync)
          Syncs the source code to a specific revision number
 void validateClient(ErrorCollection errorCollection, com.tek42.perforce.Depot depot, java.lang.String client)
          Validates the existance of the specified client of the perforce depot.
 void validateConnection(ErrorCollection errorCollection, com.tek42.perforce.Depot depot)
          Validates the connection to the perforce depot.
 void validateDepot(ErrorCollection errorCollection, com.tek42.perforce.Depot validationDepot, java.lang.String depot)
          Validates that the depot string specified is correct.
 void validateLogin(ErrorCollection errorCollection, com.tek42.perforce.Depot depot)
          Validates that the login credential supplied (ie user/password combination) is correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dateFormat

protected static final org.apache.commons.lang.time.FastDateFormat dateFormat
Constructor Detail

PerforceManager

public PerforceManager()
Method Detail

syncToRevision

public void syncToRevision(@NotNull
                           com.tek42.perforce.Depot perforceDepot,
                           @NotNull
                           java.lang.String depot,
                           int revisionNumber,
                           boolean forceSync)
                    throws RepositoryException
Syncs the source code to a specific revision number

Parameters:
revisionNumber -
forceSync -
Throws:
com.tek42.perforce.PerforceException - if perforce failed to sync the workspace
RepositoryException

syncToHead

public void syncToHead(@NotNull
                       com.tek42.perforce.Depot perforceDepot,
                       @NotNull
                       java.lang.String depot,
                       boolean forceSync)
                throws RepositoryException
Syncs the source code to head

Parameters:
forceSync -
Throws:
com.tek42.perforce.PerforceException - if perforce failed to sync the workspace
RepositoryException

setupSync

public void setupSync(@NotNull
                      com.tek42.perforce.Depot perforceDepot,
                      @NotNull
                      java.io.File sourceDirectory)
               throws RepositoryException
Sets the directory for perforce to check the code out to. To do this it alters the client definition in particular the client root. It also ensures that there are no machine restrictions in place. Please use sparingly

Parameters:
planKey -
Throws:
RepositoryException

getClientRoot

@NotNull
public java.lang.String getClientRoot(com.tek42.perforce.Depot perforceDepot)
                               throws RepositoryException
Retrieves the workspace root as defined in the client configuration

Parameters:
the - client to extract the workspace root for
Returns:
String client root, Null if it couldn't find it.
Throws:
RepositoryException

getFileNameForUrl

@Nullable
public java.lang.String getFileNameForUrl(java.lang.String fileName,
                                                   java.lang.String depot,
                                                   java.lang.String clientName)

getLatestChangeNumber

public int getLatestChangeNumber(@NotNull
                                 com.tek42.perforce.Depot perforceDepot,
                                 java.lang.String depot,
                                 int latestRevisionInBamboo)
                          throws RepositoryException
retrieves the latest change list number on the perforce server for comparison to the one stored in Bamboo

Parameters:
latestRevisionInBamboo - the last changelist number stored in bamboo
Returns:
long Number of latest changelist from perforce, If it can not find it, the latestRevisionInBamboo is returned
Throws:
RepositoryException

getChangeNumsBetweenRevisions

@NotNull
public java.util.List<java.lang.Integer> getChangeNumsBetweenRevisions(@NotNull
                                                                               com.tek42.perforce.Depot perforceDepot,
                                                                               java.lang.String depot,
                                                                               int firstRevision,
                                                                               int secondRevision)
                                                                throws RepositoryException
Retrieves a list of change log numbers between two revision numbers for the depot. This can then be used To extract the change logs.

Parameters:
firstRevision -
secondRevision -
Returns:
Throws:
RepositoryException

getChangeNumbersFromRevision

public java.util.List<java.lang.Integer> getChangeNumbersFromRevision(@NotNull
                                                                      com.tek42.perforce.Depot perforceDepot,
                                                                      java.lang.String clientViewDepot,
                                                                      int lastRevisionInBamboo)
                                                               throws RepositoryException
Throws:
RepositoryException

getChangeLogEntries

@NotNull
public java.util.List<Commit> getChangeLogEntries(@NotNull
                                                          com.tek42.perforce.Depot perforceDepot,
                                                          @NotNull
                                                          java.util.List<java.lang.Integer> changeNumbers)
                                           throws RepositoryException
Retrieves a list of Bamboo Commit Files based on list of change numbers

Parameters:
changeNumbers -
Returns:
Throws:
RepositoryException

getHostFromInfo

@Nullable
public java.lang.String getHostFromInfo(@NotNull
                                                 com.tek42.perforce.Depot perforceDepot)
parses output of perforce indo command to extract out the address of the perforce server

Returns:
address of the perforce server

validateConnection

public void validateConnection(@NotNull
                               ErrorCollection errorCollection,
                               com.tek42.perforce.Depot depot)
Validates the connection to the perforce depot. Uses the legacy perforce api

Parameters:
errorCollection -
p4exe -
port -

validateLogin

public void validateLogin(@NotNull
                          ErrorCollection errorCollection,
                          com.tek42.perforce.Depot depot)
Validates that the login credential supplied (ie user/password combination) is correct. Uses the legacy perforce api

Parameters:
errorCollection -
user -
p4exe -
port -
password - - decrypted password

validateClient

public void validateClient(@NotNull
                           ErrorCollection errorCollection,
                           com.tek42.perforce.Depot depot,
                           @NotNull
                           java.lang.String client)
Validates the existance of the specified client of the perforce depot. Uses the legacy perforce api

Parameters:
errorCollection -
user -
p4exe -
port -
client -
password -

validateDepot

public void validateDepot(@NotNull
                          ErrorCollection errorCollection,
                          com.tek42.perforce.Depot validationDepot,
                          java.lang.String depot)
Validates that the depot string specified is correct. This still uses a direct perforce command call.

Parameters:
errorCollection -
user -
p4exe -
port -
client -
depot -
password - - decrypted password

getWorkingDir

@Nullable
public java.lang.String getWorkingDir(@Nullable
                                               java.lang.String client,
                                               @Nullable
                                               java.lang.String clientRoot,
                                               @Nullable
                                               java.lang.String depot)
Extracts the directory from the depot(client view) and source code directory which will contain the build files

Parameters:
client - - name of the client
clientRoot - - the location the source will be checked out to
depot - - the depot(client view) as specified by the user
Returns:

addDefaultPerforceExe

@NotNull
public CapabilitySet addDefaultPerforceExe(@NotNull
                                                   CapabilitySet capabilitySet)
Extracts the default perforce executable from the system properties and creates a capability

Parameters:
capabilitySet - to add the capability to
Returns:
the supplied capabilitySet with the new capability included if found, else the given capabilitySet

getDepotFromView

protected java.lang.String getDepotFromView(@NotNull
                                            com.tek42.perforce.Depot perforceDepot,
                                            @Nullable
                                            java.lang.String depotView)
Takes in the client view of a depot (right hand side of the view map) and returns the actual depot (left hand side of the view map) If it fails it will return the client view, chances are what you are doing will still work with this. Perforce views are in the format //myDepot/src... //myClient/view/... with any amount of whitespace around it (also known to get \t on occassion)

Parameters:
perforceDepot -
depotView - - the client view you want to match
Returns:

getDepotViewCache

public java.util.Map<java.lang.String,java.lang.String> getDepotViewCache()

clearCache

public void clearCache()


Copyright © 2011 Atlassian. All Rights Reserved.