本文整理汇总了Java中org.apache.commons.vfs2.FileType.FILE属性的典型用法代码示例。如果您正苦于以下问题:Java FileType.FILE属性的具体用法?Java FileType.FILE怎么用?Java FileType.FILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.vfs2.FileType
的用法示例。
在下文中一共展示了FileType.FILE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGetType
/**
* Determines the type of the file, returns null if the file does not
* exist.
*/
@Override
protected FileType doGetType() throws Exception
{
if (!file.exists())
{
return FileType.IMAGINARY;
}
else if (file.isDirectory())
{
return FileType.FOLDER;
}
else if (file.isFile())
{
return FileType.FILE;
}
throw new FileSystemException("vfs.provider.Nfs/get-type.error", getName());
}
示例2: doGetType
/**
* Determines the type of the file, returns null if the file does not exist.
*
* @return the file type
*
* @throws Exception the exception
*/
@Override
protected FileType doGetType() throws Exception {
// log.debug("relative path:" + relPath);
if (this.fileInfo == null) {
return FileType.IMAGINARY;
} else if (this.fileInfo.isDirectory()) {
return FileType.FOLDER;
} else if (this.fileInfo.isFile()) {
return FileType.FILE;
} else if (this.fileInfo.isSoftLink()) {
return FileType.FILE; // getLinkDestination().getType();
}
throw new FileSystemException("vfs.provider.gsiftp/get-type.error", getName());
}
示例3: doGetType
/**
* Determines the type of the file, returns null if the file does not
* exist.
*/
@Override
protected FileType doGetType() throws Exception
{
if (part == null)
{
return FileType.IMAGINARY;
}
if (isMultipart())
{
// we cant have children ...
return FileType.FILE_OR_FOLDER;
}
return FileType.FILE;
}
示例4: doGetType
/**
* Determines the type of the file, returns null if the file does not
* exist.
*/
@Override
protected FileType doGetType() throws Exception
{
if (!file.exists())
{
return FileType.IMAGINARY;
}
else if (file.isDirectory())
{
return FileType.FOLDER;
}
else if (file.isFile())
{
return FileType.FILE;
}
throw new FileSystemException("vfs.provider.smb/get-type.error", getName());
}
示例5: setZipEntry
/**
* Sets the details for this file object.
*/
protected void setZipEntry(final ZipEntry entry)
{
if (this.entry != null)
{
return;
}
if ((entry == null) || (entry.isDirectory()))
{
type = FileType.FOLDER;
}
else
{
type = FileType.FILE;
}
this.entry = entry;
}
示例6: doGetType
/**
* Returns the file's type.
*/
@Override
protected FileType doGetType() throws Exception
{
// JDK BUG: 6192331
// if (!file.exists())
if (!file.exists() && file.length() < 1)
{
return FileType.IMAGINARY;
}
if (file.isDirectory())
{
return FileType.FOLDER;
}
// In doubt, treat an existing file as file
// if (file.isFile())
// {
return FileType.FILE;
// }
// throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
示例7: doDelete
/**
* Deletes the file.
*/
@Override
protected void doDelete() throws Exception
{
final ChannelSftp channel = fileSystem.getChannel();
try
{
if (getType() == FileType.FILE)
{
channel.rm(relPath);
}
else
{
channel.rmdir(relPath);
}
}
finally
{
fileSystem.putChannel(channel);
}
}
示例8: doGetType
/**
* Determines the type of this file. Must not return null. The return
* value of this method is cached, so the implementation can be expensive.
*/
@Override
protected FileType doGetType() throws Exception
{
// Use the HEAD method to probe the file.
method = new HeadMethod();
setupMethod(method);
final HttpClient client = fileSystem.getClient();
final int status = client.executeMethod(method);
method.releaseConnection();
if (status == HttpURLConnection.HTTP_OK)
{
return FileType.FILE;
}
else if (status == HttpURLConnection.HTTP_NOT_FOUND
|| status == HttpURLConnection.HTTP_GONE)
{
return FileType.IMAGINARY;
}
else
{
throw new FileSystemException("vfs.provider.http/head.error", getName());
}
}
示例9: setTarEntry
/**
* Sets the details for this file object.
*/
protected void setTarEntry(final TarEntry entry)
{
if (this.entry != null)
{
return;
}
if ((entry == null) || (entry.isDirectory()))
{
type = FileType.FOLDER;
}
else
{
type = FileType.FILE;
}
this.entry = entry;
}
示例10: doGetType
/** Returns the file's type. */
@Override
protected FileType doGetType() throws Exception {
// JDK BUG: 6192331
// if (!file.exists())
if (!file.exists() && file.length() < 1) {
return FileType.IMAGINARY;
}
if (file.isDirectory()) {
return FileType.FOLDER;
}
// In doubt, treat an existing file as file
// if (file.isFile())
// {
return FileType.FILE;
// }
// throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
示例11: FSManager
private FSManager() throws IOException {
fsManager = VFS.getManager();
final FileObject basePath =
fsManager.resolveFile(RES_PREFIX + File.separatorChar + ODataServiceVersion.V40.name());
final String absoluteBaseFolder = basePath.getURL().getPath();
for (FileObject fo : find(basePath, null)) {
if (fo.getType() == FileType.FILE
&& !fo.getName().getBaseName().contains("Metadata")
&& !fo.getName().getBaseName().contains("metadata")) {
final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + ODataServiceVersion.V40.name());
putInMemory(fo.getContent().getInputStream(), path);
}
}
}
示例12: getEnvFileToRead
private FileObject getEnvFileToRead(FileObject sourcePath) {
if (sourcePath.getType() == FileType.FILE && sourcePath.isReadable() && sourcePath.getName().getExtension().equalsIgnoreCase("xml")) {
return sourcePath;
} else {
return sourcePath.getChild("system-config.xml");
}
}
示例13: moveFile
/**
* Move the files
*
* @param source Location of the file
* @param destination Destination of the file
* @return return a resultStatus
*/
private boolean moveFile(String source, String destination, MessageContext messageContext,
boolean includeParentDirectory, String filePattern) {
boolean resultStatus = false;
StandardFileSystemManager manager = null;
try {
manager = FileConnectorUtils.getManager();
// Create remote object
FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
if (remoteFile.exists()) {
if (remoteFile.getType() == FileType.FILE) {
fileMove(destination, remoteFile, messageContext, manager);
} else {
folderMove(source, destination, filePattern, includeParentDirectory, messageContext, manager);
}
resultStatus = true;
if (log.isDebugEnabled()) {
log.debug("File move completed from " + source + " to " + destination);
}
} else {
log.error("The file/folder location does not exist.");
resultStatus = false;
}
} catch (IOException e) {
handleException("Unable to move a file/folder.", e, messageContext);
} finally {
if (manager != null) {
manager.close();
}
}
return resultStatus;
}
示例14: folderMove
/**
* Move the folder
*
* @param destination New location of the folder
* @param source Location of the folder
* @param messageContext The message context that is processed by a handler in the handle method
* @param includeParentDirectory Boolean type
* @param manager Standard file system manager
*/
private void folderMove(String source, String destination, String filePattern, boolean includeParentDirectory,
MessageContext messageContext, StandardFileSystemManager manager) throws IOException {
FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
if (StringUtils.isNotEmpty(filePattern)) {
FileObject[] children = remoteFile.getChildren();
for (FileObject child : children) {
if (child.getType() == FileType.FILE) {
moveFileWithPattern(child, destination, filePattern, manager, messageContext);
} else if (child.getType() == FileType.FOLDER) {
String newSource = source + File.separator + child.getName().getBaseName();
folderMove(newSource, destination, filePattern, includeParentDirectory, messageContext, manager);
}
}
} else if (includeParentDirectory) {
file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
FileConnectorUtils.init(messageContext));
file.createFolder();
remoteFile.moveTo(file);
} else {
if (!file.exists()) {
file.createFolder();
}
remoteFile.moveTo(file);
remoteFile.createFolder();
}
}
示例15: deleteFile
/**
* Delete the file repsented by the file parameter.
*
* @param file the file
*
* @return true, if successful
* @throws MotuException
*/
public boolean deleteFile(FileObject file) throws MotuException {
if (LOG.isDebugEnabled()) {
LOG.debug("deleteFile(FileObject) - entering");
}
boolean deleted = false;
try {
if (file.exists()) {
if (file.getType() != FileType.FILE) {
throw new MotuException(
ErrorType.NETCDF_LOADING,
String.format("Delete file '%s' is rejected: it is a folder. ", file.getName().toString()));
}
deleted = file.delete();
}
} catch (FileSystemException e) {
LOG.error("deleteFile(FileObject)", e);
// throw new MotuException(String.format("Unable to copy file '%s' to '%s'",
// foSrc.getURL().toString(), foDest.getURL().toString()), e);
throw new MotuException(ErrorType.NETCDF_LOADING, String.format("Unable to delete '%s'", file.getName().toString()), e);
}
if (LOG.isDebugEnabled()) {
LOG.debug("deleteFile(FileObject) - exiting");
}
return deleted;
}