in src/main/java/com/microsoft/azure/datalake/store/Core.java [691:779]
public static DirectoryEntry getFileStatus(String path,
UserGroupRepresentation oidOrUpn,
ADLStoreClient client,
RequestOptions opts,
OperationResponse resp) {
QueryParams qp = new QueryParams();
if (oidOrUpn == null) oidOrUpn = UserGroupRepresentation.OID;
String tooid = (oidOrUpn == UserGroupRepresentation.OID)? "true" : "false";
qp.add("tooid", tooid);
HttpTransport.makeCall(client, Operation.GETFILESTATUS, path, qp, null, 0, 0, opts, resp);
if (resp.successful) {
try {
String name = "";
String fullName = "";
long length = 0;
String group = "";
String user = "";
Date lastAccessTime = null;
Date lastModifiedTime = null;
DirectoryEntryType type = null;
String permission = "";
int replicationFactor = 1;
long blocksize = 256 * 1024 * 1024;
boolean aclBit = true;
Date expiryTime = null;
String fileContextId = null;
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createParser(resp.responseStream);
String fieldName, fieldValue;
jp.nextToken();
while (jp.hasCurrentToken()) {
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
fieldName = jp.getCurrentName();
jp.nextToken();
fieldValue = jp.getText();
if (fieldName.equals("length")) length = Long.parseLong(fieldValue);
if (fieldName.equals("type")) type = DirectoryEntryType.valueOf(fieldValue);
if (fieldName.equals("accessTime")) lastAccessTime = new Date(Long.parseLong(fieldValue));
if (fieldName.equals("modificationTime")) lastModifiedTime = new Date(Long.parseLong(fieldValue));
if (fieldName.equals("permission")) permission = fieldValue;
if (fieldName.equals("owner")) user = fieldValue;
if (fieldName.equals("group")) group = fieldValue;
if (fieldName.equals("blockSize")) blocksize = Long.parseLong(fieldValue);
if (fieldName.equals("replication")) replicationFactor = Integer.parseInt(fieldValue);
if (fieldName.equals("aclBit")) aclBit = Boolean.parseBoolean(fieldValue);
if (fieldName.equals("msExpirationTime")) {
long expiryms = Long.parseLong(fieldValue);
if (expiryms > 0) expiryTime = new Date(expiryms);
}
if (fieldName.equals("fileContextID")) {
fileContextId = fieldValue;
}
}
jp.nextToken();
}
jp.close();
fullName = path;
name = path.substring(path.lastIndexOf("/")+1);
return new DirectoryEntry(name,
fullName,
length,
group,
user,
lastAccessTime,
lastModifiedTime,
type,
blocksize,
replicationFactor,
permission,
aclBit,
expiryTime,
fileContextId);
} catch (IOException ex) {
resp.successful = false;
resp.message = "Unexpected error happened reading response stream or parsing JSon from getFileStatus()";
} finally {
try {
resp.responseStream.close();
} catch (IOException ex) {
//swallow since it is only the closing of the stream
}
}
}
return null;
}