jetbrains.buildServer.serverSide
Interface ProjectManager


public interface ProjectManager

Author:
Pavel.Sher Date: 05.05.2006

Field Summary
static java.lang.String PROJECT_ID_NAME
          How we call the external project identifier in the UI.
 
Method Summary
 SProject copyProject(SProject originalProject, SProject targetParent, CopyOptions options)
          Copies the given project with all subrpojects into another project.
 SProject createProject(SProject originalProject, java.lang.String newProjectName, CopyOptions options)
          Deprecated. Use copyProject(jetbrains.buildServer.serverSide.SProject, jetbrains.buildServer.serverSide.SProject, jetbrains.buildServer.serverSide.CopyOptions) instead.
 SProject createProject(java.lang.String projectName)
          Creates new project with specified name (name is case insensitive) and automatically generated external id.
 SBuildType findBuildTypeByExternalId(java.lang.String externalId)
          Searches for a build configuration with specified external id.
 SBuildType findBuildTypeById(java.lang.String internalId)
          Searches for a build configuration with the specified internal id.
 java.util.Collection<SBuildType> findBuildTypes(java.util.Collection<java.lang.String> buildTypeIds)
          Returns collection of build types corresponding to the specified collection of build type ids.
 java.util.Collection<SBuildType> findBuildTypesByExternalIds(java.util.Collection<java.lang.String> externalIds)
          Returns collection of build types corresponding to the specified external ids.
 BuildTypeTemplate findBuildTypeTemplateByExternalId(java.lang.String externalId)
          Searches for build type template by given external id
 BuildTypeTemplate findBuildTypeTemplateById(java.lang.String id)
          Searches for build type template by given internal id
 SProject findProjectByExternalId(java.lang.String externalId)
          Looks for a project with the given external id.
 SProject findProjectById(java.lang.String projectId)
          Looks for a project with the given internal id.
 SProject findProjectByName(java.lang.String projectName)
          Deprecated. since 8.0, use SProject.findProjectByName(String)
 java.lang.String findProjectExternalId(java.lang.String buildTypeId)
          Searches for a project which contains a build type with the specified build type id.
 java.lang.String findProjectId(java.lang.String buildTypeId)
          Searches for a project which contains a build type with the specified build type id.
 java.lang.String findProjectIdForTemplate(java.lang.String buildTypeTemplateId)
          Searches for a project which contains a build type template with the specified id.
 java.util.Collection<SProject> findProjects(java.util.Collection<java.lang.String> projectsIds)
          Returns collection of projects corresponding to the specified internal ids.
 java.util.Collection<SProject> findProjectsByExternalIds(java.util.Collection<java.lang.String> projectsIds)
          Returns collection of projects corresponding to the specified external ids.
 SVcsRoot findVcsRootByExternalId(java.lang.String externalId)
          Finds VCS root by external id
 SVcsRoot findVcsRootById(long id)
          Finds VCS root by id
 java.util.Collection<SVcsRoot> findVcsRootsByIds(java.util.Collection<java.lang.Long> ids)
          Finds all VCS roots having the specified ids.
 java.util.List<SBuildType> getActiveBuildTypes()
          Returns the list of build types that belong to non-archived projects only.
 java.util.List<SProject> getActiveProjects()
          Returns the list of active (non-archived) projects.
 java.util.List<SBuildType> getAllBuildTypes()
          Returns the list of all build configurations, including ones from archived projects.
 java.util.List<SBuildType> getAllBuildTypes(User user)
          Returns list of all build configurations sorted by project according to the order specified by user and then by build configuration name.
 java.util.List<BuildTypeTemplate> getAllTemplates()
          Returns list of all of the templates, including ones from archived projects.
 java.util.List<SVcsRoot> getAllVcsRoots()
           
 java.util.List<SBuildType> getArchivedBuildTypes()
          Returns list of build configurations from archived projects, sorted by project and build configuration name.
 java.util.List<SProject> getArchivedProjects()
          Returns the list of archived projects.
 java.util.List<SBuildType> getBuildTypesDependingOn(SBuildType type)
          Deprecated. use SBuildType.getArtifactsReferences()
 SProject getCommonParentProject(java.util.Collection<SProject> projects)
          Returns nearest common parent project for all projects in provided collection.
 java.util.SortedMap<SProject,java.util.List<SBuildType>> getFilteredBuildTypes(User user, BuildTypeFilter filter)
          Returns sorted map of build configurations per project.
 int getNumberOfBuildTypes()
          Returns the total number of build configurations including ones from archived projects.
 int getNumberOfProjects()
          Returns total number of projects currently loaded in the server.
 java.util.List<java.lang.String> getProjectIds()
          A helper method which returns the list of all projectID configured on the server.
 java.util.List<SProject> getProjects()
          Returns the list of all projects, including archived.
 java.util.List<SProject> getProjects(User user)
          Returns list of all projects sorted according to the order specified by user
 SProject getRootProject()
          Returns the root project.
 boolean isProjectExists(java.lang.String projectId)
          Returns true if project with the specified id exists.
 void removeProject(java.lang.String internalProjectId)
          Removes project from the current list of projects.
 

