Examples of ValueData


Examples of org.exoplatform.services.jcr.datamodel.ValueData

      {
         while (valueRecords.next())
         {
            final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
            final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
            ValueData vdata =
               valueRecords.wasNull() ? readValueData(cid, orderNum, cversion, valueRecords
                  .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum, storageId);
            data.add(vdata);
         }
      }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

                  int orderNum = resultSet.getInt(COLUMN_VORDERNUM);
                  // check is there value columns
                  if (!resultSet.wasNull())
                  {
                     final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
                     ValueData vdata =
                        resultSet.wasNull() ? readValueData(cid, orderNum, cversion, resultSet
                           .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum, storageId);
                     data.add(vdata);
                  }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

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

      for (int i = 0; i < vdata.size(); i++)
      {
         ValueData vd = vdata.get(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
            {
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

            QPath.makeChildPath(traverseQPath(tempNode.cpid), InternalQName.parse(tempNode.cname), tempNode.cindex);
      }

      // primary type if exists in the list of properties
      InternalQName ptName = null;
      ValueData ptValue = null;

      SortedSet<TempPropertyData> ptTempProp = tempNode.properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
      if (ptTempProp != null)
      {
         ptValue = ptTempProp.first().getValueData();
         ptName = InternalQName.parse(new String(ptValue.getAsByteArray(), Constants.DEFAULT_ENCODING));
      }

      // mixins if exist in the list of properties
      List<ValueData> mixinsData = new ArrayList<ValueData>();
      List<InternalQName> mixins = new ArrayList<InternalQName>();

      Set<TempPropertyData> mixinsTempProps = tempNode.properties.get(Constants.JCR_MIXINTYPES.getAsString());
      if (mixinsTempProps != null)
      {
         for (TempPropertyData mxnb : mixinsTempProps)
         {
            ValueData vdata = mxnb.getValueData();

            mixinsData.add(vdata);
            mixins.add(InternalQName.parse(new String(vdata.getAsByteArray(), Constants.DEFAULT_ENCODING)));
         }
      }

      // build node data. No need to load ACL. The node will be pushed directly for reindexing.
      NodeData nodeData =
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

         {
            List<ValueData> mvs = frozenMixinTypes.getValues();
            mixins = new InternalQName[mvs.size()];
            for (int i = 0; i < mvs.size(); i++)
            {
               ValueData mvd = mvs.get(i);
               mixins[i] = InternalQName.parse(new String(mvd.getAsByteArray()));

               if (mixins[i].equals(Constants.EXO_PRIVILEGEABLE))
               {
                  PropertyData aclData =
                     (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.EXO_PERMISSIONS, 0),
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

      }

      boolean invalid = true;

      // do not use getString because of string consuming
      ValueData valueData = value;
      if (type == PropertyType.STRING)
      {
         try
         {
            String strVal = new String(valueData.getAsByteArray(), Constants.DEFAULT_ENCODING);

            for (int i = 0; invalid && i < constraints.length; i++)
            {
               String constrString = constraints[i];
               if (strVal.matches(constrString))
               {
                  invalid = false;
               }
            }
         }
         catch (UnsupportedEncodingException e)
         {
            throw new RuntimeException("FATAL ERROR Charset " + Constants.DEFAULT_ENCODING + " is not supported!");
         }
         catch (IOException e)
         {
            throw new RepositoryException("FATAL ERROR Value data stream reading error " + e.getMessage(), e);
         }

      }
      else if (type == PropertyType.NAME)
      {
         NameValue nameVal;
         try
         {
            nameVal = new NameValue(valueData, locator);
         }
         catch (IOException e)
         {
            throw new RepositoryException(e);
         }
         for (int i = 0; invalid && i < constraints.length; i++)
         {
            String constrString = constraints[i];
            InternalQName constrName = locator.parseJCRName(constrString).getInternalName();
            if (nameVal.getQName().equals(constrName))
            {
               invalid = false;
            }
         }
      }
      else if (type == PropertyType.PATH)
      {
         PathValue pathVal;
         try
         {
            pathVal = new PathValue(valueData, locator);
         }
         catch (IOException e)
         {
            throw new RepositoryException(e);
         }
         for (int i = 0; invalid && i < constraints.length; i++)
         {
            JCRPathMatcher constrPath = parsePathMatcher(locator, constraints[i]);
            if (constrPath.match(pathVal.getQPath()))
            {
               invalid = false;
            }
         }
      }
      else if (type == PropertyType.REFERENCE)
      {
         try
         {
            ReferenceValue refVal = new ReferenceValue(valueData);
            NodeData refNode = (NodeData)itemDataConsumer.getItemData(refVal.getIdentifier().getString());
            for (int i = 0; invalid && i < constraints.length; i++)
            {
               String constrString = constraints[i];
               InternalQName constrName = locator.parseJCRName(constrString).getInternalName();
               if (nodeTypeDataManager
                  .isNodeType(constrName, refNode.getPrimaryTypeName(), refNode.getMixinTypeNames()))
               {
                  invalid = false;
               }
            }
         }
         catch (ItemNotFoundException e)
         {
            if (LOG.isDebugEnabled())
            {
               LOG.debug("Reference constraint node is not found: " + e.getMessage());
            }
            // But if it's a versionHisroy ref property for add mix:versionable...
            // we haven't a versionHisroy created until save method will be called
            // on this
            // session/item...
            // it's transient state here.
            invalid = false; // so, value is matched, we hope...
         }
         catch (RepositoryException e)
         {
            LOG.error("Reference constraint error: " + e.getMessage(), e);
            // [PN] Posible trouble is session.getNodeByUUID() call result,
            // till bug can be found in version restore operation.
            invalid = true;
         }
         catch (IOException e)
         {
            LOG.error("Reference constraint error: " + e.getMessage(), e);
            invalid = true;
         }
      }
      else if (type == PropertyType.BINARY)
      {
         long valueLength = valueData.getLength();
         for (int i = 0; invalid && i < constraints.length; i++)
         {
            String constrString = constraints[i];

            boolean minInvalid = true;
            boolean maxInvalid = true;

            MinMaxConstraint constraint = parseAsMinMax(constrString);

            long min =
               constraint.getMin().getThreshold().length() > 0 ? new Long(constraint.getMin().getThreshold())
                  : Long.MIN_VALUE;
            if (constraint.getMin().isExclusive())
            {
               if (valueLength > min)
               {
                  minInvalid = false;
               }
            }
            else
            {
               if (valueLength >= min)
               {
                  minInvalid = false;
               }
            }

            long max =
               constraint.getMax().getThreshold().length() > 0 ? new Long(constraint.getMax().getThreshold())
                  : Long.MAX_VALUE;
            if (constraint.getMax().isExclusive())
            {
               if (valueLength < max)
                  maxInvalid = false;
            }
            else
            {
               if (valueLength <= max)
                  maxInvalid = false;
            }
            invalid = maxInvalid | minInvalid;
         }
      }
      else if (type == PropertyType.DATE)
      {
         Calendar valueCalendar;
         try
         {
            valueCalendar = new DateValue(valueData).getDate();
         }
         catch (IOException e)
         {
            throw new RepositoryException(e);
         }
         for (int i = 0; invalid && i < constraints.length; i++)
         {
            boolean minInvalid = true;
            boolean maxInvalid = true;

            MinMaxConstraint constraint = parseAsMinMax(constraints[i]);
            try
            {
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Calendar min = JCRDateFormat.parse(constraint.getMin().getThreshold());
                  if (constraint.getMin().isExclusive())
                  {
                     if (valueCalendar.compareTo(min) > 0)
                     {
                        minInvalid = false;
                     }
                  }
                  else
                  {
                     if (valueCalendar.compareTo(min) >= 0)
                     {
                        minInvalid = false;
                     }
                  }
               }
               else
               {
                  minInvalid = false;
               }
            }
            catch (ValueFormatException e)
            {
               minInvalid = false;
            }

            try
            {
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Calendar max = JCRDateFormat.parse(constraint.getMax().getThreshold());
                  if (constraint.getMax().isExclusive())
                  {
                     if (valueCalendar.compareTo(max) < 0)
                        maxInvalid = false;
                  }
                  else
                  {
                     if (valueCalendar.compareTo(max) <= 0)
                        maxInvalid = false;
                  }
               }
               else
               {
                  maxInvalid = false;
               }
            }
            catch (ValueFormatException e)
            {
               maxInvalid = false;
            }

            invalid = maxInvalid | minInvalid;
         }
      }
      else if (type == PropertyType.LONG || type == PropertyType.DOUBLE)
      {
         // will be compared as double in any case
         Number valueNumber;
         try
         {
            valueNumber = new DoubleValue(valueData).getDouble();
         }
         catch (IOException e)
         {
            throw new RepositoryException(e);
         }
         for (int i = 0; invalid && i < constraints.length; i++)
         {
            boolean minInvalid = true;
            boolean maxInvalid = true;

            MinMaxConstraint constraint = parseAsMinMax(constraints[i]);

            Number min =
               constraint.getMin().getThreshold().length() > 0 ? new Double(constraint.getMin().getThreshold())
                  : Double.MIN_VALUE;
            if (constraint.getMin().isExclusive())
            {
               if (valueNumber.doubleValue() > min.doubleValue())
               {
                  minInvalid = false;
               }
            }
            else
            {
               if (valueNumber.doubleValue() >= min.doubleValue())
               {
                  minInvalid = false;
               }
            }

            Number max =
               constraint.getMax().getThreshold().length() > 0 ? new Double(constraint.getMax().getThreshold())
                  : Double.MAX_VALUE;
            if (constraint.getMax().isExclusive())
            {
               if (valueNumber.doubleValue() < max.doubleValue())
               {
                  maxInvalid = false;
               }
            }
            else
            {
               if (valueNumber.doubleValue() <= max.doubleValue())
               {
                  maxInvalid = false;
               }
            }
            invalid = maxInvalid | minInvalid;
         }
      }
      else if (type == PropertyType.BOOLEAN)
      {
         try
         {
            boolean bvalue = Boolean.parseBoolean(new String(valueData.getAsByteArray()));
            for (int i = 0; invalid && i < constraints.length; i++)
            {
               if (Boolean.parseBoolean(constraints[i]) == bvalue)
               {
                  invalid = false;
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

      ArrayList<PropertyData> refs = new ArrayList<PropertyData>();
      Iterator it = items.values().iterator();
      while (it.hasNext())
      {
         ItemData itemData = (ItemData)it.next();
         ValueData identifierVal = ((PropertyData)itemData).getValues().get(0);
         try
         {
            if ((itemData instanceof PropertyData) && ((PropertyData)itemData).getType() == PropertyType.REFERENCE
               && new String(identifierVal.getAsByteArray()).equals(identifier))
            {

               refs.add((PropertyData)itemData);
            }
         }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

       *           if error
       */
      public LocalSessionValueData(boolean asStream) throws IOException
      {
         super(getInternalData().getOrderNumber());
         ValueData idata = getInternalData();
         if (asStream)
         {
            stream = idata.getAsStream();
            bytes = null;
         }
         else
         {
            bytes = idata.getAsByteArray();
            stream = null;
         }
         length = idata.getLength();
      }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

      List<ValueData> values = data.getValues();
      int added = 0;
      for (int i = 0; i < values.size(); i++)
      {
         ValueData vdata = values.get(i);
         String refNodeIdentifier;
         try
         {
            refNodeIdentifier = ValueDataUtil.getString(vdata);
         }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.ValueData

      List<ValueData> values = data.getValues();
      int added = 0;
      for (int i = 0; i < values.size(); i++)
      {
         ValueData vdata = values.get(i);
         String refNodeIdentifier;
         try
         {
            refNodeIdentifier = ValueDataUtil.getString(vdata);
         }
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.