Example usage for org.apache.commons.vfs FileNotFolderException FileNotFolderException

List of usage examples for org.apache.commons.vfs FileNotFolderException FileNotFolderException

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileNotFolderException FileNotFolderException.

Prototype

public FileNotFolderException(final Object info0) 

Source Link

Usage

From source file:org.jclouds.vfs.provider.blobstore.BlobStoreFileObject.java

@Override
protected FileObject[] doListChildrenResolved() throws Exception {
    // if metadata is null, then the path does not exist, as doAttach would have certainly set
    // this.//from   ww w . j a  v  a  2s . c  o  m
    doAttach();
    if (metadata == null)
        throw new FileNotFolderException(getName());
    ListContainerOptions options = new ListContainerOptions();
    String name = getNameTrimLeadingSlashes();
    if (!name.equals("") && !name.equals("/")) {
        options.inDirectory(name + "/");
        logger.info(String.format(">> list: %s[%s]", getContainer(), name));
    } else {
        logger.info(String.format(">> list: %s", getContainer()));
    }
    Iterable<? extends StorageMetadata> list = lister.execute(getContainer(), options);
    Set<BlobStoreFileObject> children = Sets.newHashSet();
    loop: for (StorageMetadata md : list) {
        if (!md.getName().equals("")) {
            if (name.equals(md.getName()) && md.getType() != StorageType.BLOB) {
                continue loop;
            }
            String childName = Utils.replaceAll(md.getName(), UNDESCRIBED, "");
            BlobStoreFileObject fo = (BlobStoreFileObject) FileObjectUtils
                    .getAbstractFileObject(getFileSystem().resolveFile(getFileSystem().getFileSystemManager()
                            .resolveName(getName(), childName, NameScope.CHILD)));
            children.add(fo);
        }
    }
    logger.info(String.format("<< list: %s", children));
    return children.toArray(new BlobStoreFileObject[] {});
}

From source file:org.jclouds.vfs.provider.blobstore.BlobStoreFileObject.java

@Override
public FileObject[] getChildren() throws FileSystemException {
    if (metadata != null && metadata.getType() == StorageType.BLOB)
        throw new FileNotFolderException(getName());
    if (metadata == null) {
        try {//from ww  w  . j  a  v  a  2  s .  c  om
            FileType type = doGetType();
            if (type == FileType.FILE) {
                throw new FileNotFolderException(getName());
            }
        } catch (Exception ex) {
            Throwables.propagateIfPossible(ex, FileNotFolderException.class);
            throw new FileNotFolderException(getName(), ex);
        }
    }
    return super.getChildren();
}