Field Detail

PROJECT_ID_NAME

static final java.lang.String PROJECT_ID_NAME
How we call the external project identifier in the UI.

Since:
8.0
See Also:
Constant Field Values
Method Detail

getRootProject

@NotNull
SProject getRootProject()
Returns the root project.

Returns:
root project.
Since:
8.0

getProjects

@NotNull
java.util.List<SProject> getProjects()
Returns the list of all projects, including archived. The order: visible projects come first (sorted by name), then archived projects (sorted by name).

Returns:
list of all projects

getActiveProjects

@NotNull
java.util.List<SProject> getActiveProjects()
Returns the list of active (non-archived) projects. List is sorted by project name.

Returns:
list of non-archived projects

getArchivedProjects

@NotNull
java.util.List<SProject> getArchivedProjects()
Returns the list of archived projects. List is sorted by project name.

Returns:
list of archived projects

getNumberOfProjects

int getNumberOfProjects()
Returns total number of projects currently loaded in the server. The value always equals to getProjects().size().

Returns:
total number of projects

getProjects

@NotNull
java.util.List<SProject> getProjects(@NotNull
                                             User user)
Returns list of all projects sorted according to the order specified by user

Parameters:
user - the user
Returns:
see above

createProject

@NotNull
SProject createProject(@NotNull
                               java.lang.String projectName)
                       throws InvalidIdentifierException,
                              InvalidNameException,
                              DuplicateProjectNameException
Creates new project with specified name (name is case insensitive) and automatically generated external id. This id is generated based on the given name (and ensuring that the new id is unique). In order to create a project with specified name and external id, use #createProject(String, String, String) instead.

Parameters:
projectName - name of the new project
Returns:
newly created project
Throws:
DuplicateProjectNameException - if project with specified name already exists
InvalidIdentifierException
InvalidNameException
See Also:
#createProject(String, String, String)

copyProject

@NotNull
SProject copyProject(@NotNull
                             SProject originalProject,
                             @NotNull
                             SProject targetParent,
                             @NotNull
                             CopyOptions options)
                     throws MaxNumberOfBuildTypesReachedException,
                            NotAllIdentifiersMappedException,
                            InvalidNameException,
                            DuplicateExternalIdException
Copies the given project with all subrpojects into another project.

Also persists projects when they're copied.

Parameters:
originalProject - the project to copy.
targetParent - the parent of the newly created project
options - copy option.
Returns:
the copy of the project
Throws:
MaxNumberOfBuildTypesReachedException
NotAllIdentifiersMappedException
InvalidNameException
DuplicateExternalIdException
Since:
8.0
See Also:
CopyOptions

createProject

@NotNull
SProject createProject(@NotNull
                               SProject originalProject,
                               @NotNull
                               java.lang.String newProjectName,
                               @NotNull
                               CopyOptions options)
                       throws InvalidIdentifierException,
                              InvalidNameException,
                              MaxNumberOfBuildTypesReachedException
Deprecated. Use copyProject(jetbrains.buildServer.serverSide.SProject, jetbrains.buildServer.serverSide.SProject, jetbrains.buildServer.serverSide.CopyOptions) instead.

Creates new project by copying all settings from original project. Warning - this function doesn't copy all nested subprojects. Use copyProject(SProject, SProject, CopyOptions) instead.

Parameters:
originalProject - original project
newProjectName - name for new project. If there exists project with same name then " (1)", " (2)", ... suffix will be added to the specified name.
options - additional options
Returns:
newly created project
Throws:
MaxNumberOfBuildTypesReachedException - if original project build configurations cannot be copied because maximum number of build configurations is reached or will be exceeded if project will be copied
InvalidIdentifierException
InvalidNameException

findProjectByName

@Deprecated
@Nullable
SProject findProjectByName(@NotNull
                                               java.lang.String projectName)
Deprecated. since 8.0, use SProject.findProjectByName(String)

Searches for a project with the specified name (case insensitive) among direct subprojects of the root project. The search includes archived projects.

