protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
String propertyName = request.getParameter("property");
if ("".equals(propertyName) || propertyName == null)
throw new ResourceNotFoundException("No property specified.");
ServletOutputStream out = response.getOutputStream();
Resource resource = request.getResource();
Node currentNode = resource.adaptTo(Node.class);
javax.jcr.Property property = null;
try {
property = currentNode.getProperty(propertyName);
} catch (PathNotFoundException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found.");
throw new ResourceNotFoundException("Not found.");
} catch (RepositoryException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found.");
throw new ResourceNotFoundException("Not found.");
}
InputStream stream = null;
try {
if (property == null || property.getType() != PropertyType.BINARY) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found.");
throw new ResourceNotFoundException("Not found.");
}
long length = property.getLength();
if (length > 0) {
if (length < Integer.MAX_VALUE) {
response.setContentLength((int) length);