Search in sources :

Example 26 with FileType

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

the class S3AFileNameParser method parseUri.

@Override
public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
    StringBuilder name = new StringBuilder();
    String scheme = UriParser.extractScheme(uri, name);
    UriParser.canonicalizePath(name, 0, name.length(), this);
    // Normalize separators in the path
    UriParser.fixSeparators(name);
    // Normalise the path
    FileType fileType = UriParser.normalisePath(name);
    // Extract bucket name
    final String bucketName = UriParser.extractFirstElement(name);
    return new S3AFileName(scheme, bucketName, name.toString(), fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 27 with FileType

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

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 28 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project big-data-plugin by pentaho.

the class S3FileNameParser method parseUri.

public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
    StringBuilder buffer = new StringBuilder();
    String scheme = UriParser.extractScheme(uri, buffer);
    UriParser.canonicalizePath(buffer, 0, buffer.length(), this);
    // Normalize separators in the path
    UriParser.fixSeparators(buffer);
    // Normalise the path
    FileType fileType = UriParser.normalisePath(buffer);
    // URI includes credentials
    String keys = S3Util.getFullKeysFromURI(buffer.toString());
    if (keys != null) {
        buffer.replace(buffer.indexOf(keys), buffer.indexOf(keys) + keys.length(), "");
    }
    String path = buffer.toString();
    // Extract bucket name
    String bucketName = UriParser.extractFirstElement(buffer);
    if (keys != null) {
        bucketName = keys + bucketName;
        return new S3FileName(scheme, bucketName, buffer.length() == 0 ? path : buffer.toString(), fileType, keys);
    }
    return new S3FileName(scheme, bucketName, path, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 29 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project big-data-plugin by pentaho.

the class S3AFileNameParser method parseUri.

public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
    StringBuilder buffer = new StringBuilder();
    String scheme = UriParser.extractScheme(uri, buffer);
    UriParser.canonicalizePath(buffer, 0, buffer.length(), this);
    // Normalize separators in the path
    UriParser.fixSeparators(buffer);
    // Normalise the path
    FileType fileType = UriParser.normalisePath(buffer);
    // URI includes credentials
    String keys = S3Util.getFullKeysFromURI(buffer.toString());
    if (keys != null) {
        buffer.replace(buffer.indexOf(keys), buffer.indexOf(keys) + keys.length(), "");
    }
    String path = buffer.toString();
    // Extract bucket name
    String bucketName = UriParser.extractFirstElement(buffer);
    if (keys != null) {
        bucketName = keys + bucketName;
        return new S3AFileName(scheme, bucketName, buffer.length() == 0 ? path : buffer.toString(), fileType, keys);
    }
    return new S3AFileName(scheme, bucketName, path, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 30 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project big-data-plugin by pentaho.

the class S3NFileNameParser method parseUri.

public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
    StringBuilder buffer = new StringBuilder();
    String scheme = UriParser.extractScheme(uri, buffer);
    UriParser.canonicalizePath(buffer, 0, buffer.length(), this);
    // Normalize separators in the path
    UriParser.fixSeparators(buffer);
    // Normalise the path
    FileType fileType = UriParser.normalisePath(buffer);
    // URI includes credentials
    String keys = S3Util.getFullKeysFromURI(buffer.toString());
    if (keys != null) {
        buffer.replace(buffer.indexOf(keys), buffer.indexOf(keys) + keys.length(), "");
    }
    String path = buffer.toString();
    // Extract bucket name
    String bucketName = UriParser.extractFirstElement(buffer);
    if (keys != null) {
        bucketName = keys + bucketName;
        return new S3NFileName(scheme, bucketName, buffer.length() == 0 ? path : buffer.toString(), fileType, keys);
    }
    return new S3NFileName(scheme, bucketName, path, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

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