Parameters:
projectName - name of the project to search for
Returns:
a project or null if such a project does not exist

findProjectById

@Nullable
SProject findProjectById(@Nullable
                                  java.lang.String projectId)
Looks for a project with the given internal id.

The search includes archived projects.

Parameters:
internalId - the internal id, case insensitive.
Returns:
the found project, or null if not found.
Throws:
AccessDeniedException - no access rights for the current user
See Also:
findProjectByExternalId(String)

findProjectByExternalId

@Nullable
SProject findProjectByExternalId(@Nullable
                                          java.lang.String externalId)
Looks for a project with the given external id.

The search includes archived projects.

Parameters:
projectId - the external id of the project to search for, case insensitive.
Returns:
a project or null if project with such id does not exist
Throws:
AccessDeniedException - no access rights for the current user
Since:
8.0.
See Also:
findProjectById(String)

findProjects

@NotNull
java.util.Collection<SProject> findProjects(@NotNull
                                                    java.util.Collection<java.lang.String> projectsIds)
Returns collection of projects corresponding to the specified internal ids.

Parameters:
projectsIds - collection of internal identifiers, case sensitive.
Returns:

findProjectsByExternalIds

@NotNull
java.util.Collection<SProject> findProjectsByExternalIds(@NotNull
                                                                 java.util.Collection<java.lang.String> projectsIds)
Returns collection of projects corresponding to the specified external ids.

Parameters:
projectsIds - collection of external identifiers, case insensitive.
Returns:
see above
Since:
8.0

findBuildTypeById

@Nullable
SBuildType findBuildTypeById(@Nullable
                                      java.lang.String internalId)
                             throws AccessDeniedException
Searches for a build configuration with the specified internal id.

Parameters:
internalId - the internal id of the build configuration to search for.
Returns:
a build configuration or null if build configuration with given internal id does not exist.
Throws:
AccessDeniedException - if current authority holder doesn't have access to build configuration with given internal id.
Since:
6.5 also finds personal build configurations

findBuildTypeByExternalId

@Nullable
SBuildType findBuildTypeByExternalId(@Nullable
                                              java.lang.String externalId)
                                     throws AccessDeniedException
Searches for a build configuration with specified external id.

Parameters:
externalId - the external id of the build configuration to search for.
Returns:
a build configuration or null if build configuration with given external id does not exist.
Throws:
AccessDeniedException - if current authority holder doesn't have access to build configuration with given external id.
Since:
8.0

findBuildTypes

@NotNull
java.util.Collection<SBuildType> findBuildTypes(@NotNull
                                                        java.util.Collection<java.lang.String> buildTypeIds)
Returns collection of build types corresponding to the specified collection of build type ids. The returned collection will contain existing build types only.

Parameters:
buildTypeIds - collection of build type ids
Returns:
collection of existing build types
Since:
6.5 also returns personal build configurations

findBuildTypesByExternalIds

@NotNull
java.util.Collection<SBuildType> findBuildTypesByExternalIds(@NotNull
                                                                     java.util.Collection<java.lang.String> externalIds)
Returns collection of build types corresponding to the specified external ids.

Parameters:
externalIds - collection of external identifiers, case insensitive.
Returns:
see above
Since:
8.0

getAllBuildTypes

@NotNull
java.util.List<SBuildType> getAllBuildTypes()
Returns the list of all build configurations, including ones from archived projects. The order: build configurations from visible projects come first, then from archived projects.

Returns:
list of all build configurations

getAllTemplates

@NotNull
java.util.List<BuildTypeTemplate> getAllTemplates()
Returns list of all of the templates, including ones from archived projects. Ordering is the same as for build configurations.

Returns:
see above
Since:
5.0

getActiveBuildTypes

@NotNull
java.util.List<SBuildType> getActiveBuildTypes()
Returns the list of build types that belong to non-archived projects only.

Returns:
list of non-archived build types

getArchivedBuildTypes

@NotNull
java.util.List<SBuildType> getArchivedBuildTypes()
Returns list of build configurations from archived projects, sorted by project and build configuration name.

Returns:
list of archived build configurations.

getNumberOfBuildTypes

int getNumberOfBuildTypes()
Returns the total number of build configurations including ones from archived projects.

Returns:
number of build configurations

getAllBuildTypes

@NotNull
java.util.List<SBuildType> getAllBuildTypes(@NotNull
                                                    User user)
Returns list of all build configurations sorted by project according to the order specified by user and then by build configuration name.

Parameters:
user - user whose settings to use to sort build types
Returns:
list of all build configurations.

removeProject

