Ejemplo n.º 1
0
  public static PathMatcher readRoots() {
    PathMatcher pathMatcher = new PathMatcher();
    String rootString = StringUtil.replace(roots, "\n", ",");
    String[] roots = rootString.split(",");
    for (int i = 0; i < roots.length; i += 2) {
      if (showRoots) System.out.printf("  %-40s %-40s%n", roots[i], roots[i + 1]);
      pathMatcher.put(roots[i], roots[i + 1]);
    }

    return pathMatcher;
  }
Ejemplo n.º 2
0
  public static String getDataroot(String path, int status) {
    if (pathMatcher == null) pathMatcher = readRoots();

    String ss = getServiceSpecial(path);
    if (ss != null) return "service-" + ss;

    if (path.startsWith("//thredds/")) path = path.substring(1);

    if (!path.startsWith("/thredds/")) return "zervice-root";

    String dataRoot = null;
    String spath = path.substring(9); // remove /thredds/
    String service = findService(spath);
    if (service != null) {
      // if (service.equals("radarServer")) dataRoot = "radarServer";
      // else if (service.equals("casestudies")) dataRoot = "casestudies";
      // else if (service.equals("dqc")) dataRoot = "dqc";
      if (spath.length() > service.length()) {
        spath = spath.substring(service.length() + 1);
        PathMatcher.Match match = pathMatcher.match(spath);
        if (match != null) dataRoot = match.root;
      }
    }

    if (dataRoot == null) {
      if (status >= 400) dataRoot = "zBad";
    }

    if (dataRoot == null) {
      service = getService(path);
      dataRoot = (service != null) ? "zervice-" + service : "unknown";
    }
    return dataRoot;
  }
Ejemplo n.º 3
0
  @Override
  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    if (_pathMatcher.matches(file.getFileName())) storeFile(file.toFile());

    return super.visitFile(file, attrs);
  }