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