com.linecorp.centraldogma.internal.Util.isValidFilePath()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中com.linecorp.centraldogma.internal.Util.isValidFilePath()方法的一些代码示例,展示了Util.isValidFilePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isValidFilePath()方法的具体详情如下:
包路径:com.linecorp.centraldogma.internal.Util
类名称:Util
方法名:isValidFilePath

Util.isValidFilePath介绍

暂无

代码示例

代码示例来源:origin: line/centraldogma

public static String validateFilePath(String path, String paramName) {
  requireNonNull(path, paramName);
  if (isValidFilePath(path)) {
    return path;
  }
  throw new IllegalArgumentException(
      paramName + ": " + path + " (expected: " + FILE_PATH_PATTERN.pattern() + ')');
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-common

public static String validateFilePath(String path, String paramName) {
  requireNonNull(path, paramName);
  if (isValidFilePath(path)) {
    return path;
  }
  throw new IllegalArgumentException(
      paramName + ": " + path + " (expected: " + FILE_PATH_PATTERN.pattern() + ')');
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-common-shaded

public static String validateFilePath(String path, String paramName) {
  requireNonNull(path, paramName);
  if (isValidFilePath(path)) {
    return path;
  }
  throw new IllegalArgumentException(
      paramName + ": " + path + " (expected: " + FILE_PATH_PATTERN.pattern() + ')');
}

代码示例来源:origin: line/centraldogma

/**
 * Normalizes the path according to the following order.
 * <ul>
 *   <li>if the path is {@code null}, empty string or "/", normalize to {@code "/*"}</li>
 *   <li>if the path is a valid file path, return the path as it is</li>
 *   <li>if the path is a valid directory path, append "*" at the end</li>
 * </ul>
 */
private static String normalizePath(String path) {
  if (path == null || path.isEmpty() || "/".equals(path)) {
    return "/*";
  }
  if (isValidFilePath(path)) {
    return path;
  }
  if (isValidDirPath(path)) {
    if (path.endsWith("/")) {
      return path + '*';
    } else {
      return path + "/*";
    }
  }
  return path;
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

/**
 * Normalizes the path according to the following order.
 * <ul>
 *   <li>if the path is {@code null}, empty string or "/", normalize to {@code "/*"}</li>
 *   <li>if the path is a valid file path, return the path as it is</li>
 *   <li>if the path is a valid directory path, append "*" at the end</li>
 * </ul>
 */
private static String normalizePath(String path) {
  if (path == null || path.isEmpty() || "/".equals(path)) {
    return "/*";
  }
  if (isValidFilePath(path)) {
    return path;
  }
  if (isValidDirPath(path)) {
    if (path.endsWith("/")) {
      return path + '*';
    } else {
      return path + "/*";
    }
  }
  return path;
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

/**
 * Normalizes the path according to the following order.
 * <ul>
 *   <li>if the path is {@code null}, empty string or "/", normalize to {@code "/*"}</li>
 *   <li>if the path is a valid file path, return the path as it is</li>
 *   <li>if the path is a valid directory path, append "*" at the end</li>
 * </ul>
 */
private static String normalizePath(String path) {
  if (path == null || path.isEmpty() || "/".equals(path)) {
    return "/*";
  }
  if (isValidFilePath(path)) {
    return path;
  }
  if (isValidDirPath(path)) {
    if (path.endsWith("/")) {
      return path + '*';
    } else {
      return path + "/*";
    }
  }
  return path;
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

/**
 * Converts the specified {@code request} to {@link Optional} which contains {@link Query} when
 * the request has a valid file path. {@link Optional#EMPTY} otherwise.
 */
@Override
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
               Class<?> expectedResultType) throws Exception {
  final String path = getPath(ctx);
  final Optional<Iterable<String>> jsonPaths = getJsonPaths(ctx);
  if (jsonPaths.isPresent()) {
    return Optional.of(Query.ofJsonPath(path, jsonPaths.get()));
  }
  if (isValidFilePath(path)) {
    return Optional.of(Query.of(QueryType.IDENTITY, path));
  }
  return Optional.empty();
}

代码示例来源:origin: line/centraldogma

private static void listFiles(Repository repository, String pathPattern, Revision normalizedRevision,
               Map<FindOption<?>, ?> options, CompletableFuture<List<EntryDto<?>>> result) {
  repository.find(normalizedRevision, pathPattern, options).handle((entries, thrown) -> {
    if (thrown != null) {
      result.completeExceptionally(thrown);
      return null;
    }
    // If the pathPattern is a valid file path and the result is a directory, the client forgets to add
    // "/*" to the end of the path. So, let's do it and invoke once more.
    // This is called once at most, because the pathPattern is not a valid file path anymore.
    if (isValidFilePath(pathPattern) && entries.size() == 1 &&
      entries.values().iterator().next().type() == DIRECTORY) {
      listFiles(repository, pathPattern + "/*", normalizedRevision, options, result);
    } else {
      result.complete(entries.values().stream()
                  .map(entry -> convert(repository, entry))
                  .collect(toImmutableList()));
    }
    return null;
  });
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

private static void listFiles(Repository repository, String pathPattern, Revision normalizedRevision,
               Map<FindOption<?>, ?> options, CompletableFuture<List<EntryDto<?>>> result) {
  repository.find(normalizedRevision, pathPattern, options).handle((entries, thrown) -> {
    if (thrown != null) {
      result.completeExceptionally(thrown);
      return null;
    }
    // If the pathPattern is a valid file path and the result is a directory, the client forgets to add
    // "/*" to the end of the path. So, let's do it and invoke once more.
    // This is called once at most, because the pathPattern is not a valid file path anymore.
    if (isValidFilePath(pathPattern) && entries.size() == 1 &&
      entries.values().iterator().next().type() == DIRECTORY) {
      listFiles(repository, pathPattern + "/*", normalizedRevision, options, result);
    } else {
      result.complete(entries.values().stream()
                  .map(entry -> convert(repository, entry))
                  .collect(toImmutableList()));
    }
    return null;
  });
}

代码示例来源:origin: line/centraldogma

/**
 * Converts the specified {@code request} to {@link Optional} which contains {@link Query} when
 * the request has a valid file path. {@link Optional#EMPTY} otherwise.
 */
@Override
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
               Class<?> expectedResultType) throws Exception {
  final String path = getPath(ctx);
  final Optional<Iterable<String>> jsonPaths = getJsonPaths(ctx);
  if (jsonPaths.isPresent()) {
    return Optional.of(Query.ofJsonPath(path, jsonPaths.get()));
  }
  if (isValidFilePath(path)) {
    return Optional.of(Query.of(QueryType.IDENTITY, path));
  }
  return Optional.empty();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

/**
 * Converts the specified {@code request} to {@link Optional} which contains {@link Query} when
 * the request has a valid file path. {@link Optional#EMPTY} otherwise.
 */
@Override
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
               Class<?> expectedResultType) throws Exception {
  final String path = getPath(ctx);
  final Optional<Iterable<String>> jsonPaths = getJsonPaths(ctx);
  if (jsonPaths.isPresent()) {
    return Optional.of(Query.ofJsonPath(path, jsonPaths.get()));
  }
  if (isValidFilePath(path)) {
    return Optional.of(Query.of(QueryType.IDENTITY, path));
  }
  return Optional.empty();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

private static void listFiles(Repository repository, String pathPattern, Revision normalizedRevision,
               Map<FindOption<?>, ?> options, CompletableFuture<List<EntryDto<?>>> result) {
  repository.find(normalizedRevision, pathPattern, options).handle(voidFunction((entries, thrown) -> {
    if (thrown != null) {
      result.completeExceptionally(thrown);
      return;
    }
    // If the pathPattern is a valid file path and the result is a directory, the client forgets to add
    // "/*" to the end of the path. So, let's do it and invoke once more.
    // This is called once at most, because the pathPattern is not a valid file path anymore.
    if (isValidFilePath(pathPattern) && entries.size() == 1 &&
      entries.values().iterator().next().type() == DIRECTORY) {
      listFiles(repository, pathPattern + "/*", normalizedRevision, options, result);
    } else {
      result.complete(entries.values().stream()
                  .map(entry -> convert(repository, entry))
                  .collect(toImmutableList()));
    }
  }));
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

if (!Util.isValidFilePath(localPath)) {
  continue;

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

if (!Util.isValidFilePath(localPath)) {
  continue;

代码示例来源:origin: line/centraldogma

if (!Util.isValidFilePath(localPath)) {
  continue;

相关文章