Пример #1
0
  /**
   * Creates a new lock for the specified resource.
   *
   * @param db database
   * @param p path
   * @param scope lock scope
   * @param type lock type
   * @param depth lock depth
   * @param user lock user
   * @param to lock timeout
   * @return lock token
   * @throws IOException I/O exception
   */
  public String lock(
      final String db,
      final String p,
      final String scope,
      final String type,
      final String depth,
      final String user,
      final Long to)
      throws IOException {

    initLockDb();
    final String token = UUID.randomUUID().toString();

    final WebDAVQuery query =
        new WebDAVQuery(
            "w:create-lock(" + "$path, $token, $scope, $type, $depth, $owner,$timeout)");
    query.bind("path", db + SEP + p);
    query.bind("token", token);
    query.bind("scope", scope);
    query.bind("type", type);
    query.bind("depth", depth);
    query.bind("owner", user);
    query.bind("timeout", to == null ? Long.MAX_VALUE : to);
    execute(query);
    return token;
  }