[exo-jcr-commits] exo-jcr SVN: r2408 - in jcr/branches/1.14.x: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed May 19 09:15:15 EDT 2010


Author: tolusha
Date: 2010-05-19 09:15:14 -0400 (Wed, 19 May 2010)
New Revision: 2408

Modified:
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
   jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
   jcr/branches/1.14.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
Log:
EXOJCR-732: Using SpoolFile instead of File in ValueData's constructors 

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -39,6 +39,7 @@
 import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
 import org.exoplatform.services.jcr.impl.storage.JCRItemExistsException;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
 import org.exoplatform.services.jcr.observation.ExtendedEvent;
 
 import java.io.EOFException;
@@ -441,8 +442,8 @@
                (TransientValueData)(propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));
 
             // re-init the value
-            tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, listFile.get(i), fileCleaner, -1,
-               null, true));
+            tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, new SpoolFile(listFile.get(i)
+               .getAbsolutePath()), fileCleaner, -1, null, true));
          }
       }
    }

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -43,6 +43,7 @@
 import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
 import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
 import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
@@ -768,8 +769,8 @@
                               if (pfile != null)
                               {
                                  vdata =
-                                    new TransientValueData(currentProperty.getValues().size(), null, null, pfile,
-                                       fileCleaner, maxBufferSize, null, true);
+                                    new TransientValueData(currentProperty.getValues().size(), null, null,
+                                       new SpoolFile(pfile.getAbsolutePath()), fileCleaner, maxBufferSize, null, true);
                               }
                               else
                               {

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -19,6 +19,7 @@
 package org.exoplatform.services.jcr.impl.dataflow;
 
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 
@@ -59,7 +60,7 @@
       }
 
       // TODO use InputStream instead of spoolFile and use Channel.transferFrom.
