List of usage examples for org.apache.commons.vfs2 FileType equals
public boolean equals(Object obj)
From source file:net.sf.jabb.web.action.VfsTreeAction.java
/** * Populate a node./*from w ww .j a v a 2s. c o m*/ * @param root Relative root directory. * @param file The file object. * @return The node data structure which presents the file. * @throws FileSystemException */ protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException { boolean noChild = true; FileType type = file.getType(); if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)) { noChild = file.getChildren().length == 0; } String relativePath = root.getName().getRelativeName(file.getName()); return populateTreeNodeData(file, noChild, relativePath); }
From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GsiFtpFileObject.java
/** * Called when the children of this file change. * //ww w . j a v a2 s. c om * @param child the child * @param newType the new type */ @Override protected void onChildrenChanged(FileName child, FileType newType) { if (children != null && newType.equals(FileType.IMAGINARY)) { try { children.remove(UriParser.decode(child.getBaseName())); } catch (FileSystemException e) { throw new RuntimeException(e.getMessage()); } } else { // if child was added we have to rescan the children // TODO - get rid of this children = null; } }
From source file:org.cloudifysource.esc.installer.filetransfer.VfsFileTransfer.java
@Override public void copyFiles(final InstallationDetails details, final Set<String> excludedFiles, final List<File> additionalFiles, final long endTimeMillis) throws TimeoutException, InstallerException { logger.fine("Copying files to: " + host + " from local dir: " + localDir.getName().getPath() + " excluding " + excludedFiles.toString()); try {//from w ww .ja v a2 s . c o m if (remoteDir.exists()) { FileType type = remoteDir.getType(); if (!type.equals(FileType.FOLDER)) { throw new InstallerException("The remote location: " + remoteDir.getName().getFriendlyURI() + " exists but is not a directory"); } if (deleteRemoteDirectoryContents) { logger.info("Deleting contents of remote directory: " + remoteDir.getName().getFriendlyURI()); remoteDir.delete(new FileDepthSelector(1, Integer.MAX_VALUE)); } FileObject[] children = remoteDir.getChildren(); if (children.length > 0) { throw new InstallerException( "The remote directory: " + remoteDir.getName().getFriendlyURI() + " is not empty"); } } remoteDir.copyFrom(localDir, new FileSelector() { @Override public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { if (excludedFiles.contains(fileInfo.getFile().getName().getBaseName())) { logger.fine(fileInfo.getFile().getName().getBaseName() + " excluded"); return false; } final FileObject remoteFile = fileSystemManager.resolveFile(remoteDir, localDir.getName().getRelativeName(fileInfo.getFile().getName())); if (!remoteFile.exists()) { logger.fine(fileInfo.getFile().getName().getBaseName() + " missing on server"); return true; } if (fileInfo.getFile().getType() == FileType.FILE) { final long remoteSize = remoteFile.getContent().getSize(); final long localSize = fileInfo.getFile().getContent().getSize(); final boolean res = localSize != remoteSize; if (res) { logger.fine(fileInfo.getFile().getName().getBaseName() + " different on server"); } return res; } return false; } @Override public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } }); for (final File file : additionalFiles) { logger.fine("copying file: " + file.getAbsolutePath() + " to remote directory"); final FileObject fileObject = fileSystemManager.resolveFile("file:" + file.getAbsolutePath()); final FileObject remoteFile = remoteDir.resolveFile(file.getName()); remoteFile.copyFrom(fileObject, new AllFileSelector()); } logger.fine("Copying files to: " + host + " completed."); } catch (final FileSystemException e) { throw new InstallerException("Failed to copy files to remote host " + host + ": " + e.getMessage(), e); } checkTimeout(endTimeMillis); }
From source file:org.pentaho.googledrive.vfs.GoogleDriveFileObject.java
private void resolveFileMetadata() throws Exception { String parentId = null;//from w w w . j a va 2 s . c om 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; } } }
From source file:pl.otros.vfs.browser.table.FileObjectComparator.java
private int compareTypes(FileType type1, FileType type2) { if (type1.equals(FileType.FILE) && !type2.equals(FileType.FILE)) { return 1; } else if (!type1.equals(FileType.FILE) && type2.equals(FileType.FILE)) { return -1; }/* w w w .jav a 2 s .co m*/ return 0; }