use of org.apache.jackrabbit.webdav.client.methods.HttpMerge 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();
}
}
}
Aggregations