com.atlassian.bamboo.repository.perforce
Class PerforceRepository

java.lang.Object
  extended by com.atlassian.bamboo.repository.AbstractRepository
      extended by com.atlassian.bamboo.repository.perforce.PerforceRepository
All Implemented Interfaces:
ConvertibleFromConfig, InitablePluginModule, CleanCheckoutAwareRepository, CleanWorkingDirectoryAwareRepository, IncludeExcludeAwareRepository, MavenPomAccessorCapableRepository, MutableQuietPeriodAwareRepository, QuietPeriodAwareRepository, Repository, DescriptionProvider, NameProvider, BambooPluginModule, BuildConfigurationAwarePlugin, ConfigurablePlugin, PostConfigurableRepository, RepositoryV2, java.io.Serializable

public class PerforceRepository
extends AbstractRepository
implements PostConfigurableRepository, MutableQuietPeriodAwareRepository, MavenPomAccessorCapableRepository

This class provides a Perforce implemention of the Repository interface.

See Also:
Serialized Form

Field Summary
static java.lang.String BAD_FORMAT
           
static java.lang.String COMPLETE_PLUGIN_KEY
           
static java.lang.String KEY
           
static java.lang.String NAME
           
static java.lang.String P4_CAPABILITY_KEY
           
static java.lang.String P4_CLIENT
           
static java.lang.String P4_DEPOT
           
static java.lang.String P4_MANAGE
           
static java.lang.String P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH
           
static java.lang.String P4_PASSWD
           
static java.lang.String P4_PORT
           
static java.lang.String P4_USER
           
protected  PerforceManager perforceManager
           
static java.lang.String TEMPORARY_P4_PASSWORD
           
 
Fields inherited from class com.atlassian.bamboo.repository.AbstractRepository
BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, CLEAN_CHECKOUT_PARAM, CLEAN_WORKING_DIRECTORY_PARAM, repositoryModuleDescriptor, templateRenderer, textProvider, variableSubstitutionBean
 
Fields inherited from interface com.atlassian.bamboo.repository.Repository
SELECTED_REPOSITORY, UNKNOWN_HOST
 
Fields inherited from interface com.atlassian.bamboo.repository.IncludeExcludeAwareRepository
FILTER_PATTERN_EXCLUDE, FILTER_PATTERN_INCLUDE, FILTER_PATTERN_OPTION, FILTER_PATTERN_REGEX
 
Constructor Summary
PerforceRepository()
           
 
Method Summary
 void addDefaultValues(BuildConfiguration buildConfiguration)
          Extension point for adding default values to the form for BuildConfigurationAwarePlugin.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
 BuildChanges collectChangesSinceLastBuild(java.lang.String planKey, java.lang.String lastVcsRevisionKey)
          Access the perforce repository to retrieve change logs since the lastVCSRevisionKey
 int compareTo(java.lang.Object obj)
           
 boolean equals(java.lang.Object o)
           
 void getAllSourceCode(Build build)
          Deprecated. 
 java.lang.String getClient()
          Obtain the perforce client we're using
 java.lang.String getDepot()
          What's the build depot that we're checking for changes?
 java.lang.String getEncryptedPassword()
          Whats the encryted password for the user
 java.lang.String getHost()
          Retrieves the address of the Perforce Server
 MavenPomAccessor getMavenPomAccessor()
           
 java.lang.String getMavenPomCheckoutPomRelativePath()
           
 int getMaxRetries()
          Returns the maximum number of times to collect changes
 java.lang.String getName()
          Return the name of the repository
 java.lang.String getP4Executable()
          Which perforce p4 exe are we using?
 com.tek42.perforce.Depot getPerforceDepot()
          Retrieves an instance of a Perforce Depot populated with the builds information
 java.lang.String getPort()
          Which perforce server are we using?
 int getQuietPeriod()
          Returns the number of seconds to wait between each retry
 java.io.File getSourceCodeDirectory(java.lang.String planKey)
          Retrieves the location that the build will occur, If the workspace is managed this includes the source code directory specified by bamboo followed by the directory structure as indicated in the client view.
 java.lang.String getSubstitutedClient()
           
 java.lang.String getSubstitutedDepot()
           
 java.lang.String getSubstitutedPort()
           
 java.lang.String getSubstitutedUser()
           
 java.lang.String getUrl()
           
 java.lang.String getUser()
          What's the optional perforce user name? Returns null if we are not using a user
 int hashCode()
           
 boolean isManageWorkspace()
           
 boolean isPerforceExecutableSet()
          For configuration screens
 boolean isQuietPeriodEnabled()
          Returns true if we were to enable the quiet period
 boolean isRepositoryDifferent(Repository repository)
          Checks if the current repo is the same as the given repository
 void performPostConfiguration(BuildConfiguration buildConfiguration, Plan plan)
          Allows any other configuration to be performed after another repository has been created.
 void performPostConfigurationForSelectedRepository(BuildConfiguration buildConfiguration, Plan plan)
          Allows any other configuration to be performed after this repository has been created
 void populateFromConfig(org.apache.commons.configuration.HierarchicalConfiguration config)
          Update the current object with data in the HierarchicalConfiguration
 void prepareConfigObject(BuildConfiguration buildConfiguration)
          Do any preprocessing work before validation occurs.
 java.lang.String retrieveSourceCode(BuildContext buildContext, java.lang.String vcsRevisionKey)
          Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from head
 java.lang.String retrieveSourceCode(java.lang.String planKey, java.lang.String vcsRevisionKey)
          Checks out the latest source code to an appropriate repository
 void setCapabilityContext(CapabilityContext capabilityContext)
           
 void setClient(java.lang.String client)
          Define the client we're using to connect to the perforce server
 void setDepot(java.lang.String depot)
          Define the build depot
 void setEncryptedPassword(java.lang.String encryptedPassword)
          Set the password for the user.
 void setManageWorkspace(boolean manageWorkspace)
           
 void setMavenPomCheckoutPomRelativePath(java.lang.String mavenPomCheckoutPomRelativePath)
           
 void setMaxRetries(int maxRetries)
           
 void setPerforceManager(PerforceManager perforceManager)
           
 void setPlanManager(PlanManager planManager)
           
 void setPort(java.lang.String port)
          Define the perforce server and port we're going to connect to
 void setQuietPeriod(int quietPeriod)
           
 void setQuietPeriodEnabled(boolean quietPeriodEnabled)
           
 void setUser(java.lang.String user)
          Override the default user, if you want to specify the perforce user
 void setWorkingDir(java.io.File workingDir)
          Ignore in as perforce will determine the working directory based on the client information
 org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
          Generate a HierarchicalConfiguration from the current state of the object
 ErrorCollection validate(BuildConfiguration buildConfiguration)
          Validates the properties in the BuildConfiguration object.
 
