List of usage examples for org.apache.commons.vfs2 FileObject getName
FileName getName();
From source file:com.wipro.ats.bdre.tdimport.FileMonitor.java
@Override public void fileCreated(FileChangeEvent fileChangeEvent) throws Exception { FileObject obj = fileChangeEvent.getFile(); LOGGER.debug("File Created " + obj.getURL()); String dirPath = obj.getParent().getName().getPath(); LOGGER.debug("Full path " + obj.getName().getPath()); //Don't process anything with _archive if (dirPath.startsWith(monDir + "/" + archiveDirName)) { return;//from www .java2 s. c o m } //Don't process directory if (obj.getType() == FileType.FOLDER) { return; } String fileName = obj.getName().getPath(); //Checking if the file name matches with the given pattern if (fileName.matches(filePattern)) { FileContent fc = obj.getContent(); LOGGER.debug("Matched File Pattern by " + fileName); putEligibleFileInfoInMap(obj.getName().getBaseName(), fc); } }
From source file:de.innovationgate.utils.DirComparer.java
private void addFileHash(Map<String, String> hashes, FileObject file, FileObject root) throws NoSuchAlgorithmException, IOException, FileSystemException { String path = root.getName().getRelativeName(file.getName()); if (file.getType().equals(FileType.FOLDER)) { hashes.put(path, ""); } else {/*from w w w. ja v a 2s . co m*/ String hash = MD5HashingInputStream.getStreamHash(file.getContent().getInputStream()); hashes.put(path, hash); } }
From source file:architecture.ee.jdbc.sqlquery.factory.impl.AbstractSqlQueryFactory.java
private FileObject[] findSqlFiles(FileObject fo) throws FileSystemException { return fo.findFiles(new FileSelector() { public boolean includeFile(FileSelectInfo fileInfo) throws Exception { FileObject f = fileInfo.getFile(); log.debug("varifing : " + f.getName()); return StringUtils.endsWith(f.getName().getBaseName(), DEFAULT_FILE_SUFFIX); }/*ww w . j a v a2 s . c o m*/ public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return VFSUtils.isFolder(fileInfo.getFile()); } }); }
From source file:io.hops.hopsworks.api.zeppelin.util.ZeppelinResource.java
public void forceKillInterpreter(InterpreterSetting interpreter, Project project) { FileObject[] pidFiles;//from w w w .j a v a2s . co m try { pidFiles = getPidFiles(project); } catch (URISyntaxException | FileSystemException ex) { logger.log(Level.SEVERE, "Could not read pid files ", ex); return; } boolean running = false; for (FileObject file : pidFiles) { if (file.getName().toString().contains("interpreter-" + interpreter.getName() + "-")) { running = isProccessAlive(readPid(file)); if (running) { forceKillProccess(readPid(file)); break; } } } }
From source file:io.hops.hopsworks.api.zeppelin.util.ZeppelinResource.java
/** * Checks if an interpreter is running/*from w w w. j a va 2 s .c om*/ * can return false if pid file reading fails. * <p/> * @param interpreter * @param project * @return */ public boolean isInterpreterRunning(InterpreterSetting interpreter, Project project) { FileObject[] pidFiles; try { pidFiles = getPidFiles(project); } catch (URISyntaxException | FileSystemException ex) { logger.log(Level.SEVERE, "Could not read pid files ", ex); return false; } boolean running = false; for (FileObject file : pidFiles) { if (file.getName().toString().contains("interpreter-" + interpreter.getName() + "-")) { running = isProccessAlive(readPid(file)); //in the rare case were there are more that one pid files for the same //interpreter break only when we find running one if (running) { break; } } } return running; }
From source file:com.sonicle.webtop.vfs.bol.js.JsGridFile.java
public JsGridFile(StoreShareFolder folder, FileObject fo, String fileId, SharingLink dlLink, SharingLink ulLink) {//from www . j a v a2s. c o m this.fileId = fileId; this.type = getFileType(fo); this.mtype = (type.equals("folder")) ? "" : ServletHelper.guessMediaType(fo.getName().getBaseName(), true); this.name = fo.getName().getBaseName(); this.ext = fo.getName().getExtension(); this.size = getFileSize(fo); this.lastModified = getFileLastModified(fo); DateTime now = DateTimeUtils.now(); if (dlLink != null) { this.dlLink = dlLink.getLinkId(); this.dlLinkExp = dlLink.isExpired(now); } else { this.dlLink = null; this.dlLinkExp = false; } if (ulLink != null) { this.ulLink = ulLink.getLinkId(); this.ulLinkExp = ulLink.isExpired(now); } else { this.ulLink = null; this.ulLinkExp = false; } this.eperms = folder.getElementsPerms().toString(); }
From source file:com.streamsets.pipeline.stage.origin.remote.FTPRemoteDownloadSourceDelegate.java
@Override Offset createOffset(String file) throws IOException { FileObject fileObject = getChild(file); Offset offset = new Offset(relativizeToRoot(fileObject.getName().getPath()), getModTime(fileObject), ZERO); return offset; }
From source file:de.innovationgate.wgpublisher.design.fs.FileSystemDesignManager.java
public static boolean isValidDesignFile(FileObject file, DesignFileValidator validator) { return !file.getName().getBaseName().startsWith(".") && validator.isValidFileName(file.getName().getBaseName()); }
From source file:de.innovationgate.wgpublisher.design.sync.FileContainerDeployment.java
protected ContainerFile getContainerFile(FileObject file) { return (ContainerFile) _files.get(file.getName().getBaseName().toLowerCase()); }
From source file:de.innovationgate.wgpublisher.design.sync.DesignDeployment.java
public void doAttachFile(WGDocument doc, FileObject file) throws WGDesignSyncException { try {//from w w w.ja v a2s. com if (!file.exists()) { throw new WGDesignSyncException("Attaching file '" + file.getName().getPath() + "' to document '" + doc.getDocumentKey() + "' failed because the file does not exist."); } if (!doc.attachFile(file.getContent().getInputStream(), file.getName().getBaseName())) { throw new WGDesignSyncException("Attaching file '" + file.getName().getPath() + "' to document '" + doc.getDocumentKey() + "' failed."); } } catch (Exception e) { throw new WGDesignSyncException("Attaching file '" + file.getName().getPath() + "' to document '" + doc.getDocumentKey() + "' failed.", e); } }