Package org.apache.jackrabbit.webdav

Examples of org.apache.jackrabbit.webdav.DavException


     * @see DavResource#unlock(String)
     */
    public void unlock(String lockToken) throws DavException {
        ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
        if (lock == null) {
            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
        } else if (lock.isLockedByToken(lockToken)) {
            if (lock instanceof JcrActiveLock) {
                try {
                    node.unlock();
                } catch (RepositoryException e) {
                    throw new JcrDavException(e);
                }
            } else {
                lockManager.releaseLock(lockToken, this);
            }
        } else {
            throw new DavException(DavServletResponse.SC_LOCKED);
        }
    }
View Full Code Here


    /**
     * @see Report#init(DavResource, ReportInfo)
     */
    public void init(DavResource resource, ReportInfo info) throws DavException {
        if (resource == null || !(resource instanceof VersionControlledResource)) {
            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:version-tree report can only be created for version-controlled resources and version resources.");
        }
        this.resource = resource;
        setInfo(info);
    }
View Full Code Here

     * @throws DavException if the given <code>ReportInfo</code>
     * does not contain a DAV:version-tree element.
     */
    private void setInfo(ReportInfo info) throws DavException {
        if (info == null || !getType().isRequestedReportType(info)) {
            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:locate-by-history element expected.");
        }
        Element versionHistorySet = info.getContentElement(XML_VERSION_HISTORY_SET, NAMESPACE);
        if (versionHistorySet == null) {
            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "The DAV:locate-by-history element must contain a DAV:version-history-set child.");
        }
        ElementIterator it = DomUtil.getChildren(versionHistorySet, DavConstants.XML_HREF, DavConstants.NAMESPACE);
        while (it.hasNext()) {
            String href = DomUtil.getText(it.nextElement());
            if (href != null && !"".equals(href)) {
View Full Code Here

                if (request.matchesIfHeader(resource.getHref(), activeLocks[i].getToken(), etag)) {
                    lList.add(resource.refreshLock(lockInfo, activeLocks[i].getToken()));
                }
            }
            if (lList.isEmpty()) {
                throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
            }
            ActiveLock[] refreshedLocks = (ActiveLock[]) lList.toArray(new ActiveLock[lList.size()]);
            response.sendRefreshLockResponse(refreshedLocks);
        } else {
            // create a new lock
View Full Code Here

     * or not a DAV:merge element.
     */
    public MergeInfo(Element mergeElement) throws DavException {
        if (!DomUtil.matches(mergeElement, XML_MERGE, NAMESPACE)) {
            log.warn("'DAV:merge' element expected");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        // if property name set if present
        Element propElem = DomUtil.getChildElement(mergeElement, DavConstants.XML_PROP, DavConstants.NAMESPACE);
        if (propElem != null) {
View Full Code Here

     * or not a DAV:options element.
     */
    public static OptionsInfo createFromXml(Element optionsElement) throws DavException {
        if (!DomUtil.matches(optionsElement, DeltaVConstants.XML_OPTIONS, DeltaVConstants.NAMESPACE)) {
            log.warn("DAV:options element expected");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }
        OptionsInfo oInfo = new OptionsInfo();
        ElementIterator it = DomUtil.getChildren(optionsElement);
        while (it.hasNext()) {
            // todo: not correct since assuming its the deltaV-namespace
View Full Code Here

     * @throws DavException if the report element is <code>null</code>.
     */
    public ReportInfo(Element reportElement, int depth) throws DavException {
        if (reportElement == null) {
            log.warn("Report request body must not be null.");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        this.typeLocalName = reportElement.getLocalName();
        this.typeNamespace = DomUtil.getNamespace(reportElement);
        this.depth = depth;
View Full Code Here

     * @throws IllegalArgumentException if the specified Xml element was not valid.
     */
    public static OrderPatch createFromXml(Element orderPatchElement) throws DavException {
        if (!DomUtil.matches(orderPatchElement, XML_ORDERPATCH, NAMESPACE)) {
            log.warn("ORDERPATH request body must start with an 'orderpatch' element.");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        // retrieve the href of the orderingtype element
        String orderingType;
        Element otype = DomUtil.getChildElement(orderPatchElement, XML_ORDERING_TYPE, NAMESPACE);
        if (otype != null) {
            orderingType = DomUtil.getChildText(otype, DavConstants.XML_HREF, DavConstants.NAMESPACE);
        } else {
            log.warn("ORDERPATH request body must contain an 'ordering-type' child element.");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        // set build the list of ordering instructions
        List tmpList = new ArrayList();
        ElementIterator it = DomUtil.getChildren(orderPatchElement, XML_ORDER_MEMBER, NAMESPACE);
        while (it.hasNext()) {
            Element el = it.nextElement();
            try {
                // retrieve text 'DAV:segment' child of this DAV:order-member element
                String segment = DomUtil.getChildText(el, XML_SEGMENT, NAMESPACE);
                // retrieve the 'DAV:position' child element
                Position pos = Position.createFromXml(DomUtil.getChildElement(el, XML_POSITION, NAMESPACE));
                Member om = new Member(segment, pos);
                tmpList.add(om);
            } catch (IllegalArgumentException e) {
                log.warn("Invalid element in 'orderpatch' request body: " + e.getMessage());
                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
            }
        }
        Member[] instructions = (Member[]) tmpList.toArray(new Member[tmpList.size()]);
        return new OrderPatch(orderingType, instructions);
    }
View Full Code Here

     * structure.
     */
    public UpdateInfo(Element updateElement) throws DavException {
        if (!DomUtil.matches(updateElement, XML_UPDATE, NAMESPACE)) {
            log.warn("DAV:update element expected");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        boolean done = false;
        ElementIterator it = DomUtil.getChildren(updateElement, XML_VERSION, NAMESPACE);
            while (it.hasNext()) {
            List hrefList = new ArrayList();
            Element el = it.nextElement();
            hrefList.add(DomUtil.getChildText(el, DavConstants.XML_HREF, DavConstants.NAMESPACE));
            versionHref = (String[])hrefList.toArray(new String[hrefList.size()]);
            done = true;
        }

        // alternatively 'DAV:label-name' elements may be present.
        if (!done) {
            it = DomUtil.getChildren(updateElement, XML_LABEL_NAME, NAMESPACE);
            while (it.hasNext()) {
                List labelList = new ArrayList();
                Element el = it.nextElement();
                labelList.add(DomUtil.getText(el));
                labelName = (String[])labelList.toArray(new String[labelList.size()]);
                done = true;
            }
        }

        // last possibility: a DAV:workspace element
        if (!done) {
            Element wspElem = DomUtil.getChildElement(updateElement, XML_WORKSPACE, NAMESPACE);
            if (wspElem != null) {
                workspaceHref = DomUtil.getChildTextTrim(wspElem, DavConstants.XML_HREF, DavConstants.NAMESPACE);
        } else {
                log.warn("DAV:update element must contain either DAV:version, DAV:label-name or DAV:workspace child element.");
                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }
        }

        // if property name set if present
        if (DomUtil.hasChildElement(updateElement, DavConstants.XML_PROP, DavConstants.NAMESPACE)) {
View Full Code Here

     * or DAV:remove elements.
     */
    public LabelInfo(Element labelElement, int depth) throws DavException {
        if (!DomUtil.matches(labelElement, DeltaVConstants.XML_LABEL, DeltaVConstants.NAMESPACE)) {
            log.warn("DAV:label element expected");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }

        String label = null;
        int type = -1;
        for (int i = 0; i < typeNames.length && type == -1; i++) {
            if (DomUtil.hasChildElement(labelElement, typeNames[i], NAMESPACE)) {
                type = i;
                Element el = DomUtil.getChildElement(labelElement, typeNames[i], NAMESPACE);
                label = DomUtil.getChildText(el, XML_LABEL_NAME, NAMESPACE);
            }
            }
        if (label == null) {
            log.warn("DAV:label element must contain at least one set, add or remove element defining a label-name.");
            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
        }
        this.labelName = label;
        this.type = type;
        this.depth = depth;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.webdav.DavException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.