com.atlassian.bamboo.repository.perforce
Class PerforceRepository

java.lang.Object
  extended by com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
      extended by com.atlassian.bamboo.v2.build.BaseConfigurablePlugin
          extended by com.atlassian.bamboo.repository.AbstractRepository
              extended by com.atlassian.bamboo.repository.AbstractStandaloneRepository
                  extended by com.atlassian.bamboo.repository.perforce.PerforceRepository
All Implemented Interfaces:
ConvertibleFromConfig, InitablePluginModule, AdvancedConfigurationAwareRepository, FilterChangesetAwareRepository, IncludeExcludeAwareRepository, MavenPomAccessorCapableRepository, OnceOffCapableRepository, QuietPeriodAwareRepository, Repository, StandaloneRepository, DescriptionProvider, NameProvider, BambooPluginModule, BuildConfigurationAwarePlugin, ConfigurablePlugin, RenderableBuildConfiguration, LegacyRepository, RepositoryV2, RequirementsAwareRepository, java.io.Serializable

public class PerforceRepository
extends AbstractStandaloneRepository
implements LegacyRepository, MavenPomAccessorCapableRepository, RequirementsAwareRepository

This class provides a Perforce implementation 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_USECLIENTMAPPING
           
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
administrationConfigurationManager, BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, customVariableContext, featureManager, REPO_PREFIX, repositoryModuleDescriptor, templateRenderer, textProvider
 
Fields inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
moduleDescriptor
 
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
 
Fields inherited from interface com.atlassian.bamboo.repository.FilterChangesetAwareRepository
CHANGESET_FILTER_PATTERN_REGEX, MAVEN_RELEASE_PLUGIN_EXCLUSION_PATTERN
 
Constructor Summary
PerforceRepository()
           
 
Method Summary
 void addDefaultValues(BuildConfiguration buildConfiguration)
          Extension point for adding default values to the form for RenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
 BuildRepositoryChanges collectChangesForRevision(PlanKey planKey, java.lang.String targetRevision)
          Collects the changes for the targetRevision.
 BuildRepositoryChanges 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)
           
 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()
           
 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?
 java.util.Set<Requirement> getRequirements()
           
 java.io.File getSourceCodeDirectory(PlanKey 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 isRepositoryDifferent(Repository repository)
          Checks if the current repo is the same as the given repository
 boolean isUseClientMapping()
           
 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
 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 setEncryptionService(EncryptionService encryptionService)
           
 void setManageWorkspace(boolean manageWorkspace)
           
 void setMavenPomCheckoutPomRelativePath(java.lang.String mavenPomCheckoutPomRelativePath)
           
 void setPerforceManager(PerforceManager perforceManager)
           
 void setPort(java.lang.String port)
          Define the perforce server and port we're going to connect to
 void setUseClientMapping(boolean useClientMapping)
           
 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.AbstractStandaloneRepository
getAdvancedEditHtml, getAdvancedViewHtml, getEditHtml, getViewHtml
 
Methods inherited from class com.atlassian.bamboo.repository.AbstractRepository
checkConnection, customizeBuildRequirements, getAdvancedEditHtml, getAdvancedViewHtml, getBranchIntegrationEditHtml, getChangesetFilterPatternRegex, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getLocationIdentifier, getMavenPomCheckoutAccessEditHtml, getMaxCommitsToReturn, getMaxRetries, getMinimalEditHtml, getQuietPeriod, getShortKey, getSystemWideExclusionPatterns, getViewHtml, getWorkingDirectory, init, isAdvancedOptionEnabled, isQuietPeriodEnabled, isWorkspaceEmpty, removeBuildRequirements, setAdministrationConfigurationManager, setBuildDirectoryManager, setBuildLoggerManager, setChangesetFilterPatternRegex, setCustomVariableContext, setFeatureManager, setFilterFilePatternOption, setFilterFilePatternRegex, setTemplateRenderer, setTextProvider, substituteString, toMergeCapableRepository
 
Methods inherited from class com.atlassian.bamboo.v2.build.BaseConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
Methods inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
isConfigurationMissing, populateContextForEdit, populateContextForView
 
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
 
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
Methods inherited from interface com.atlassian.bamboo.v2.build.RenderableBuildConfiguration
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_USECLIENTMAPPING

public static final java.lang.String P4_USECLIENTMAPPING
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

collectChangesForRevision

@NotNull
public BuildRepositoryChanges collectChangesForRevision(@NotNull
                                                                PlanKey planKey,
                                                                @Nullable
                                                                java.lang.String targetRevision)
                                                 throws RepositoryException
Description copied from interface: OnceOffCapableRepository
Collects the changes for the targetRevision. This method is called only on server side (never on agent).

Specified by:
collectChangesForRevision in interface OnceOffCapableRepository
Overrides:
collectChangesForRevision in class AbstractRepository
Returns:
A build changes object with the appropriate build changes (that is - with the single commit data relevant for targetRevision)
Throws:
RepositoryException - if something goes wrong

collectChangesSinceLastBuild

@NotNull
public BuildRepositoryChanges 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
                                                   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 LegacyRepository
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 RenderableBuildConfiguration.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

getRequirements

public java.util.Set<Requirement> getRequirements()
Specified by:
getRequirements in interface RequirementsAwareRepository

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)

isUseClientMapping

public boolean isUseClientMapping()

setUseClientMapping

public void setUseClientMapping(boolean useClientMapping)

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
                                                   PlanKey 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

@NotNull
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

addDefaultValues

public void addDefaultValues(@NotNull
                             BuildConfiguration buildConfiguration)
Description copied from interface: BuildConfigurationAwarePlugin
Extension point for adding default values to the form for RenderableBuildConfiguration.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
Overrides:
prepareConfigObject in class BaseBuildConfigurationAwarePlugin
Parameters:
buildConfiguration - - @NotNull

isPerforceExecutableSet

public boolean isPerforceExecutableSet()
For configuration screens

Returns:
true if perforce capability is set and exists

setPerforceManager

public void setPerforceManager(PerforceManager perforceManager)

setCapabilityContext

public void setCapabilityContext(CapabilityContext capabilityContext)

setEncryptionService

public void setEncryptionService(EncryptionService encryptionService)


Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.