void removeProject(@NotNull
                   java.lang.String internalProjectId)
                   throws ProjectRemoveFailedException
Removes project from the current list of projects. Project directory will be placed into the '_trash' folder.

Parameters:
internalProjectId - internal id of project to remove
Throws:
ProjectRemoveFailedException - if remove failed

getProjectIds

java.util.List<java.lang.String> getProjectIds()
A helper method which returns the list of all projectID configured on the server.

Returns:
the list of all projectID configured on the server.

getFilteredBuildTypes

java.util.SortedMap<SProject,java.util.List<SBuildType>> getFilteredBuildTypes(@NotNull
                                                                               User user,
                                                                               @Nullable
                                                                               BuildTypeFilter filter)
Returns sorted map of build configurations per project. Build types can be filtered by specified BuildTypeFilter. Projects in the map are sorted according to the projects order specified by user.

Parameters:
user - the user
filter - filter of build configurations, can be null
Returns:
sorted map of build types per project

findProjectId

@Nullable
java.lang.String findProjectId(@NotNull
                                        java.lang.String buildTypeId)
Searches for a project which contains a build type with the specified build type id. Returns internal id of this project or null if such project does not exist. The search includes archived projects.

Parameters:
buildTypeId - id of a build type
Returns:
project internal id of a project containing specified build type

findProjectExternalId

@Nullable
java.lang.String findProjectExternalId(@NotNull
                                                java.lang.String buildTypeId)
Searches for a project which contains a build type with the specified build type id. Returns external id of this project or null if such project does not exist. The search includes archived projects.

Parameters:
buildTypeId - id of a build type
Returns:
project external id of a project containing specified build type
Since:
8.0

findProjectIdForTemplate

@Nullable
java.lang.String findProjectIdForTemplate(@NotNull
                                                   java.lang.String buildTypeTemplateId)
Searches for a project which contains a build type template with the specified id. Returns id of this project or null if such project does not exist. The search includes archived projects.

Parameters:
buildTypeTemplateId - id of a build type template
Returns:
project id of a project containing specified build type template
Since:
6.5

isProjectExists

boolean isProjectExists(@NotNull
                        java.lang.String projectId)
Returns true if project with the specified id exists. In contrast to #findProjectByProjectId(String) this method does not check permissions and will return true if project exists even if user does not have permissions to access this project.

Parameters:
projectId - the internal id of the project
Returns:
see above
Since:
5.0

getBuildTypesDependingOn

java.util.List<SBuildType> getBuildTypesDependingOn(@NotNull
                                                    SBuildType type)
Deprecated. use SBuildType.getArtifactsReferences()

Returns the list of build types that depend on type (by artifacts).

Parameters:
type - build type
Returns:
list of build types depending on type

findBuildTypeTemplateById

@Nullable
BuildTypeTemplate findBuildTypeTemplateById(@NotNull
                                                     java.lang.String id)
Searches for build type template by given internal id

Parameters:
id - the internal id of template
Returns:
found template or null
Since:
5.0

findBuildTypeTemplateByExternalId

@Nullable
BuildTypeTemplate findBuildTypeTemplateByExternalId(@NotNull
                                                             java.lang.String externalId)
Searches for build type template by given external id

Parameters:
id - the external id of template
Returns:
found template or null
Since:
8.0

getCommonParentProject

@NotNull
SProject getCommonParentProject(@NotNull
                                        java.util.Collection<SProject> projects)
Returns nearest common parent project for all projects in provided collection.

Parameters:
projects - projects to find common parent for
Returns:
common parent project
Since:
8.0

findVcsRootById

@Nullable
SVcsRoot findVcsRootById(long id)
Finds VCS root by id

Parameters:
id - vcs root id
Returns:
found VCS root or null
Since:
8.0

findVcsRootByExternalId

@Nullable
SVcsRoot findVcsRootByExternalId(@NotNull
                                          java.lang.String externalId)
Finds VCS root by external id

Parameters:
externalId - external vcs root id
Returns:
found VCS root or null
Since:
8.0

findVcsRootsByIds

@NotNull
java.util.Collection<SVcsRoot> findVcsRootsByIds(@NotNull
                                                         java.util.Collection<java.lang.Long> ids)
Finds all VCS roots having the specified ids. Returns roots in the same order as provided ids.

Parameters:
ids - ids of VCS roots
Returns:
collection of found VCS roots
Since:
8.0

getAllVcsRoots

@NotNull
java.util.List<SVcsRoot> getAllVcsRoots()
Returns:
all VCS roots configured in all projects
Since:
8.0