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

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


                              File pfile = propertyValue.getFile();
                              if (pfile != null)
                              {
                                 vdata =
                                    new TransientValueData(currentProperty.getValues().size(), null, null,
                                       new SpoolFile(PrivilegedFileHelper.getAbsolutePath(pfile)), fileCleaner,
                                       maxBufferSize, null, true);
                              }
                              else
                              {
                                 vdata = new TransientValueData(currentProperty.getValues().size(), new byte[]{});
View Full Code Here


   private SpoolFile getAsFile(ObjectInputStream ois, long fileSize) throws IOException
   {
      int bufferSize = 1024 * 8;
      byte[] buf = new byte[bufferSize];

      SpoolFile tempFile = SpoolFile.createTempFile("vdincb" + System.currentTimeMillis(), ".stmp", tempDir);
      FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(tempFile);
      long readBytes = fileSize;

      while (readBytes > 0)
      {
View Full Code Here

         OutputStream sfout = null;
         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

         byte[] buffer = new byte[0];
         byte[] tmpBuff = new byte[2048];
         int read = 0;
         int len = 0;
         SpoolFile sf = null;
         OutputStream sfout = null;

         try
         {
            while ((read = tmpStream.read(tmpBuff)) >= 0)
            {
               if (sfout != null)
               {
                  // spool to temp file
                  sfout.write(tmpBuff, 0, read);
                  len += read;
               }
               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);
                  buffer = null;
                  len += read;
               }
               else
               {
                  // reallocate new buffer and spool old buffer contents
                  byte[] newBuffer = new byte[len + read];
                  System.arraycopy(buffer, 0, newBuffer, 0, len);
                  System.arraycopy(tmpBuff, 0, newBuffer, len, read);
                  buffer = newBuffer;
                  len += read;
               }
            }

            if (sf != null)
            {
               // spooled to file
               this.spoolChannel = null;
               this.spoolFile = sf;
               this.data = null;
            }
            else
            {
               // ...bytes
               this.spoolChannel = null;
               this.spoolFile = null;
               this.data = buffer;
            }

            this.spooled = true;
         }
         catch (IOException e)
         {
            if (sf != null)
            {
               try
               {
                  sf.release(this);
                  fileCleaner.addFile(sf);
               }
               catch (FileNotFoundException ex)
               {
                  if (LOG.isDebugEnabled())
                  {
                     LOG.debug("Could not remove temporary file : " + sf.getAbsolutePath());
                  }
               }
            }
           
            throw new IllegalStateException("Error of spooling to temp file from " + tmpStream
View Full Code Here

         // don't send any data there (no stream, no bytes)
         super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true, true);

         this.maxIOBuffSize = calcMaxIOSize();

         SpoolFile sf = null;
         FileChannel sch = null;
         try
         {
            sf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
View Full Code Here

         // don't send any data there (no stream, no bytes)
         super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true, true);

         this.maxIOBuffSize = calcMaxIOSize();

         SpoolFile sf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
         OutputStream sfout = PrivilegedFileHelper.fileOutputStream(sf);
         try
         {
            byte[] tmpBuff = new byte[2048];
            int read = 0;
View Full Code Here

            }
            else
            {

               // switch from bytes to file/channel
               SpoolFile chf = null;
               FileChannel chch = null;
               long newIndex = 0; // first pos to write

               try
               {
View Full Code Here

               this.data = newBytes;
            }
            else
            {
               // switch from bytes to file/channel
               SpoolFile chf = null;
               FileChannel chch = null;
               try
               {
                  chf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
                  chch = new RandomAccessFile(chf, "rw").getChannel();
View Full Code Here

    */
   public void addNewStream(FixupStream fs) throws IOException
   {
      this.getFixupStreams().add(fs);

      SpoolFile f = SpoolFile.createTempFile("tempFile" + IdGenerator.generate(), ".tmp", tempDir);

      this.getListFile().add(f);
      this.getListRandomAccessFiles().add(PrivilegedFileHelper.randomAccessFile(f, "rw"));

   }
View Full Code Here

         ValueData vd = (propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));

         // re-init the value
         propertyData.getValues().set(
            listFixupStream.get(i).getValueDataId(),
                  new StreamPersistedValueData(vd.getOrderNumber(), new SpoolFile(listFile.get(i).getAbsolutePath())));
      }

      if (listRandomAccessFile != null)
         for (int i = 0; i < listRandomAccessFile.size(); i++)
            listRandomAccessFile.get(i).close();
View Full Code Here

TOP

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

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.