Examples of IVirtualFile


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

    Connection connection = null;
    ZipOutputStream zip = null;
    try {
      connection = dataSource.getConnection();
     
      IVirtualFile storage = BackupUtil.rotate(this.storageDirectory, "backup", "dat", 20);
      storage.setIOHandler( new EncryptionIOHandler(provider) );
     
      zip = new ZipOutputStream(storage.getOutputStream());
     
      PrintWriter writer = new PrintWriter(zip, true);
      for (EncryptedTable table : getEncryptedTables(connection)) {
        ZipEntry entry = new ZipEntry(table.tableName + ".dat");
        zip.putNextEntry(entry);
View Full Code Here

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

    ZipInputStream is = null;
    try {
      connection = dataSource.getConnection();
      for (int i=1; i<=20; i++) {
        try {
          IVirtualFile storage = this.storageDirectory.getFile(BackupUtil.getRotatedFileName("backup", "dat", 1));
          if (storage == null) return;
         
          storage.setIOHandler( new EncryptionIOHandler(provider) );
          is = new ZipInputStream(storage.getInputStream());
         
          ZipEntry entry = null;
          BufferedReader reader = new BufferedReader(new InputStreamReader(is));
          while ( (entry = is.getNextEntry()) != null ) {
            EncryptedTable found = null;
View Full Code Here

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

   * @param name The name of the new file
   * @param url The URL that forms the source for input/output for the file
   * @return A new file that will automatically be created in this directory
   */
  public IVirtualFile createFile(String name, URL url) {
    IVirtualFile file = new DirectoryFile(name, this);
    file.setIOHandler(new URLIOHandler(url));
    this.artifacts.put(name, file);
    return file;
  }
View Full Code Here

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

   * @return The file this is linking
   */
  public IVirtualFile getDelegate() { return delegate; }
 
  public <T> IVirtualFile unwrap(Class<T> type) {
    IVirtualFile artifact = this;
    while (artifact instanceof VirtualArtifactWrapped && !(type.isAssignableFrom(artifact.getClass()))) {
      artifact = (IVirtualFile) ((VirtualArtifactWrapped)artifact).getDelegate();
    }
    return artifact;
  }
View Full Code Here

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

   *
   * @return The file that can be used for the backup
   */
  public static IVirtualFile rotate (IVirtualDirectory directory, String prefix, String extension, int maxRotations) {
    for (int i=maxRotations; i>0; i--) {
      IVirtualFile rotation = directory.getFile(getRotatedFileName(prefix, extension, i));
      if (rotation != null) {
        if (i == maxRotations) rotation.remove();
        else rotation.rename(getRotatedFileName(prefix, extension, i+1));
      }
    }
    return directory.getFile(getRotatedFileName(prefix, extension, 1), true);
  }
View Full Code Here

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

   * @return The most recent file available for recovery
   */
  public static IVirtualFile reverseRotation (IVirtualDirectory directory, String prefix, String extension, int maxRotations) {
    int minimum = -1;
    for (int i=1; i<=maxRotations; i++) {
      IVirtualFile rotation = directory.getFile(getRotatedFileName(prefix, extension, i));
      if (rotation != null) {
        if (i == 1) {
          IVirtualFile reverse = rotate(directory, prefix + "-reverse", extension, maxRotations);
          rotation.copy(reverse);
          if (!rotation.remove())
            throw new IllegalStateException("Could not remove rotation file: " + rotation);
        }
        else {
View Full Code Here

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

    try {
      IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(descriptor), true);

      String prefix = this.createFilenamePrefix(descriptor);
     
      IVirtualFile imported = packageDir.getFile(remote.getName().replaceAll("[:/]+", "-") + "remote-" + prefix + ".pom", true);
      ((ProjectObjectModel) descriptor).write(imported.getOutputStream());
    } catch (VirtualArtifactNotFoundException e) {
      throw new ClassPackageException(descriptor, "Could not import remote descriptor", e);
    } catch (IOException e) {
      throw new ClassPackageException(descriptor, "Could not import remote descriptor", e);
    } catch (JAXBException e) {
View Full Code Here

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

  @Override public IClassPackageDescriptor getCachedRemotedDescriptor(IClassPackageResolver resolver, IClassPackageRepositoryRemote remote, IClassPackageReference reference) {
    IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(reference), true);

    String prefix = this.createFilenamePrefix(reference);
   
    IVirtualFile cache = packageDir.getFile( remote.getName().replaceAll("[:/ ]+", "-") + "remote-" + prefix + ".pom" );
   
    ProjectObjectModel pom = cache == null ? null : ProjectObjectModel.parse(resolver, cache);
   
    return pom;
  }
View Full Code Here

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

        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;
    try {
      out = cache.getOutputStream();
      properties.store(out, "#Last modified on: " + new Date());
    } catch (IOException e) {
      throw ThrowableManagerRegistry.caught(e);
    } finally {
      if (out != null) try { out.close(); } catch (IOException e) { ThrowableManagerRegistry.caught(e); }
View Full Code Here

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

  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();
          while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            attempts.add(new ClassPackageRepositoryRemoteAttemptImpl(Long.parseLong(properties.getProperty(name)), name));
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.