Пример #1
0
  /**
   * Returns the path of the locked file for the provided lock.
   *
   * <p>Examples:
   *
   * <pre>
   * default://locks@system/repo/master/some/path/to/file.txt.ulock =>
   * default://master@repo/some/path/to/file.txt
   *
   * file:\\locks@system\repo\master\some\path\to\file.txt.ulock =>
   * file:\\master@repo\some\path\to\file.txt
   * </pre>
   *
   * @param lockPath the path of a lock, must not be null.
   * @return the locked path.
   */
  public static Path fromLock(final Path lockPath) {
    checkNotNull("path", lockPath);

    final String uri =
        lockPath
            .toURI()
            .replaceFirst("locks@system(/|\\\\)([^/&^\\\\]*)(/|\\\\)([^/&^\\\\]*)", "$4@$2");

    return PathFactory.newPath(
        lockPath.getFileName().replace(LOCK_FILE_EXTENSION, ""),
        uri.replace(LOCK_FILE_EXTENSION, ""));
  }
Пример #2
0
 public static Path newLock(final Path path) {
   Path lockPath = newLockPath(path);
   return PathFactory.newPath(
       path.getFileName() + LOCK_FILE_EXTENSION, lockPath.toURI() + LOCK_FILE_EXTENSION);
 }