use of org.apache.jackrabbit.webdav.version.DeltaVResource in project jackrabbit by apache.
the class ExpandPropertyReport method getResponse.
/**
* Builds a <code>MultiStatusResponse</code> for the given resource respecting
* the properties specified. Any property that represents a {@link HrefProperty}
* is expanded: It's name equals the name of a valid {@link HrefProperty}.
* However the value of that given property (consisting of one or multiple DAV:href elements)
* is replaced by the Xml representation of a separate
* {@link MultiStatusResponse multistatus responses} for the
* resource referenced by the given DAV:href elements. The responses may
* themselves have properties, which are defined by the separate list.
*
* @param res
* @param propertyElements
* @return <code>MultiStatusResponse</code> for the given resource.
* @see ExpandProperty
*/
private MultiStatusResponse getResponse(DavResource res, Iterator<Element> propertyElements) {
MultiStatusResponse resp = new MultiStatusResponse(res.getHref(), null);
while (propertyElements.hasNext()) {
Element propertyElem = propertyElements.next();
// retrieve the localName present in the "name" attribute
String nameAttr = propertyElem.getAttribute(ATTR_NAME);
if (nameAttr == null || "".equals(nameAttr)) {
// NOTE: this is not valid according to the DTD
continue;
}
// retrieve the namespace present in the "namespace" attribute
// NOTE: if this attribute is missing the DAV: namespace represents the default.
String namespaceAttr = propertyElem.getAttribute(ATTR_NAMESPACE);
Namespace namespace = (namespaceAttr != null) ? Namespace.getNamespace(namespaceAttr) : NAMESPACE;
DavPropertyName propName = DavPropertyName.create(nameAttr, namespace);
DavProperty<?> p = res.getProperty(propName);
if (p != null) {
if (p instanceof HrefProperty && res instanceof DeltaVResource) {
ElementIterator it = DomUtil.getChildren(propertyElem, XML_PROPERTY, NAMESPACE);
resp.add(new ExpandProperty((DeltaVResource) res, (HrefProperty) p, it));
} else {
resp.add(p);
}
} else {
resp.add(propName, DavServletResponse.SC_NOT_FOUND);
}
}
return resp;
}
use of org.apache.jackrabbit.webdav.version.DeltaVResource in project jackrabbit by apache.
the class AbstractWebdavServlet method doMkWorkspace.
/**
* The MKWORKSPACE method
*
* @param request
* @param response
* @param resource
* @throws DavException
* @throws IOException
*/
protected void doMkWorkspace(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
if (resource.exists()) {
AbstractWebdavServlet.log.warn("Cannot create a new workspace. Resource already exists.");
response.sendError(DavServletResponse.SC_FORBIDDEN);
return;
}
DavResource parentResource = resource.getCollection();
if (parentResource == null || !parentResource.exists() || !parentResource.isCollection()) {
// parent does not exist or is not a collection
response.sendError(DavServletResponse.SC_CONFLICT);
return;
}
if (!(parentResource instanceof DeltaVResource)) {
response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
((DeltaVResource) parentResource).addWorkspace(resource);
response.setStatus(DavServletResponse.SC_CREATED);
}
use of org.apache.jackrabbit.webdav.version.DeltaVResource in project jackrabbit by apache.
the class AbstractWebdavServlet method doReport.
/**
* The REPORT method
*
* @param request
* @param response
* @param resource
* @throws DavException
* @throws IOException
*/
protected void doReport(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
ReportInfo info = request.getReportInfo();
Report report;
if (resource instanceof DeltaVResource) {
report = ((DeltaVResource) resource).getReport(info);
} else if (resource instanceof AclResource) {
report = ((AclResource) resource).getReport(info);
} else {
response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
int statusCode = (report.isMultiStatusReport()) ? DavServletResponse.SC_MULTI_STATUS : DavServletResponse.SC_OK;
response.sendXmlResponse(report, statusCode);
}
use of org.apache.jackrabbit.webdav.version.DeltaVResource in project jackrabbit by apache.
the class AbstractWebdavServlet method doOptions.
/**
* The OPTION method
*
* @param request
* @param response
* @param resource
*/
protected void doOptions(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
response.addHeader(DavConstants.HEADER_DAV, resource.getComplianceClass());
response.addHeader("Allow", resource.getSupportedMethods());
response.addHeader("MS-Author-Via", DavConstants.HEADER_DAV);
if (resource instanceof SearchResource) {
String[] langs = ((SearchResource) resource).getQueryGrammerSet().getQueryLanguages();
for (String lang : langs) {
response.addHeader(SearchConstants.HEADER_DASL, "<" + lang + ">");
}
}
// with DeltaV the OPTIONS request may contain a Xml body.
OptionsResponse oR = null;
OptionsInfo oInfo = request.getOptionsInfo();
if (oInfo != null && resource instanceof DeltaVResource) {
oR = ((DeltaVResource) resource).getOptionResponse(oInfo);
}
if (oR == null) {
response.setStatus(DavServletResponse.SC_OK);
} else {
response.sendXmlResponse(oR, DavServletResponse.SC_OK);
}
}
Aggregations