jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r780025 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/
Date Fri, 29 May 2009 16:11:46 GMT
Author: stefan
Date: Fri May 29 16:11:45 2009
New Revision: 780025

URL: http://svn.apache.org/viewvc?rev=780025&view=rev
Log:
JCR-1609: new Property Types


Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=780025&r1=780024&r2=780025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Fri May 29 16:11:45 2009
@@ -22,6 +22,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.math.BigDecimal;
+import java.net.URI;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
@@ -1014,6 +1015,8 @@
                         log.debug("Unable to coerce '" + literal + "' into a DECIMAL: " +
e.toString());
                     }
                     break;
+                case PropertyType.URI:
+                    // fall through... TODO: correct?
                 case PropertyType.STRING:
                     values.add(literal);
                     log.debug("Using literal " + literal + " as is.");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java?rev=780025&r1=780024&r2=780025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
Fri May 29 16:11:45 2009
@@ -200,7 +200,6 @@
             case PropertyType.REFERENCE:
             case PropertyType.STRING:
                 return value.getString();
-                // TODO: JSR 283 now node types
             default:
                 throw new RepositoryException("Unsupported type: "
                         + PropertyType.nameFromValue(value.getType()));

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=780025&r1=780024&r2=780025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
Fri May 29 16:11:45 2009
@@ -442,13 +442,13 @@
         } else {
             switch (type) {
                 case PropertyType.BINARY:
-                    return vf.createValue(((BLOBFileValue) val).getStream());
+                    return vf.createValue((BLOBFileValue) val);
                 case PropertyType.BOOLEAN:
-                    return vf.createValue(((Boolean) val).booleanValue());
+                    return vf.createValue((Boolean) val);
                 case PropertyType.DATE:
                     return vf.createValue((Calendar) val);
                 case PropertyType.DOUBLE:
-                    return vf.createValue(((Double) val).doubleValue());
+                    return vf.createValue((Double) val);
                 case PropertyType.LONG:
                     return vf.createValue(((Long) val).longValue());
                 case PropertyType.DECIMAL:
@@ -458,13 +458,15 @@
                 case PropertyType.WEAKREFERENCE:
                     return vf.createValue(val.toString(), PropertyType.WEAKREFERENCE);
                 case PropertyType.URI:
-                    return new URIValue((URI) val);
+                    //return new URIValue((URI) val);
+                    return vf.createValue(val.toString(),  PropertyType.URI);
                 case PropertyType.PATH:
                     return vf.createValue(resolver.getJCRPath((Path) val), PropertyType.PATH);
                 case PropertyType.NAME:
                     return vf.createValue(resolver.getJCRName((Name) val), PropertyType.NAME);
                 case PropertyType.STRING:
-                    return new StringValue((String) val);
+                    //return new StringValue((String) val);
+                    return vf.createValue((String) val);
                 default:
                     throw new RepositoryException("illegal internal value type");
             }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java?rev=780025&r1=780024&r2=780025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
Fri May 29 16:11:45 2009
@@ -285,7 +285,7 @@
             case PropertyType.BINARY:
                 // convert to BINARY
                 try {
-                    val = factory.createValue(srcValue.getStream());
+                    val = factory.createValue(srcValue.getBinary());
                 } catch (RepositoryException re) {
                     throw new ValueFormatException("conversion failed: "
                             + PropertyType.nameFromValue(srcType) + " to "
@@ -369,6 +369,8 @@
                             throw new ValueFormatException("failed to convert source value
to PATH value",
                                     re);
                         }
+                        // the following call will throw ValueFormatException
+                        // if p is not a valid PATH
                         val = factory.createValue(path, targetType);
                         break;
 
@@ -391,6 +393,8 @@
                             p = p.substring(2);
                         }
 
+                        // the following call will throw ValueFormatException
+                        // if p is not a valid PATH
                         val = factory.createValue(p, targetType);
                         break;
 
@@ -431,9 +435,35 @@
                             throw new ValueFormatException("failed to convert source value
to NAME value",
                                     re);
                         }
+                        // the following call will throw ValueFormatException
+                        // if p is not a valid NAME
                         val = factory.createValue(name, targetType);
                         break;
 
+                    case PropertyType.URI:
+                        URI uri;
+                        try {
+                            uri = URI.create(srcValue.getString());
+                        } catch (RepositoryException re) {
+                            // should never happen
+                            throw new ValueFormatException("failed to convert source value
to NAME value",
+                                    re);
+                        }
+                        if (uri.isAbsolute()) {
+                            // uri contains scheme...
+                            throw new ValueFormatException("failed to convert URI value to
NAME value");
+                        }
+                        String p = uri.getPath();
+
+                        if (p.startsWith("./")) {
+                            p = p.substring(2);
+                        }
+
+                        // the following call will throw ValueFormatException
+                        // if p is not a valid NAME
+                        val = factory.createValue(p, targetType);
+                        break;
+
                     case PropertyType.BOOLEAN:
                     case PropertyType.DATE:
                     case PropertyType.DOUBLE:
@@ -479,6 +509,7 @@
                     case PropertyType.LONG:
                     case PropertyType.DECIMAL:
                     case PropertyType.PATH:
+                    case PropertyType.URI:
                     case PropertyType.NAME:
                         throw new ValueFormatException("conversion failed: "
                                 + PropertyType.nameFromValue(srcType) + " to "
@@ -517,6 +548,7 @@
                     case PropertyType.DOUBLE:
                     case PropertyType.LONG:
                     case PropertyType.DECIMAL:
+                    case PropertyType.URI:
                     case PropertyType.PATH:
                     case PropertyType.NAME:
                         throw new ValueFormatException("conversion failed: "



Mime
View raw message