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

Examples of org.exoplatform.services.jcr.impl.util.io.SpoolFile.acquire()


   public void testFileInUse() throws FileNotFoundException
   {
      SpoolFile sf = new SpoolFile(DIR_NAME + FILE_NAME);

      sf.acquire("holder");
      assertTrue("The file has holder. It must be in use.", sf.inUse());

      sf.release("holder");
      assertFalse("The file has no holder. It should not be in use.", sf.inUse());
View Full Code Here


   {
      // This method creates a file on disk space.
      SpoolFile sf = SpoolFile.createTempFile("prefix", "suffics", new File(DIR_NAME));

      // Add new holder of file and try to delete a file with holder.
      sf.acquire("holder");
      assertFalse("File in use.", sf.delete());

      // Release file and try to delete a file without holder.
      sf.release("holder");
      assertTrue("File not in use. It should be deleted", sf.delete());
View Full Code Here

   {
      // This method not creates a file on disk space.
      SpoolFile sf = new SpoolFile(DIR_NAME + FILE_NAME);

      // Add and release new holder of file.
      sf.acquire("holder");
      sf.release("holder");

      // Now file is free. It can be deleted.
      // File on disk does not exist. It will not be removed from disk space.
      assertTrue("Deleted file was not created on the disk.", sf.delete());
View Full Code Here

   {
      // This method creates a file on disk space.
      SpoolFile sf = SpoolFile.createTempFile("prefix", "suffics", new File(DIR_NAME));

      // Add and release new holder of file.
      sf.acquire("holder");
      sf.release("holder");

      // Now file is free. It can be deleted.
      // File is present on the disk. It will be removed from disk space.
      assertTrue("File should be removed.", sf.delete());
View Full Code Here

         int read = 0;

         try
         {
            SpoolFile sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
            sf.acquire(this);
            sfout = PrivilegedFileHelper.fileOutputStream(sf);

            while ((read = tmpStream.read(tmpBuff)) >= 0)
               sfout.write(tmpBuff, 0, read);
View Full Code Here

               else if (len + read > maxBufferSize && fileCleaner != null)
               {
                  // threshold for keeping data in memory exceeded,
                  // if have a fileCleaner create temp file and spool buffer contents.
                  sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
                  sf.acquire(this);

                  sfout = PrivilegedFileHelper.fileOutputStream(sf);

                  sfout.write(buffer, 0, len);
                  sfout.write(tmpBuff, 0, read);
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.