Package org.exoplatform.services.jcr.impl.util.io

Examples of org.exoplatform.services.jcr.impl.util.io.FileCleaner


   @Override
   protected void setUp() throws Exception
   {
      super.setUp();

      cleaner = new FileCleaner(2000);

      rootDir = new File(new File("target"), "vs1");
      rootDir.mkdirs();

      new File(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
View Full Code Here


   }

   public void testCreateFileStreamTransientValueData() throws Exception
   {
      FileCleaner testFileCleaner = new FileCleaner();
      try
      {
         byte[] buf = "0123456789".getBytes();
         File file = new File("target/testCreateFileStreamTransientValueData");
         if (file.exists())
            file.delete();
         FileOutputStream out = new FileOutputStream(file);
         out.write(buf);
         out.close();

         FileInputStream fs1 = new FileInputStream(file);
         TransientValueData vd =
            new TransientValueData(0, null, fs1, null, testFileCleaner, 5, new File("target"), true);

         // spool to file
         InputStream fs2 = vd.getAsStream();
         assertEquals(10, vd.getLength());
         assertTrue(fs2 instanceof FileInputStream);

         // not the same object as new is is from spool file
         assertNotSame(fs1, fs2);
         // spooled to file so not a byte array
         assertFalse(vd.isByteArray());

         // next call return not the same object as well
         // (new stream every time)
         assertNotSame(vd.getAsStream(), fs2);
         assertEquals(10, vd.getLength());

         // gets as byte array
         assertEquals(10, vd.getAsByteArray().length);
         // but still spooled to file
         assertFalse(vd.isByteArray());

      }
      finally
      {
         testFileCleaner.halt();
      }

   }
View Full Code Here

      assertTrue(vd.getAsStream() instanceof FileInputStream);
   }

   public void testIfFinalizeRemovesTempFileStreamValueData() throws Exception
   {
      FileCleaner testFileCleaner = new FileCleaner(1000, true);
      try
      {
         byte[] buf = "0123456789".getBytes();
         File file = new File(new File("target"), "testIfFinalizeRemovesTempFileStreamValueData");
         SwapFile swapFile = SwapFile.get(new File("target"), "testIfFinalizeRemovesTempFileStreamValueData",testFileCleaner);
         //File file = new File("target/testIfFinalizeRemovesTempFileStreamValueData");
         //if (file.exists())
         //  file.delete();
         FileOutputStream out = new FileOutputStream(swapFile);
         out.write(buf);
         out.close();

         CleanableFilePersistedValueData vd = new CleanableFilePersistedValueData(0, swapFile, testFileCleaner);
         assertTrue(file.exists());

         vd = null;
         swapFile = null;
        
         System.gc();

         // allows GC to call finalize on vd
         Thread.sleep(2500);
         System.gc();

         assertFalse(file.exists());
      }
      finally
      {
         testFileCleaner.halt();
      }
   }
View Full Code Here

         this.swapDirectory = new File(DEF_SWAPDIR);
      }
      if (!swapDirectory.exists())
         swapDirectory.mkdirs();

      this.swapCleaner = new FileCleaner(false);

      initDatabase();

      String suParam = null;
      boolean enableStorageUpdate = false;
View Full Code Here

   {
      WorkspaceContainerFacade workspaceContainer =
         repoService.getRepository(repositoryName).getWorkspaceContainer(workspaceName);
      WorkspacePersistentDataManager dataManager =
         (WorkspacePersistentDataManager)workspaceContainer.getComponent(WorkspacePersistentDataManager.class);
      FileCleaner fileCleaner =
         ((FileCleanerHolder)workspaceContainer.getComponent(FileCleanerHolder.class)).getFileCleaner();
      JCRRestore restorer = new JCRRestore(dataManager, fileCleaner);
      restorer.incrementalRestore(new File(pathBackupFile));
   }
View Full Code Here

    */
   public WorkspaceDataTransmitter(CacheableWorkspaceDataManager dataManager) throws RepositoryConfigurationException
   {
      dataManager.addItemPersistenceListener(this);
      // TODO: need to use FileCleaner from FileCleanerHolder
      this.fileCleaner = new FileCleaner(ReplicationService.FILE_CLEANRE_TIMEOUT);
   }
View Full Code Here

    *           will be generated the RepositoryConfigurationException
    */
   public AbstractWorkspaceDataReceiver() throws RepositoryConfigurationException
   {
      // TODO: need to use FileCleaner from FileCleanerHolder
      this.fileCleaner = new FileCleaner(ReplicationService.FILE_CLEANRE_TIMEOUT);
      mapPendingBinaryFile = new HashMap<String, PendingBinaryFile>();

      state = INIT_MODE;
   }
View Full Code Here

      this.dataManager = dataManager;

      this.namespaceRegistry = namespaceRegistry;
      this.locationFactory = locationFactory;

      this.fileCleaner = new FileCleaner(false); // cleaner should be started!
      this.maxBufferSize =
         config.getContainer().getParameterInteger(WorkspaceDataContainer.MAXBUFFERSIZE_PROP,
            WorkspaceDataContainer.DEF_MAXBUFFERSIZE);

      this.restorePath =
View Full Code Here

      this.dataManager = dataManager;

      this.namespaceRegistry = namespaceRegistry;
      this.locationFactory = locationFactory;

      this.fileCleaner = new FileCleaner(false); // cleaner should be started!
      this.maxBufferSize =
         config.getContainer().getParameterInteger(WorkspaceDataContainer.MAXBUFFERSIZE_PROP,
            WorkspaceDataContainer.DEF_MAXBUFFERSIZE);
      this.restorePath = restorePath;
   }
View Full Code Here

      AccessManager accessManager) throws RepositoryConfigurationException, PathNotFoundException, RepositoryException
   {
      super(config, repConfig, dataManager, namespaceRegistry, locationFactory, nodeTypeManager, valueFactory,
         accessManager);

      this.fileCleaner = new FileCleaner();

      restoreDir = restorePath;

      String fullBackupPath = getFullBackupPath();
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.util.io.FileCleaner

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.