jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r425079 - in /jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr: DefaultItemCollection.java DefaultItemResource.java property/ValuesProperty.java search/SearchResultProperty.java
Date Mon, 24 Jul 2006 14:53:01 GMT
Author: angela
Date: Mon Jul 24 07:53:00 2006
New Revision: 425079

URL: http://svn.apache.org/viewvc?rev=425079&view=rev
Log:
remove usage of ValueFactoryImpl introduced with rev.424227 in order to
get rid of deprecated calls -> pass ValueFactory instead

Modified:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=425079&r1=425078&r2=425079&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
Mon Jul 24 07:53:00 2006
@@ -902,7 +902,7 @@
         try {
             Document reqBody = DomUtil.BUILDER_FACTORY.newDocumentBuilder().parse(in);
             DavProperty defaultProp = DefaultDavProperty.createFromXml(reqBody.getDocumentElement());
-            ValuesProperty vp = new ValuesProperty(defaultProp, PropertyType.STRING);
+            ValuesProperty vp = new ValuesProperty(defaultProp, PropertyType.STRING, getRepositorySession().getValueFactory());
             return vp;
         } catch (IOException e) {
             log.debug(errorMsg, e);

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=425079&r1=425078&r2=425079&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
Mon Jul 24 07:53:00 2006
@@ -50,6 +50,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.ValueFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.InputStream;
 import java.io.IOException;
@@ -166,9 +167,10 @@
         try {
             Property prop = (Property) item;
             int defaultType = prop.getType();
-            ValuesProperty vp = new ValuesProperty(property, defaultType);
+            ValueFactory vfact = getRepositorySession().getValueFactory();
+            ValuesProperty vp = new ValuesProperty(property, defaultType, vfact);
             if (property.getName().equals(JCR_VALUE)) {
-                prop.setValue(vp.getJcrValue(vp.getValueType()));
+                prop.setValue(vp.getJcrValue(vp.getValueType(), vfact));
             } else if (property.getName().equals(JCR_VALUES)) {
                 prop.setValue(vp.getJcrValues());
             } else {

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=425079&r1=425078&r2=425079&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
Mon Jul 24 07:53:00 2006
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.webdav.jcr.property;
 
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
@@ -34,6 +33,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.ValueFactory;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -79,8 +79,12 @@
      * @param defaultType default type of the values to be deserialized. If however
      * the {@link #XML_VALUE 'value'} elements provide a {@link #ATTR_VALUE_TYPE 'type'}
      * attribute, the default value is ignored.
+     * @param valueFactory Factory used to retrieve JCR values from the value
+     * of the given <code>DavProperty</code>.
      */
-    public ValuesProperty(DavProperty property, int defaultType) throws RepositoryException,
DavException {
+    public ValuesProperty(DavProperty property, int defaultType,
+                          ValueFactory valueFactory)
+        throws RepositoryException, DavException {
         super(property.getName(), false);
 
         if (!(JCR_VALUES.equals(property.getName()) || JCR_VALUE.equals(getName()))) {
@@ -113,7 +117,7 @@
             Element[] elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
             jcrValues = new Value[elems.length];
             for (int i = 0; i < elems.length; i++) {
-                jcrValues[i] = getJcrValue(elems[i], defaultType);
+                jcrValues[i] = getJcrValue(elems[i], defaultType, valueFactory);
             }
         }
     }
@@ -136,7 +140,9 @@
      * @throws ValueFormatException
      * @throws RepositoryException
      */
-    private static Value getJcrValue(Element valueElement, int defaultType) throws ValueFormatException,
RepositoryException {
+    private static Value getJcrValue(Element valueElement, int defaultType,
+                                     ValueFactory valueFactory)
+        throws ValueFormatException, RepositoryException {
         if (valueElement == null) {
             return null;
         }
@@ -145,7 +151,7 @@
         String typeStr = DomUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
         int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
         // deserialize value ->> see #toXml where values are serialized
-        return ValueHelper.deserialize(value, type, true, ValueFactoryImpl.getInstance());
+        return ValueHelper.deserialize(value, type, true, valueFactory);
     }
 
     /**
@@ -155,11 +161,11 @@
      * @throws ValueFormatException if convertion of the internal jcr values to
      * the specified value type fails.
      */
-    public Value[] getJcrValues(int propertyType) throws ValueFormatException {
+    public Value[] getJcrValues(int propertyType, ValueFactory valueFactory) throws ValueFormatException
{
         checkPropertyName(JCR_VALUES);
         Value[] vs = new Value[jcrValues.length];
         for (int i = 0; i < jcrValues.length; i++) {
-            vs[i] = ValueHelper.convert(jcrValues[i], propertyType, ValueFactoryImpl.getInstance());
+            vs[i] = ValueHelper.convert(jcrValues[i], propertyType, valueFactory);
         }
         return jcrValues;
     }
@@ -180,11 +186,11 @@
      * @return
      * @throws ValueFormatException
      */
-    public Value getJcrValue(int propertyType) throws ValueFormatException {
+    public Value getJcrValue(int propertyType, ValueFactory valueFactory) throws ValueFormatException
{
         checkPropertyName(JCR_VALUE);
         return (jcrValues.length == 0)
                 ? null
-                : ValueHelper.convert(jcrValues[0], propertyType, ValueFactoryImpl.getInstance());
+                : ValueHelper.convert(jcrValues[0], propertyType, valueFactory);
     }
 
     /**

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java?rev=425079&r1=425078&r2=425079&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
Mon Jul 24 07:53:00 2006
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.webdav.jcr.search;
 
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
@@ -32,6 +31,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.ValueFactory;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -67,11 +67,13 @@
      * Wrap the specified <code>DavProperty</code> in a new <code>SearchResultProperty</code>.
      *
      * @param property
+     * @param valueFactory factory used to deserialize the xml value to a JCR value.
      * @throws RepositoryException if an error occurs while build the property value
      * @throws IllegalArgumentException if the specified property does have the
      * required form.
+     * @see #getValues()
      */
-    public SearchResultProperty(DavProperty property) throws RepositoryException {
+    public SearchResultProperty(DavProperty property, ValueFactory valueFactory) throws RepositoryException
{
         super(property.getName(), true);
         if (!SEARCH_RESULT_PROPERTY.equals(getName())) {
 	    throw new IllegalArgumentException("SearchResultProperty may only be created from a
property named " + SEARCH_RESULT_PROPERTY.toString());
@@ -85,11 +87,11 @@
             while (elemIt.hasNext()) {
                 Object el = elemIt.next();
                 if (el instanceof Element) {
-                    parseColumnElement((Element)el, colList, valList);
+                    parseColumnElement((Element)el, colList, valList, valueFactory);
                 }
             }
         } else if (propValue instanceof Element) {
-            parseColumnElement((Element)property.getValue(), colList, valList);
+            parseColumnElement((Element)property.getValue(), colList, valList, valueFactory);
         } else {
             new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column'
xml elements.");
         }
@@ -98,7 +100,9 @@
         values = (Value[]) valList.toArray(new Value[valList.size()]);
     }
 
-    private void parseColumnElement(Element columnElement, List columnNames, List values)
throws ValueFormatException, RepositoryException {
+    private void parseColumnElement(Element columnElement, List columnNames,
+                                    List values, ValueFactory valueFactory)
+        throws ValueFormatException, RepositoryException {
         if (!DomUtil.matches(columnElement, COLUMN, ItemResourceConstants.NAMESPACE)) {
             log.debug("dcr:column element expected within search result.");
             return;
@@ -110,7 +114,7 @@
         if (valueElement != null) {
             String typeStr = DomUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
             jcrValue = ValueHelper.deserialize(DomUtil.getText(valueElement),
-                    PropertyType.valueFromName(typeStr), true, ValueFactoryImpl.getInstance());
+                    PropertyType.valueFromName(typeStr), true, valueFactory);
         } else {
             jcrValue = null;
         }



Mime
View raw message