jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r464839 - /jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
Date Tue, 17 Oct 2006 07:00:01 GMT
Author: angela
Date: Tue Oct 17 00:00:00 2006
New Revision: 464839

URL: http://svn.apache.org/viewvc?view=rev&rev=464839
Log:
work in progress

resolve todo

Modified:
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java?view=diff&rev=464839&r1=464838&r2=464839
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
Tue Oct 17 00:00:00 2006
@@ -23,6 +23,9 @@
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.value.ValueFormat;
+import org.apache.jackrabbit.value.QValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -38,6 +41,11 @@
 public class QPropertyDefinitionImpl extends QItemDefinitionImpl implements QPropertyDefinition
{
 
     /**
+     * Logger instance for this class
+     */
+    private static Logger log = LoggerFactory.getLogger(QPropertyDefinitionImpl.class);
+
+    /**
      * The required type.
      */
     private final int requiredType;
@@ -50,7 +58,7 @@
     /**
      * The default values.
      */
-    private final String[] defaultValues;
+    private final QValue[] defaultValues;
 
     /**
      * The 'multiple' flag
@@ -80,15 +88,15 @@
 
         Element child = DomUtil.getChildElement(pdefElement, DEFAULTVALUES_ELEMENT, null);
         if (child == null) {
-            defaultValues = new String[0];
+            defaultValues = new QValue[0];
         } else {
             List vs = new ArrayList();
             ElementIterator it = DomUtil.getChildren(child, DEFAULTVALUE_ELEMENT, null);
             while (it.hasNext()) {
-                String qValue = ValueFormat.getQValue(DomUtil.getText(it.nextElement()),
requiredType, nsResolver).getString();
+                QValue qValue = ValueFormat.getQValue(DomUtil.getText(it.nextElement()),
requiredType, nsResolver);
                 vs.add(qValue);
             }
-            defaultValues = (String[]) vs.toArray(new String[vs.size()]);
+            defaultValues = (QValue[]) vs.toArray(new QValue[vs.size()]);
         }
 
         child = DomUtil.getChildElement(pdefElement, VALUECONSTRAINTS_ELEMENT, null);
@@ -128,12 +136,27 @@
      * {@inheritDoc}
      */
     public String[] getDefaultValues() {
-        return defaultValues;
+        String[] strs = new String[defaultValues.length];
+        for (int i = 0; i < defaultValues.length; i++) {
+            try {
+                strs[i] = defaultValues[i].getString();
+            } catch (RepositoryException e) {
+                log.error("Internal error while retrieving default values.", e);
+            }
+        }
+        return strs;
     }
 
     public InputStream[] getDefaultValuesAsStream() {
-        // todo: implementation missing
-        return null;
+        InputStream[] ins = new InputStream[defaultValues.length];
+        for (int i = 0; i < defaultValues.length; i++) {
+            try {
+                ins[i] = defaultValues[i].getStream();
+            } catch (RepositoryException e) {
+                log.error("Internal error while retrieving default values.", e);
+            }
+        }
+        return ins;
     }
 
     /**



Mime
View raw message