use of jetbrains.buildServer.server.rest.errors.NotFoundException in project teamcity-rest by JetBrains.
the class BuildPromotionFinder method findSingleItem.
@Nullable
@Override
public BuildPromotion findSingleItem(@NotNull final Locator locator) {
if (locator.isSingleValue()) {
@NotNull final Long singleValueAsLong;
try {
// noinspection ConstantConditions
singleValueAsLong = locator.getSingleValueAsLong();
} catch (LocatorProcessException e) {
throw new BadRequestException("Invalid single value: '" + locator.getSingleValue() + "'. Should be a numeric build id", e);
}
// difference from 9.0 behavior where we never searched by promotion id in case of single value locators
return getBuildPromotionById(singleValueAsLong, myBuildPromotionManager, myBuildsManager);
}
Long promotionId = locator.getSingleDimensionValueAsLong(PROMOTION_ID);
if (promotionId == null) {
// support TeamCity 8.0 dimension
promotionId = locator.getSingleDimensionValueAsLong(PROMOTION_ID_ALIAS);
}
if (promotionId != null) {
return BuildFinder.getBuildPromotion(promotionId, myBuildPromotionManager);
}
Long buildId = locator.getSingleDimensionValueAsLong(BUILD_ID);
if (buildId != null) {
final SBuild build = myBuildsManager.findBuildInstanceById(buildId);
if (build != null) {
return build.getBuildPromotion();
}
throw new NotFoundException("No build found by build id '" + buildId + "'.");
}
final Long id = locator.getSingleDimensionValueAsLong(DIMENSION_ID);
if (id != null) {
return getBuildPromotionById(id, myBuildPromotionManager, myBuildsManager);
}
return null;
}
use of jetbrains.buildServer.server.rest.errors.NotFoundException in project teamcity-rest by JetBrains.
the class BuildPromotionFinder method getBuildPromotion.
@NotNull
public BuildPromotion getBuildPromotion(@Nullable final SBuildType buildType, @Nullable final String locatorText) {
if (buildType == null) {
return getItem(locatorText);
}
final Locator locator = locatorText != null ? new Locator(locatorText) : Locator.createEmptyLocator();
if (locator.isEmpty() || !locator.isSingleValue()) {
return getItem(patchLocatorWithBuildType(buildType, locator));
}
// single value locator
// use logic like BuildFinder: if there is build type and single value, assume it's build number
final String buildNumber = locator.getSingleValue();
assert buildNumber != null;
SBuild build = myBuildsManager.findBuildInstanceByBuildNumber(buildType.getInternalId(), buildNumber);
if (build != null)
return build.getBuildPromotion();
throw new NotFoundException("No build can be found by number '" + buildNumber + "' in the build type with id '" + buildType.getExternalId() + "'");
/*
final BuildPromotion singleItem = findSingleItem(locator);
if (singleItem != null) { //will find it the regular way, go for it with all due checks
return getItem(locator.getStringRepresentation());
}
*/
}
use of jetbrains.buildServer.server.rest.errors.NotFoundException in project teamcity-rest by JetBrains.
the class BuildTypeFinder method getPrefilteredItems.
@NotNull
@Override
public ItemHolder<BuildTypeOrTemplate> getPrefilteredItems(@NotNull final Locator locator) {
// this should be the first one as the order returned here is important!
final String selectedForUser = locator.getSingleDimensionValue(DIMENSION_SELECTED);
if (selectedForUser != null) {
return getItemHolder(getSelectedByUser(locator, selectedForUser));
}
/*
this uses weird order of the results which is probably not what is needed
String buildLocator = locator.getSingleDimensionValue(BUILD);
if (buildLocator != null) {
List<BuildPromotion> builds = myServiceLocator.getSingletonService(BuildPromotionFinder.class).getItems(buildLocator).myEntries;
Set<BuildTypeOrTemplate> buildTypes = builds.stream().map(build -> build.getBuildType()).filter(Objects::nonNull).map(buildType -> new BuildTypeOrTemplate(buildType))
.collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
return FinderDataBinding.getItemHolder(buildTypes);
}
*/
final String snapshotDependencies = locator.getSingleDimensionValue(SNAPSHOT_DEPENDENCY);
if (snapshotDependencies != null) {
final GraphFinder<BuildTypeOrTemplate> graphFinder = new GraphFinder<BuildTypeOrTemplate>(this, new SnapshotDepsTraverser(myPermissionChecker));
return getItemHolder(graphFinder.getItems(snapshotDependencies).myEntries);
}
final String artifactDependencies = locator.getSingleDimensionValue(ARTIFACT_DEPENDENCY);
if (artifactDependencies != null) {
final GraphFinder<BuildTypeOrTemplate> graphFinder = new GraphFinder<BuildTypeOrTemplate>(this, new ArtifactDepsTraverser(myPermissionChecker));
return getItemHolder(graphFinder.getItems(artifactDependencies).myEntries);
}
final String vcsRoot = locator.getSingleDimensionValue(VCS_ROOT_DIMENSION);
if (vcsRoot != null) {
final Set<SVcsRoot> vcsRoots = new HashSet<SVcsRoot>(myServiceLocator.getSingletonService(VcsRootFinder.class).getItems(vcsRoot).myEntries);
final VcsManager vcsManager = myServiceLocator.getSingletonService(VcsManager.class);
final LinkedHashSet<BuildTypeOrTemplate> result = new LinkedHashSet<BuildTypeOrTemplate>();
for (SVcsRoot root : vcsRoots) {
// can optimize more by checking template flag here
result.addAll(BuildTypes.fromBuildTypes(root.getUsagesInConfigurations()));
result.addAll(BuildTypes.fromTemplates(vcsManager.getAllTemplateUsages(root)));
}
// order of the result is not well defined here, might need to resort...
return getItemHolder(result);
}
final String vcsRootInstance = locator.getSingleDimensionValue(VCS_ROOT_INSTANCE_DIMENSION);
if (vcsRootInstance != null) {
final Set<jetbrains.buildServer.vcs.VcsRootInstance> vcsRootInstances = new HashSet<jetbrains.buildServer.vcs.VcsRootInstance>(myServiceLocator.getSingletonService(VcsRootInstanceFinder.class).getItems(vcsRootInstance).myEntries);
final List<SBuildType> result = new ArrayList<SBuildType>();
for (jetbrains.buildServer.vcs.VcsRootInstance root : vcsRootInstances) {
result.addAll(root.getUsages().keySet());
// cannot find templates by instances
}
// order of the result is not well defined here, might need to resort...
return getItemHolder(BuildTypes.fromBuildTypes(result));
}
final String templateLocator = locator.getSingleDimensionValue(TEMPLATE_DIMENSION_NAME);
if (templateLocator != null) {
final BuildTypeTemplate buildTemplate;
try {
buildTemplate = getBuildTemplate(null, templateLocator, true);
} catch (NotFoundException e) {
throw new NotFoundException("No templates found by locator '" + templateLocator + "' specified in '" + TEMPLATE_DIMENSION_NAME + "' dimension : " + e.getMessage());
} catch (BadRequestException e) {
throw new BadRequestException("Error while searching for templates by locator '" + templateLocator + "' specified in '" + TEMPLATE_DIMENSION_NAME + "' dimension : " + e.getMessage(), e);
}
return getItemHolder(BuildTypes.fromBuildTypes(buildTemplate.getUsages()));
}
List<SProject> projects = null;
final String projectLocator = locator.getSingleDimensionValue(DIMENSION_PROJECT);
if (projectLocator != null) {
projects = myProjectFinder.getItems(projectLocator).myEntries;
}
SProject affectedProject = null;
final String affectedProjectLocator = locator.getSingleDimensionValue(AFFECTED_PROJECT);
if (affectedProjectLocator != null) {
affectedProject = myProjectFinder.getItem(affectedProjectLocator);
}
List<BuildTypeOrTemplate> result = new ArrayList<BuildTypeOrTemplate>();
Boolean template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_FLAG_DIMENSION_NAME);
if (template == null || !template) {
if (projects != null) {
result.addAll(getBuildTypes(projects));
} else if (affectedProject != null) {
result.addAll(BuildTypes.fromBuildTypes(affectedProject.getBuildTypes()));
} else {
result.addAll(BuildTypes.fromBuildTypes(myProjectManager.getAllBuildTypes()));
}
}
if (template == null || template) {
if (projects != null) {
result.addAll(getTemplates(projects));
} else if (affectedProject != null) {
result.addAll(BuildTypes.fromTemplates(affectedProject.getBuildTypeTemplates()));
} else {
result.addAll(BuildTypes.fromTemplates(myProjectManager.getAllTemplates()));
}
}
return getItemHolder(result);
}
use of jetbrains.buildServer.server.rest.errors.NotFoundException in project teamcity-rest by JetBrains.
the class BuildTypeFinder method getFilter.
@NotNull
@Override
public ItemFilter<BuildTypeOrTemplate> getFilter(@NotNull final Locator locator) {
final MultiCheckerFilter<BuildTypeOrTemplate> result = new MultiCheckerFilter<BuildTypeOrTemplate>();
if (locator.isUnused(DIMENSION_ID)) {
final String id = locator.getSingleDimensionValue(DIMENSION_ID);
if (id != null) {
result.add(item -> id.equals(item.getId()));
}
}
if (locator.isUnused(DIMENSION_INTERNAL_ID)) {
final String internalId = locator.getSingleDimensionValue(DIMENSION_INTERNAL_ID);
if (internalId != null) {
result.add(item -> internalId.equals(item.getInternalId()));
}
}
if (locator.isUnused(DIMENSION_UUID)) {
final String uuid = locator.getSingleDimensionValue(DIMENSION_UUID);
if (uuid != null) {
result.add(item -> uuid.equals(((BuildTypeIdentityEx) item.getIdentity()).getEntityId().getConfigId()));
}
}
final String name = locator.getSingleDimensionValue(DIMENSION_NAME);
if (name != null) {
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return name.equalsIgnoreCase(item.getName());
}
});
}
if (locator.isUnused(DIMENSION_PROJECT)) {
final String projectLocator = locator.getSingleDimensionValue(DIMENSION_PROJECT);
if (projectLocator != null) {
final List<SProject> projects = myProjectFinder.getItems(projectLocator).myEntries;
if (projects.size() == 1) {
final SProject internalProject = projects.iterator().next();
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return internalProject.getProjectId().equals(item.getProject().getProjectId());
}
});
} else {
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return projects.contains(item.getProject());
}
});
}
}
}
final String affectedProjectDimension = locator.getSingleDimensionValue(AFFECTED_PROJECT);
if (affectedProjectDimension != null) {
@NotNull final SProject parentProject = myProjectFinder.getItem(affectedProjectDimension);
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return ProjectFinder.isSameOrParent(parentProject, item.getProject());
}
});
}
final Boolean paused = locator.getSingleDimensionValueAsBoolean(PAUSED);
if (paused != null) {
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
final Boolean pausedState = item.isPaused();
return FilterUtil.isIncludedByBooleanFilter(paused, pausedState != null && pausedState);
}
});
}
if (locator.isUnused(BUILD)) {
String buildLocator = locator.getSingleDimensionValue(BUILD);
if (buildLocator != null) {
List<BuildPromotion> builds = myServiceLocator.getSingletonService(BuildPromotionFinder.class).getItems(buildLocator).myEntries;
Set<String> buldTypeIds = builds.stream().map(build -> build.getBuildType()).filter(Objects::nonNull).map(buildType -> buildType.getInternalId()).collect(Collectors.toSet());
result.add(item -> buldTypeIds.contains(item.getInternalId()));
}
}
// experimental
final String compatibleAagentLocator = locator.getSingleDimensionValue(COMPATIBLE_AGENT);
if (compatibleAagentLocator != null) {
final List<SBuildAgent> agents = myAgentFinder.getItems(compatibleAagentLocator).myEntries;
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
if (item.getBuildType() == null)
return false;
for (SBuildAgent agent : agents) {
if (AgentFinder.canActuallyRun(agent, item.getBuildType()))
return true;
}
return false;
}
});
}
// experimental
final Long compatibleAgentsCount = locator.getSingleDimensionValueAsLong(COMPATIBLE_AGENTS_COUNT);
if (compatibleAgentsCount != null) {
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
if (item.getBuildType() == null)
return false;
long count = 0;
for (SBuildAgent agent : myAgentFinder.getItems(null).myEntries) {
// or should process unauthorized as well?
if (AgentFinder.canActuallyRun(agent, item.getBuildType()) && agent.isRegistered() && agent.isAuthorized() && agent.isEnabled())
count++;
if (count > compatibleAgentsCount)
return false;
}
return count == compatibleAgentsCount;
}
});
}
if (locator.isUnused(DIMENSION_SELECTED)) {
final String selectedByUser = locator.getSingleDimensionValue(DIMENSION_SELECTED);
if (selectedByUser != null) {
List<BuildTypeOrTemplate> filterSet = getSelectedByUser(locator, selectedByUser);
result.add(item -> filterSet.contains(item));
}
}
final String parameterDimension = locator.getSingleDimensionValue(PARAMETER);
if (parameterDimension != null) {
final ParameterCondition parameterCondition = ParameterCondition.create(parameterDimension);
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
final boolean canView = !BuildType.shouldRestrictSettingsViewing(item.get(), myPermissionChecker);
if (!canView) {
LOG.debug("While filtering build types by " + PARAMETER + " user does not have enough permissions to see settings. Excluding build type: " + item.describe(false));
return false;
}
return parameterCondition.matches(item.get());
}
});
}
final String settingDimension = locator.getSingleDimensionValue(SETTING);
if (settingDimension != null) {
final ParameterCondition condition = ParameterCondition.create(settingDimension);
result.add(item -> {
final boolean canView = !BuildType.shouldRestrictSettingsViewing(item.get(), myPermissionChecker);
if (!canView) {
LOG.debug("While filtering build types by " + SETTING + " user does not have enough permissions to see settings. Excluding build type: " + item.describe(false));
return false;
}
return condition.matches(new MapParametersProviderImpl(BuildTypeUtil.getSettingsParameters(item, null, true, false)), new MapParametersProviderImpl(BuildTypeUtil.getSettingsParameters(item, null, true, false)));
});
}
final Boolean template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_FLAG_DIMENSION_NAME);
if (template != null) {
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return FilterUtil.isIncludedByBooleanFilter(template, item.isTemplate());
}
});
}
final String type = locator.getSingleDimensionValue(TYPE);
if (type != null) {
String typeOptionValue = TypedFinderBuilder.getEnumValue(type, BuildTypeOptions.BuildConfigurationType.class).name();
result.add(item -> typeOptionValue.equals(item.get().getOption(BuildTypeOptions.BT_BUILD_CONFIGURATION_TYPE)));
}
// experimental
final String filterBuilds = locator.getSingleDimensionValue(FILTER_BUILDS);
if (filterBuilds != null) {
BuildPromotionFinder promotionFinder = myServiceLocator.getSingletonService(BuildPromotionFinder.class);
FinderSearchMatcher<BuildPromotion> matcher = new FinderSearchMatcher<>(filterBuilds, promotionFinder);
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
@Override
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
SBuildType buildType = item.getBuildType();
if (buildType == null)
return false;
String defaults = Locator.getStringLocator(BuildPromotionFinder.BUILD_TYPE, BuildTypeFinder.getLocator(buildType), PagerData.COUNT, "1");
return matcher.matches(defaults);
}
});
}
final String snapshotDependencies = locator.getSingleDimensionValue(SNAPSHOT_DEPENDENCY);
if (snapshotDependencies != null) {
final GraphFinder<BuildTypeOrTemplate> graphFinder = new GraphFinder<BuildTypeOrTemplate>(this, new SnapshotDepsTraverser(myPermissionChecker));
final List<BuildTypeOrTemplate> boundingList = graphFinder.getItems(snapshotDependencies).myEntries;
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return boundingList.contains(item);
}
});
}
final String artifactDependencies = locator.getSingleDimensionValue(ARTIFACT_DEPENDENCY);
if (artifactDependencies != null) {
final GraphFinder<BuildTypeOrTemplate> graphFinder = new GraphFinder<BuildTypeOrTemplate>(this, new ArtifactDepsTraverser(myPermissionChecker));
final List<BuildTypeOrTemplate> boundingList = graphFinder.getItems(artifactDependencies).myEntries;
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return boundingList.contains(item);
}
});
}
final String templateLocator = locator.getSingleDimensionValue(TEMPLATE_DIMENSION_NAME);
if (templateLocator != null) {
try {
// only this can throw exceptions caught later
final BuildTypeTemplate buildTemplate = getBuildTemplate(null, templateLocator, true);
final List<BuildTypeOrTemplate> boundingList = BuildTypes.fromBuildTypes(buildTemplate.getUsages());
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return boundingList.contains(item);
}
});
} catch (NotFoundException e) {
// legacy support for boolean template
Boolean legacyTemplateFlag = null;
try {
legacyTemplateFlag = locator.getSingleDimensionValueAsBoolean(TEMPLATE_DIMENSION_NAME);
} catch (LocatorProcessException eNested) {
// not a boolean, throw original error
throw new NotFoundException("No templates found by locator '" + templateLocator + "' specified in '" + TEMPLATE_DIMENSION_NAME + "' dimension : " + e.getMessage());
}
// legacy request detected
if (legacyTemplateFlag != null) {
final boolean legacyTemplateFlagFinal = legacyTemplateFlag;
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
return FilterUtil.isIncludedByBooleanFilter(legacyTemplateFlagFinal, item.isTemplate());
}
});
}
} catch (BadRequestException e) {
throw new BadRequestException("Error while searching for templates by locator '" + templateLocator + "' specified in '" + TEMPLATE_DIMENSION_NAME + "' dimension : " + e.getMessage(), e);
}
}
if (locator.isUnused(VCS_ROOT_DIMENSION)) {
final String vcsRoot = locator.getSingleDimensionValue(VCS_ROOT_DIMENSION);
if (vcsRoot != null) {
final Set<SVcsRoot> vcsRoots = new HashSet<SVcsRoot>(myServiceLocator.getSingletonService(VcsRootFinder.class).getItems(vcsRoot).myEntries);
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
for (VcsRootInstanceEntry vcsRootInstanceEntry : item.getVcsRootInstanceEntries()) {
if (vcsRoots.contains(vcsRootInstanceEntry.getVcsRoot().getParent()))
return true;
}
return false;
}
});
}
}
if (locator.isUnused(VCS_ROOT_INSTANCE_DIMENSION)) {
final String vcsRootInstance = locator.getSingleDimensionValue(VCS_ROOT_INSTANCE_DIMENSION);
if (vcsRootInstance != null) {
final Set<jetbrains.buildServer.vcs.VcsRootInstance> vcsRootInstances = new HashSet<jetbrains.buildServer.vcs.VcsRootInstance>(myServiceLocator.getSingletonService(VcsRootInstanceFinder.class).getItems(vcsRootInstance).myEntries);
result.add(new FilterConditionChecker<BuildTypeOrTemplate>() {
public boolean isIncluded(@NotNull final BuildTypeOrTemplate item) {
for (VcsRootInstanceEntry vcsRootInstanceEntry : item.getVcsRootInstanceEntries()) {
if (vcsRootInstances.contains(vcsRootInstanceEntry.getVcsRoot()))
return true;
}
return false;
}
});
}
}
return result;
}
use of jetbrains.buildServer.server.rest.errors.NotFoundException in project teamcity-rest by JetBrains.
the class BuildTypeFinder method findSingleItem.
@Override
@Nullable
public BuildTypeOrTemplate findSingleItem(@NotNull final Locator locator) {
if (locator.isSingleValue()) {
// no dimensions found, assume it's an internal id, external id or name
final String value = locator.getSingleValue();
assert value != null;
BuildTypeOrTemplate buildType = findBuildTypeOrTemplateByInternalId(value, null);
if (buildType != null) {
return buildType;
}
buildType = findBuildTypeOrTemplateByExternalId(value, null);
if (buildType != null) {
return buildType;
}
// assume it's a name
final BuildTypeOrTemplate buildTypeByName = findBuildTypebyName(value, null, null);
if (buildTypeByName != null) {
return buildTypeByName;
}
throw new NotFoundException("No build type or template is found by id, internal id or name '" + value + "'.");
}
String internalId = locator.getSingleDimensionValue(DIMENSION_INTERNAL_ID);
if (!StringUtil.isEmpty(internalId)) {
Boolean template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_FLAG_DIMENSION_NAME);
if (template == null) {
// legacy support for boolean value
try {
template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_DIMENSION_NAME);
} catch (LocatorProcessException e) {
// override default message as it might be confusing here due to legacy support
throw new BadRequestException("Try omitting dimension '" + TEMPLATE_DIMENSION_NAME + "' here");
}
}
BuildTypeOrTemplate buildType = findBuildTypeOrTemplateByInternalId(internalId, template);
if (buildType != null) {
return buildType;
}
throw new NotFoundException("No " + getName(template) + " is found by internal id '" + internalId + "'.");
}
String uuid = locator.getSingleDimensionValue(DIMENSION_UUID);
if (!StringUtil.isEmpty(uuid)) {
Boolean template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_FLAG_DIMENSION_NAME);
BuildTypeOrTemplate buildType = findBuildTypeOrTemplateByUuid(uuid, template);
if (buildType != null) {
return buildType;
}
// protecting against brute force uuid guessing
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
throw new NotFoundException("No " + getName(template) + " is found by uuid '" + uuid + "'.");
}
String id = locator.getSingleDimensionValue(DIMENSION_ID);
if (!StringUtil.isEmpty(id)) {
Boolean template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_FLAG_DIMENSION_NAME);
if (template == null) {
// legacy support for boolean value
try {
template = locator.getSingleDimensionValueAsBoolean(TEMPLATE_DIMENSION_NAME);
} catch (LocatorProcessException e) {
// override default message as it might be confusing here due to legacy support
throw new BadRequestException("Try omitting dimension '" + TEMPLATE_DIMENSION_NAME + "' here");
}
}
BuildTypeOrTemplate buildType = findBuildTypeOrTemplateByExternalId(id, template);
if (buildType != null) {
return buildType;
}
// support pre-8.0 style of template ids
final BuildTypeOrTemplate templateByOldIdWithPrefix = findTemplateByOldIdWithPrefix(id);
if (templateByOldIdWithPrefix != null) {
return templateByOldIdWithPrefix;
}
if (TeamCityProperties.getBoolean(APIController.REST_COMPATIBILITY_ALLOW_EXTERNAL_ID_AS_INTERNAL)) {
buildType = findBuildTypeOrTemplateByInternalId(id, template);
if (buildType != null) {
return buildType;
}
throw new NotFoundException("No " + getName(template) + " is found by id '" + id + "' in compatibility mode." + " Cannot be found by external or internal id '" + id + "'.");
}
throw new NotFoundException("No " + getName(template) + " is found by id '" + id + "'.");
}
return null;
}
Aggregations