HDFS-2424. Added a root element "HdfsFileStatuses" for the response of webhdfs listStatus.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1183175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2011-10-14 00:30:30 +00:00
parent 59df2d48c3
commit c46dbedaf9
3 changed files with 10 additions and 5 deletions

View File

@ -117,9 +117,12 @@ Trunk (unreleased changes)
webhdfs responses. (szetszwo) webhdfs responses. (szetszwo)
HDFS-2428. Convert com.sun.jersey.api.ParamException$QueryParamException HDFS-2428. Convert com.sun.jersey.api.ParamException$QueryParamException
to IllegalArgumentException and response it http BAD_REQUEST in webhdfs. to IllegalArgumentException and response it as http BAD_REQUEST in webhdfs.
(szetszwo) (szetszwo)
HDFS-2424. Added a root element "HdfsFileStatuses" for the response
of webhdfs listStatus. (szetszwo)
Release 0.23.0 - Unreleased Release 0.23.0 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -490,7 +490,8 @@ private static StreamingOutput getListingStream(final NamenodeProtocols np,
@Override @Override
public void write(final OutputStream outstream) throws IOException { public void write(final OutputStream outstream) throws IOException {
final PrintStream out = new PrintStream(outstream); final PrintStream out = new PrintStream(outstream);
out.println("{\"" + HdfsFileStatus.class.getSimpleName() + "\":["); out.println("{\"" + HdfsFileStatus.class.getSimpleName() + "es\":{\""
+ HdfsFileStatus.class.getSimpleName() + "\":[");
final HdfsFileStatus[] partial = first.getPartialListing(); final HdfsFileStatus[] partial = first.getPartialListing();
if (partial.length > 0) { if (partial.length > 0) {
@ -509,7 +510,8 @@ public void write(final OutputStream outstream) throws IOException {
} }
} }
out.println("]}"); out.println();
out.println("]}}");
} }
}; };
} }

View File

@ -404,8 +404,8 @@ public FileStatus[] listStatus(final Path f) throws IOException {
final HttpOpParam.Op op = GetOpParam.Op.LISTSTATUS; final HttpOpParam.Op op = GetOpParam.Op.LISTSTATUS;
final Map<?, ?> json = run(op, f); final Map<?, ?> json = run(op, f);
final Object[] array = (Object[])json.get( final Map<?, ?> rootmap = (Map<?, ?>)json.get(HdfsFileStatus.class.getSimpleName() + "es");
HdfsFileStatus.class.getSimpleName()); final Object[] array = (Object[])rootmap.get(HdfsFileStatus.class.getSimpleName());
//convert FileStatus //convert FileStatus
final FileStatus[] statuses = new FileStatus[array.length]; final FileStatus[] statuses = new FileStatus[array.length];