Search in sources :

Example 6 with FileInfo

use of org.apache.crail.metadata.FileInfo in project incubator-crail by apache.

the class CoreDataStore method _listEntries.

public DirectoryInputStream _listEntries(String name, boolean randomize) throws Exception {
    FileName directory = new FileName(name);
    if (CrailConstants.DEBUG) {
        LOG.info("getDirectoryList: " + name);
    }
    RpcGetFile fileRes = rpcConnection.getFile(directory, false).get(CrailConstants.RPC_TIMEOUT, TimeUnit.MILLISECONDS);
    if (fileRes.getError() != RpcErrors.ERR_OK) {
        LOG.info("getDirectoryList: " + RpcErrors.messages[fileRes.getError()]);
        throw new FileNotFoundException(RpcErrors.messages[fileRes.getError()]);
    }
    FileInfo dirInfo = fileRes.getFile();
    if (!dirInfo.getType().isContainer()) {
        LOG.info("getDirectoryList: " + RpcErrors.messages[RpcErrors.ERR_FILE_IS_NOT_DIR]);
        throw new FileNotFoundException(RpcErrors.messages[RpcErrors.ERR_FILE_IS_NOT_DIR]);
    }
    CoreDirectory dirFile = new CoreDirectory(this, dirInfo, name);
    DirectoryInputStream inputStream = dirFile.getDirectoryInputStream(randomize);
    return inputStream;
}
Also used : FileInfo(org.apache.crail.metadata.FileInfo) FileName(org.apache.crail.metadata.FileName) FileNotFoundException(java.io.FileNotFoundException) RpcGetFile(org.apache.crail.rpc.RpcGetFile)

Aggregations

FileInfo (org.apache.crail.metadata.FileInfo)6 IOException (java.io.IOException)3 BlockInfo (org.apache.crail.metadata.BlockInfo)3 FileNotFoundException (java.io.FileNotFoundException)1 FileName (org.apache.crail.metadata.FileName)1 RpcGetFile (org.apache.crail.rpc.RpcGetFile)1