Package org.exoplatform.services.jcr.storage.value

Examples of org.exoplatform.services.jcr.storage.value.ValueIOChannel


    *           if no such storage found with Value storageId
    */
   protected ValueData readValueData(PropertyData pdata, int orderNumber, String storageId) throws SQLException,
      IOException, ValueStorageNotFoundException
   {
      ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
      try
      {
         return channel.read(pdata.getIdentifier(), orderNumber, maxBufferSize);
      }
      finally
      {
         channel.close();
      }
   }
View Full Code Here


      for (int i = 0; i < vdata.size(); i++)
      {
         ValueData vd = vdata.get(i);
         vd.setOrderNumber(i);
         ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
         InputStream stream;
         int streamLength;
         String storageId;
         if (channel == null)
         {
            // prepare write of Value in database
            if (vd.isByteArray())
            {
               byte[] dataBytes = vd.getAsByteArray();
               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               // will spool TransienValueData to a temp file
               stream = vd.getAsStream();
               streamLength = stream.available(); // ask on FileInputStream actually
            }
            storageId = null;
         }
         else
         {
            // write Value in external VS
            channel.write(data.getIdentifier(), vd);
            valueChanges.add(channel);
            storageId = channel.getStorageId();
            stream = null;
            streamLength = 0;
         }
         addValueData(cid, i, stream, streamLength, storageId);
      }
View Full Code Here

      List<ValueData> vdata = data.getValues();

      for (int i = 0; i < vdata.size(); i++)
      {
         ValueData vd = vdata.get(i);
         ValueIOChannel channel = this.containerConfig.valueStorageProvider.getApplicableChannel(data, i);
         InputStream stream;
         int streamLength;
         String storageId;
         if (channel == null)
         {
            // prepare write of Value in database
            if (vd.isByteArray())
            {
               byte[] dataBytes = vd.getAsByteArray();
               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile =
                  SwapFile.get(this.containerConfig.spoolConfig.tempDirectory,
                     cid + i + "." + data.getPersistedVersion(),this.containerConfig.spoolConfig.fileCleaner);
               try
               {
                  long vlen = WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
                  if (vlen <= Integer.MAX_VALUE)
                  {
                     streamLength = (int)vlen;
                  }
                  else
                  {
                     throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                        + ". Property " + data.getQPath().getAsString());
                  }
               }
               finally
               {
                  swapFile.spoolDone();
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
            sizeHandler.accumulateNewSize(streamLength);
         }
         else
         {
            // write Value in external VS
            channel.write(data.getIdentifier(), vd, sizeHandler);
            valueChanges.add(channel);
            storageId = channel.getStorageId();
            stream = null;
            streamLength = 0;
         }

         if (i < totalOldValues)
View Full Code Here

   private void deleteValues(String cid, PropertyData pdata, Set<String> storageDescs, int totalOldValues,
      ChangedSizeHandler sizeHandler) throws IOException, SQLException, InvalidItemStateException, RepositoryException
   {
      for (String storageId : storageDescs)
      {
         final ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId);
         try
         {
            sizeHandler.accumulatePrevSize(channel.getValueSize(pdata.getIdentifier()));

            channel.delete(pdata.getIdentifier());
            valueChanges.add(channel);
         }
         finally
         {
            channel.close();
         }
      }

      if (pdata.getValues().size() < totalOldValues)
      {
View Full Code Here

            {
               String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC);
               String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID);
               int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM);

               ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc);

               dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum);
            }
         }
         finally
         {
            JDBCUtils.freeResources(result, null, null);
View Full Code Here

            {
               String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC);
               String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID);
               int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM);

               ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc);

               dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum);
            }
         }
         finally
         {
            JDBCUtils.freeResources(result, null, null);
View Full Code Here

         }

         // delete all values in value storage
         for (String storageId : storages)
         {
            final ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId);
            try
            {
               sizeHandler.accumulatePrevSize(channel.getValueSize(pdata.getIdentifier()));

               channel.delete(pdata.getIdentifier());
               valueChanges.add(channel);
            }
            finally
            {
               channel.close();
            }
         }

         // delete all Values in database
         deleteValueData(cid);
View Full Code Here

    *           if no such storage found with Value storageId
    */
   protected ValueDataWrapper readValueData(String identifier, int orderNumber, int type, String storageId)
      throws SQLException, IOException, ValueStorageNotFoundException
   {
      ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId);
      try
      {
         return channel.read(identifier, orderNumber, type, containerConfig.spoolConfig);
      }
      finally
      {
         channel.close();
      }
   }
View Full Code Here

      List<ValueData> vdata = data.getValues();

      for (int i = 0; i < vdata.size(); i++)
      {
         ValueData vd = vdata.get(i);
         ValueIOChannel channel = this.containerConfig.valueStorageProvider.getApplicableChannel(data, i);

         InputStream stream;
         int streamLength;
         String storageId;

         if (channel == null)
         {
            // prepare write of Value in database
            if (vd.isByteArray())
            {
               byte[] dataBytes = vd.getAsByteArray();
               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile =
                  SwapFile.get(this.containerConfig.spoolConfig.tempDirectory,
                     cid + i + "." + data.getPersistedVersion(),this.containerConfig.spoolConfig.fileCleaner);
               try
               {
                  long vlen = WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
                  if (vlen <= Integer.MAX_VALUE)
                  {
                     streamLength = (int)vlen;
                  }
                  else
                  {
                     throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                        + ". Property " + data.getQPath().getAsString());
                  }
               }
               finally
               {
                  swapFile.spoolDone();
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
            sizeHandler.accumulateNewSize(streamLength);
         }
         else
         {
            // write Value in external VS
            valueChanges.add(channel);
            channel.write(data.getIdentifier(), vd, sizeHandler);
            storageId = channel.getStorageId();
            stream = null;
            streamLength = 0;
         }
         addValueData(cid, i, stream, streamLength, storageId);
      }
View Full Code Here

         int count = prop.getValues().length;
         Map<Integer, FileIOChannel> channels = new HashMap<Integer, FileIOChannel>();

         for (int i = 0; i < count; i++)
         {
            ValueIOChannel channel = storageProvider.getApplicableChannel((PropertyData)propertyImpl.getData(), i);
            if (channel != null)
            {
               channels.put(i, (FileIOChannel)channel);
            }
         }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.storage.value.ValueIOChannel

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.