use of jetbrains.buildServer.serverSide.SBuildType in project commit-status-publisher by JetBrains.
the class SecurityParametersReportPageExtension method isAvailable.
@Override
public boolean isAvailable(@NotNull final HttpServletRequest request) {
if (!super.isAvailable(request))
return false;
HealthStatusItem item = getStatusItem(request);
SBuildType bt = (SBuildType) item.getAdditionalData().get("buildType");
if (bt == null)
return false;
return SessionUser.getUser(request).isPermissionGrantedForProject(bt.getProjectId(), Permission.VIEW_BUILD_CONFIGURATION_SETTINGS);
}
use of jetbrains.buildServer.serverSide.SBuildType in project commit-status-publisher by JetBrains.
the class MissingSettingsReport method report.
@Override
public void report(@NotNull HealthStatusScope scope, @NotNull HealthStatusItemConsumer consumer) {
for (SBuildType bt : scope.getBuildTypes()) {
Collection<SBuildFeatureDescriptor> features = bt.getBuildFeaturesOfType(CommitStatusPublisherFeature.TYPE);
for (SBuildFeatureDescriptor feature : features) {
if (bt.isEnabled(feature.getId())) {
Map<String, String> params = feature.getParameters();
String publisherId = params.get(Constants.PUBLISHER_ID_PARAM);
if (publisherId == null || !publisherId.equals(SPACE_PUBLISHER_ID))
continue;
CommitStatusPublisherSettings settings = myPublisherManager.findSettings(publisherId);
if (settings != null) {
Map<String, Object> healthItemData = settings.checkHealth(bt, params);
if (healthItemData != null) {
String identity = REPORT_TYPE + "_BT_" + bt.getInternalId() + "_FEATURE_" + feature.getId();
healthItemData.put("buildType", bt);
healthItemData.put("featureId", feature.getId());
consumer.consumeForBuildType(bt, new HealthStatusItem(identity, CATEGORY, healthItemData));
}
}
}
}
}
}
use of jetbrains.buildServer.serverSide.SBuildType in project commit-status-publisher by JetBrains.
the class NoFQDNServerUrlReport method report.
@Override
public void report(@NotNull HealthStatusScope scope, @NotNull HealthStatusItemConsumer consumer) {
for (SBuildType bt : scope.getBuildTypes()) {
Collection<SBuildFeatureDescriptor> features = bt.getBuildFeaturesOfType(CommitStatusPublisherFeature.TYPE);
for (SBuildFeatureDescriptor feature : features) {
if (bt.isEnabled(feature.getId())) {
Map<String, String> params = feature.getParameters();
String publisherId = params.get(Constants.PUBLISHER_ID_PARAM);
if (publisherId == null)
continue;
CommitStatusPublisherSettings settings = myPublisherManager.findSettings(publisherId);
if (null != settings && settings.isFQDNTeamCityUrlRequired()) {
String rootUrl = myLinks.getRootUrlByProjectInternalId(bt.getProjectId());
if (!URL_WITH_FQDN_PATTERN.matcher(rootUrl).matches()) {
String identity = REPORT_TYPE + "_BT_" + bt.getInternalId() + "_FEATURE_" + feature.getId();
Map<String, Object> additionalData = new HashMap<>();
additionalData.put("rootUrl", rootUrl);
additionalData.put("buildType", bt);
additionalData.put("publisherType", settings.getName());
consumer.consumeForBuildType(bt, new HealthStatusItem(identity, CATEGORY, additionalData));
}
}
}
}
}
}
use of jetbrains.buildServer.serverSide.SBuildType in project commit-status-publisher by JetBrains.
the class DeprecatedAuthReport method report.
@Override
public void report(@NotNull HealthStatusScope scope, @NotNull HealthStatusItemConsumer consumer) {
for (SBuildType bt : scope.getBuildTypes()) {
Collection<SBuildFeatureDescriptor> features = bt.getBuildFeaturesOfType(CommitStatusPublisherFeature.TYPE);
for (SBuildFeatureDescriptor feature : features) {
if (bt.isEnabled(feature.getId())) {
Map<String, String> params = feature.getParameters();
String publisherId = params.get(Constants.PUBLISHER_ID_PARAM);
if (publisherId == null || !publisherId.equals(Constants.GITHUB_PUBLISHER_ID))
continue;
CommitStatusPublisherSettings settings = myPublisherManager.findSettings(publisherId);
if (null != settings && GitHubApiAuthenticationType.PASSWORD_AUTH.getValue().equals(params.get(Constants.GITHUB_AUTH_TYPE))) {
String identity = REPORT_TYPE + "_BT_" + bt.getInternalId() + "_FEATURE_" + feature.getId();
Map<String, Object> additionalData = new HashMap<>();
additionalData.put("buildType", bt);
additionalData.put("publisherType", settings.getName());
consumer.consumeForBuildType(bt, new HealthStatusItem(identity, CATEGORY, additionalData));
}
}
}
}
}
use of jetbrains.buildServer.serverSide.SBuildType in project teamcity-rest by JetBrains.
the class Investigation method getFromPostedAndApply.
@NotNull
public List<InvestigationWrapper> getFromPostedAndApply(@NotNull final ServiceLocator serviceLocator, final boolean allowMultipleResult) {
checkIsValid();
if (target == null) {
throw new BadRequestException("Invalid 'investigation' entity: 'target' should be specified");
}
ProblemTarget.ProblemTargetData targetData;
try {
targetData = target.getFromPosted(serviceLocator);
} catch (BadRequestException e) {
throw new BadRequestException("Invalid 'investigation' entity: " + e.getMessage());
}
ResponsibilityEntry entry = new ResponsibilityEntryEx(TypedFinderBuilder.getEnumValue(state, ResponsibilityEntry.State.class), assignee.getFromPosted(serviceLocator.getSingletonService(UserFinder.class)), serviceLocator.getSingletonService(UserFinder.class).getCurrentUser(), new Date(), assignment == null || assignment.getTextFromPosted() == null ? "" : assignment.getTextFromPosted(), resolution.getFromPostedForInvestigation(serviceLocator));
ResponsibilityFacadeEx responsibilityFacade = serviceLocator.getSingletonService(ResponsibilityFacadeEx.class);
InvestigationFinder investigationFinder = serviceLocator.findSingletonService(InvestigationFinder.class);
assert investigationFinder != null;
List<InvestigationWrapper> resultEntries = new ArrayList<>(1);
if (targetData.isAnyProblem()) {
List<BuildType> buildTypesFromPosted = scope.getBuildTypesFromPosted(serviceLocator);
if (!allowMultipleResult && buildTypesFromPosted.size() > 1) {
throw new OnlySingleEntitySupportedException("Invalid 'scope' entity: for this request only single buildType is supported within 'buildTypes' entity");
}
for (BuildType buildType : buildTypesFromPosted) {
responsibilityFacade.setBuildTypeResponsibility(buildType, entry);
resultEntries.add(investigationFinder.getItem(InvestigationFinder.getLocator((SBuildType) buildType)));
}
} else {
if (scope.buildTypes != null) {
throw new BadRequestException("Invalid 'investigation' entity: Invalid 'scope' entity: 'buildTypes' should not be specified for not buildType-level investigation");
}
SProject project = scope.getProjectFromPosted(serviceLocator);
List<STest> tests = targetData.getTests();
if (!tests.isEmpty()) {
if (!allowMultipleResult && tests.size() > 1) {
throw new OnlySingleEntitySupportedException("Invalid 'target' entity: for this request only single test is supported within 'tests' entity");
}
responsibilityFacade.setTestNameResponsibility(tests.stream().map(sTest -> sTest.getName()).distinct().collect(Collectors.toList()), project.getProjectId(), entry);
tests.stream().map(test -> // only one item should be found in the project
investigationFinder.getItem(InvestigationFinder.getLocatorForTest(test.getTestNameId(), project))).distinct().forEachOrdered(resultEntries::add);
}
List<Long> problems = targetData.getProblemIds();
if (!problems.isEmpty()) {
if (!allowMultipleResult && problems.size() > 1) {
throw new OnlySingleEntitySupportedException("Invalid 'target' entity: for this request only single problem is supported within 'problems' entity");
}
responsibilityFacade.setBuildProblemResponsibility(// seems like only id is used inside
problems.stream().distinct().map(problemId -> ProblemWrapper.getBuildProblemInfo(problemId.intValue(), project.getProjectId())).collect(Collectors.toList()), project.getProjectId(), entry);
problems.stream().distinct().map(problemId -> // only one item should be found in the project
investigationFinder.getItem(InvestigationFinder.getLocatorForProblem(problemId.intValue(), project))).forEachOrdered(resultEntries::add);
}
}
if (!allowMultipleResult && resultEntries.size() != 1) {
throw new BadRequestException("Invalid 'investigation' entity: Invalid 'target' entity: found " + resultEntries.size() + " result entities, while exactly one is required");
}
return resultEntries;
}
Aggregations