Object[] buffer = new Object[]{"get-lock", path};
write("(w(s))", buffer);
authenticate();
List items = read("l", null, false);
items = (List) items.get(0);
SVNLock lock = SVNReader.getLock(items);
if (lock == null) {
lock = new SVNLock(path, "", null, null, null, null);
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_LOCKED, "No lock on path ''{0}''", path);
if (handler != null) {
handler.handleUnlock(path, lock, err);
}
continue;
}
id = lock.getID();
}
Object[] buffer = new Object[]{"unlock", path, id, Boolean.valueOf(force)};
write("(w(s(s)w))", buffer);
authenticate();
SVNErrorMessage error = null;
try {
read("", null, false);
} catch (SVNException e) {
if (e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_LOCKED) {
error = e.getErrorMessage();
error = SVNErrorMessage.create(error.getErrorCode(), error.getMessageTemplate(), path);
} else {
throw e;
}
}
if (handler != null) {
SVNLock lock = new SVNLock(path, id, null, null, null, null);
handler.handleUnlock(path, lock, error);
}
}
}