use of jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor in project teamcity-rest by JetBrains.
the class DataProvider method getTrigger.
public static BuildTriggerDescriptor getTrigger(final BuildTypeSettings buildType, final String triggerLocator) {
if (StringUtil.isEmpty(triggerLocator)) {
throw new BadRequestException("Empty trigger locator is not supported.");
}
final Locator locator = new Locator(triggerLocator);
if (locator.isSingleValue()) {
// no dimensions found, assume it's trigger id
final String triggerId = locator.getSingleValue();
if (StringUtil.isEmpty(triggerId)) {
throw new BadRequestException("Trigger id cannot be empty.");
}
@SuppressWarnings("ConstantConditions") final BuildTriggerDescriptor foundTrigger = buildType.findTriggerById(triggerId);
if (foundTrigger == null) {
throw new NotFoundException("No trigger found by id '" + triggerLocator + "' in build type.");
}
return foundTrigger;
}
throw new BadRequestException("No trigger can be found by locator '" + triggerLocator + "'. Locator should be trigger id.");
}
Aggregations