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);
}
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);
}
}
Aggregations