public static File asFile( FileObject fileObject ) { return new File( fileObject.getName().getPath() ); } }
public String getPath() { return file.getName().getPath(); }
/** * Returns the file's type. */ protected FileType doGetType() throws FileSystemException { if (getName().getPath().endsWith("/")) { return FileType.FOLDER; } else { return FileType.FILE; } }
@Override public void fileDeleted(FileChangeEvent fileChangeEvent) throws FileSystemException { FileObject fileObject = fileChangeEvent.getFile(); LOGGER.info(String.format("Received file deletion event for file: %s", fileObject)); File file = new File(fileObject.getName().getPath()); if (ConfigFileFilter.isFileSupported(file)) { configurationService.delete(file.getParentFile().getName()); Map<String, Object> params = new HashMap<>(); params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath()); sendEvent(ConfigurationConstants.FILE_DELETED_EVENT_SUBJECT, params); } }
@Override public void fileCreated(FileChangeEvent fileChangeEvent) throws IOException { FileObject fileObject = fileChangeEvent.getFile(); LOGGER.info(String.format("Received file creation event for file: %s", fileObject)); File file = new File(fileObject.getName().getPath()); if (ConfigFileFilter.isFileSupported(file)) { configurationService.addOrUpdate(file); Map<String, Object> params = new HashMap<>(); params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath()); sendEvent(ConfigurationConstants.FILE_CREATED_EVENT_SUBJECT, params); } }
private void display(final CommandContext context, final FileObject file, final FileObject root) throws FileSystemException { assert context != null; assert file != null; String path; try { path = new URI(this.path).resolve(root.getURL().toURI().relativize(file.getURL().toURI())).toString(); } catch (Exception e) { path = file.getName().getPath(); } IO io = context.getIo(); io.info(path); }
@Override public void fileChanged(FileChangeEvent fileChangeEvent) { FileObject fileObject = fileChangeEvent.getFile(); LOGGER.info(String.format("Received file update event for file: %s", fileObject)); File file = new File(fileObject.getName().getPath()); if (ConfigFileFilter.isFileSupported(file)) { configurationService.addOrUpdate(file); Map<String, Object> params = new HashMap<>(); params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath()); sendEvent(ConfigurationConstants.FILE_CHANGED_EVENT_SUBJECT, params); } }
public JarURLConnectionImpl(JarFileObject file, FileContent content) throws MalformedURLException, FileSystemException { //This is because JarURLConnection SUCKS!! super(new URL(HACK_URL)); this.url = file.getURL(); this.content = content; this.parentURL = file.getURL(); this.entryName = file.getName().getPath(); this.file = file; }
/** * Determines if another file name is a descendent of this file name. */ public boolean isDescendent(final FileName descendent, final NameScope scope) { if (!descendent.getRootURI().equals(getRootURI())) { return false; } return checkName(getPath(), descendent.getPath(), scope); }
/** * Determines if another file name is an ancestor of this file name. */ public boolean isAncestor(final FileName ancestor) { if (!ancestor.getRootURI().equals(getRootURI())) { return false; } return checkName(ancestor.getPath(), getPath(), NameScope.DESCENDENT); }
private void display(final CommandContext context, final FileObject file) throws FileSystemException { assert context != null; assert file != null; IO io = context.getIo(); io.info(file.getName().getPath()); }
/** * Renames the file */ protected void doRename(FileObject newfile) throws Exception { final boolean ok; final FtpClient ftpClient = ftpFs.getClient(); try { String oldName = getName().getPath(); String newName = newfile.getName().getPath(); ok = ftpClient.rename(oldName, newName); } finally { ftpFs.putClient(ftpClient); } if (!ok) { throw new FileSystemException("vfs.provider.ftp/rename-file.error", new Object[]{getName().toString(), newfile}); } this.fileInfo = null; children = EMPTY_FTP_FILE_MAP; }
/** * @see net.sourceforge.taverna.publish.Repository#publish(org.apache.commons.vfs.FileObject[], * org.apache.commons.vfs.FileObject) */ public void publish(FileObject[] filelist, FileObject startingDir) throws PublicationException { String filedir = startingDir.getName().getPath(); FileObject destFile = null; try { for (int i = 0; i < filelist.length; i++) { // filelist[i].getName(). destFile = this.fsManager.resolveFile(filedir + LINE_ENDING); FileUtil.copyContent(filelist[i], startingDir); } } catch (IOException e) { throw new PublicationException(e); } }
/** * @see net.sourceforge.taverna.publish.Repository#publish(org.apache.commons.vfs.FileObject[], * org.apache.commons.vfs.FileObject) */ public void publish(FileObject[] filelist, FileObject startingDir) throws PublicationException { String filedir = startingDir.getName().getPath(); FileObject destFile = null; try { for (int i = 0; i < filelist.length; i++) { // filelist[i].getName(). destFile = this.fsManager.resolveFile(filedir + LINE_ENDING); FileUtil.copyContent(filelist[i], startingDir); } } catch (IOException e) { throw new PublicationException(e); } }
/** * @see net.sourceforge.taverna.publish.Repository#publish(java.io.File[], * java.io.File) */ public void publish(FileObject[] filelist, FileObject startingDir) throws PublicationException { String filedir = startingDir.getName().getPath(); FileObject destFile = null; try { for (int i = 0; i < filelist.length; i++) { // filelist[i].getName(). destFile = this.fsManager.resolveFile(filedir + LINE_ENDING); FileUtil.copyContent(filelist[i], startingDir); } } catch (IOException e) { throw new PublicationException(e); } }
/** * * @see net.sourceforge.taverna.publish.Repository#publish(org.apache.commons.vfs.FileObject[], * org.apache.commons.vfs.FileObject) */ public void publish(FileObject[] filelist, FileObject startingDir) throws PublicationException { String filedir = startingDir.getName().getPath(); FileObject destFile = null; try { for (int i = 0; i < filelist.length; i++) { // filelist[i].getName(). destFile = this.fsManager.resolveFile(filedir + LINE_ENDING); FileUtil.copyContent(filelist[i], startingDir); } } catch (IOException e) { throw new PublicationException(e); } }
public static UnixFsObject.Directory dirFromFileObject( RelativePath toFile, FileObject fromFile, FileAttributes attributes ) throws FileSystemException { if ( !fromFile.getType().equals( FileType.FOLDER ) ) { throw new FileSystemException( "Not a directory: " + fromFile.getName().getPath() + ", was: " + fromFile.getType() ); } FileContent content = fromFile.getContent(); return UnixFsObject.directory( toFile, new LocalDateTime( content.getLastModifiedTime() ), attributes ); } }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); FileObject file; if (path != null) { file = resolveFile(context, path); } else { file = getCurrentDirectory(context); } if (file.getType().hasChildren()) { listChildren(io, file); } else { io.info(file.getName().getPath()); } FileObjects.close(file); return Result.SUCCESS; }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); FileObject file; if (path != null) { file = resolveFile(context, path); } else { file = getCurrentDirectory(context); } if (file.getType().hasChildren()) { listChildren(io, file); } else { io.info(file.getName().getPath()); } FileObjects.close(file); return Result.SUCCESS; }
file.setPath( fileObjects[i].getName().getPath() ); file.setFile( fileObjects[i].getType().equals( FileType.FILE ) ); file.setLastModificationDate( new Date( fileObjects[i].getContent().getLastModifiedTime() ) );