Methods inherited from class com.atlassian.bamboo.repository.AbstractRepository
checkConnection, createStringFromList, customizeBuildRequirements, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getLocationIdentifier, getMavenPomCheckoutAccessEditHtml, getMinimalEditHtml, getShortKey, getTriggerIpAddress, getVariableSubstitutionBean, getViewHtml, getWorkingDirectory, init, isCleanCheckout, isCleanWorkingDirectory, isWorkspaceEmpty, referencesDifferentRepository, removeBuildRequirements, setBuildDirectoryManager, setBuildLoggerManager, setCleanCheckout, setCleanWorkingDirectory, setFilterFilePatternOption, setFilterFilePatternRegex, setReferencesDifferentRepository, setTemplateRenderer, setTextProvider, setTriggerIpAddress, setVariableSubstitutionBean
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.bamboo.repository.Repository
checkConnection, getKey, getLocationIdentifier, getMinimalEditHtml, getShortKey, getTriggerIpAddress, setReferencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.repository.RepositoryV2
referencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
Methods inherited from interface com.atlassian.bamboo.v2.build.BuildConfigurationAwarePlugin
getEditHtml, getViewHtml
 
Methods inherited from interface com.atlassian.bamboo.utils.DescriptionProvider
getDescription
 

Field Detail

NAME

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

KEY

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

COMPLETE_PLUGIN_KEY

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

P4_PORT

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

P4_CLIENT

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

P4_DEPOT

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

P4_USER

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

P4_PASSWD

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

P4_MANAGE

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

P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH

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

TEMPORARY_P4_PASSWORD

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

BAD_FORMAT

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

P4_CAPABILITY_KEY

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

perforceManager

protected transient PerforceManager perforceManager
Constructor Detail

PerforceRepository

public PerforceRepository()
Method Detail

collectChangesSinceLastBuild

@NotNull
public BuildChanges collectChangesSinceLastBuild(@NotNull
                                                         java.lang.String planKey,
                                                         @Nullable
                                                         java.lang.String lastVcsRevisionKey)
                                          throws RepositoryException
Access the perforce repository to retrieve change logs since the lastVCSRevisionKey

Specified by:
collectChangesSinceLastBuild in interface RepositoryV2
Parameters:
planKey -
lastVcsRevisionKey - - the revision number for the last build
Returns:
Build Changes with the change logs and the current revision key
Throws:
RepositoryException - If perforce fails to collect the changes

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   java.lang.String planKey,
                                                   @Nullable
                                                   java.lang.String vcsRevisionKey)
                                    throws RepositoryException
Description copied from interface: RepositoryV2
Checks out the latest source code to an appropriate repository

