List of usage examples for org.apache.commons.vfs2 FileObject isHidden
boolean isHidden() throws FileSystemException;
From source file:org.apache.accumulo.start.classloader.vfs.providers.ReadOnlyHdfsFileProviderTest.java
@Test public void testIsHidden() throws Exception { FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo);/* w w w. ja v a 2 s. com*/ Assert.assertFalse(fo.exists()); // Create the test file FileObject file = createTestFile(hdfs); Assert.assertFalse(file.isHidden()); }
From source file:org.apache.zeppelin.notebook.repo.OldVFSNotebookRepo.java
@Override public List<OldNoteInfo> list(AuthenticationInfo subject) throws IOException { FileObject rootDir = getRootDir(); FileObject[] children = rootDir.getChildren(); List<OldNoteInfo> infos = new LinkedList<>(); for (FileObject f : children) { String fileName = f.getName().getBaseName(); if (f.isHidden() || fileName.startsWith(".") || fileName.startsWith("#") || fileName.startsWith("~")) { // skip hidden, temporary files continue; }//from w w w . ja va 2s . c o m if (!isDirectory(f)) { // currently single note is saved like, [NOTE_ID]/note.json. // so it must be a directory continue; } OldNoteInfo info = null; try { info = getNoteInfo(f); if (info != null) { infos.add(info); } } catch (Exception e) { LOG.error("Can't read note " + f.getName().toString()); } } return infos; }
From source file:org.apache.zeppelin.notebook.repo.VFSNotebookRepo.java
@Override public List<NoteInfo> list() throws IOException { FileObject rootDir = getRootDir(); FileObject[] children = rootDir.getChildren(); List<NoteInfo> infos = new LinkedList<NoteInfo>(); for (FileObject f : children) { String fileName = f.getName().getBaseName(); if (f.isHidden() || fileName.startsWith(".") || fileName.startsWith("#") || fileName.startsWith("~")) { // skip hidden, temporary files continue; }// www . j av a 2 s. c o m if (!isDirectory(f)) { // currently single note is saved like, [NOTE_ID]/note.json. // so it must be a directory continue; } NoteInfo info = null; try { info = getNoteInfo(f); if (info != null) { infos.add(info); } } catch (IOException e) { logger.error("Can't read note " + f.getName().toString(), e); } } return infos; }
From source file:org.esupportail.portlet.filemanager.services.vfs.VfsAccessImpl.java
private boolean isFileHidden(FileObject file) { boolean isHidden = false; // file.isHidden() works in current version of VFS (1.0) only for local file object :( if (file instanceof LocalFile) { try {/*from w w w. j a va 2s .c o m*/ isHidden = file.isHidden(); } catch (FileSystemException e) { log.warn("Error on file.isHidden() method ...", e); } } else { // at the moment here we just check if the file begins with a dot // ... so it works just for unix files ... isHidden = file.getName().getBaseName().startsWith("."); } return isHidden; }
From source file:org.pentaho.di.trans.steps.file.BaseFileInputStep.java
/** * Prepare file-dependent data for fill additional fields. *//*w ww .ja va 2 s. com*/ protected void fillFileAdditionalFields(D data, FileObject file) throws FileSystemException { data.shortFilename = file.getName().getBaseName(); data.path = KettleVFS.getFilename(file.getParent()); data.hidden = file.isHidden(); data.extension = file.getName().getExtension(); data.uriName = file.getName().getURI(); data.rootUriName = file.getName().getRootURI(); if (file.getType().hasContent()) { data.lastModificationDateTime = new Date(file.getContent().getLastModifiedTime()); data.size = file.getContent().getSize(); } else { data.lastModificationDateTime = null; data.size = null; } }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTableModel.java
public int getRowCount() { if (selectedPath == null) { return 0; }//w ww .j a va 2 s .c o m try { if (selectedPath.getType() != FileType.FOLDER) { return 0; } final FileObject[] children = selectedPath.getChildren(); int count = 0; for (int i = 0; i < children.length; i++) { final FileObject child = children[i]; if (isShowHiddenFiles() == false && child.isHidden()) { continue; } if (child.getType() != FileType.FOLDER) { if (PublishUtil.acceptFilter(filters, child.getName().getBaseName()) == false) { continue; } } count += 1; } return count; } catch (FileSystemException fse) { UncaughtExceptionsModel.getInstance().addException(fse); return 0; } }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTableModel.java
public FileObject getElementForRow(final int row) { if (selectedPath == null) { return null; }/*from ww w. jav a 2s. co m*/ try { if (selectedPath.getType() != FileType.FOLDER) { return null; } final FileObject[] children = selectedPath.getChildren(); int count = 0; for (int i = 0; i < children.length; i++) { final FileObject child = children[i]; if (isShowHiddenFiles() == false && child.isHidden()) { continue; } if (child.getType() != FileType.FOLDER) { if (PublishUtil.acceptFilter(filters, child.getName().getBaseName()) == false) { continue; } } if (count == row) { return child; } count += 1; } return null; } catch (FileSystemException fse) { UncaughtExceptionsModel.getInstance().addException(fse); return null; } }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java
/** * Returns the child of <code>parent</code> at index <code>index</code> in the parent's child array. * <code>parent</code> must be a node previously obtained from this data source. This should not return * <code>null</code> if <code>index</code> is a valid index for <code>parent</code> (that is <code>index >= 0 && index * < getChildCount(parent</code>)). * * @param parent/*from www . ja v a 2s . c o m*/ * a node in the tree, obtained from this data source * @return the child of <code>parent</code> at index <code>index</code> */ public Object getChild(Object parent, final int index) { if (parent instanceof RepositoryTreeRoot) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if (parent == null) { return null; } } try { final FileObject parElement = (FileObject) parent; final FileObject[] children = parElement.getChildren(); int count = 0; for (int i = 0; i < children.length; i++) { final FileObject child = children[i]; if (isShowFoldersOnly() && child.getType() != FileType.FOLDER) { continue; } if (isShowHiddenFiles() == false && child.isHidden()) { continue; } if (child.getType() != FileType.FOLDER && PublishUtil.acceptFilter(filters, child.getName().getBaseName()) == false) { continue; } if (count == index) { return child; } count += 1; } return children[index]; } catch (FileSystemException fse) { logger.debug("Failed", fse); return null; } }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java
/** * Returns the number of children of <code>parent</code>. Returns 0 if the node is a leaf or if it has no children. * <code>parent</code> must be a node previously obtained from this data source. * * @param parent/*from www . j av a 2 s. c om*/ * a node in the tree, obtained from this data source * @return the number of children of the node <code>parent</code> */ public int getChildCount(Object parent) { if (parent instanceof RepositoryTreeRoot) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if (parent == null) { return 0; } } try { final FileObject parElement = (FileObject) parent; if (parElement.getType() != FileType.FOLDER) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for (int i = 0; i < children.length; i++) { final FileObject child = children[i]; if (isShowFoldersOnly() && child.getType() != FileType.FOLDER) { continue; } if (isShowHiddenFiles() == false && child.isHidden()) { continue; } if (child.getType() != FileType.FOLDER && PublishUtil.acceptFilter(filters, child.getName().getBaseName()) == false) { continue; } count += 1; } return count; } catch (FileSystemException fse) { logger.debug("Failed", fse); return 0; } }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java
/** * Returns the index of child in parent. If either <code>parent</code> or <code>child</code> is <code>null</code>, * returns -1. If either <code>parent</code> or <code>child</code> don't belong to this tree model, returns -1. * * @param parent/*w w w . j a v a2 s . c om*/ * a note in the tree, obtained from this data source * @param childNode * the node we are interested in * @return the index of the child in the parent, or -1 if either <code>child</code> or <code>parent</code> are * <code>null</code> or don't belong to this tree model */ public int getIndexOfChild(Object parent, final Object childNode) { if (parent instanceof RepositoryTreeRoot) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if (parent == null) { return -1; } } try { final FileObject parChild = (FileObject) childNode; final FileObject parElement = (FileObject) parent; final FileObject[] childs = parElement.getChildren(); int count = 0; for (int i = 0; i < childs.length; i++) { final FileObject child = childs[i]; if (isShowFoldersOnly() && child.getType() != FileType.FOLDER) { continue; } if (isShowHiddenFiles() == false && child.isHidden()) { continue; } if (child.getType() != FileType.FOLDER && PublishUtil.acceptFilter(filters, child.getName().getBaseName()) == false) { continue; } if (child.getName().equals(parChild.getName())) { return count; } count += 1; } return -1; } catch (FileSystemException fse) { logger.debug("Failed", fse); return -1; } }