Search in sources :

Example 1 with ResourceProviderDTO

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

the class ResourceResolverWebConsolePlugin method dumpDTOsHtml.

private void dumpDTOsHtml(final PrintWriter pw) {
    titleHtml(pw, "Resource Providers", "Lists all available and activate resource prodivers.");
    pw.println("<tr class='content'>");
    pw.println("<th class='content'>Provider</th>");
    pw.println("<th class='content'>Path</th>");
    pw.println("<th class='content'>Configuration</th>");
    pw.println("</tr>");
    final RuntimeDTO runtimeDTO = this.runtimeService.getRuntimeDTO();
    for (final ResourceProviderDTO dto : runtimeDTO.providers) {
        // get service reference
        final ServiceReference<ResourceProvider<?>> ref = this.getServiceReference(dto.serviceId);
        final StringBuilder sb = new StringBuilder();
        if (dto.name != null) {
            sb.append(dto.name);
            sb.append(' ');
        } else {
            sb.append("<unnamed> ");
        }
        if (ref != null) {
            sb.append("(serviceId = ");
            sb.append(dto.serviceId);
            sb.append(", bundleId = ");
            sb.append(ref.getBundle().getBundleId());
            sb.append(")");
        }
        pw.print("<tr class='content'>");
        pw.print("<td class='content' style='vertical-align: top'>");
        pw.print(ResponseUtil.escapeXml(sb.toString()));
        pw.print("</td>");
        pw.print("<td class='content' style='vertical-align: top'>");
        pw.print(ResponseUtil.escapeXml(dto.path));
        pw.print("</td>");
        pw.print("<td class='content' style='vertical-align: top'>");
        pw.print("auth=");
        pw.print(dto.authType.name());
        pw.print("<br/>");
        pw.print("adaptable=");
        pw.print(dto.adaptable);
        pw.print("<br/>");
        pw.print("attributable=");
        pw.print(dto.attributable);
        pw.print("<br/>");
        pw.print("modifiable=");
        pw.print(dto.modifiable);
        pw.print("<br/>");
        pw.print("refreshable=");
        pw.print(dto.refreshable);
        pw.print("<br/>");
        pw.print("supportsQueryLanguage=");
        pw.print(dto.supportsQueryLanguage);
        pw.print("<br/>");
        pw.print("useResourceAccessSecurity=");
        pw.print(dto.useResourceAccessSecurity);
        pw.println("</td></tr>");
    }
    if (runtimeDTO.failedProviders.length > 0) {
        titleHtml(pw, "Failed Resource Providers", "Lists all failed providers.");
        pw.println("<tr class='content'>");
        pw.println("<th class='content'>Provider</th>");
        pw.println("<th class='content'>Path</th>");
        pw.println("<th class='content'>Reason</th>");
        pw.println("</tr>");
        for (final ResourceProviderFailureDTO dto : runtimeDTO.failedProviders) {
            // get service reference
            final ServiceReference<ResourceProvider<?>> ref = this.getServiceReference(dto.serviceId);
            final StringBuilder sb = new StringBuilder();
            if (dto.name != null) {
                sb.append(dto.name);
                sb.append(' ');
            } else {
                sb.append("<unnamed> ");
            }
            if (ref != null) {
                sb.append("(serviceId = ");
                sb.append(dto.serviceId);
                sb.append(", bundleId = ");
                sb.append(ref.getBundle().getBundleId());
                sb.append(")");
            }
            pw.print("<tr class='content'>");
            pw.print("<td class='content' style='vertical-align: top'>");
            pw.print(ResponseUtil.escapeXml(sb.toString()));
            pw.print("</td>");
            pw.print("<td class='content' style='vertical-align: top'>");
            pw.print(ResponseUtil.escapeXml(dto.path));
            pw.print("</td>");
            pw.print("<td class='content' style='vertical-align: top'>");
            pw.print(dto.reason.name());
            pw.println("</td></tr>");
        }
    }
}
Also used : ResourceProviderFailureDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderFailureDTO) ResourceProviderDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO) ResourceProvider(org.apache.sling.spi.resource.provider.ResourceProvider) RuntimeDTO(org.apache.sling.api.resource.runtime.dto.RuntimeDTO)

Example 2 with ResourceProviderDTO

use of org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO 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)

Example 3 with ResourceProviderDTO

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

the class ResourceResolverWebConsolePlugin method dumpDTOsText.

private void dumpDTOsText(final PrintWriter pw) {
    pw.println("Resource Providers");
    final String format = "%35s %25s %15s\r\n";
    pw.printf(format, "Provider", "Path", "Configuration");
    final RuntimeDTO runtimeDTO = this.runtimeService.getRuntimeDTO();
    for (final ResourceProviderDTO dto : runtimeDTO.providers) {
        // get service reference
        final ServiceReference<ResourceProvider<?>> ref = this.getServiceReference(dto.serviceId);
        final StringBuilder sb = new StringBuilder();
        if (dto.name != null) {
            sb.append(dto.name);
            sb.append(' ');
        } else {
            sb.append("<unnamed> ");
        }
        if (ref != null) {
            sb.append("(serviceId = ");
            sb.append(dto.serviceId);
            sb.append(", bundleId = ");
            sb.append(ref.getBundle().getBundleId());
            sb.append(")");
        }
        final StringBuilder config = new StringBuilder();
        config.append("auth=");
        config.append(dto.authType.name());
        config.append(", adaptable=");
        config.append(dto.adaptable);
        config.append(", attributable=");
        config.append(dto.attributable);
        config.append(", modifiable=");
        config.append(dto.modifiable);
        config.append(", refreshable=");
        config.append(dto.refreshable);
        config.append(", supportsQueryLanguage=");
        config.append(dto.supportsQueryLanguage);
        config.append(", useResourceAccessSecurity=");
        config.append(dto.useResourceAccessSecurity);
        pw.printf(format, sb.toString(), dto.path, config.toString());
    }
    pw.println();
    if (runtimeDTO.failedProviders.length > 0) {
        pw.println("Failed Resource Providers");
        pw.printf(format, "Provider", "Path", "Reason");
        for (final ResourceProviderFailureDTO dto : runtimeDTO.failedProviders) {
            // get service reference
            final ServiceReference<ResourceProvider<?>> ref = this.getServiceReference(dto.serviceId);
            final StringBuilder sb = new StringBuilder();
            if (dto.name != null) {
                sb.append(dto.name);
                sb.append(' ');
            } else {
                sb.append("<unnamed> ");
            }
            if (ref != null) {
                sb.append("(serviceId = ");
                sb.append(dto.serviceId);
                sb.append(", bundleId = ");
                sb.append(ref.getBundle().getBundleId());
                sb.append(")");
            }
            pw.printf(format, sb.toString(), dto.path, dto.reason.name());
        }
        pw.println();
    }
}
Also used : ResourceProviderFailureDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderFailureDTO) ResourceProviderDTO(org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO) ResourceProvider(org.apache.sling.spi.resource.provider.ResourceProvider) RuntimeDTO(org.apache.sling.api.resource.runtime.dto.RuntimeDTO)

Aggregations

ResourceProviderDTO (org.apache.sling.api.resource.runtime.dto.ResourceProviderDTO)3 ResourceProviderFailureDTO (org.apache.sling.api.resource.runtime.dto.ResourceProviderFailureDTO)3 RuntimeDTO (org.apache.sling.api.resource.runtime.dto.RuntimeDTO)2 ResourceProvider (org.apache.sling.spi.resource.provider.ResourceProvider)2 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