Search in sources :

Example 1 with FailureReason

use of org.apache.sling.api.resource.runtime.dto.FailureReason in project sling by apache.

the class ResourceProviderTracker method fill.

public void fill(final RuntimeDTO dto) {
    final List<ResourceProviderDTO> dtos = new ArrayList<ResourceProviderDTO>();
    final List<ResourceProviderFailureDTO> failures = new ArrayList<ResourceProviderFailureDTO>();
    synchronized (this.handlers) {
        for (final List<ResourceProviderHandler> handlers : this.handlers.values()) {
            boolean isFirst = true;
            for (final ResourceProviderHandler h : handlers) {
                final ResourceProviderDTO d;
                if (isFirst) {
                    d = new ResourceProviderDTO();
                    dtos.add(d);
                    isFirst = false;
                } else {
                    d = new ResourceProviderFailureDTO();
                    ((ResourceProviderFailureDTO) d).reason = FailureReason.shadowed;
                    failures.add((ResourceProviderFailureDTO) d);
                }
                fill(d, h);
            }
        }
    }
    synchronized (this.invalidProviders) {
        for (final Map.Entry<ResourceProviderInfo, FailureReason> entry : this.invalidProviders.entrySet()) {
            final ResourceProviderFailureDTO d = new ResourceProviderFailureDTO();
            fill(d, entry.getKey());
            d.reason = entry.getValue();
            failures.add(d);
        }
    }
    dto.providers = dtos.toArray(new ResourceProviderDTO[dtos.size()]);
    dto.failedProviders = failures.toArray(new ResourceProviderFailureDTO[failures.size()]);
}
Also used : ResourceProviderFailureDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderFailureDTO) ResourceProviderDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO) FailureReason(org.apache.sling.api.resource.runtime.dto.FailureReason) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 FailureReason (org.apache.sling.api.resource.runtime.dto.FailureReason)1 ResourceProviderDTO (org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO)1 ResourceProviderFailureDTO (org.apache.sling.api.resource.runtime.dto.ResourceProviderFailureDTO)1