use of org.apache.sling.api.resource.runtime.dto.RuntimeDTO 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>");
}
}
}
use of org.apache.sling.api.resource.runtime.dto.RuntimeDTO in project sling by apache.
the class ResourceProviderTrackerTest method fillDto.
@Test
public void fillDto() throws Exception {
RuntimeDTO dto = new RuntimeDTO();
tracker.fill(dto);
assertThat(dto.providers, arrayWithSize(2));
assertThat(dto.failedProviders, arrayWithSize(1));
}
use of org.apache.sling.api.resource.runtime.dto.RuntimeDTO 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();
}
}
use of org.apache.sling.api.resource.runtime.dto.RuntimeDTO in project sling by apache.
the class RuntimeServiceImpl method getRuntimeDTO.
@Override
public RuntimeDTO getRuntimeDTO() {
final RuntimeDTO dto = new RuntimeDTO();
tracker.fill(dto);
return dto;
}
Aggregations