Package org.jboss.virtual.plugins.context.zip

Examples of org.jboss.virtual.plugins.context.zip.ZipEntryContext


   * @throws IOException
   * @throws URISyntaxException
   */
  public IndexMetadataFactory(URL url) throws IOException, URISyntaxException {
    VFS.init();
    ZipEntryContext context = new ZipEntryContext(url);
    VirtualFileHandler vfh = context.getRoot();
    VirtualFile vdb = new VirtualFile(vfh);
    List<VirtualFile> children = vdb.getChildrenRecursively(new VirtualFileFilter() {
      @Override
      public boolean accepts(VirtualFile file) {
        return file.getName().endsWith(IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT);


   protected VFSContext getVFSContext(String name) throws Exception
   {
      URL url = getRootResource(name);
      url = JarUtils.createJarURL(url);
      return new ZipEntryContext(url);
   }

      if (parent != null)
         delegatorUrl = getChildURL(parent, name);

      delegatorUrl = setOptionsToURL(delegatorUrl);
      ZipEntryContext ctx = new ZipEntryContext(delegatorUrl, delegator, fileUrl);

      VirtualFileHandler handler = ctx.getRoot();
      delegator.setDelegate(handler);

      return delegator;
   }

   }

   protected VFSContext getVFSContext(URL url) throws Exception
   {
      url = JarUtils.createJarURL(url);
      return new ZipEntryContext(url);
   }

   protected VFSContext getVFSContext(String name) throws Exception
   {
      URL url = getResource("/vfs/context/jar/" + name + ".jar");
      url = JarUtils.createJarURL(url);
      return new ZipEntryContext(url);
   }

      return new ZipEntryContext(url);
   }

   protected VFSContext createVSFContext(URL url) throws Exception
   {
      return new ZipEntryContext(url);
   }

      InputStream is = url.openStream();
      OutputStream os = new FileOutputStream(tmpJar);
      VFSUtils.copyStreamAndClose(is, os);

      ZipEntryContext context = new ZipEntryContext(tmpJar.toURI().toURL());
      assertTrue("context.getRoot().exists()", context.getRoot().exists());

      boolean isDeleted = context.getRoot().delete(1000);
      assertTrue("delete tmp file: " + tmpJar, isDeleted);
      assertFalse("context.getRoot().exists()", context.getRoot().exists());
   }

      nested = nested.getChild("level3.zip");
      assertEquals("Second level nested Real URL", jarURL, nested.getRealURL().toExternalForm());

      // nested root test
      url = getResource("/vfs/test/");
      ZipEntryContext zctx = new ZipEntryContext(new URL("vfszip:" + url.getPath() + "/level1.zip/level2.zip/level3.zip"));

      VirtualFileHandler handler = zctx.getRoot();
      assertEquals("Nested root Real URL", jarURL, handler.getRealURL().toExternalForm());

      List<VirtualFileHandler> children = handler.getChildren(false);
      for (VirtualFileHandler child: children)
      {

      URL delegatorUrl = fileUrl;

      if (parent != null)
         delegatorUrl = getChildURL(parent, name);

      ZipEntryContext ctx = new ZipEntryContext(delegatorUrl, delegator, fileUrl);

      VirtualFileHandler handler = ctx.getRoot();
      delegator.setDelegate(handler);

      return delegator;
   }

      if (parent != null)
         delegatorUrl = getChildURL(parent, name);

      delegatorUrl = setOptionsToURL(delegatorUrl);
      ZipEntryContext ctx = new ZipEntryContext(delegatorUrl, delegator, fileUrl);

      VirtualFileHandler handler = ctx.getRoot();
      delegator.setDelegate(handler);

      return delegator;
   }

TOP

Related Classes of org.jboss.virtual.plugins.context.zip.ZipEntryContext

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.