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);
}
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();
}
}
}
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;
}
Aggregations