Search in sources :

Example 1 with LicensingPolicyEx

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;
    });
}
Also used : PermissionChecker(jetbrains.buildServer.server.rest.data.PermissionChecker) LicensingPolicyEx(jetbrains.buildServer.serverSide.LicensingPolicyEx)

Aggregations

PermissionChecker (jetbrains.buildServer.server.rest.data.PermissionChecker)1 LicensingPolicyEx (jetbrains.buildServer.serverSide.LicensingPolicyEx)1