header.setHeaderValue(HTTPHeader.SVN_VERSION_NAME_HEADER, Long.toString(revision));
}
if (force) {
header.setHeaderValue(HTTPHeader.SVN_OPTIONS_HEADER, "lock-steal");
}
DAVLockHandler handler = new DAVLockHandler();
SVNErrorMessage context = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "Lock request failed");
IHTTPConnection httpConnection = getConnection();
HTTPStatus status = httpConnection.request("LOCK", path, header, body, -1, 0, null, handler, context);
if (status.getError() != null) {
SVNErrorManager.error(status.getError(), SVNLogType.NETWORK);
}
if (status != null) {
String userName = httpConnection.getLastValidCredentials() != null ? httpConnection.getLastValidCredentials().getUserName() : null;
String created = status.getHeader().getFirstHeaderValue(HTTPHeader.CREATION_DATE_HEADER);
if (userName == null || created == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_MALFORMED_DATA, "Incomplete lock data returned");
SVNErrorManager.error(err, SVNLogType.NETWORK);
}
Date createdDate = created != null ? SVNDate.parseDate(created) : null;
return new SVNLock(info.baselinePath, handler.getID(), userName, comment, createdDate, null);
}
return null;
}