Interface ProjectManager

    • 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
      • findProjectByName

        @Deprecated
        @Nullable
        SProject findProjectByName​(@NotNull
                                   java.lang.String projectName)
        Deprecated.
        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 internalId)
        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 or internalId is null.
        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.

        Since 8.1 the method also looks up the project by the previous external ids. So the result project can have a different external id after a call. But the later is impossible if there is a project that currently has a externalId.
        Parameters:
        externalId - the external id of the project to search for, case insensitive.
        Returns:
        a project or null if project with such id does not exist or externalId is null.
        Throws:
        AccessDeniedException - no access rights for the current user
        Since:
        8.0.
        See Also:
        findProjectById(String)
      • findProjectByConfigId

        @Nullable
        SProject findProjectByConfigId​(@Nullable
                                       java.lang.String configId)
        Looks for a project with the given config id.

        The search includes archived projects.

        Parameters:
        configId - the config 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:
        9.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:
        collection of projects corresponding to the specified internal ids
      • 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. The collection is guaranteed to be a mutable one.

        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. Since 8.1 the method also looks up the build type by the previous external ids. So the result build type can have a different external id after a call. But the later is impossible if there is a build type that currently has a externalId.
        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 or the id is null.
        Throws:
        AccessDeniedException - if current authority holder doesn't have access to build configuration with given external id.
        Since:
        8.0
      • findBuildTypeByConfigId

        @Nullable
        SBuildType findBuildTypeByConfigId​(@Nullable
                                           java.lang.String configId)
                                    throws AccessDeniedException
        Searches for a build configuration with specified config id.
        Parameters:
        configId - the config id of the build configuration to search for.
        Returns:
        a build configuration or null if build configuration with given config id does not exist.
        Throws:
        AccessDeniedException - if current authority holder doesn't have access to build configuration with given config id.
        Since:
        9.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 internal ids
        Returns:
        collection of existing build types
      • 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 findProjectById(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
      • 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​(@Nullable
                                                            java.lang.String externalId)
        Searches for build type template by given external id. Since 8.1 the method also looks up the template by the previous external ids. So the result project can have a different external id after a call. But the later is impossible if there is a template that currently has a externalId.
        Parameters:
        externalId - the external id of template
        Returns:
        found template or null, if template can't be found or external id is null.
        Since:
        8.0
      • findBuildTypeTemplateByConfigId

        @Nullable
        BuildTypeTemplate findBuildTypeTemplateByConfigId​(@NotNull
                                                          java.lang.String configId)
        Searches for build type template by given config id.
        Parameters:
        configId - the config id of template
        Returns:
        found template or null
        Since:
        9.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
      • getProjectsComparator

        @NotNull
        java.util.Comparator<SProject> getProjectsComparator()
        Returns:
        Comparator to sort projects with server-wide custom ordering
        Since:
        9.1
      • getBuildTypesComparator

        @NotNull
        java.util.Comparator<SBuildType> getBuildTypesComparator()
        Returns:
        Comparator to sort build configurations with server-wide custom ordering. Project ordering is not used by this comparator - use BuildTypeComparator to order build configurations from different projects.
        Since:
        9.1