use of org.apache.jackrabbit.webdav.client.methods.BaseDavRequest in project jackrabbit by apache.
the class RepositoryServiceImpl method submit.
@Override
public void submit(Batch batch) throws RepositoryException {
if (!(batch instanceof BatchImpl)) {
throw new RepositoryException("Unknown Batch implementation.");
}
BatchImpl batchImpl = (BatchImpl) batch;
if (batchImpl.isEmpty()) {
batchImpl.dispose();
return;
}
HttpRequestBase request = null;
try {
HttpClient client = batchImpl.start();
boolean success = false;
try {
Iterator<HttpRequestBase> it = batchImpl.requests();
while (it.hasNext()) {
request = it.next();
initMethod(request, batchImpl, true);
HttpResponse response = client.execute(request);
if (request instanceof BaseDavRequest) {
((BaseDavRequest) request).checkSuccess(response);
} else {
// use generic HTTP status code checking
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
throw new DavException(statusCode, "Unexpected status code " + statusCode + " in response to " + request.getMethod() + " request.");
}
}
request.releaseConnection();
}
success = true;
} finally {
// make sure the lock is removed. if any of the methods
// failed the unlock is used to abort any pending changes
// on the server.
batchImpl.end(client, success);
}
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e, request);
} finally {
batchImpl.dispose();
}
}
Aggregations