Search in sources :

Example 1 with BaselineResource

use of org.apache.jackrabbit.webdav.version.BaselineResource in project jackrabbit by apache.

the class CompareBaselineReport method init.

/**
     *
     * @param resource
     * @param info
     * @throws DavException
     * @see Report#init(DavResource, ReportInfo)
     */
public void init(DavResource resource, ReportInfo info) throws DavException {
    // validate info
    if (!getType().isRequestedReportType(info)) {
        throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:compare-baseline element expected.");
    }
    // make sure the report is applied to a version history resource
    if (resource != null && (resource instanceof BaselineResource)) {
        this.requestBaseline = (BaselineResource) resource;
    } else {
        throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:compare-baseline report can only be created for a baseline resource.");
    }
    // make sure the DAV:href element inside the request body points to
    // an baseline resource (precondition for this report).
    String compareHref = DomUtil.getText(info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE));
    DavResourceLocator locator = resource.getLocator();
    DavResourceLocator compareLocator = locator.getFactory().createResourceLocator(locator.getPrefix(), compareHref);
    DavResource compRes = resource.getFactory().createResource(compareLocator, resource.getSession());
    if (compRes instanceof BaselineResource) {
        compareBaseline = (BaselineResource) compRes;
    } else {
        throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:latest-activity-version report: The DAV:href in the request body MUST identify an activity.");
    }
// TODO: eventually add check for 'same-baseline-history' (RFC: "A server MAY require that the baselines being compared be from the same baseline history.")
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) BaselineResource(org.apache.jackrabbit.webdav.version.BaselineResource) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Aggregations

DavException (org.apache.jackrabbit.webdav.DavException)1 DavResource (org.apache.jackrabbit.webdav.DavResource)1 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)1 BaselineResource (org.apache.jackrabbit.webdav.version.BaselineResource)1