private String evaluateGroup()

in src/main/java/org/apache/sling/installer/hc/OsgiInstallerHealthCheck.java [147:204]


    private String evaluateGroup(ResourceGroup group, FormattingResultLog hcLog) {
        Resource invalidResource = null;
        String resourceType = "";
        boolean isGroupRelevant = false;
        // go through all resources within the given group
        for (Resource resource : group.getResources()) {
            // check for the correct type
            resourceType = resource.getType();
            switch (resourceType) {
            case InstallableResource.TYPE_CONFIG:
                if (!configuration.checkConfigurations()) {
                    LOG.debug("Skip resource '{}', configuration checks are disabled", resource.getEntityId());
                    return "";
                }
                break;
            case InstallableResource.TYPE_BUNDLE:
                if (!configuration.checkBundles()) {
                    LOG.debug("Skip resource '{}', bundle checks are disabled", resource.getEntityId());
                    return "";
                }
                break;
            default:
                LOG.debug("Skip resource '{}' as it is neither a bundle nor a configuration but a {}",
                        resource.getEntityId(), resourceType);
                return "";
            }
            if (Arrays.stream(configuration.urlPrefixes()).anyMatch(resource.getURL()::startsWith)) {
                isGroupRelevant = true;
                switch (resource.getState()) {
                case IGNORED: // means a considered resource was found and it is invalid
                    // still the other resources need to be evaluated
                case INSTALL:
                    if (!configuration.allowIgnoredArtifactsInGroup()) {
                        reportInvalidResource(resource, resourceType, hcLog);
                    } else {
                        if (invalidResource == null) {
                            invalidResource = resource;
                        }
                    }
                    break;
                default:
                    if (configuration.allowIgnoredArtifactsInGroup()) {
                        // means a considered resource was found and it is valid
                        // no need to evaluate other resources from this group
                        return resourceType;
                    }
                }
            } else {
                LOG.debug("Skipping resource '{}' as its URL is not starting with any of these prefixes '{}'", resource, (Object) configuration.urlPrefixes()); // NOSONAR java:S1905
            }
        }
        if (invalidResource != null && configuration.allowIgnoredArtifactsInGroup()) {
            reportInvalidResource(invalidResource, resourceType, hcLog);
        }
        
        // only return resource type if at least one resource in it belonged to a covered url prefix
        return isGroupRelevant ? resourceType : "";
    }