예제 #1
0
  public DAVLock refreshLock(DAVResource resource, String lockToken, Date newTime)
      throws DAVException {
    // TODO: add here authz check
    FSFS fsfs = resource.getFSFS();
    String path = resource.getResourceURI().getPath();

    FSLock svnLock = null;
    try {
      svnLock = (FSLock) fsfs.getLockHelper(path, false);
    } catch (SVNException e) {
      throw DAVException.convertError(
          e.getErrorMessage(),
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          "Token doesn't point to a lock.",
          null);
    }

    if (svnLock == null || !svnLock.getID().equals(lockToken)) {
      throw new DAVException(
          "Lock refresh request doesn't match existing lock.",
          HttpServletResponse.SC_UNAUTHORIZED,
          DAVErrorCode.LOCK_SAVE_LOCK);
    }

    try {
      svnLock =
          (FSLock)
              fsfs.lockPath(
                  svnLock.getPath(),
                  svnLock.getID(),
                  resource.getUserName(),
                  svnLock.getComment(),
                  newTime,
                  SVNRepository.INVALID_REVISION,
                  true,
                  svnLock.isDAVComment());
    } catch (SVNException e) {
      SVNErrorMessage err = e.getErrorMessage();
      if (err.getErrorCode() == SVNErrorCode.FS_NO_USER) {
        throw new DAVException(
            "Anonymous lock refreshing is not allowed.",
            HttpServletResponse.SC_UNAUTHORIZED,
            DAVErrorCode.LOCK_SAVE_LOCK);
      }
      throw DAVException.convertError(
          err,
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          "Failed to refresh existing lock.",
          null);
    }
    return convertSVNLockToDAVLock(svnLock, false, resource.exists());
  }