org.apache.jackrabbit.webdav.property.DavPropertyNameIterator Java Examples

The following examples show how to use org.apache.jackrabbit.webdav.property.DavPropertyNameIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractWebdavServlet.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * The PROPFIND method
 * 
 * @param request the HTTP request
 * @param response the server's response
 * @param resource the DAV resource
 * 
 * @throws IOException generic I/O error
 */
protected void doPropFind(WebdavRequest request, WebdavResponse response, DavResource resource)
		throws IOException, DavException {

	log.debug("doPropFind");
	if (log.isDebugEnabled())
		log.debug("[READ] FINDING {} {}",
				(resource.isCollection() ? "DOCUMENTS WITHIN THE FOLDER" : "JUST THE DOCUMENT"),
				resource.getDisplayName());

	if (!resource.exists()) {
		log.warn("Resource not found: {}", resource.getResourcePath());
		response.sendError(DavServletResponse.SC_NOT_FOUND);
		return;
	}

	DavPropertyNameSet requestProperties = request.getPropFindProperties();

	if (log.isDebugEnabled()) {
		DavPropertyNameIterator iter = requestProperties.iterator();
		StringBuffer sb = new StringBuffer("Requested properties: ");
		while (iter.hasNext()) {
			sb.append(((DavPropertyName) iter.next()).getName());
			sb.append(",");
		}
		log.debug(sb.toString());
	}

	int propfindType = request.getPropFindType();

	int depth = Context.get().getProperties().getInt("webdav.depth", 1);
	String headerDepth = request.getHeader("Depth");
	if (StringUtils.isNotEmpty(headerDepth)) {
		if ("infinity".equals(headerDepth))
			depth = request.getDepth(DEPTH_INFINITY);
		else {
			depth = Integer.parseInt(headerDepth);
		}
	}

	MultiStatus mstatus = new MultiStatus();
	mstatus.addResourceProperties(resource, requestProperties, propfindType, depth);

	response.sendMultiStatus(mstatus);
}