Search in sources :

Example 1 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project jackrabbit by apache.

the class VFSTestUtils method deleteAllDescendantFiles.

/**
 * Deletes all the descendant files under the folder.
 * @param folderObject folder object
 * @throws FileSystemException if any file system exception occurs
 * @throws DataStoreException if any file system exception occurs
 */
static void deleteAllDescendantFiles(FileObject folderObject) throws FileSystemException, DataStoreException {
    List<FileObject> children = VFSUtils.getChildFileOrFolders(folderObject);
    FileType fileType;
    for (FileObject child : children) {
        fileType = child.getType();
        if (fileType == FileType.FILE) {
            boolean deleted = child.delete();
            if (!deleted) {
                LOG.warn("File not deleted: {}", child.getName().getFriendlyURI());
            }
        } else if (fileType == FileType.FOLDER) {
            deleteAllDescendantFiles(child);
        }
    }
}
Also used : FileType(org.apache.commons.vfs2.FileType) FileObject(org.apache.commons.vfs2.FileObject)

Example 2 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project pentaho-kettle by pentaho.

the class ConnectionFileNameParser method parseUri.

public static AbstractFileName parseUri(String uri, FileNameParser fileNameParser) throws FileSystemException {
    StringBuilder name = new StringBuilder();
    String scheme = UriParser.extractScheme(uri, name);
    UriParser.canonicalizePath(name, 0, name.length(), fileNameParser);
    UriParser.fixSeparators(name);
    FileType fileType = UriParser.normalisePath(name);
    // Extract the named connection name
    final String connection = UriParser.extractFirstElement(name);
    String path = name.toString();
    return new ConnectionFileName(scheme, connection, path, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 3 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project pentaho-kettle by pentaho.

the class GoogleDriveFileObject method resolveFileMetadata.

private void resolveFileMetadata() throws Exception {
    String parentId = null;
    if (getName().getParent() != null) {
        File parent = searchFile(getName().getParent().getBaseName(), null);
        if (parent != null) {
            FileType mime = MIME_TYPES.get(parent.getMimeType());
            if (mime.equals(FileType.FOLDER)) {
                parentId = parent.getId();
            }
        }
    }
    String fileName = getName().getBaseName();
    File file = searchFile(fileName, parentId);
    if (file != null) {
        mimeType = MIME_TYPES.get(file.getMimeType());
        id = file.getId();
    } else {
        if (getName().getURI().equals(GoogleDriveFileProvider.SCHEME + ":///")) {
            mimeType = FileType.FOLDER;
        }
    }
}
Also used : FileType(org.apache.commons.vfs2.FileType) File(com.google.api.services.drive.model.File)

Example 4 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project pentaho-platform by pentaho.

the class SolutionRepositoryVfsFileObject method getName.

public FileName getName() {
    initFile();
    FileType fileType = null;
    try {
        fileType = getType();
    } catch (Exception ex) {
        fileType = FileType.FOLDER;
    }
    return new SolutionRepositoryFileName(fileRef, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType) UnifiedRepositoryException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException) FileSystemException(org.apache.commons.vfs2.FileSystemException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 5 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project spoofax by metaborg.

the class ResourceAgent method isDirectory.

@Override
public boolean isDirectory(String fn) {
    try {
        final FileObject resource = resourceService.resolve(workingDir, fn);
        final FileType type = resource.getType();
        return type == FileType.FOLDER || type == FileType.FILE_OR_FOLDER;
    } catch (FileSystemException e) {
        throw new RuntimeException("Could not check if file " + fn + " is a directory", e);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileType(org.apache.commons.vfs2.FileType) FileObject(org.apache.commons.vfs2.FileObject)

Aggregations

FileType (org.apache.commons.vfs2.FileType)29 FileSystemException (org.apache.commons.vfs2.FileSystemException)8 FileObject (org.apache.commons.vfs2.FileObject)4 File (com.google.api.services.drive.model.File)2 ArrayList (java.util.ArrayList)2 FileName (org.apache.commons.vfs2.FileName)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 Timestamp (java.sql.Timestamp)1 JAXBElement (javax.xml.bind.JAXBElement)1 FileNotFolderException (org.apache.commons.vfs2.FileNotFolderException)1 AbstractFileName (org.apache.commons.vfs2.provider.AbstractFileName)1 AbstractFileProvider (org.apache.commons.vfs2.provider.AbstractFileProvider)1 FileProvider (org.apache.commons.vfs2.provider.FileProvider)1 LocalFileProvider (org.apache.commons.vfs2.provider.LocalFileProvider)1 DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)1