List of usage examples for org.apache.commons.vfs2 FileSelector FileSelector
FileSelector
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); }/*from w w w . j a va 2 s .c om*/ public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return VFSUtils.isFolder(fileInfo.getFile()); } }); }
From source file:com.carrotgarden.nexus.example.script.ScriptStorageImpl.java
@Override public void initialize() throws InitializationException { scriptStore = new LinkedHashMap<String, String>(); FileObject listendir;/*from w w w . j a v a 2 s . c om*/ try { final FileSystemManager fsManager = VFS.getManager(); scriptDir = config.getWorkingDirectory("scripts"); if (!scriptDir.exists()) { scriptDir.mkdirs(); try { new File(scriptDir, "place your .groovy files here.txt").createNewFile(); } catch (final IOException e) { throw new InitializationException(e.getMessage(), e); } } listendir = fsManager.resolveFile(scriptDir.getAbsolutePath()); } catch (final FileSystemException e) { throw new InitializationException(e.getMessage(), e); } final FileSelector selector = new FileSelector() { @Override public boolean traverseDescendents(final FileSelectInfo arg0) throws Exception { return true; } @Override public boolean includeFile(final FileSelectInfo arg0) throws Exception { return isScriptFile(arg0.getFile()); } }; try { final FileObject[] availableScripts = listendir.findFiles(selector); for (final FileObject fileObject : availableScripts) { updateScript(fileObject); } } catch (final FileSystemException e) { log.warn("Unable to perform initial directory scan.", e); } final DefaultFileMonitor monitor = new DefaultFileMonitor(this); monitor.setRecursive(true); monitor.addFile(listendir); monitor.start(); this.fileMonitor = monitor; }
From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java
public FileObject[] findByExtension(final FileObject fo, final String ext) throws FileSystemException { return fo.findFiles(new FileSelector() { @Override//from w w w . ja v a2 s . c om public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { return fileInfo.getFile().getName().getExtension().equals(ext); } @Override public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } }); }
From source file:com.anrisoftware.sscontrol.filesystem.FileSystem.java
private FileObject[] listFiles(FileObject location, final Pattern pattern) throws org.apache.commons.vfs2.FileSystemException { return location.findFiles(new FileSelector() { @Override//from w w w .jav a 2 s . c om public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return true; } @Override public boolean includeFile(FileSelectInfo fileInfo) throws Exception { String name = fileInfo.getFile().getName().getBaseName(); Matcher matcher = pattern.matcher(name); return matcher.matches(); } }); }
From source file:com.app.server.SARDeployer.java
public CopyOnWriteArrayList<String> unpack(final FileObject unpackFileObject, final File outputDir, StandardFileSystemManager fileSystemManager) throws IOException { outputDir.mkdirs();/*ww w . j a va 2 s . co m*/ URLClassLoader webClassLoader; CopyOnWriteArrayList<String> classPath = new CopyOnWriteArrayList<String>(); final FileObject packFileObject = fileSystemManager .resolveFile("jar:" + unpackFileObject.toString() + "!/"); try { FileObject outputDirFileObject = fileSystemManager.toFileObject(outputDir); outputDirFileObject.copyFrom(packFileObject, new AllFileSelector()); FileObject[] libs = outputDirFileObject.findFiles(new FileSelector() { public boolean includeFile(FileSelectInfo arg0) throws Exception { return arg0.getFile().getName().getBaseName().toLowerCase().endsWith(".jar"); } public boolean traverseDescendents(FileSelectInfo arg0) throws Exception { // TODO Auto-generated method stub return true; } }); /*String replaceString="file:///"+outputDir.getAbsolutePath().replace("\\","/"); replaceString=replaceString.endsWith("/")?replaceString:replaceString+"/";*/ // System.out.println(replaceString); for (FileObject lib : libs) { // System.out.println(outputDir.getAbsolutePath()); // System.out.println(jsp.getName().getFriendlyURI()); classPath.add(lib.getName().getFriendlyURI()); // System.out.println(relJspName); } } finally { packFileObject.close(); } return classPath; }
From source file:de.innovationgate.wgpublisher.services.WGACoreServicesImpl.java
public void deleteFSDesignResource(RemoteSession session, String path) throws WGAServiceException { if (!isAdminServiceEnabled()) { throw new WGAServiceException("Administrative services are disabled"); }/* ww w. j a v a 2 s. c om*/ if (!isAdminSession(session)) { throw new WGAServiceException("You need an administrative login to access this service."); } WGADesignSource source = _core.getDesignManager().getDesignSources() .get(WGAConfiguration.UID_DESIGNSOURCE_FILESYSTEM); if (source instanceof FileSystemDesignSource) { FileSystemDesignSource fsSource = (FileSystemDesignSource) source; try { fsSource.getDir().refresh(); FileObject resource = fsSource.getDir().resolveFile(path); String basePath = fsSource.getDir().getURL().getPath(); String resourcePath = resource.getURL().getPath(); if (!resourcePath.startsWith(basePath)) { throw new WGAServiceException( new IllegalArgumentException("Illegal design resource path '" + path + "'.")); } if (resource.exists()) { resource.delete(new FileSelector() { public boolean includeFile(FileSelectInfo fileInfo) throws Exception { return true; } public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return true; } }); clearDesignFileCache(fsSource, fsSource.getDir().getName().getRelativeName(resource.getName())); } } catch (FileSystemException e) { throw new WGAServiceException("Deleting FSDesignResource '" + path + "' failed.", e); } } }
From source file:com.app.server.EJBDeployer.java
public void scanJar(FileObject jarFile, HashSet<Class<?>>[] classanotwith, Class[] annot, ClassLoader cL) throws FileSystemException { //FileObject[] childs=jarFile.getChildren(); //for(FileObject child:childs){ FileObject[] classes = jarFile.findFiles(new FileSelector() { @Override//from w w w .j a va2 s. co m public boolean includeFile(FileSelectInfo arg0) throws Exception { return arg0.getFile().getName().getBaseName().endsWith(".class"); } @Override public boolean traverseDescendents(FileSelectInfo arg0) throws Exception { // TODO Auto-generated method stub return true; } }); //} int index = 0; for (FileObject cls : classes) { try { Class<?> clz = cL.loadClass(cls.getURL().toURI().toString() .replace(jarFile.getURL().toURI().toString(), "").replace("/", ".").replace(".class", "")); index = 0; for (Class annotclz : annot) { if (clz.getAnnotation(annotclz) != null) { classanotwith[index].add(clz); } index++; } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.app.server.WarDeployer.java
public Vector<URL> unpack(final FileObject unpackFileObject, final File outputDir, StandardFileSystemManager fileSystemManager, ConcurrentHashMap<String, String> jsps) throws IOException { outputDir.mkdirs();/*from w w w.j a v a 2 s .co m*/ URLClassLoader webClassLoader; Vector<URL> libraries = new Vector<URL>(); final FileObject packFileObject = fileSystemManager.resolveFile(unpackFileObject.toString()); try { FileObject outputDirFileObject = fileSystemManager.toFileObject(outputDir); outputDirFileObject.copyFrom(packFileObject, new AllFileSelector()); FileObject[] jspFiles = outputDirFileObject.findFiles(new FileSelector() { public boolean includeFile(FileSelectInfo arg0) throws Exception { return arg0.getFile().getName().getBaseName().toLowerCase().endsWith(".jsp") || arg0.getFile().getName().getBaseName().toLowerCase().endsWith(".jar"); } public boolean traverseDescendents(FileSelectInfo arg0) throws Exception { // TODO Auto-generated method stub return true; } }); String replaceString = "file:///" + outputDir.getAbsolutePath().replace("\\", "/"); replaceString = replaceString.endsWith("/") ? replaceString : replaceString + "/"; // System.out.println(replaceString); for (FileObject jsplibs : jspFiles) { // System.out.println(outputDir.getAbsolutePath()); // System.out.println(jsp.getName().getFriendlyURI()); if (jsplibs.getName().getBaseName().endsWith(".jar")) { libraries.add(new URL(jsplibs.getName().getFriendlyURI())); } else { String relJspName = jsplibs.getName().getFriendlyURI().replace(replaceString, ""); jsps.put(relJspName, relJspName); } // System.out.println(relJspName); } } finally { packFileObject.close(); } return libraries; }
From source file:org.apache.olingo.fit.utils.FSManager.java
public void deleteEntity(final String relativePath) { final String path = getAbsolutePath(relativePath, null); LOG.info("Delete {}", path); try {//w w w.ja v a2 s . c o m final FileObject fileObject = fsManager.resolveFile(MEM_PREFIX + path); if (fileObject.exists()) { fileObject.delete(new FileSelector() { @Override public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { return true; } @Override public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } }); } } catch (IOException ignore) { // ignore exception } }
From source file:org.apache.olingo.fit.utils.FSManager.java
public final FileObject[] find(final FileObject fo, final String ext) throws FileSystemException { return fo.findFiles(new FileSelector() { @Override//w w w. jav a2 s . com public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { return ext == null ? true : fileInfo.getFile().getName().getExtension().equals(ext); } @Override public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } }); }