Exemplo n.º 1
0
 /**
  * Write a node to output. Node information includes path, modification, permission, owner and
  * group. For files, it also includes size, replication and block-size.
  */
 static void writeInfo(String parent, HdfsFileStatus i, XMLOutputter doc) throws IOException {
   final SimpleDateFormat ldf = df.get();
   doc.startTag(i.isDir() ? "directory" : "file");
   doc.attribute("path", i.getFullPath(new Path(parent)).toUri().getPath());
   doc.attribute("modified", ldf.format(new Date(i.getModificationTime())));
   doc.attribute("accesstime", ldf.format(new Date(i.getAccessTime())));
   if (!i.isDir()) {
     doc.attribute("size", String.valueOf(i.getLen()));
     doc.attribute("replication", String.valueOf(i.getReplication()));
     doc.attribute("blocksize", String.valueOf(i.getBlockSize()));
   }
   doc.attribute("permission", (i.isDir() ? "d" : "-") + i.getPermission());
   doc.attribute("owner", i.getOwner());
   doc.attribute("group", i.getGroup());
   doc.endTag();
 }
Exemplo n.º 2
0
  /** Build a map from the query string, setting values and defaults. */
  protected Map<String, String> buildRoot(HttpServletRequest request, XMLOutputter doc) {
    final String path = ServletUtil.getDecodedPath(request, "/listPaths");
    final String exclude =
        request.getParameter("exclude") != null ? request.getParameter("exclude") : "\\..*\\.crc";
    final String filter =
        request.getParameter("filter") != null ? request.getParameter("filter") : ".*";
    final boolean recur =
        request.getParameter("recursive") != null
            && "yes".equals(request.getParameter("recursive"));

    Map<String, String> root = new HashMap<String, String>();
    root.put("path", path);
    root.put("recursive", recur ? "yes" : "no");
    root.put("filter", filter);
    root.put("exclude", exclude);
    root.put("time", df.get().format(new Date()));
    root.put("version", VersionInfo.getVersion());
    return root;
  }