Examples of MultiStatusResponse


Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

        // TODO: missing undo of successful set/remove if subsequent operation fails
        // NOTE, that this is relevant with transactions only.

        // success: save all changes together if no error occured
        complete();
        return new MultiStatusResponse(getHref(), DavServletResponse.SC_OK);
    }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            response.sendError(DavServletResponse.SC_BAD_REQUEST);
            return;
        }

        MultiStatus ms = new MultiStatus();
        MultiStatusResponse msr = resource.alterProperties(changeList);
        ms.addResponse(msr);
        response.sendMultiStatus(ms);
    }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            throw new DavException(DavServletResponse.SC_LOCKED);
        }
        if (!exists()) {
            throw new DavException(DavServletResponse.SC_NOT_FOUND);
        }
        MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
        boolean success = true;

        // loop over List and remember all properties and propertyNames
        // that have successfully been altered
        List successList = new ArrayList();
        Iterator it = changeList.iterator();
        while (it.hasNext()) {
            Object propEntry = it.next();
            if (propEntry instanceof DavPropertyName) {
                DavPropertyName propName = (DavPropertyName)propEntry;
                try {
                    removeJcrProperty(propName);
                    successList.add(propName);
                } catch (RepositoryException e) {
                    msr.add(propName, new JcrDavException(e).getErrorCode());
                    success = false;
                }
            } else if (propEntry instanceof DavProperty) {
                DavProperty prop = (DavProperty)propEntry;
                try {
                    setJcrProperty(prop);
                    successList.add(prop);
                } catch (RepositoryException e) {
                    msr.add(prop.getName(), new JcrDavException(e).getErrorCode());
                    success = false;
                }
            } else {
                throw new IllegalArgumentException("unknown object in change list: " + propEntry.getClass().getName());
            }
        }

        try {
            if (success) {
                // save all changes together (reverted in case this fails)
                node.save();
            } else {
                // set/remove of at least a single prop failed: undo modifications.
                node.refresh(false);
            }
            /* loop over list of properties/names that were successfully altered
               and them to the multistatus response respecting the resulte of the
               complete action. in case of failure set the status to 'failed-dependency'
               in order to indicate, that altering those names/properties would
               have succeeded, if no other error occured.*/
            it = successList.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                int status = (success) ? DavServletResponse.SC_OK : DavServletResponse.SC_FAILED_DEPENDENCY;
                if (o instanceof DavProperty) {
                    msr.add(((DavProperty) o).getName(), status);
                } else {
                    msr.add((DavPropertyName) o, status);
                }
            }
            return msr;
        } catch (RepositoryException e) {
            // revert any changes made so far an throw exception
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            // add resources to the multistatus, that failed to be merged
            while (failed.hasNext()) {
                Node failedNode = failed.nextNode();
                DavResourceLocator loc = getLocatorFromItem(failedNode);
                DavResource res = createResourceFromLocator(loc);
                ms.addResponse(new MultiStatusResponse(res, mergeInfo.getPropertyNameSet()));
            }

        } catch (RepositoryException e) {
            throw new JcrDavException(e);
        }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            while (events.hasNext()) {
                try {
                    Event e = events.nextEvent();
                    DavResourceLocator loc = getLocatorFromItemPath(e.getPath());
                    DavResource res = createResourceFromLocator(loc);
                    ms.addResponse(new MultiStatusResponse(res, propNameSet));

                } catch (DavException e) {
                    // should not occur
                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
                } catch (RepositoryException e) {
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            } else {
                throw new IllegalArgumentException("unknown object in change list: " + propEntry.getClass().getName());
            }
        }
        complete();
        return new MultiStatusResponse(getHref(), DavServletResponse.SC_OK);
    }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

     * @param depth
     * @param ms
     * @see #getResponse(DavResource, Iterator)
     */
    private void addResponses(DavResource res, int depth, MultiStatus ms) {
        MultiStatusResponse response = getResponse(res, propertyElements);
        ms.addResponse(response);
        if (depth > 0) {
            DavResourceIterator it = res.getMembers();
            while (it.hasNext()) {
                addResponses(it.nextResource(), depth-1, ms);
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

     * @param propertyElements
     * @return <code>MultiStatusResponse</code> for the given resource.
     * @see ExpandProperty
     */
    private MultiStatusResponse getResponse(DavResource res, Iterator propertyElements) {
        MultiStatusResponse resp = new MultiStatusResponse(res.getHref(), null);
        while (propertyElements.hasNext()) {
            Element propertyElem = (Element)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;
    }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

        private ExpandProperty(DeltaVResource deltaVResource, HrefProperty hrefProperty, ElementIterator elementIter) {
            super(hrefProperty.getName(), hrefProperty.isProtected());
            try {
                DavResource[] refResource = deltaVResource.getReferenceResources(hrefProperty.getName());
                for (int i = 0; i < refResource.length; i++) {
                    MultiStatusResponse resp = getResponse(refResource[i], elementIter);
                    valueList.add(resp);
                }
            } catch (DavException e) {
                // invalid references or unknown property
                log.error(e.getMessage());
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

            MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
            if (responses.length < 1) {
                throw new ItemNotFoundException("Unable to retrieve the node with id " + saveGetIdString(nodeId, sessionInfo));
            }

            MultiStatusResponse nodeResponse = null;
            List<MultiStatusResponse> childResponses = new ArrayList<MultiStatusResponse>();
            for (MultiStatusResponse response : responses) {
                if (isSameResource(uri, response)) {
                    nodeResponse = response;
                } else {
                    childResponses.add(response);
                }
            }

            if (nodeResponse == null) {
                throw new ItemNotFoundException("Unable to retrieve the node " + saveGetIdString(nodeId, sessionInfo));
            }

            DavPropertySet propSet = nodeResponse.getProperties(DavServletResponse.SC_OK);
            Object type = propSet.get(DavPropertyName.RESOURCETYPE).getValue();
            if (type == null) {
                // the given id points to a Property instead of a Node
                throw new ItemNotFoundException("No node for id " + saveGetIdString(nodeId, sessionInfo));
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.