Search in sources :

Example 6 with FileType

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

the class S3NFileNameParser 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 S3NFileName(scheme, bucketName, name.toString(), fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 7 with FileType

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

the class DropboxFileNameParser method parseUri.

@Override
public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
    StringBuilder name = new StringBuilder();
    String scheme = UriParser.extractScheme(context.getFileSystemManager().getSchemes(), 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);
    return new DropboxFileName(scheme, name.toString(), fileType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 8 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 9 with FileType

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

the class DelegateFileObject method setFile.

/**
 * Attaches or detaches the target file.
 *
 * @param file The FileObject.
 * @throws Exception if an error occurs.
 */
public void setFile(final FileObject file) throws Exception {
    final FileType oldType = doGetType();
    if (file != null) {
        WeakRefFileListener.installListener(file, this);
    }
    this.fileObject = file;
    maybeTypeChanged(oldType);
}
Also used : FileType(org.apache.commons.vfs2.FileType)

Example 10 with FileType

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

the class AbstractFileObject method moveTo.

/**
 * Moves (rename) the file to another one.
 *
 * @param destFile The target FileObject.
 * @throws FileSystemException if an error occurs.
 */
@Override
public void moveTo(final FileObject destFile) throws FileSystemException {
    if (canRenameTo(destFile)) {
        if (!getParent().isWriteable()) {
            throw new FileSystemException("vfs.provider/rename-parent-read-only.error", getName(), getParent().getName());
        }
    } else if (!isWriteable()) {
        throw new FileSystemException("vfs.provider/rename-read-only.error", getName());
    }
    if (destFile.exists() && !isSameFile(destFile)) {
        destFile.deleteAll();
    // throw new FileSystemException("vfs.provider/rename-dest-exists.error", destFile.getName());
    }
    if (canRenameTo(destFile)) {
        // issue rename on same filesystem
        try {
            attach();
            // remember type to avoid attach
            final FileType srcType = getType();
            doRename(destFile);
            FileObjectUtils.getAbstractFileObject(destFile).handleCreate(srcType);
            // now the destFile is no longer imaginary. force reattach.
            destFile.close();
            // fire delete-events. This file-object (src) is like deleted.
            handleDelete();
        } catch (final RuntimeException re) {
            throw re;
        } catch (final Exception exc) {
            throw new FileSystemException("vfs.provider/rename.error", exc, getName(), destFile.getName());
        }
    } else {
        // different fs - do the copy/delete stuff
        destFile.copyFrom(this, Selectors.SELECT_SELF);
        if ((destFile.getType().hasContent() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE) || destFile.getType().hasChildren() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)) && fileSystem.hasCapability(Capability.GET_LAST_MODIFIED)) {
            destFile.getContent().setLastModifiedTime(this.getContent().getLastModifiedTime());
        }
        deleteSelf();
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileType(org.apache.commons.vfs2.FileType) FileNotFolderException(org.apache.commons.vfs2.FileNotFolderException) PrivilegedActionException(java.security.PrivilegedActionException) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

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