Package net.sourceforge.javautil.common.io

Examples of net.sourceforge.javautil.common.io.IVirtualDirectory


   
    return pom;
  }
 
  public void cacheRemoteAttempt(List<IClassPackageRepositoryRemote> remote, IClassPackageReference reference) {
    IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(reference), true);

    String filename = this.createFilenamePrefix(reference) + ".pom.lastUpdated";
    Properties properties = new Properties();
   
    if (packageDir.getFile(filename) != null) {
      try {
        properties.load(packageDir.getFile(filename).getInputStream());
      } catch (IOException e) {
        log.warning("Could not load previous remote attempt cache for: " + reference + ": " + e.getMessage());
        ThrowableManagerRegistry.caught(e);
      }
    }
   
    IVirtualFile cache = packageDir.getFile(filename, true);
    for (IClassPackageRepositoryRemote rr : remote) {
      properties.setProperty(rr.getRepositoryURL().toExternalForm(), String.valueOf(System.currentTimeMillis()));
    }
   
    OutputStream out = null;
View Full Code Here


  }
 
  public List<IClassPackageRepositoryRemoteAttempt> getLastRemoteAttempts(IClassPackageReference reference) {
    List<IClassPackageRepositoryRemoteAttempt> attempts = new ArrayList<IClassPackageRepositoryRemoteAttempt>();
   
    IVirtualDirectory packageDir = this.getDirectory(reference);
    if (packageDir != null) {
      IVirtualFile cache = packageDir.getFile(this.createFilenamePrefix(reference) + ".pom.lastUpdated");
      if (cache != null) {
        try {
          Properties properties = new Properties();
          properties.load( cache.getInputStream() );
          Enumeration names = properties.propertyNames();
View Full Code Here

   
    return attempts;
  }
 
  public void importPackage(IVirtualFile file, String packaging, IClassPackageReference reference) {
    IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(reference), true);
   
    String jarPrefix = this.createJarPrefix(reference);
    String prefix = this.createFilenamePrefix(reference);
   
    IVirtualFile target = packageDir.getFile(jarPrefix + "." + packaging);
    if (target == null) {
      ProjectObjectModel pom = new ProjectObjectModel();
      pom.setModelVersion("4.0");
      pom.setGroupId(reference.getGroupId());
      pom.setArtifactId(reference.getArtifactId());
      pom.setVersionString(reference.getVersion().toVersionString());
      pom.setPackaging(packaging);
     
      try {
        pom.write(packageDir.createFile(prefix + ".pom").getOutputStream());
        file.copy( packageDir.createFile(jarPrefix + "." + packaging) );
       
        this.clearCachedInformation(reference);
      } catch (JAXBException e) {
        throw ThrowableManagerRegistry.caught(e);
      } catch (IOException e) {
View Full Code Here

      throw new IllegalArgumentException("This package already exists");
    }
  }
 
  public void importPackage(IClassPackageRepositoryRemote remote, IClassPackageResolver resolver, IClassPackageReference reference) {
    IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(reference), true);

    String jarPrefix = this.createJarPrefix(reference);
    String prefix = this.createFilenamePrefix(reference);
   
    URL source = null;
   
    URL pom = remote.getResource(reference, prefix + ".pom");
    if (pom != null) {
      boolean validated = this.download(pom, packageDir.getFile(prefix + ".pom", true));
     
      if (!validated) this.handleInvalidChecksum(packageDir, reference, pom);
     
      ProjectObjectModel pomXml = this.resolveDescriptor(resolver, reference);
      if ("pom".equals( pomXml.getPackaging() )) return;
     
      source = remote.getResource(reference, jarPrefix + ".jar");
      if (source == null) return;
     
    } else {
      return;
    }
   
    boolean validated = this.download(source, packageDir.getFile(jarPrefix + ".jar", true));
    if (!validated) this.handleInvalidChecksum(packageDir, reference, pom);
  }
View Full Code Here

    }
    return null;
  }

  @Override public ProjectObjectModel resolveDescriptor(IClassPackageResolver resolver, IClassPackageReference reference) {
    IVirtualDirectory directory = this.getDirectory(reference);
    if (directory != null) {
      IVirtualFile pd = directory.getFile( this.createFilenamePrefix(reference) + ".pom" );
      try {
        ProjectObjectModel model = pd != null ? ProjectObjectModel.parse(resolver, pd) : null;
//        if (model != null && model.getVersion() == null)
//          model.setVersionString( reference.getVersion().toVersionString() );
//       
View Full Code Here

    return null;
  }
 
  public List<IVersion> getVersionsAvailable(IClassArtifactReference reference) {
    try {
      IVirtualDirectory artifactDir = this.directory.getDirectory( this.createArtifactPath(reference) );
     
      List<IVersion> version = new ArrayList<IVersion>();
     
      for (IVirtualDirectory versionDir : artifactDir.getDirectories()) {
        version.add( ClassPackageImpl.decode(versionDir.getName()) );
      }
     
      return version;
    } catch (VirtualArtifactNotFoundException e) {
View Full Code Here

    return resolver;
  }

  public static void addProjectMainTarget (CompositeClassSource ccs, ProjectObjectModel model, IVirtualDirectory root) {
    try {
      IVirtualDirectory dir = root.getDirectory( new SimplePath(model.getCompileDirectoryOrDefault()) );
      ccs.add(new VirtualDirectoryClassSource(dir));
    } catch (VirtualArtifactNotFoundException e) {
    }
  }
View Full Code Here

    }
  }
 
  public static void addProjectTestTarget (CompositeClassSource ccs, ProjectObjectModel model, IVirtualDirectory root) {
    try{
      IVirtualDirectory dir = root.getDirectory( new SimplePath(model.getCompileTestsDirectoryOrDefault()) );
      ccs.add(new VirtualDirectoryClassSource(dir));
    } catch (VirtualArtifactNotFoundException e) {
    }
  }
View Full Code Here

  /**
   * This will detect standard locations of the {@link ProjectObjectModel} file.
   */
  protected IVirtualFile getDescriptorFile (IVirtualArtifact possibleClassPackage) {
    if (possibleClassPackage instanceof IVirtualDirectory) {
      IVirtualDirectory pkg = (IVirtualDirectory) possibleClassPackage;
      IVirtualFile pomXMLFile = pkg.getFile(ProjectObjectModel.DEFAULT_FILE_NAME);
      if (pomXMLFile == null) {
        if ( pkg.isExists(JARRED_PATH_PREFIX) ) {
          try {
            IVirtualDirectory group = pkg.getDirectory(JARRED_PATH_PREFIX).getDirectories().get(0);
            IVirtualDirectory artifact = group.getDirectories().get(0);
           
            pomXMLFile = artifact.getFile(ProjectObjectModel.DEFAULT_FILE_NAME);
            if (pomXMLFile != null) return pomXMLFile;
          } catch (ArrayIndexOutOfBoundsException e) {}
        }
      } else return pomXMLFile;
    }
View Full Code Here

   * @param repositoryName The repository to retreive
   * @param autoCreate True if the repository should be created if it does not already exist, otherwise false
   * @return The in memory repository
   */
  public static IVirtualDirectory getInMemoryRepository (String repositoryName, boolean autoCreate) {
    IVirtualDirectory repository = VirtualArtifactSystem.get(MEMORY_REPOSITORY_VAS, true).getDirectory(repositoryName, autoCreate);
    if (repository == null) throw new IllegalArgumentException("Could not find repository: " + repositoryName);
    return repository;
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.common.io.IVirtualDirectory

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.