Search in sources :

Example 1 with ProjectAgentPoolImpl

use of jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl in project teamcity-rest by JetBrains.

the class ProjectAgentPoolResolver method project.

@NotNull
public Project project(@NotNull ProjectAgentPool pool, @NotNull DataFetchingEnvironment env) {
    AgentPool realPool = pool.getRealPool();
    if (!realPool.isProjectPool()) {
        throw new RuntimeException(String.format("Pool id=%d is not a project pool.", realPool.getAgentPoolId()));
    }
    String projectId = ((ProjectAgentPoolImpl) realPool).getProjectId();
    SProject project = myProjectManager.findProjectById(projectId);
    if (project == null) {
        throw new RuntimeException(String.format("ProjectAgentPool id=%d does not have a project.", realPool.getAgentPoolId()));
    }
    return new Project(project);
}
Also used : ProjectAgentPoolImpl(jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl) SProject(jetbrains.buildServer.serverSide.SProject) Project(jetbrains.buildServer.server.graphql.model.Project) SProject(jetbrains.buildServer.serverSide.SProject) AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ProjectAgentPoolImpl

use of jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl in project teamcity-rest by JetBrains.

the class AgentPoolFinder method getPoolOwnerProject.

@Nullable
public PontentiallyInaccessibleProject getPoolOwnerProject(@NotNull final AgentPool projectAgentPool) {
    if (!projectAgentPool.isProjectPool())
        return null;
    ProjectAgentPoolImpl projectPool;
    try {
        projectPool = (ProjectAgentPoolImpl) projectAgentPool;
    } catch (ClassCastException e) {
        // should never happen
        return null;
    }
    final ProjectManager projectManager = myServiceLocator.getSingletonService(ProjectManager.class);
    try {
        return new PontentiallyInaccessibleProject(projectPool.getProjectId(), projectManager.findProjectById(projectPool.getProjectId()));
    } catch (AccessDeniedException e) {
        return new PontentiallyInaccessibleProject(projectPool.getProjectId(), null);
    }
}
Also used : ProjectAgentPoolImpl(jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl) AccessDeniedException(jetbrains.buildServer.serverSide.auth.AccessDeniedException) ProjectManager(jetbrains.buildServer.serverSide.ProjectManager) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectAgentPoolImpl (jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl)2 Project (jetbrains.buildServer.server.graphql.model.Project)1 ProjectAgentPool (jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool)1 ProjectManager (jetbrains.buildServer.serverSide.ProjectManager)1 SProject (jetbrains.buildServer.serverSide.SProject)1 AgentPool (jetbrains.buildServer.serverSide.agentPools.AgentPool)1 AccessDeniedException (jetbrains.buildServer.serverSide.auth.AccessDeniedException)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1