Specified by:
retrieveSourceCode in interface RepositoryV2
vcsRevisionKey - - may be null if you want latest code
Returns:
vcsRevisionKey - the revision
Throws:
RepositoryException

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   BuildContext buildContext,
                                                   @Nullable
                                                   java.lang.String vcsRevisionKey)
                                    throws RepositoryException
Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from head

Specified by:
retrieveSourceCode in interface RepositoryV2
Parameters:
buildContext - - for the build being checked out
vcsRevisionKey - - the revision to checkout the source from
Returns:
the revision key of the checkout (only changes if checked out from head)
Throws:
RepositoryException - if Perforce fails to

getPerforceDepot

@NotNull
public com.tek42.perforce.Depot getPerforceDepot()
Retrieves an instance of a Perforce Depot populated with the builds information

Returns:

getP4Executable

@Nullable
public java.lang.String getP4Executable()
Which perforce p4 exe are we using?

Returns:
The location of the exe

validate

@NotNull
public ErrorCollection validate(@NotNull
                                        BuildConfiguration buildConfiguration)
Description copied from interface: BuildConfigurationAwarePlugin
Validates the properties in the BuildConfiguration object. The name of the properties match those passed in through the form fragments in BuildConfigurationAwarePlugin.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan) template.

Specified by:
validate in interface BuildConfigurationAwarePlugin
Overrides:
validate in class AbstractRepository
Parameters:
buildConfiguration - - @NotNull
Returns:
ErrorCollection keyed by the field name. @NotNull

performPostConfiguration

public void performPostConfiguration(BuildConfiguration buildConfiguration,
                                     Plan plan)
Description copied from interface: PostConfigurableRepository
Allows any other configuration to be performed after another repository has been created.

Specified by:
performPostConfiguration in interface PostConfigurableRepository

performPostConfigurationForSelectedRepository

public void performPostConfigurationForSelectedRepository(BuildConfiguration buildConfiguration,
                                                          Plan plan)
Description copied from interface: PostConfigurableRepository
Allows any other configuration to be performed after this repository has been created

Specified by:
performPostConfigurationForSelectedRepository in interface PostConfigurableRepository

getClient

public java.lang.String getClient()
Obtain the perforce client we're using

Returns:
the client

getSubstitutedClient

public java.lang.String getSubstitutedClient()

setClient

public void setClient(java.lang.String client)
Define the client we're using to connect to the perforce server

Parameters:
client - The client

getPort

public java.lang.String getPort()
Which perforce server are we using?

Returns:
The perforce server (they call it port for some strange reason)

getSubstitutedPort

public java.lang.String getSubstitutedPort()

setPort

public void setPort(java.lang.String port)
Define the perforce server and port we're going to connect to

Parameters:
port - The perforce server and port

getDepot

public java.lang.String getDepot()
What's the build depot that we're checking for changes?

Returns:
the build

getSubstitutedDepot

public java.lang.String getSubstitutedDepot()

setDepot

public void setDepot(java.lang.String depot)
Define the build depot

Parameters:
depot - The depot

setUser

public void setUser(java.lang.String user)
Override the default user, if you want to specify the perforce user

Parameters:
user - The perforce user

getUser

public java.lang.String getUser()
What's the optional perforce user name? Returns null if we are not using a user

Returns:
The perforce user

getSubstitutedUser

public java.lang.String getSubstitutedUser()

isManageWorkspace

public boolean isManageWorkspace()

setManageWorkspace

public void setManageWorkspace(boolean manageWorkspace)

setEncryptedPassword

public void setEncryptedPassword(java.lang.String encryptedPassword)
Set the password for the user. This password should be encrypted

Parameters:
encryptedPassword -

getEncryptedPassword

public java.lang.String getEncryptedPassword()
Whats the encryted password for the user

Returns:
encrypted password

getMavenPomCheckoutPomRelativePath

public java.lang.String getMavenPomCheckoutPomRelativePath()

setMavenPomCheckoutPomRelativePath

public void setMavenPomCheckoutPomRelativePath(java.lang.String mavenPomCheckoutPomRelativePath)

getName

@NotNull
public java.lang.String getName()
Return the name of the repository

Specified by:
getName in interface Repository
Specified by:
getName in interface DescriptionProvider
Specified by:
getName in interface NameProvider
Returns:
String name of the repository

getUrl

public java.lang.String getUrl()

setWorkingDir

public void setWorkingDir(java.io.File workingDir)
Ignore in as perforce will determine the working directory based on the client information

Overrides:
setWorkingDir in class AbstractRepository
Parameters:
workingDir - ignored

getSourceCodeDirectory

@NotNull
public java.io.File getSourceCodeDirectory(@NotNull
                                                   java.lang.String planKey)
                                    throws RepositoryException
