Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileSystemManager

@author Adam Murdoch

  public Properties getProperties() {
    if (_properties == null) {
      TemporaryFile tempFile = null;
      try {       
        tempFile = new TemporaryFile("template_" + _name, getContent(), WGADesignerPlugin.getDefault().getStateLocation().toFile());
        FileSystemManager fsManager = VFS.getManager();
        FileObject propFile = fsManager.resolveFile("zip:" + tempFile.getFile().toURI() + "!" + PROPERTIES_FILENAME);
        if (propFile.exists()) {
          _properties = new Properties();
          InputStream propIn = null;
          try {
            propIn = propFile.getContent().getInputStream();
View Full Code Here


  public void createOrUpdateDefaultDeployment(File defaultWGAWar, IProgressMonitor monitor) throws FileSystemException, IOException, ZipException {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    FileSystemManager fsManager = VFS.getManager();
    FileObject propFile = fsManager.resolveFile( "zip:" + defaultWGAWar.toURI() + "!/WEB-INF/wgabuild.properties");
    //_defaultDeploymentName = DEFAULT_DEPLOYMENT_PREFIX + WGADeployment.determineWGAVersion(propFile.getURL().openStream(), "_", true, false);
       
    // init default wga installation
    // check if we already have a deployment with same major, minor version
    WGADeployment existingDefaultDeployment = getDeployment(DEFAULT_DEPLOYMENT_NAME);
View Full Code Here

  }

  public static boolean isWGAVersionSupported(File wgaWar) {
    InputStream propIn = null;
    try {
      FileSystemManager fsManager = VFS.getManager();
      FileObject propFile = fsManager.resolveFile( "zip:" + wgaWar.toURI() + "!/WEB-INF/wgabuild.properties");
      propIn = propFile.getURL().openStream();
      Version version = WGADeployment.determineWGAVersion(propIn);
      if (version != null) {
        if (version.isAtLeast(Activator.SUPPORTED_WGA_VERSION_MIN.getMajor(),  Activator.SUPPORTED_WGA_VERSION_MIN.getMinor())) {
          if (version.getMajorVersion() < Activator.SUPPORTED_WGA_VERSION_MAX.getMajor()) {
View Full Code Here

        }
        for (int i = 0; i < args.length; i++)
        {
            try
            {
                FileSystemManager mgr = VFS.getManager();
                System.out.println();
                System.out.println("Parsing: " + args[i]);
                FileObject file = mgr.resolveFile(args[i]);
                System.out.println("URL: " + file.getURL());
                System.out.println("getName(): " + file.getName());
                System.out.println("BaseName: " + file.getName().getBaseName());
                System.out.println("Extension: " + file.getName().getExtension());
                System.out.println("Path: " + file.getName().getPath());
View Full Code Here

{
  private final static int NUOF_RESOLVES = 100000;

  public static void main(String[] args) throws FileSystemException
  {
    FileSystemManager mgr = VFS.getManager();

    FileObject root = mgr
        .resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr");
    FileName rootName = root.getName();
 
    testNames(mgr, rootName);
View Full Code Here

     * Sanity test.
     */
    public void testDefaultInstance() throws Exception
    {
        // Locate the default manager
        final FileSystemManager manager = VFS.getManager();

        // Lookup a test jar file
        final File jarFile = getTestResource("test.jar");
        FileObject file = manager.toFileObject(jarFile);
        assertNotNull(file);
        assertTrue(file.exists());
        assertSame(FileType.FILE, file.getType());

        // Expand it
        file = manager.createFileSystem(file);
        assertNotNull(file);
        assertTrue(file.exists());
        assertSame(FileType.FOLDER, file.getType());
    }
View Full Code Here

  public static String resolveSchema(final ResourceManager resourceManager,
                                     final ResourceKey contextKey,
                                     String catalogUrl)
      throws FileSystemException
  {
    final FileSystemManager fsManager = VFS.getManager();
    if (fsManager == null)
    {
      throw Util.newError("Cannot get virtual file system manager");
    }

    // Workaround VFS bug.
    if (catalogUrl.startsWith("file://localhost"))
    {
      catalogUrl = catalogUrl.substring("file://localhost".length());
    }
    if (catalogUrl.startsWith("file:"))
    {
      catalogUrl = catalogUrl.substring("file:".length());
    }

    try
    {
      final File catalogFile = new File(catalogUrl).getCanonicalFile();
      final FileObject file = fsManager.toFileObject(catalogFile);
      if (file.isReadable())
      {
        return catalogFile.getPath();
      }
    }
View Full Code Here

  // build the jar
  // VFS currently does not support building zip files -> use java's ZipOutputStream
  private void buildJar(String newJar) throws IOException
  {
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(newJar ));
    FileSystemManager fsManager = VFS.getManager();
    for (String jar : _jar2class.keySet())
    {
      FileObject jarFile;
      if (jar.endsWith(".jar"))
        jarFile = fsManager.resolveFile( "jar:"+jar );
      else
        jarFile = fsManager.resolveFile( jar );
       
        for (String file : _jar2class.get(jar))
        {
          file = file.replaceAll("\\.", "/");
          file += ".class";
          FileObject f = fsManager.resolveFile(jarFile, file);
          if (f.exists())
            addFile(f, file, out);
          else
            System.out.println("file not found "+f);
       
View Full Code Here

      public void run() {
    initialize();
      while (reader == null) {
        getLogger().info("attempting to load file: " + getFileURL());
        try {
          FileSystemManager fileSystemManager = VFS.getManager();
          FileObject fileObject = fileSystemManager.resolveFile(getFileURL());
          reader = new InputStreamReader(fileObject.getContent().getInputStream());
        } catch (FileSystemException fse) {
          getLogger().info("file not available - will try again in 10 seconds");
          synchronized(this) {
            try {
View Full Code Here

     * Sanity test.
     */
    public void testDefaultInstance() throws Exception
    {
        // Locate the default manager
        final FileSystemManager manager = VFS.getManager();

        // Lookup a test jar file
        final File jarFile = getTestResource("test.jar");
        FileObject file = manager.toFileObject(jarFile);
        assertNotNull(file);
        assertTrue(file.exists());
        assertSame(FileType.FILE, file.getType());

        // Expand it
        file = manager.createFileSystem(file);
        assertNotNull(file);
        assertTrue(file.exists());
        assertSame(FileType.FOLDER, file.getType());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs.FileSystemManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.