Search in sources :

Example 1 with DeltaVResource

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;
}
Also used : ElementIterator(org.apache.jackrabbit.webdav.xml.ElementIterator) HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) Element(org.w3c.dom.Element) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) DeltaVResource(org.apache.jackrabbit.webdav.version.DeltaVResource) Namespace(org.apache.jackrabbit.webdav.xml.Namespace) DavPropertyName(org.apache.jackrabbit.webdav.property.DavPropertyName)

Example 2 with DeltaVResource

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);
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) DeltaVResource(org.apache.jackrabbit.webdav.version.DeltaVResource)

Example 3 with DeltaVResource

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);
}
Also used : Report(org.apache.jackrabbit.webdav.version.report.Report) AclResource(org.apache.jackrabbit.webdav.security.AclResource) ReportInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo) DeltaVResource(org.apache.jackrabbit.webdav.version.DeltaVResource)

Example 4 with DeltaVResource

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);
    }
}
Also used : DeltaVResource(org.apache.jackrabbit.webdav.version.DeltaVResource) SearchResource(org.apache.jackrabbit.webdav.search.SearchResource) OptionsResponse(org.apache.jackrabbit.webdav.version.OptionsResponse) OptionsInfo(org.apache.jackrabbit.webdav.version.OptionsInfo)

Aggregations

DeltaVResource (org.apache.jackrabbit.webdav.version.DeltaVResource)4 DavResource (org.apache.jackrabbit.webdav.DavResource)1 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)1 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)1 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)1 SearchResource (org.apache.jackrabbit.webdav.search.SearchResource)1 AclResource (org.apache.jackrabbit.webdav.security.AclResource)1 OptionsInfo (org.apache.jackrabbit.webdav.version.OptionsInfo)1 OptionsResponse (org.apache.jackrabbit.webdav.version.OptionsResponse)1 Report (org.apache.jackrabbit.webdav.version.report.Report)1 ReportInfo (org.apache.jackrabbit.webdav.version.report.ReportInfo)1 ElementIterator (org.apache.jackrabbit.webdav.xml.ElementIterator)1 Namespace (org.apache.jackrabbit.webdav.xml.Namespace)1 Element (org.w3c.dom.Element)1