-      public NewEditableValueData(File spoolFile, int orderNumber, FileCleaner fileCleaner, int maxBufferSize,
+      public NewEditableValueData(SpoolFile spoolFile, int orderNumber, FileCleaner fileCleaner, int maxBufferSize,
          File tempDirectory) throws IOException
       {
 
@@ -68,11 +69,11 @@
 
          this.maxIOBuffSize = calcMaxIOSize();
 
-         File sf = null;
+         SpoolFile sf = null;
          FileChannel sch = null;
          try
          {
-            sf = File.createTempFile("jcrvdedit", null, tempDirectory);
+            sf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
 
             sch = new RandomAccessFile(sf, "rw").getChannel();
 
@@ -123,7 +124,7 @@
 
          this.maxIOBuffSize = calcMaxIOSize();
 
-         File sf = File.createTempFile("jcrvdedit", null, tempDirectory);
+         SpoolFile sf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
          OutputStream sfout = new FileOutputStream(sf);
          try
          {
@@ -177,44 +178,6 @@
          return buffSize;
       }
 
-      //   public TransientValueData createTransientCopy() throws RepositoryException
-      //   {
-      //      if (isByteArray())
-      //      {
-      //         // bytes, make a copy of real data
-      //         byte[] newBytes = new byte[data.length];
-      //         System.arraycopy(data, 0, newBytes, 0, newBytes.length);
-      //         return new TransientValueData(newBytes, orderNumber);
-      //      }
-      //      else
-      //      {
-      //         // stream, make a copy
-      //         try
-      //         {
-      //            // force changes made to the file
-      //            spoolChannel.force(false);
-      //
-      //            InputStream thisStream = getAsStream();
-      //            try
-      //            {
-      //               TransientValueData copy =
-      //                  new TransientValueData(orderNumber, null, thisStream, null, fileCleaner, maxBufferSize,
-      //                     tempDirectory, true);
-      //               copy.spoolInputStream(); // force spool - read now, till the source isn't changed
-      //               return copy;
-      //            }
-      //            finally
-      //            {
-      //               thisStream.close();
-      //            }
-      //         }
-      //         catch (IOException e)
-      //         {
-      //            throw new RepositoryException("Create transient copy error. " + e, e);
-      //         }
-      //      }
-      //   }
-
       /**
        * Update with <code>length</code> bytes from the specified <code>stream</code> to this value data
        * at <code>position</code>.
@@ -294,13 +257,13 @@
             {
 
                // switch from bytes to file/channel
-               File chf = null;
+               SpoolFile chf = null;
                FileChannel chch = null;
                long newIndex = 0; // first pos to write
 
                try
                {
-                  chf = File.createTempFile("jcrvdedit", null, tempDirectory);
+                  chf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
                   chch = new RandomAccessFile(chf, "rw").getChannel();
 
                   // allocate the space for whole file
@@ -397,11 +360,11 @@
             else
             {
                // switch from bytes to file/channel
-               File chf = null;
+               SpoolFile chf = null;
                FileChannel chch = null;
                try
                {
-                  chf = File.createTempFile("jcrvdedit", null, tempDirectory);
+                  chf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
                   chch = new RandomAccessFile(chf, "rw").getChannel();
 
                   ReadableByteChannel bch = Channels.newChannel(new ByteArrayInputStream(this.data));
@@ -504,7 +467,7 @@
       this.delegate = new NewEditableValueData(bytes, orderNumber, fileCleaner, maxBufferSize, tempDirectory);
    }
 
-   public EditableValueData(File spoolFile, int orderNumber, FileCleaner fileCleaner, int maxBufferSize,
+   public EditableValueData(SpoolFile spoolFile, int orderNumber, FileCleaner fileCleaner, int maxBufferSize,
       File tempDirectory) throws IOException
    {
       this.delegate = new NewEditableValueData(spoolFile, orderNumber, fileCleaner, maxBufferSize, tempDirectory);

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -70,7 +70,7 @@
 
       protected InputStream tmpStream;
 
-      protected File spoolFile;
+      protected SpoolFile spoolFile;
 
       protected final boolean closeTmpStream;
 
@@ -146,7 +146,7 @@
        * @throws IOException
        *           if read error
        */
-      protected NewValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
+      protected NewValueData(int orderNumber, byte[] bytes, InputStream stream, SpoolFile spoolFile,
          FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile, boolean closeTmpStream)
          throws IOException
       {
@@ -163,10 +163,7 @@
 
          if (spoolFile != null)
          {
-            if (spoolFile instanceof SpoolFile)
-            {
-               ((SpoolFile)spoolFile).acquire(this);
-            }
+            spoolFile.acquire(this);
 
             if (this.tmpStream != null)
             {
@@ -744,7 +741,7 @@
     * @throws IOException
     *           if read error
     */
-   public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
+   public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, SpoolFile spoolFile,
       FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile, boolean closeTmpStream)
       throws IOException
    {
@@ -775,7 +772,7 @@
     * @throws IOException
     *           if read error
     */
-   public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
+   public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, SpoolFile spoolFile,
       FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile) throws IOException
    {
       this.delegate =
@@ -823,7 +820,7 @@
     * @throws IOException
     *           if read error
     */
-   public TransientValueData(int orderNumber, File spoolFile, FileCleaner fileCleaner, boolean deleteSpoolFile)
+   public TransientValueData(int orderNumber, SpoolFile spoolFile, FileCleaner fileCleaner, boolean deleteSpoolFile)
       throws IOException
    {
       this.delegate =
@@ -1191,7 +1188,7 @@
     * 
     * @return File temp file
     */
-   public File getSpoolFile()
+   public SpoolFile getSpoolFile()
    {
       if (delegate instanceof NewValueData)
       {

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -21,7 +21,6 @@
 import org.exoplatform.services.jcr.datamodel.ValueData;
 import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
 import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.util.io.SwapFile;
 
 import java.io.Externalizable;
 import java.io.File;

Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -41,7 +41,7 @@
 
    protected InputStream stream;
 
-   protected File tempFile;
+   protected SpoolFile tempFile;
 
    /**
     * StreamPersistedValueData  constructor for stream data.
@@ -61,7 +61,7 @@
     * @param tempFile File
     * @throws FileNotFoundException 
     */
-   public StreamPersistedValueData(int orderNumber, File tempFile) throws FileNotFoundException
+   public StreamPersistedValueData(int orderNumber, SpoolFile tempFile) throws FileNotFoundException
    {
       this(orderNumber, tempFile, null);
    }
@@ -91,15 +91,15 @@
     * @param tempFile File
     * @throws FileNotFoundException 
     */
-   public StreamPersistedValueData(int orderNumber, File tempFile, File destFile) throws FileNotFoundException
+   public StreamPersistedValueData(int orderNumber, SpoolFile tempFile, File destFile) throws FileNotFoundException
    {
       super(orderNumber, destFile);
       this.tempFile = tempFile;
       this.stream = null;
 
-      if (tempFile != null && tempFile instanceof SpoolFile)
+      if (tempFile != null)
       {
-         ((SpoolFile)tempFile).acquire(this);
+         tempFile.acquire(this);
       }
    }
 
@@ -129,7 +129,7 @@
     * 
     * @return File temporary file or null
     */
-   public File getTempFile()
+   public SpoolFile getTempFile()
    {
       return tempFile;
    }
@@ -233,9 +233,9 @@
             ((SwapFile)file).release(this);
          }
 
-         if (tempFile != null && tempFile instanceof SpoolFile)
+         if (tempFile != null)
          {
-            ((SpoolFile)tempFile).release(this);
+            tempFile.release(this);
          }
       }
       finally

Modified: jcr/branches/1.14.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java	2010-05-18 12:29:14 UTC (rev 2407)
+++ jcr/branches/1.14.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java	2010-05-19 13:15:14 UTC (rev 2408)
@@ -25,6 +25,7 @@
 import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
 import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
 import org.exoplatform.services.jcr.util.IdGenerator;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
@@ -472,7 +473,7 @@
    public void restore() throws IOException
    {
       // TODO same code as in BackupWorkspaceInitializer?
-      
+
       List<ItemState> listItemState = itemDataChangesLog.getAllStates();
       for (int i = 0; i < this.listFixupStream.size(); i++)
       {
@@ -484,8 +485,8 @@
             (TransientValueData)(propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));
 
          // re-init the value
-         tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, listFile.get(i), fileCleaner, -1,
-            null, true));
+         tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, new SpoolFile(listFile.get(i)
+            .getAbsolutePath()), fileCleaner, -1, null, true));
       }
 
       if (listRandomAccessFile != null)



More information about the exo-jcr-commits mailing list