Examples of MultiStatusResponse


Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

        }
        if (!exists()) {
            throw new DavException(DavServletResponse.SC_NOT_FOUND);
        }

        MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
        boolean success = true;

        // loop over set and remove Sets and remember all properties and propertyNames
        // that have successfully been altered
        List successList = new ArrayList();
        DavPropertyIterator setIter = setProperties.iterator();
        while (setIter.hasNext()) {
            DavProperty prop = setIter.nextProperty();
            try {
                setJcrProperty(prop);
                successList.add(prop);
            } catch (RepositoryException e) {
                msr.add(prop.getName(), new JcrDavException(e).getErrorCode());
                success = false;
            }
        }

        Iterator remNameIter = removePropertyNames.iterator();
        while (remNameIter.hasNext()) {
            DavPropertyName propName = (DavPropertyName) remNameIter.next();
            try {
                removeJcrProperty(propName);
                successList.add(propName);
            } catch (RepositoryException e) {
                msr.add(propName, new JcrDavException(e).getErrorCode());
                success = false;
            }
        }

        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.*/
            Iterator 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

            return;
        }

        MultiStatus ms = new MultiStatus();
        try {
            MultiStatusResponse msr = resource.alterProperties(setProperties, removeProperties);
            ms.addResponse(msr);
        } catch (DavException e) {
            /* NOTE: known bug with litmus, which expects the exception (e.g. 423)
               to the set instead of the MultiStatus Code. RFC 2518 explicitely
               expects the errors to be included in the multistatus.
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

            // a webdav compliant resource path of it.
            String itemPath = row.getValue(JcrConstants.JCR_PATH).getString();
            // create a new ms-response for this row of the result set
            DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), itemPath, false);
            String href = loc.getHref(true);
            MultiStatusResponse resp = new MultiStatusResponse(href, null);
            // build the s-r-property
            SearchResultProperty srp = new SearchResultProperty(columnNames, values);
            resp.add(srp);
            ms.addResponse(resp);
        }
        return ms;
    }
View Full Code Here

Examples of org.apache.jackrabbit.webdav.MultiStatusResponse

        while (setIter.hasNext()) {
            DavProperty prop = setIter.nextProperty();
            internalSetProperty(prop);
        }
        complete();
        return new MultiStatusResponse(getHref(), DavServletResponse.SC_OK);
    }
View Full Code Here

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

            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

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

            throw new DavException(DavServletResponse.SC_LOCKED);
        }
        if (!exists()) {
            throw new DavException(DavServletResponse.SC_NOT_FOUND);
        }
        MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
        try {
            Map failures = config.getPropertyManager().alterProperties(getPropertyImportContext(changeList), isCollection());
            if (failures.isEmpty()) {
                // 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.*/
            Iterator it = changeList.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                int statusCode;
                if (failures.containsKey(o)) {
                    Object error = failures.get(o);
                    statusCode = (error instanceof RepositoryException)
                        ? new JcrDavException((RepositoryException) error).getErrorCode()
                        : DavServletResponse.SC_INTERNAL_SERVER_ERROR;
                } else {
                    statusCode = (failures.isEmpty()) ? DavServletResponse.SC_OK : DavServletResponse.SC_FAILED_DEPENDENCY;
                }
                if (o instanceof DavProperty) {
                    msr.add(((DavProperty) o).getName(), statusCode);
                } else {
                    msr.add((DavPropertyName) o, statusCode);
                }
            }
            return msr;
        } catch (RepositoryException e) {
            // revert any changes made so far an throw exception
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.