Retrieves the location that the build will occur, If the workspace is managed this includes the source code directory specified by bamboo followed by the directory structure as indicated in the client view. If the workspace is not manages this will include the root directory as specified the perforce client definition followed by the directory structure as indicated in the client view. This is not validated in any way.

Specified by:
getSourceCodeDirectory in interface RepositoryV2
Overrides:
getSourceCodeDirectory in class AbstractRepository
Parameters:
planKey -
Returns:
The location of the perforce build files
Throws:
RepositoryException - if it can not connect to perforce, could not find appropriate directory or the depot string is incorrect.

getHost

public java.lang.String getHost()
Retrieves the address of the Perforce Server

Specified by:
getHost in interface Repository
Returns:
string host information

isRepositoryDifferent

public boolean isRepositoryDifferent(@NotNull
                                     Repository repository)
Description copied from interface: RepositoryV2
Checks if the current repo is the same as the given repository

Specified by:
isRepositoryDifferent in interface RepositoryV2
Parameters:
repository - to compare against
Returns:
true of repositories are different, false if the same;

getMavenPomAccessor

@NotNull
public MavenPomAccessor getMavenPomAccessor()
Specified by:
getMavenPomAccessor in interface MavenPomAccessorCapableRepository

getAllSourceCode

@Deprecated
public void getAllSourceCode(Build build)
                      throws RepositoryException
Deprecated. 

Force perforce to checkout all the source code. The -f flag is required so that even if the src dir has been deleted locally, P4 still d/l the source files again.

Parameters:
build -
Throws:
RepositoryException - Something went wrong

addDefaultValues

public void addDefaultValues(@NotNull
                             BuildConfiguration buildConfiguration)
Description copied from interface: BuildConfigurationAwarePlugin
Extension point for adding default values to the form for BuildConfigurationAwarePlugin.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)

Specified by:
addDefaultValues in interface BuildConfigurationAwarePlugin
Overrides:
addDefaultValues in class AbstractRepository
Parameters:
buildConfiguration - - @NotNull

populateFromConfig

public void populateFromConfig(@NotNull
                               org.apache.commons.configuration.HierarchicalConfiguration config)
Description copied from interface: ConvertibleFromConfig
Update the current object with data in the HierarchicalConfiguration

Specified by:
populateFromConfig in interface ConvertibleFromConfig
Overrides:
populateFromConfig in class AbstractRepository

toConfiguration

@NotNull
public org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
Description copied from interface: ConvertibleFromConfig
Generate a HierarchicalConfiguration from the current state of the object

Specified by:
toConfiguration in interface ConvertibleFromConfig
Overrides:
toConfiguration in class AbstractRepository
Returns:
Always returns an HierarchicalConfiguration. Never null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)

prepareConfigObject

public void prepareConfigObject(@NotNull
                                BuildConfiguration buildConfiguration)
Description copied from interface: BuildConfigurationAwarePlugin
Do any preprocessing work before validation occurs. For repository, builder and web repository plugins this will only be called if the plugin is select by the user.

Specified by:
prepareConfigObject in interface BuildConfigurationAwarePlugin
Parameters:
buildConfiguration - - @NotNull

isPerforceExecutableSet

public boolean isPerforceExecutableSet()
For configuration screens

Returns:
true if perforce capability is set and exists

isQuietPeriodEnabled

public boolean isQuietPeriodEnabled()
Description copied from interface: QuietPeriodAwareRepository
Returns true if we were to enable the quiet period

Specified by:
isQuietPeriodEnabled in interface QuietPeriodAwareRepository
Returns:

setQuietPeriodEnabled

public void setQuietPeriodEnabled(boolean quietPeriodEnabled)
Specified by:
setQuietPeriodEnabled in interface MutableQuietPeriodAwareRepository

getQuietPeriod

public int getQuietPeriod()
Description copied from interface: QuietPeriodAwareRepository
Returns the number of seconds to wait between each retry

Specified by:
getQuietPeriod in interface QuietPeriodAwareRepository
Returns:
seconds between retries

setQuietPeriod

public void setQuietPeriod(int quietPeriod)
Specified by:
setQuietPeriod in interface MutableQuietPeriodAwareRepository

getMaxRetries

public int getMaxRetries()
Description copied from interface: QuietPeriodAwareRepository
Returns the maximum number of times to collect changes

Specified by:
getMaxRetries in interface QuietPeriodAwareRepository
Returns:

setMaxRetries

public void setMaxRetries(int maxRetries)
Specified by:
setMaxRetries in interface MutableQuietPeriodAwareRepository

setPerforceManager

public void setPerforceManager(PerforceManager perforceManager)

setCapabilityContext

public void setCapabilityContext(CapabilityContext capabilityContext)

setPlanManager

public void setPlanManager(PlanManager planManager)


Copyright © 2010 Atlassian. All Rights Reserved.