Search in sources :

Example 11 with FileType

use of org.geotoolkit.gml.xml.v321.FileType in project commons-vfs by apache.

the class LayeredFileNameParser method parseUri.

/**
 * Parses the base and name into a FileName.
 *
 * @param context The component context.
 * @param baseFileName The base FileName.
 * @param fileName name The target file name.
 * @return The constructed FileName.
 * @throws FileSystemException if an error occurs.
 */
@Override
public FileName parseUri(final VfsComponentContext context, final FileName baseFileName, final String fileName) throws FileSystemException {
    final StringBuilder name = new StringBuilder();
    // Extract the scheme
    final String scheme = UriParser.extractScheme(context.getFileSystemManager().getSchemes(), fileName, name);
    // Extract the Layered file URI
    final String rootUriName = extractRootName(name);
    FileName rootUri = null;
    if (rootUriName != null) {
        rootUri = context.parseURI(rootUriName);
    }
    // Decode and normalise the path
    UriParser.canonicalizePath(name, 0, name.length(), this);
    UriParser.fixSeparators(name);
    final FileType fileType = UriParser.normalisePath(name);
    final String path = name.toString();
    return new LayeredFileName(scheme, rootUri, path, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType) FileName(org.apache.commons.vfs2.FileName)

Example 12 with FileType

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

the class AzureFileNameParser method parseUri.

@Override
public FileName parseUri(final VfsComponentContext context, FileName base, String filename) throws FileSystemException {
    final StringBuilder name = new StringBuilder();
    Authority auth = null;
    String path = null;
    FileType fileType;
    int eidx = filename.indexOf("@/");
    if (eidx != -1)
        filename = filename.substring(0, eidx + 1) + "windowsazure.com" + filename.substring(eidx + 1);
    String scheme;
    try {
        auth = extractToPath(filename, name);
        if (auth.getUserName() == null) {
            scheme = UriParser.extractScheme(filename, name);
            UriParser.canonicalizePath(name, 0, name.length(), this);
            UriParser.fixSeparators(name);
        } else {
            scheme = auth.getScheme();
        }
        fileType = UriParser.normalisePath(name);
        path = name.toString();
        if (path.equals("")) {
            path = "/";
        }
    } catch (FileSystemException fse) {
        scheme = UriParser.extractScheme(filename, name);
        UriParser.canonicalizePath(name, 0, name.length(), this);
        UriParser.fixSeparators(name);
        fileType = UriParser.normalisePath(name);
        path = name.toString();
    }
    return new AzureFileName(scheme, path, fileType);
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileType(org.apache.commons.vfs2.FileType)

Example 13 with FileType

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

the class S3FileNameParser 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);
    String fullPath = name.toString();
    // Extract bucket name
    final String bucketName = UriParser.extractFirstElement(name);
    return new S3FileName(scheme, bucketName, fullPath, fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 14 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 15 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)

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