use of jetbrains.buildServer.serverSide.LicensingPolicyEx in project teamcity-rest by JetBrains.
the class LicensingData method initLicensingPolicyDependantFields.
private void initLicensingPolicyDependantFields(@NotNull LicenseKeysManager licenseKeysManager, @NotNull Fields fields, @NotNull BeanContext beanContext) {
final LicensingPolicyEx licensingPolicy = licenseKeysManager.getLicensingPolicy();
final PermissionChecker permissionChecker = beanContext.getSingletonService(PermissionChecker.class);
licenseUseExceeded = ValueWithDefault.decideDefaultIgnoringAccessDenied(fields.isIncluded("licenseUseExceeded"), () -> {
permissionChecker.checkGlobalPermission(Permission.MANAGE_SERVER_LICENSES);
return licensingPolicy.isMaxNumberOfBuildTypesExceeded();
});
agentsLeft = ValueWithDefault.decideIncludeByDefault(myFields.isIncluded("agentsLeft"), () -> {
if (permissionChecker.hasGlobalPermission(Permission.MANAGE_SERVER_LICENSES) || permissionChecker.hasGlobalPermission(Permission.VIEW_AGENT_DETAILS))
return licensingPolicy.getAgentsLicensesLeft();
return null;
});
buildTypesLeft = ValueWithDefault.decideDefaultIgnoringAccessDenied(fields.isIncluded("buildTypesLeft"), () -> {
permissionChecker.checkGlobalPermission(Permission.MANAGE_SERVER_LICENSES);
int result = licensingPolicy.getBuildTypesLicensesLeft();
return result == -1 ? null : result;
});
}
Aggregations