/**
* @see RepositoryService#submit(Batch)
*/
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;
}
DavMethod method = null;
try {
HttpClient client = batchImpl.start();
boolean success = false;
try {
Iterator<DavMethod> it = batchImpl.methods();
while (it.hasNext()) {
method = it.next();
initMethod(method, batchImpl, true);
client.executeMethod(method);
method.checkSuccess();
method.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, method);
} finally {
batchImpl.dispose();
}