Search in sources :

Example 1 with VersionBomPolicyStatusView

use of com.blackducksoftware.integration.hub.api.generated.view.VersionBomPolicyStatusView in project hub-detect by blackducksoftware.

the class PolicyChecker method getPolicyStatus.

/**
 * For the given DetectProject, find the matching Hub project/version, then all of its code locations, then all of their scan summaries, wait until they are all complete, then get the policy status.
 *
 * @throws IntegrationException
 */
public PolicyStatusDescription getPolicyStatus(final ProjectService projectService, final ProjectVersionView version) throws IntegrationException {
    final VersionBomPolicyStatusView versionBomPolicyStatusView = projectService.getPolicyStatusForVersion(version);
    final PolicyStatusDescription policyStatusDescription = new PolicyStatusDescription(versionBomPolicyStatusView);
    PolicyStatusApprovalStatusType statusEnum = PolicyStatusApprovalStatusType.NOT_IN_VIOLATION;
    if (policyStatusDescription.getCountInViolation() != null && policyStatusDescription.getCountInViolation().value > 0) {
        statusEnum = PolicyStatusApprovalStatusType.IN_VIOLATION;
    } else if (policyStatusDescription.getCountInViolationOverridden() != null && policyStatusDescription.getCountInViolationOverridden().value > 0) {
        statusEnum = PolicyStatusApprovalStatusType.IN_VIOLATION_OVERRIDDEN;
    }
    logger.info(String.format("Policy Status: %s", statusEnum.name()));
    return policyStatusDescription;
}
Also used : PolicyStatusDescription(com.blackducksoftware.integration.hub.service.model.PolicyStatusDescription) PolicyStatusApprovalStatusType(com.blackducksoftware.integration.hub.api.generated.enumeration.PolicyStatusApprovalStatusType) VersionBomPolicyStatusView(com.blackducksoftware.integration.hub.api.generated.view.VersionBomPolicyStatusView)

Aggregations

PolicyStatusApprovalStatusType (com.blackducksoftware.integration.hub.api.generated.enumeration.PolicyStatusApprovalStatusType)1 VersionBomPolicyStatusView (com.blackducksoftware.integration.hub.api.generated.view.VersionBomPolicyStatusView)1 PolicyStatusDescription (com.blackducksoftware.integration.hub.service.model.PolicyStatusDescription)1