Example usage for org.apache.commons.vfs2 FileObject toString

List of usage examples for org.apache.commons.vfs2 FileObject toString

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileObject toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

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);// w  ww. j a  v  a 2 s.c om
    assertTrue("File unreadable:" + fo.toString() + " type=" + fo.getType(), fo.isReadable());
}

From source file:com.stratuscom.harvester.PropertiesFileReaderTest.java

/** 
Check that the MockFileUtility returns the profile directory as the
'src/test/files' dir.//from  w  w  w. jav a  2s . c  o  m
@throws Exception 
*/
@Test
public void testMockFileUtility() throws Exception {
    FileObject fo = fileUtility.getProfileDirectory();

    System.out.println("fo=" + fo);
    assertTrue(fo.toString().endsWith("files"));
}

From source file:com.stratuscom.harvester.CommonsVFSTest.java

/**
Should be able to get the current directory, and it should end with
'testfiles/testroot'.// w  ww  . j  a v a2  s.co m
@throws Exception
 */
@Test
public void testBaseFile() throws Exception {
    FileObject fo = fileSystemManager.resolveFile(new File("."), ".");
    System.out.println("fo=" + fo);
    assertTrue(fo.toString().endsWith("harvester-container-core"));
}

From source file:com.stratuscom.harvester.CommonsVFSTest.java

/**
Should be able to go to a directory and ask for files that end with ".jar".
@throws Exception/*from ww  w.  j av  a2 s. c  o m*/
 */
@Test
public void testSuffixSelector() throws Exception {
    FileObject fo = fileSystemManager.resolveFile(new File("."), "target/reggie-module");
    System.out.println("fo=" + fo);
    assertTrue(fo.toString().endsWith("target/reggie-module"));
    List<FileObject> jars = Utils.findChildrenWithSuffix(fo, Strings.DOT_JAR);
    assertTrue("Didn't get any jar files.", jars.size() > 0);
}

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 v a 2 s  . c  om*/
@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:com.stratuscom.harvester.CommonsVFSTest.java

/**
If we create a virtual file system based on a jar file, we should be
able to add other jar files by adding junctions to the root, with the name
of the file we're adding./* ww  w  . jav a2  s  . c o  m*/
        
        
Unfortunately, this theory doesn't pan out...
org.apache.commons.vfs.FileSystemException: Attempting to create a nested junction at "null/otherStart.properties".  Nested junctions are not supported.
at org.apache.commons.vfs.impl.VirtualFileSystem.addJunction(VirtualFileSystem.java:111)
        
 */
@Test
@Ignore /*Didin't work, see above */
public void testFileSystemJunctions() throws Exception {
    FileObject reggieJar = fileSystemManager.resolveFile(new File("../../build/test/files"),
            "reggie-module.jar");
    assertTrue("Bad file:" + reggieJar.toString(), reggieJar.toString().endsWith("reggie-module.jar"));
    FileObject reggieJarFS = fileSystemManager.createFileSystem(reggieJar);

    FileObject virtRoot = fileSystemManager.createVirtualFileSystem((String) null);
    virtRoot.getFileSystem().addJunction("/", reggieJarFS);
    checkPresentAndReadable(virtRoot, "start.properties");
    FileObject startProperties = virtRoot.resolveFile("start.properties");
    assertNotNull(startProperties);
    assertTrue(
            "Properties file unreadable:" + startProperties.toString() + " type=" + startProperties.getType(),
            startProperties.isReadable());

    /* Now try to add in a junction to a jar file */
    virtRoot.getFileSystem().addJunction("otherStart.properties", startProperties);
    checkPresentAndReadable(virtRoot, "otherStart.properties");
}

From source file:edu.byu.nlp.data.streams.DirectoryReader.java

public DirectoryReader(FileObject directory, String fieldname) throws FileSystemException {
    Preconditions.checkNotNull(directory);
    Preconditions.checkArgument(directory.getType() == FileType.FOLDER, directory + " is not a directory");
    this.source = directory.toString();
    this.directory = directory;
    this.fieldname = fieldname;
}

From source file:com.stratuscom.harvester.classloading.VFSClassLoaderTest.java

/**
Just to make sure that we have the base setup correct, ensure that we
can read the 'start.properties' file inside the reggie-module jar.
@throws Exception/*from   w  w w.  j  a v  a  2  s  .com*/
 */
@Test
public void testCanReadStartDotProperties() throws Exception {
    FileObject startProperties = reggieModuleRoot.resolveFile("start.properties");
    assertNotNull(startProperties);
    assertTrue(
            "Properties file unreadable:" + startProperties.toString() + " type=" + startProperties.getType(),
            startProperties.isReadable());
}

From source file:com.stratuscom.harvester.deployer.CommandLineAppRunner.java

private void deployServiceArchive(FileObject archiveFile, String[] commandLineArgs) {
    try {//w  ww.  j a v  a  2  s.  c om
        /* Try the archive in all the deployers to see if someone can 
         * handle it. For now there's only one.
         */

        /*
         * Create the ApplicationEnvironment for the archive.
         */
        ServiceLifeCycle deployedApp = deployer.deployServiceArchive(myName, archiveFile);

        deployedApp.startWithArgs(commandLineArgs);
    } catch (Throwable t) {
        log.log(Level.WARNING, MessageNames.FAILED_DEPLOY_SERVICE, archiveFile.toString());
        log.log(Level.WARNING, MessageNames.EXCEPTION_THROWN, Utils.stackTrace(t));
    }
}