use of org.apache.jackrabbit.webdav.MultiStatus in project jackrabbit by apache.
the class URIResolverImpl method getItemUri.
String getItemUri(ItemId itemId, String workspaceName, SessionInfo sessionInfo) throws RepositoryException {
IdURICache cache = getCache(workspaceName);
// check if uri is available from cache
if (cache.containsItemId(itemId)) {
return cache.getUri(itemId);
} else {
StringBuffer uriBuffer = new StringBuffer();
Path path = itemId.getPath();
String uniqueID = itemId.getUniqueID();
// resolver uuid part
if (uniqueID != null) {
ItemId uuidId = (path == null) ? itemId : service.getIdFactory().createNodeId(uniqueID);
if (path != null && cache.containsItemId(uuidId)) {
// append uri of parent node, that is already cached
uriBuffer.append(cache.getUri(uuidId));
} else {
// try to request locate-by-uuid report to build the uri
ReportInfo rInfo = new ReportInfo(JcrRemotingConstants.REPORT_LOCATE_BY_UUID, ItemResourceConstants.NAMESPACE);
rInfo.setContentElement(DomUtil.hrefToXml(uniqueID, domFactory));
HttpReport request = null;
try {
String wspUri = getWorkspaceUri(workspaceName);
request = new HttpReport(wspUri, rInfo);
HttpResponse response = service.executeRequest(sessionInfo, request);
request.checkSuccess(response);
MultiStatus ms = request.getResponseBodyAsMultiStatus(response);
if (ms.getResponses().length == 1) {
String absoluteUri = resolve(wspUri, ms.getResponses()[0].getHref());
uriBuffer.append(absoluteUri);
cache.add(absoluteUri, uuidId);
} else {
throw new ItemNotFoundException("Cannot identify item with uniqueID " + uniqueID);
}
} catch (IOException e) {
throw new RepositoryException(e.getMessage());
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
} else {
// start build uri from root-item
uriBuffer.append(getRootItemUri(workspaceName));
}
// resolve relative-path part unless it denotes the root-item
if (path != null && !path.denotesRoot()) {
String jcrPath = service.getNamePathResolver(sessionInfo).getJCRPath(path);
if (!path.isAbsolute() && !uriBuffer.toString().endsWith("/")) {
uriBuffer.append("/");
}
uriBuffer.append(Text.escapePath(jcrPath));
}
String itemUri = uriBuffer.toString();
if (!cache.containsItemId(itemId)) {
cache.add(itemUri, itemId);
}
return itemUri;
}
}
use of org.apache.jackrabbit.webdav.MultiStatus in project jackrabbit by apache.
the class RFC4918PropfindTest method testPropfindInclude.
public void testPropfindInclude() throws IOException, DavException, URISyntaxException {
String testuri = this.root + "iftest";
int status;
try {
HttpPut put = new HttpPut(testuri);
put.setEntity(new StringEntity("1"));
status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
assertEquals("status: " + status, 201, status);
DavPropertyNameSet names = new DavPropertyNameSet();
names.add(DeltaVConstants.COMMENT);
HttpPropfind propfind = new HttpPropfind(testuri, DavConstants.PROPFIND_ALL_PROP_INCLUDE, names, 0);
HttpResponse resp = this.client.execute(propfind, this.context);
status = resp.getStatusLine().getStatusCode();
assertEquals(207, status);
MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(resp);
MultiStatusResponse[] responses = multistatus.getResponses();
assertEquals(1, responses.length);
MultiStatusResponse response = responses[0];
DavPropertySet found = response.getProperties(200);
DavPropertySet notfound = response.getProperties(404);
assertTrue(found.contains(DeltaVConstants.COMMENT) || notfound.contains(DeltaVConstants.COMMENT));
} finally {
delete(testuri);
}
}
use of org.apache.jackrabbit.webdav.MultiStatus in project jackrabbit by apache.
the class ExpandPropertyReport method getMultiStatus.
/**
* Retrieve the multistatus object that is returned in response to the
* expand-property report request.
*
* @return
* @throws NullPointerException if info and resource have not been set.
*/
private MultiStatus getMultiStatus() {
MultiStatus ms = new MultiStatus();
addResponses(resource, info.getDepth(), ms);
return ms;
}
use of org.apache.jackrabbit.webdav.MultiStatus in project jackrabbit by apache.
the class AbstractWebdavServlet method doUpdate.
/**
* The UPDATE method
*
* @param request
* @param response
* @param resource
* @throws DavException
* @throws IOException
*/
protected void doUpdate(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
if (!(resource instanceof VersionControlledResource)) {
response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
UpdateInfo info = request.getUpdateInfo();
MultiStatus ms = ((VersionControlledResource) resource).update(info);
response.sendMultiStatus(ms);
}
use of org.apache.jackrabbit.webdav.MultiStatus 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);
}
Aggregations