com.atlassian.bamboo.build
Class HibernateBuildManager

java.lang.Object
  extended by com.atlassian.bamboo.build.HibernateBuildManager
All Implemented Interfaces:
BuildManager

public class HibernateBuildManager
extends java.lang.Object
implements BuildManager


Constructor Summary
HibernateBuildManager()
           
 
Method Summary
 void addBuildResults(Build build, BuildResults buildResults)
           
 void createBuild(Build build, BuildConfiguration buildConfiguration, HibernateAcl acl)
          Save a new build object with the passed buildConfiguration
 Project createProject(java.lang.String key, java.lang.String name)
           
 void deleteBuild(java.lang.String buildKey)
          Removes the build from system
 void deleteProject(Project project)
           
 boolean exists(java.lang.String key)
          Returns true if build exists with the provided key (eg.
 java.util.Set<Build> filterFavouritedBuilds(java.util.Collection<Build> builds, com.atlassian.user.User user)
          Return a set of Builds that are a subset of the given Builds collection that are favourited by the User
 java.util.Collection<Build> getAllBuilds()
          Returns a collection of all Build objects
 java.util.Collection<Build> getAllBuildsForClone()
           
 java.util.Collection<Build> getAllBuildsForEdit()
           
 java.util.Collection<Build> getAllBuildsForRead()
           
 java.util.Set<Project> getAllProjects()
           
 Build getBuildById(long id)
          Returns the build given the id
 Build getBuildByKey(java.lang.String key)
          Returns the build given a key
 Build getBuildByProjectAndName(java.lang.String projectKey, java.lang.String buildName)
           
 BuildResults getBuildResults(Build build, java.lang.Integer buildNumber)
          Return BuildResults for the given Build and buildNumber
 BuildResults getBuildResults(java.lang.String planKey, java.lang.Integer buildNumber)
          Return BuildResults for the given planKey and buildNumber
 java.util.Collection<Build> getBuildsByProjectForRead(Project project)
          This is the manager equivalent of a project.getBuilds.
 java.util.Collection<Build> getBuildsForDeletion()
           
 java.util.Collection<Build> getFavouriteBuildsByProjectForRead(Project project, com.atlassian.user.User user)
          Return a set of favourited builds Builds that belong to Project and @{link User}
 java.util.Collection<Build> getFavouriteBuildsForRead(com.atlassian.user.User user)
           
 int getPlanCount()
          How many plans currently exist
 java.util.Map<Project,java.util.Collection<Build>> getProjectBuilds(boolean includeEmptyProjects)
          Return a map of Build collections which belong to a Project
 Project getProjectById(long id)
           
 Project getProjectByKey(java.lang.String key)
           
 Project getProjectByName(java.lang.String projectName)
           
 boolean isAllowBuilding(java.lang.String planKey)
          Checks if a particular build is allowed to be built.
 boolean isBuildingSuspended()
          Checks whether or not bamboo is currently suspended from building due to license reasons.
 boolean isExistingBuildKey(java.lang.String givenKey)
          Is there an existing build with the same key?
 boolean isExistingBuildKey(java.lang.String projectKey, java.lang.String buildKey)
          Returns true if the build key already exists within the given project key
 boolean isExistingBuildName(java.lang.String buildName)
           
 boolean isExistingBuildName(java.lang.String projectKey, java.lang.String buildName)
          Returns true if the build name already exists within the given project key
 boolean isExistingProjectKey(java.lang.String projectKey)
           
 boolean isExistingProjectName(java.lang.String projectName)
           
 boolean isPlanCreationAllowed()
          Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!
 boolean recheckBuildingSuspended()
          Force the build manager to double check if building should be suspended or not.
 java.util.Collection<Build> retreiveAllBuilds()
           
 java.lang.String revertVcsRevisionKey(java.lang.String buildKey, java.lang.String revisionForBuild, java.lang.String previousRevision)
          Revert lastVcsRevisionKey in build based on previous build revision contained in BuildContext.
 void saveBuild(Build build)
          Persists a build
 void saveProject(Project project)
           
 void saveSuspendBuild(java.lang.String buildKey, boolean setSuspendBuild)
          Persists a build for enable/disable
 void setAclService(org.acegisecurity.acls.MutableAclService aclService)
           
 void setAdminErrorHandler(AdminErrorHandler adminErrorHandler)
           
 void setBambooLicenseManager(BambooLicenseManager bambooLicenseManager)
           
 void setBuildDao(BuildDao buildDao)
           
 void setBuildDefinitionConverter(BuildDefinitionConverter buildDefinitionConverter)
           
 void setBuildDefinitionManager(BuildDefinitionManager buildDefinitionManager)
           
 void setBuildResultsSummaryManager(BuildResultsSummaryManager buildResultsSummaryManager)
           
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setLabelManager(LabelManager labelManager)
           
 void setPlanDao(PlanDao planDao)
           
 void setPlanDependencyManager(PlanDependencyManager planDependencyManager)
           
 void setPlanParticleManager(PlanParticleManager planParticleManager)
           
 void setPlanScheduler(PlanScheduler planScheduler)
           
 void setProjectManager(ProjectManager projectManager)
           
 void updateNames(java.lang.String projectName, java.lang.String buildName, Build build)
          Updates project and plan names.
 void updateNamesAndDescription(java.lang.String projectName, java.lang.String buildName, java.lang.String description, Build build)
          Updates project and plan names and plan description.
 java.lang.String updateVcsRevisionKey(BuildContext buildContext)
          Updates lastVcsRevisionKey in build based on revision contained in BuildContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateBuildManager

public HibernateBuildManager()
Method Detail

getBuildByKey

@Nullable
public Build getBuildByKey(java.lang.String key)
Description copied from interface: BuildManager
Returns the build given a key

Specified by:
getBuildByKey in interface BuildManager
Parameters:
key - - full key of the build. eg. BAM-MAIN null safe
Returns:
A Build if the key matches. Otherwise null

getBuildById

public Build getBuildById(long id)
Description copied from interface: BuildManager
Returns the build given the id

Specified by:
getBuildById in interface BuildManager
Returns:
A Build. null if not found.

getAllBuilds

public java.util.Collection<Build> getAllBuilds()
Description copied from interface: BuildManager
Returns a collection of all Build objects

Specified by:
getAllBuilds in interface BuildManager
Returns:
all builds in the system, Collections.emptyList() if none exists

getAllBuildsForRead

public java.util.Collection<Build> getAllBuildsForRead()
Specified by:
getAllBuildsForRead in interface BuildManager

retreiveAllBuilds

public java.util.Collection<Build> retreiveAllBuilds()
Specified by:
retreiveAllBuilds in interface BuildManager

getAllBuildsForEdit

public java.util.Collection<Build> getAllBuildsForEdit()
Specified by:
getAllBuildsForEdit in interface BuildManager

getAllBuildsForClone

public java.util.Collection<Build> getAllBuildsForClone()
Specified by:
getAllBuildsForClone in interface BuildManager

getBuildsForDeletion

public java.util.Collection<Build> getBuildsForDeletion()
Specified by:
getBuildsForDeletion in interface BuildManager

getBuildsByProjectForRead

public java.util.Collection<Build> getBuildsByProjectForRead(Project project)
Description copied from interface: BuildManager
This is the manager equivalent of a project.getBuilds. However, this is permission filtered.

Specified by:
getBuildsByProjectForRead in interface BuildManager
Returns:

getFavouriteBuildsForRead

public java.util.Collection<Build> getFavouriteBuildsForRead(com.atlassian.user.User user)
Specified by:
getFavouriteBuildsForRead in interface BuildManager

filterFavouritedBuilds

public java.util.Set<Build> filterFavouritedBuilds(@NotNull
                                                   java.util.Collection<Build> builds,
                                                   @NotNull
                                                   com.atlassian.user.User user)
Description copied from interface: BuildManager
Return a set of Builds that are a subset of the given Builds collection that are favourited by the User

Specified by:
filterFavouritedBuilds in interface BuildManager
Returns:
favoritedBuilds

getFavouriteBuildsByProjectForRead

public java.util.Collection<Build> getFavouriteBuildsByProjectForRead(Project project,
                                                                      com.atlassian.user.User user)
Description copied from interface: BuildManager
Return a set of favourited builds Builds that belong to Project and @{link User}

Specified by:
getFavouriteBuildsByProjectForRead in interface BuildManager
Returns:
favoritedBuilds

isExistingBuildName

public boolean isExistingBuildName(java.lang.String buildName)

isExistingBuildKey

public boolean isExistingBuildKey(java.lang.String givenKey)
Is there an existing build with the same key?

Parameters:
givenKey -
Returns:
true if another build exists with the givenKey

isExistingBuildName

public boolean isExistingBuildName(java.lang.String projectKey,
                                   java.lang.String buildName)
Description copied from interface: BuildManager
Returns true if the build name already exists within the given project key

Specified by:
isExistingBuildName in interface BuildManager
Parameters:
projectKey - (doesn't have to exist for this check)
buildName - to check
Returns:
true if build name already exists in that project

isExistingBuildKey

public boolean isExistingBuildKey(java.lang.String projectKey,
                                  java.lang.String buildKey)
Description copied from interface: BuildManager
Returns true if the build key already exists within the given project key

Specified by:
isExistingBuildKey in interface BuildManager
Parameters:
projectKey - (doesn't have to exist for this check)
buildKey - to check
Returns:
true if build name already exists in that project

exists

public boolean exists(java.lang.String key)
Description copied from interface: BuildManager
Returns true if build exists with the provided key (eg. BAM-BOO)

Specified by:
exists in interface BuildManager
Returns:
exists

getPlanCount

public int getPlanCount()
How many plans currently exist

Specified by:
getPlanCount in interface BuildManager
Returns:
number of plans found in the database

isPlanCreationAllowed

public boolean isPlanCreationAllowed()
Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!

Specified by:
isPlanCreationAllowed in interface BuildManager
Returns:
true if a plan can be created otherwise false;

createProject

@NotNull
public Project createProject(@NotNull
                                     java.lang.String key,
                                     @NotNull
                                     java.lang.String name)

getAllProjects

public java.util.Set<Project> getAllProjects()

getProjectByKey

public Project getProjectByKey(@NotNull
                               java.lang.String key)

getProjectById

public Project getProjectById(long id)

getProjectByName

public Project getProjectByName(@NotNull
                                java.lang.String projectName)

isExistingProjectKey

public boolean isExistingProjectKey(@NotNull
                                    java.lang.String projectKey)

isExistingProjectName

public boolean isExistingProjectName(@NotNull
                                     java.lang.String projectName)

saveProject

public void saveProject(@NotNull
                        Project project)

deleteProject

public void deleteProject(@NotNull
                          Project project)

createBuild

public void createBuild(Build build,
                        BuildConfiguration buildConfiguration,
                        HibernateAcl acl)
                 throws PlanCreationDeniedException
Description copied from interface: BuildManager
Save a new build object with the passed buildConfiguration

Specified by:
createBuild in interface BuildManager
Parameters:
build - @NotNull
buildConfiguration - @NotNull
Throws:
PlanCreationDeniedException - if the plan can not be created due to licensing.

saveBuild

public void saveBuild(Build build)
Description copied from interface: BuildManager
Persists a build

Specified by:
saveBuild in interface BuildManager
Parameters:
build - cannot be null

saveSuspendBuild

public void saveSuspendBuild(java.lang.String buildKey,
                             boolean setSuspendBuild)
Description copied from interface: BuildManager
Persists a build for enable/disable

Specified by:
saveSuspendBuild in interface BuildManager
Parameters:
buildKey - of the build to be suspended/resumed
setSuspendBuild - true if the build should be suspended, false if resumed

getBuildByProjectAndName

public Build getBuildByProjectAndName(java.lang.String projectKey,
                                      java.lang.String buildName)
Specified by:
getBuildByProjectAndName in interface BuildManager

updateNames

public void updateNames(java.lang.String projectName,
                        java.lang.String buildName,
                        Build build)
Description copied from interface: BuildManager
Updates project and plan names.

Specified by:
updateNames in interface BuildManager
Parameters:
projectName - new name of the project
buildName - new name of the plan
build - build object to be modified and stored.

updateNamesAndDescription

public void updateNamesAndDescription(java.lang.String projectName,
                                      java.lang.String buildName,
                                      @Nullable
                                      java.lang.String description,
                                      Build build)
Updates project and plan names and plan description.

Specified by:
updateNamesAndDescription in interface BuildManager
Parameters:
projectName - new name of the project
buildName - new name of the plan
description - new plan description
build - build object to be modified and stored.

isAllowBuilding

public boolean isAllowBuilding(@NotNull
                               java.lang.String planKey)
Description copied from interface: BuildManager
Checks if a particular build is allowed to be built. It checks if it exists, not suspened, and that there is no global flag that has stopped building

Specified by:
isAllowBuilding in interface BuildManager
Returns:
true if the planKey is a valid build that is allowed to be built

deleteBuild

public void deleteBuild(@NotNull
                        java.lang.String buildKey)
Description copied from interface: BuildManager
Removes the build from system

Specified by:
deleteBuild in interface BuildManager
Parameters:
buildKey - String name for build

getProjectBuilds

@NotNull
public java.util.Map<Project,java.util.Collection<Build>> getProjectBuilds(boolean includeEmptyProjects)
Description copied from interface: BuildManager
Return a map of Build collections which belong to a Project

Specified by:
getProjectBuilds in interface BuildManager
Parameters:
includeEmptyProjects - set to true if you want all of the projects regardless if they have any builds
Returns:
build collection map

updateVcsRevisionKey

public java.lang.String updateVcsRevisionKey(@NotNull
                                             BuildContext buildContext)
Description copied from interface: BuildManager
Updates lastVcsRevisionKey in build based on revision contained in BuildContext

Specified by:
updateVcsRevisionKey in interface BuildManager
Returns:
updated lastVcsRevisionKey

revertVcsRevisionKey

public java.lang.String revertVcsRevisionKey(@NotNull
                                             java.lang.String buildKey,
                                             @NotNull
                                             java.lang.String revisionForBuild,
                                             @Nullable
                                             java.lang.String previousRevision)
Description copied from interface: BuildManager
Revert lastVcsRevisionKey in build based on previous build revision contained in BuildContext. The only reason to revert revision is for the situation, when build is abandoned and no subsequent build has been started. If subsequent build has been already started, there is no effect of reverting vcsRevisionKey

Specified by:
revertVcsRevisionKey in interface BuildManager
Returns:

addBuildResults

public void addBuildResults(Build build,
                            BuildResults buildResults)
Specified by:
addBuildResults in interface BuildManager

getBuildResults

@Nullable
public BuildResults getBuildResults(Build build,
                                             java.lang.Integer buildNumber)
Description copied from interface: BuildManager
Return BuildResults for the given Build and buildNumber

Specified by:
getBuildResults in interface BuildManager
Returns:
buildResults

getBuildResults

public BuildResults getBuildResults(java.lang.String planKey,
                                    java.lang.Integer buildNumber)
Description copied from interface: BuildManager
Return BuildResults for the given planKey and buildNumber

Specified by:
getBuildResults in interface BuildManager
Returns:
buildResults

isBuildingSuspended

public boolean isBuildingSuspended()
Description copied from interface: BuildManager
Checks whether or not bamboo is currently suspended from building due to license reasons. This value is cached.

Specified by:
isBuildingSuspended in interface BuildManager
Returns:
true if building is suspended.

recheckBuildingSuspended

public boolean recheckBuildingSuspended()
Description copied from interface: BuildManager
Force the build manager to double check if building should be suspended or not. USE SPARINGLY!

Specified by:
recheckBuildingSuspended in interface BuildManager
Returns:
the new value

setBuildDefinitionConverter

public void setBuildDefinitionConverter(BuildDefinitionConverter buildDefinitionConverter)

setBuildDao

public void setBuildDao(BuildDao buildDao)

setProjectManager

public void setProjectManager(ProjectManager projectManager)

setBuildDefinitionManager

public void setBuildDefinitionManager(BuildDefinitionManager buildDefinitionManager)

setBuildResultsSummaryManager

public void setBuildResultsSummaryManager(BuildResultsSummaryManager buildResultsSummaryManager)

setAclService

public void setAclService(org.acegisecurity.acls.MutableAclService aclService)

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)

setLabelManager

public void setLabelManager(LabelManager labelManager)

setBambooLicenseManager

public void setBambooLicenseManager(BambooLicenseManager bambooLicenseManager)

setAdminErrorHandler

public void setAdminErrorHandler(AdminErrorHandler adminErrorHandler)

setPlanDependencyManager

public void setPlanDependencyManager(PlanDependencyManager planDependencyManager)

setPlanParticleManager

public void setPlanParticleManager(PlanParticleManager planParticleManager)

setPlanScheduler

public void setPlanScheduler(PlanScheduler planScheduler)

setPlanDao

public void setPlanDao(PlanDao planDao)


Copyright © 2010 Atlassian. All Rights Reserved.