Search in sources :

Example 1 with MergeInfo

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

the class AbstractWebdavServlet method doMerge.

/**
 * The MERGE method
 *
 * @param request
 * @param response
 * @param resource
 * @throws DavException
 * @throws IOException
 */
protected void doMerge(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
    if (!(resource instanceof VersionControlledResource)) {
        response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }
    MergeInfo info = request.getMergeInfo();
    MultiStatus ms = ((VersionControlledResource) resource).merge(info);
    response.sendMultiStatus(ms);
}
Also used : MergeInfo(org.apache.jackrabbit.webdav.version.MergeInfo) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus) VersionControlledResource(org.apache.jackrabbit.webdav.version.VersionControlledResource)

Example 2 with MergeInfo

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

the class RepositoryServiceImpl method merge.

@Override
public Iterator<NodeId> merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName, boolean bestEffort, boolean isShallow) throws RepositoryException {
    HttpMerge request = null;
    try {
        Document doc = DomUtil.createDocument();
        String wspHref = obtainAbsolutePathFromUri(uriResolver.getWorkspaceUri(srcWorkspaceName));
        Element mElem = MergeInfo.createMergeElement(new String[] { wspHref }, !bestEffort, false, doc);
        if (isShallow) {
            mElem.appendChild(DomUtil.depthToXml(false, doc));
        }
        MergeInfo mInfo = new MergeInfo(mElem);
        String uri = getItemUri(nodeId, sessionInfo);
        request = new HttpMerge(uri, mInfo);
        initMethod(request, sessionInfo, !isUnLockMethod(request));
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
        MultiStatusResponse[] resps = request.getResponseBodyAsMultiStatus(response).getResponses();
        List<NodeId> failedIds = new ArrayList<NodeId>(resps.length);
        for (MultiStatusResponse resp : resps) {
            String href = resolve(uri, resp.getHref());
            failedIds.add(uriResolver.getNodeId(href, sessionInfo));
        }
        return failedIds.iterator();
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (ParserConfigurationException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : MergeInfo(org.apache.jackrabbit.webdav.version.MergeInfo) DavException(org.apache.jackrabbit.webdav.DavException) Element(org.w3c.dom.Element) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) Document(org.w3c.dom.Document) HttpMerge(org.apache.jackrabbit.webdav.client.methods.HttpMerge) NodeId(org.apache.jackrabbit.spi.NodeId) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 3 with MergeInfo

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

the class WebdavRequestImpl method getMergeInfo.

/**
 * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getMergeInfo()
 */
public MergeInfo getMergeInfo() throws DavException {
    MergeInfo mInfo = null;
    Document requestDocument = getRequestDocument();
    if (requestDocument != null) {
        mInfo = new MergeInfo(requestDocument.getDocumentElement());
    }
    return mInfo;
}
Also used : MergeInfo(org.apache.jackrabbit.webdav.version.MergeInfo) Document(org.w3c.dom.Document)

Aggregations

MergeInfo (org.apache.jackrabbit.webdav.version.MergeInfo)3 Document (org.w3c.dom.Document)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 RepositoryException (javax.jcr.RepositoryException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 HttpResponse (org.apache.http.HttpResponse)1 NodeId (org.apache.jackrabbit.spi.NodeId)1 DavException (org.apache.jackrabbit.webdav.DavException)1 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)1 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)1 HttpMerge (org.apache.jackrabbit.webdav.client.methods.HttpMerge)1 VersionControlledResource (org.apache.jackrabbit.webdav.version.VersionControlledResource)1 Element (org.w3c.dom.Element)1