jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r767539 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ jackrabbit-...
Date Wed, 22 Apr 2009 14:33:27 GMT
Author: jukka
Date: Wed Apr 22 14:33:27 2009
New Revision: 767539

URL: http://svn.apache.org/viewvc?rev=767539&view=rev
Log:
1.5: Merged revisions 758003 and 760876 (JCR-1996 and JCR-2052)

Added:
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/InvalidDateTest.java
      - copied unchanged from r758003, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/InvalidDateTest.java
Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DateField.java
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
    jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
    jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java
    jackrabbit/branches/1.5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr 22 14:33:27 2009
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397,727402,727492,727701,728022,731896,731934,731941,73234
 7,732678,732686,732689,732693,732703,732715-732716,732719,732728,732730,732734-732738,732740,732742-732743,732745,732867,732883,733057-733059,733061,733080,734092,734366,734375,734400,734709,735401,736021,736030,736274,736276,736650-736651,736653-736656,736658,736680,737695,738087,738119,738121,738419,738422,738474,738512,739210,739212,739226,740262,740734,740736-740738,740747,740749-740750,741052,741100,741121,741206,741208-741210,741213,741509,741524,741652,741803,742382,742538,743295,743713,743718,743726,743734,743738,744883-744884,744889,744895,744911,744935,744940,744954,744956,745041,745051,745053,745056,745060,745120,745500,745534,745824,745849,746301-746302,746486,746602-746603,746609,746666,746747-746748,746932,746946,747096,747325,747347,747358-747360,747362,747365,747368,747372,747785,747839,748065-748066,748232-748233,748243,748247,748486,749237,749448,749622,749953,749965,750008,750011,750437,750536,752036-752039,752044,752046-752051,752053-752054,752056,752058-
 752060,752063-752067,752115,752131,752414-752415,752457-752458,752478,752480,752543-752545,752640,752809,752831,752839-752841,753225-753228,753232,753244,753328,755512,755582,756378,756403,756405,756409,756429,756432,756442,756444-756445,757364,757698,757775-757776,757814,757854,757856,757862,758193,758263,758265,758349,758354,758629,758632,758634-758636,758639-758642,758646,758649,758653-758654,759880,759889,760386,760479,760945,761267,761279-761280,761282-761283,761292,761634,761645,761690-761691,761715,762671,762675,762700,762702,762731,762737,762755,762780-762781,762789,762793,762797,762802,762804,762808,762813-762814,762817-762818,762821-762823,763146,763160,763188,763205,763215,763242,763244,763248,763617,765322,765328,765337,765532,765551,765554,765556,765585
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397,727402,727492,727701,728022,731896,731934,731941,73234
 7,732678,732686,732689,732693,732703,732715-732716,732719,732728,732730,732734-732738,732740,732742-732743,732745,732867,732883,733057-733059,733061,733080,734092,734366,734375,734400,734709,735401,736021,736030,736274,736276,736650-736651,736653-736656,736658,736680,737695,738087,738119,738121,738419,738422,738474,738512,739210,739212,739226,740262,740734,740736-740738,740747,740749-740750,741052,741100,741121,741206,741208-741210,741213,741509,741524,741652,741803,742382,742538,743295,743713,743718,743726,743734,743738,744883-744884,744889,744895,744911,744935,744940,744954,744956,745041,745051,745053,745056,745060,745120,745500,745534,745824,745849,746301-746302,746486,746602-746603,746609,746666,746747-746748,746932,746946,747096,747325,747347,747358-747360,747362,747365,747368,747372,747785,747839,748065-748066,748232-748233,748243,748247,748486,749237,749448,749622,749953,749965,750008,750011,750437,750536,752036-752039,752044,752046-752051,752053-752054,752056,752058-
 752060,752063-752067,752115,752131,752414-752415,752457-752458,752478,752480,752543-752545,752640,752809,752831,752839-752841,753225-753228,753232,753244,753328,755512,755582,756378,756403,756405,756409,756429,756432,756442,756444-756445,757364,757698,757775-757776,757814,757854,757856,757862,758003,758193,758263,758265,758349,758354,758629,758632,758634-758636,758639-758642,758646,758649,758653-758654,758667,759880,759889,760386,760479,760876,760900,760945,761267,761279-761280,761282-761283,761292,761634,761645,761690-761691,761715,762671,762675,762700,762702,762731,762737,762755,762780-762781,762789,762793,762797,762802,762804,762808,762813-762814,762817-762818,762821-762823,763146,763160,763188,763205,763215,763242,763244,763248,763617,765322,765328,765337,765532,765551,765554,765556,765585

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Wed Apr 22 14:33:27 2009
@@ -530,7 +530,11 @@
 
     public void setValue(Calendar value) throws RepositoryException {
         if (value != null) {
-            setValue(session.getValueFactory().createValue(value));
+            try {
+                setValue(session.getValueFactory().createValue(value));
+            } catch (IllegalArgumentException e) {
+                throw new ValueFormatException(e.getMessage());
+            }
         } else {
             remove();
         }

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DateField.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DateField.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DateField.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DateField.java
Wed Apr 22 14:33:27 2009
@@ -74,6 +74,8 @@
     /**
      * Converts a millisecond time to a string suitable for indexing.
      * Supported date range is: 30 BC - 3189
+     * @throws IllegalArgumentException if the given <code>time</code> is not
+     *                                  within the supported date range.
      */
     public static String timeToString(long time) {
 
@@ -81,13 +83,13 @@
 
 
         if (time < 0) {
-            throw new RuntimeException("time too early");
+            throw new IllegalArgumentException("time too early");
         }
 
         String s = Long.toString(time, Character.MAX_RADIX);
 
         if (s.length() > DATE_LEN) {
-            throw new RuntimeException("time too late");
+            throw new IllegalArgumentException("time too late");
         }
 
         // Pad with leading zeros

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
Wed Apr 22 14:33:27 2009
@@ -49,6 +49,7 @@
 import java.util.Set;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Date;
 
 /**
  * Creates a lucene <code>Document</code> object from a {@link javax.jcr.Node}.
@@ -505,8 +506,13 @@
     protected void addCalendarValue(Document doc, String fieldName, Object internalValue)
{
         Calendar value = (Calendar) internalValue;
         long millis = value.getTimeInMillis();
-        doc.add(createFieldWithoutNorms(fieldName, DateField.timeToString(millis),
-                PropertyType.DATE));
+        try {
+            doc.add(createFieldWithoutNorms(fieldName, DateField.timeToString(millis),
+                    PropertyType.DATE));
+        } catch (IllegalArgumentException e) {
+            log.warn("'{}' is outside of supported date value range.",
+                    new Date(value.getTimeInMillis()));
+        }
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
Wed Apr 22 14:33:27 2009
@@ -38,6 +38,7 @@
         suite.addTestSuite(XATest.class);
         suite.addTestSuite(RestoreAndCheckoutTest.class);
         suite.addTestSuite(NodeImplTest.class);
+        suite.addTestSuite(InvalidDateTest.class);
         suite.addTestSuite(SessionGarbageCollectedTest.class);
 
         return suite;

Modified: jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
Wed Apr 22 14:33:27 2009
@@ -211,23 +211,14 @@
      * @param cal the time value to be formatted into a date/time string.
      * @return the formatted date/time string.
      * @throws IllegalArgumentException if a <code>null</code> argument is passed
+     * or the calendar cannot be represented as defined by ISO 8601 (i.e. year
+     * with more than four digits).
      */
-    public static String format(Calendar cal) {
+    public static String format(Calendar cal) throws IllegalArgumentException {
         if (cal == null) {
             throw new IllegalArgumentException("argument can not be null");
         }
 
-        // determine era and adjust year if necessary
-        int year = cal.get(Calendar.YEAR);
-        if (cal.isSet(Calendar.ERA)
-                && cal.get(Calendar.ERA) == GregorianCalendar.BC) {
-            /**
-             * calculate year using astronomical system:
-             * year n BCE => astronomical year -n + 1
-             */
-            year = 0 - year + 1;
-        }
-
         /**
          * the format of the date/time string is:
          * YYYY-MM-DDThh:mm:ss.SSSTZD
@@ -237,7 +228,7 @@
          */
         StringBuffer buf = new StringBuffer();
         // year ([-]YYYY)
-        buf.append(XXXX_FORMAT.format(year));
+        buf.append(XXXX_FORMAT.format(getYear(cal)));
         buf.append('-');
         // month (MM)
         buf.append(XX_FORMAT.format(cal.get(Calendar.MONTH) + 1));
@@ -272,4 +263,32 @@
         }
         return buf.toString();
     }
+
+    /**
+     * Returns the astonomical year of the given calendar.
+     *
+     * @param cal a calendar instance.
+     * @return the astronomical year.
+     * @throws IllegalArgumentException if calendar cannot be represented as
+     *                                  defined by ISO 8601 (i.e. year with more
+     *                                  than four digits).
+     */
+    public static int getYear(Calendar cal) throws IllegalArgumentException {
+        // determine era and adjust year if necessary
+        int year = cal.get(Calendar.YEAR);
+        if (cal.isSet(Calendar.ERA)
+                && cal.get(Calendar.ERA) == GregorianCalendar.BC) {
+            /**
+             * calculate year using astronomical system:
+             * year n BCE => astronomical year -n + 1
+             */
+            year = 0 - year + 1;
+        }
+
+        if (year > 9999 || year < -9999) {
+            throw new IllegalArgumentException("Calendar has more than four " +
+                    "year digits, cannot be formatted as ISO8601: " + year);
+        }
+        return year;
+    }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java
Wed Apr 22 14:33:27 2009
@@ -37,10 +37,13 @@
      * Constructs a <code>DateValue</code> object representing a date.
      *
      * @param date the date this <code>DateValue</code> should represent
+     * @throws IllegalArgumentException if the given date cannot be represented
+     * as defined by ISO 8601.
      */
-    public DateValue(Calendar date) {
+    public DateValue(Calendar date) throws IllegalArgumentException {
         super(TYPE);
         this.date = date;
+        ISO8601.getYear(date);
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=767539&r1=767538&r2=767539&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
Wed Apr 22 14:33:27 2009
@@ -113,9 +113,6 @@
     public Object visit(QueryRootNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         node.getLocationNode().accept(this, data);
-        if (node.getOrderNode() != null) {
-            node.getOrderNode().accept(this, data);
-        }
         Name[] selectProps = node.getSelectProperties();
         if (selectProps.length > 0) {
             sb.append('/');
@@ -138,6 +135,9 @@
                 sb.append(')');
             }
         }
+        if (node.getOrderNode() != null) {
+            node.getOrderNode().accept(this, data);
+        }
         return data;
     }
 



Mime
View raw message