in src/main/java/org/apache/sling/servlets/get/impl/helpers/XMLRenderer.java [47:98]
public void render(SlingJakartaHttpServletRequest req, SlingJakartaHttpServletResponse resp) throws IOException {
final Resource r = req.getResource();
if (ResourceUtil.isNonExistingResource(r)) {
throw new ResourceNotFoundException("No data to render.");
}
resp.setContentType(req.getResponseContentType());
resp.setCharacterEncoding("UTF-8");
// are we included?
final boolean isIncluded = req.getAttribute(SlingConstants.ATTR_REQUEST_JAKARTA_SERVLET) != null;
try {
final Node node = r.adaptTo(Node.class);
if (node != null) {
try {
if (req.getRequestPathInfo().getSelectorString() == null
|| req.getRequestPathInfo().getSelectorString().equals(DOCVIEW)) {
// check if response is adaptable to a content handler
final ContentHandler ch = resp.adaptTo(ContentHandler.class);
if (ch == null) {
node.getSession().exportDocumentView(node.getPath(), resp.getOutputStream(), false, false);
} else {
node.getSession().exportDocumentView(node.getPath(), ch, false, false);
}
} else if (req.getRequestPathInfo().getSelectorString().equals(SYSVIEW)) {
// check if response is adaptable to a content handler
final ContentHandler ch = resp.adaptTo(ContentHandler.class);
if (ch == null) {
node.getSession().exportSystemView(node.getPath(), resp.getOutputStream(), false, false);
} else {
node.getSession().exportSystemView(node.getPath(), ch, false, false);
}
} else {
resp.sendError(HttpServletResponse.SC_NO_CONTENT); // NO Content
}
} catch (Exception e) {
throw new ServletException("Unable to export resource as xml: " + r, e);
}
} else {
if (!isIncluded) {
resp.sendError(HttpServletResponse.SC_NO_CONTENT); // NO Content
}
}
} catch (final Throwable t) {
// if the JCR api is not available, we get here
if (!isIncluded) {
resp.sendError(HttpServletResponse.SC_NO_CONTENT); // NO Content
}
}
}