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);
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations