List of usage examples for org.apache.commons.vfs2 FileObject resolveFile
FileObject resolveFile(String path) throws FileSystemException;
From source file:net.dempsy.distconfig.apahcevfs.Utils.java
public static FileObject nextFile(final FileObject lastFile, final FileObject parent) throws FileSystemException { if (lastFile == null) return parent.resolveFile(genVersionSuffix(0)); final int lastVersion = getVersion(lastFile); return lastFile.getParent().resolveFile(genVersionSuffix(lastVersion + 1)); }
From source file:com.googlecode.vfsjfilechooser2.utils.VFSUtils.java
/** * Returns a file representation/*from w w w. ja v a 2 s . c o m*/ * @param folder A folder * @param filename A filename * @return a file contained in a given folder */ public static FileObject resolveFileObject(FileObject folder, String filename) { try { return folder.resolveFile(filename); } catch (FileSystemException ex) { return null; } }
From source file:com.app.server.EARDeployer.java
public static void getClassList(FileObject jarFile, CopyOnWriteArrayList classList, StandardFileSystemManager fsManager) throws FileSystemException { // log.info(jarFile); FileObject nestedFS = null; FileObject[] children = null; if (jarFile.getURL().toString().trim().endsWith(".jar")) { nestedFS = fsManager.createFileSystem(jarFile); children = nestedFS.resolveFile("/").getChildren(); } else if (jarFile.getType() == FileType.FOLDER) { children = jarFile.getChildren(); }/*from w ww .ja v a 2s . c om*/ // log.info(); // log.info( "Children of " + jarFile.getName().getURI() ); if (children == null) return; for (int i = 0; i < children.length; i++) { // log.info(children[i].+" "+ // children[i].getName().getBaseName() ); if (children[i].getType() == FileType.FILE && children[i].getName().getBaseName().endsWith(".class")) classList.add(children[i].toString().substring(children[i].toString().lastIndexOf('!') + 2)); getClassList(children[i], classList, fsManager); } }
From source file:com.web.server.EARDeployer.java
public static void getClassList(FileObject jarFile, CopyOnWriteArrayList classList, StandardFileSystemManager fsManager) throws FileSystemException { // System.out.println(jarFile); FileObject nestedFS = null; FileObject[] children = null; if (jarFile.getURL().toString().trim().endsWith(".jar")) { nestedFS = fsManager.createFileSystem(jarFile); children = nestedFS.resolveFile("/").getChildren(); } else if (jarFile.getType() == FileType.FOLDER) { children = jarFile.getChildren(); }//from ww w .j a va2s.co m // System.out.println(); // System.out.println( "Children of " + jarFile.getName().getURI() ); if (children == null) return; for (int i = 0; i < children.length; i++) { // System.out.println(children[i].+" "+ // children[i].getName().getBaseName() ); if (children[i].getType() == FileType.FILE && children[i].getName().getBaseName().endsWith(".class")) classList.add(children[i].toString().substring(children[i].toString().lastIndexOf('!') + 2)); getClassList(children[i], classList, fsManager); } }
From source file:com.stratuscom.harvester.ProfileConfigReader.java
private ContainerConfig readProfileConfig() throws SAXException, JAXBException, FileNotFoundException, IOException { Unmarshaller um = Bootstrap.createConfigUnmarshaller(); FileObject profileDir = fileUtility.getProfileDirectory(); FileObject configFile = profileDir.resolveFile(Strings.CONFIG_XML); log.log(Level.FINE, MessageNames.CONFIG_FILE, configFile.toString()); InputStream is = configFile.getContent().getInputStream(); ContainerConfig containerConfig = (ContainerConfig) um.unmarshal(is); return containerConfig; }
From source file:com.stratuscom.harvester.CommonsVFSTest.java
void checkPresentAndReadable(FileObject root, String name) throws FileSystemException { FileObject fo = root.resolveFile(name); assertNotNull(fo);//from w w w . ja va2 s . c o m assertTrue("File unreadable:" + fo.toString() + " type=" + fo.getType(), fo.isReadable()); }
From source file:com.stratuscom.harvester.CommonsVFSTest.java
/** Make sure we can use the jar:syntax to get to the 'start.properties' file inside the constructed reggie module jar. */// w w w. j a va 2 s. c o m @Test public void testFileInReggieModuleJar() throws Exception { FileObject reggieJar = fileSystemManager.resolveFile(new File("target/reggie-module"), "reggie-module.jar"); assertTrue("Bad file:" + reggieJar.toString(), reggieJar.toString().endsWith("reggie-module.jar")); FileObject reggieJarFS = fileSystemManager.createFileSystem(Strings.JAR, reggieJar); FileObject startProperties = reggieJarFS.resolveFile("start.properties"); assertNotNull(startProperties); assertTrue( "Properties file unreadable:" + startProperties.toString() + " type=" + startProperties.getType(), startProperties.isReadable()); }
From source file:hadoopInstaller.installation.UploadConfiguration.java
private void uploadConfiguration(FileObject remoteDirectory, Host host) throws InstallationError { try {/*from ww w .j a va 2 s. c om*/ FileObject configurationDirectory = remoteDirectory.resolveFile("hadoop/etc/hadoop/"); //$NON-NLS-1$ if (deleteOldFiles) { configurationDirectory.delete(new AllFileSelector()); log.debug("HostInstallation.Upload.DeletingOldFiles", //$NON-NLS-1$ host.getHostname()); } else if (!configurationDirectory.exists()) { throw new InstallationError("HostInstallation.Upload.NotDeployed"); //$NON-NLS-1$ } configurationDirectory.copyFrom(filesToUpload, new AllFileSelector()); modifyEnvShFile(host, configurationDirectory, InstallerConstants.ENV_FILE_HADOOP); modifyEnvShFile(host, configurationDirectory, InstallerConstants.ENV_FILE_YARN); try { configurationDirectory.close(); } catch (FileSystemException ex) { log.warn("HostInstallation.CouldNotClose", //$NON-NLS-1$ configurationDirectory.getName().getURI()); } } catch (FileSystemException e) { throw new InstallationError(e, "HostInstallation.Upload.Error", //$NON-NLS-1$ remoteDirectory.getName().getURI()); } }
From source file:com.stratuscom.harvester.classloading.VFSClassLoaderTest.java
@Before public void setUp() throws Exception { fileSystemManager = VFS.getManager(); FileObject currentDir = fileSystemManager.toFileObject(new File(".")); FileObject reggieModuleJar = currentDir.resolveFile("target/reggie-module/reggie-module.jar"); reggieModuleRoot = fileSystemManager.createFileSystem(Strings.JAR, reggieModuleJar); libRoot = reggieModuleRoot.resolveFile(Strings.LIB); }
From source file:com.streamsets.pipeline.lib.remote.TestFTPRemoteFile.java
@Test public void testCreateAndCommitOutputStream() throws Exception { String name = "file.txt"; String filePath = "/some/path/"; FileObject fileObject = Mockito.mock(FileObject.class); FileName fileName = Mockito.mock(FileName.class); Mockito.when(fileObject.getName()).thenReturn(fileName); Mockito.when(fileName.getBaseName()).thenReturn(name); FileObject parentFileObject = Mockito.mock(FileObject.class); FileObject tempFileObject = Mockito.mock(FileObject.class); Mockito.when(fileObject.getParent()).thenReturn(parentFileObject); Mockito.when(parentFileObject.resolveFile(Mockito.any())).thenReturn(tempFileObject); FileContent tempFileContent = Mockito.mock(FileContent.class); Mockito.when(tempFileObject.getContent()).thenReturn(tempFileContent); FTPRemoteFile file = new FTPRemoteFile(filePath + name, 0L, fileObject); try {/* ww w. j a va2s . co m*/ file.commitOutputStream(); Assert.fail("Expected IOException because called commitOutputStream before createOutputStream"); } catch (IOException ioe) { Assert.assertEquals("Cannot commit " + filePath + name + " - it must be written first", ioe.getMessage()); } file.createOutputStream(); Mockito.verify(parentFileObject).resolveFile("_tmp_" + name); Mockito.verify(tempFileContent).getOutputStream(); file.commitOutputStream(); Mockito.verify(tempFileObject).moveTo(fileObject); }