Package org.apache.aries.application.filesystem

Examples of org.apache.aries.application.filesystem.IFile


   * @param manifestName the name of manifest
   * @return Manifest, or null if none found.
   * @throws IOException
   */
  public static Manifest obtainManifestFromAppDir(IDirectory appDir, String manifestName) throws IOException{
    IFile manifestFile = appDir.getFile(manifestName);
    Manifest man = null;
    if (manifestFile != null) {
      man = parseManifest(manifestFile.open());
    }
    return man;
  }
View Full Code Here


    root = this;
  }

  public IFile getFile(String name)
  {
    IFile result = null;
   
    String entryName = isRoot() ? name : getName() + "/" + name;
   
    ZipEntry entryFile = getEntry(entryName);
   
View Full Code Here

                                       JarFile jarFile,
                                       ModuleIDBuilder idBuilder)
        throws IOException, DeploymentException {       
        ApplicationMetadataFactory factory = getApplicationMetadataFactory();       
        IDirectory ebaFile = FileSystem.getFSRoot(new File(jarFile.getName()));       
        IFile applicationManifestFile = ebaFile.getFile(AppConstants.APPLICATION_MF);
        Manifest applicationManifest;
        if (applicationManifestFile != null) {
            InputStream in = applicationManifestFile.open();
            try {
                applicationManifest = ManifestProcessor.parseManifest(in);
            } finally {
                try { in.close(); } catch (IOException ignore) {}
            }
View Full Code Here

                                       JarFile jarFile,
                                       ModuleIDBuilder idBuilder)
        throws IOException, DeploymentException {
        ApplicationMetadataFactory factory = getApplicationMetadataFactory();
        IDirectory ebaFile = FileSystem.getFSRoot(new File(jarFile.getName()));
        IFile applicationManifestFile = ebaFile.getFile(AppConstants.APPLICATION_MF);
        Manifest applicationManifest;
        if (applicationManifestFile != null) {
            InputStream in = applicationManifestFile.open();
            try {
                applicationManifest = ManifestProcessor.parseManifest(in);
            } finally {
                try { in.close(); } catch (IOException ignore) {}
            }
View Full Code Here

    assertNotNull(zip.getEntry("file.txt"));
    assertNotNull(zip.getEntry("subdir/someFile.txt"));
    zip.close();
   
    IDirectory dir = FileSystem.getFSRoot(new File("ioUtilsTest"));
    IFile izip = dir.getFile("test.zip");
    File output = new File("ioUtilsTest/zipout");
    output.mkdirs();
    IOUtils.unpackZip(izip, output);
    File a = new File(output,"file.txt");
    File b = new File(output,"subdir");
View Full Code Here

   */
  public void runBasicDirTest(IDirectory dir, long len, long time) throws IOException
  {
    assertNull("for some reason our fake app has a fake blueprint file.", dir.getFile("OSGI-INF/blueprint/aries.xml"));
   
    IFile file = dir.getFile(AppConstants.APPLICATION_MF);
   
    assertNotNull("we could not find the application manifest", file);
   
    assertEquals(AppConstants.APPLICATION_MF, file.getName().replace('\\', '/'));
    assertTrue("The last update time is not within 2 seconds of the expected value. Expected: " + time + " Actual: " + file.getLastModified(), Math.abs(time - file.getLastModified()) < 2000);
    assertEquals(len, file.getSize());
    assertEquals("META-INF", file.getParent().getName());
    assertFalse(file.isDirectory());
    assertTrue(file.isFile());
   
    List<IFile> files = dir.listFiles();
    Iterator<IFile> it = files.iterator();
    while (it.hasNext()) {
      IFile f = it.next();
      if (f.getName().equalsIgnoreCase(".svn")) {
        it.remove();
      }
    }
   
    assertEquals(1, files.size());
    List<IFile> allFiles = dir.listAllFiles();
    Iterator<IFile> its = allFiles.iterator();
    while (its.hasNext()) {
      IFile f = its.next();
      if (f.getName().toLowerCase().contains(".svn")) {
        its.remove();
      }
    }
   
    assertEquals(3, allFiles.size());
    IFile metaInf = files.get(0);
   
    assertTrue(metaInf.isDirectory());
    assertEquals("META-INF", metaInf.getName());
    assertNotNull(metaInf.convert());
   
    for (IFile aFile : dir) {
      if (!aFile.getName().equalsIgnoreCase(".svn")) {
        assertTrue(aFile.isDirectory());
        assertEquals("META-INF", aFile.getName());
        assertNotNull(aFile.convert());
      }
    }
   
    InputStream is = file.open();
   
    Manifest man = new Manifest(is);
    //remember to close the input stream after use
    is.close();
    assertEquals("com.travel.reservation", man.getMainAttributes().getValue("Application-SymbolicName"));
   
    IFile applicationMF2 = dir.getFile(AppConstants.APPLICATION_MF);
   
    Assert.assertEqualsContract(file, applicationMF2, dir);
    Assert.assertHashCodeEquals(file, applicationMF2, true);
  }
View Full Code Here

     */
   
    IDirectory storedEba = FileSystem.getFSRoot(dest);
    assertNotNull (storedEba);
    assertEquals (storedEba.listFiles().size(), 3);
    IFile ifile = storedEba.getFile("META-INF/APPLICATION.MF");
    assertNotNull (ifile);
    ifile = storedEba.getFile ("META-INF/DEPLOYMENT.MF");
    assertNotNull (ifile);
    ifile = storedEba.getFile ("foo.bar.widgets.jar");
    assertNotNull (ifile);
View Full Code Here

             
          int last_slash = fullPath.lastIndexOf("/");
          appName = fullPath.substring(last_slash + 1, fullPath.length());
      }
                 
      IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF);
      /* We require that all other .jar and .war files included by-value be valid bundles
       * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate
       * wars to wabs, plain jars to bundles
       */
      Set<BundleInfo> extraBundlesInfo = new HashSet<BundleInfo>();
View Full Code Here

   * @return parsed manifest, or an empty Manifest
   * @throws IOException
   */
  private Manifest parseApplicationManifest (IDirectory source) throws IOException {
    Manifest result = new Manifest();
    IFile f = source.getFile(AppConstants.APPLICATION_MF);
    if (f != null) {
      InputStream is = null;
      try {
        is = f.open();
        result = ManifestProcessor.parseManifest(is);
      } catch (IOException iox) {
        _logger.error ("APPMANAGEMENT0007E", new Object[]{source.getName(), iox});
        throw iox;
      } finally {
View Full Code Here

     */
   
    IDirectory storedEba = FileSystem.getFSRoot(dest);
    assertNotNull (storedEba);
    assertEquals (storedEba.listFiles().size(), 3);
    IFile ifile = storedEba.getFile("META-INF/APPLICATION.MF");
    assertNotNull (ifile);
    ifile = storedEba.getFile ("META-INF/DEPLOYMENT.MF");
    assertNotNull (ifile);
    ifile = storedEba.getFile ("foo.bar.widgets.jar");
    assertNotNull (ifile);
View Full Code Here

TOP

Related Classes of org.apache.aries.application.filesystem.IFile

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.