chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1456955 - in /chemistry/opencmis/trunk: chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apach...
Date Fri, 15 Mar 2013 13:53:44 GMT
Author: fmui
Date: Fri Mar 15 13:53:44 2013
New Revision: 1456955

URL: http://svn.apache.org/r1456955
Log:
CMIS 1.1 AtomPub: optimization and small fixes

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java
Fri Mar 15 13:53:44 2013
@@ -18,14 +18,12 @@
  */
 package org.apache.chemistry.opencmis.commons.impl;
 
-import java.lang.ref.SoftReference;
 import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
-import java.util.Locale;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.TimeZone;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -38,15 +36,26 @@ public class DateTimeHelper {
             .compile("(\\d{4,9})-([01]\\d)-([0-3]\\d)T([0-2]\\d):([0-5]\\d):([0-5]\\d)(\\.(\\d+))?(([+-][0-2]\\d:[0-5]\\d)|Z)?");
     private static final BigDecimal BD1000 = new BigDecimal(1000);
 
-    private static final String[] HTTP_DATETIME = new String[] { "EEE, dd MMM yyyy HH:mm:ss
zzz",
-            "EEE, dd-MMM-yy HH:mm:ss zzz", "EEE MMM d HH:mm:ss yyyy" };
+    private static final String[] WDAYS = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu",
"Fri", "Sat" };
 
-    private static final ThreadLocal<SoftReference<SimpleDateFormat[]>> THREADLOCAL_HTTP_FORMATS
= new ThreadLocal<SoftReference<SimpleDateFormat[]>>() {
-        @Override
-        protected SoftReference<SimpleDateFormat[]> initialValue() {
-            return new SoftReference<SimpleDateFormat[]>(new SimpleDateFormat[HTTP_DATETIME.length]);
+    private static final String[] MONTHS = new String[] { "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug",
+            "Sep", "Oct", "Nov", "Dec" };
+
+    private static final Map<String, Integer> MONTHS_MAP = new HashMap<String, Integer>();
+    static {
+        for (int i = 0; i < MONTHS.length; i++) {
+            MONTHS_MAP.put(MONTHS[i], i);
         }
-    };
+    }
+
+    private static final Pattern HTTP_DATETIME1 = Pattern
+            .compile("\\w{3}, ([0-3]\\d) (\\w{3}) (\\d{4}) ([0-2]\\d):([0-5]\\d):([0-5]\\d)
GMT");
+
+    private static final Pattern HTTP_DATETIME2 = Pattern
+            .compile("\\w{6,9}, ([0-3]\\d)-(\\w{3})-(\\d{2}) ([0-2]\\d):([0-5]\\d):([0-5]\\d)
GMT");
+
+    private static final Pattern HTTP_DATETIME3 = Pattern
+            .compile("\\w{3} (\\w{3}) ([0-3 ]\\d) ([0-2]\\d):([0-5]\\d):([0-5]\\d) (\\d{4})");
 
     /**
      * Parses a xsd:dateTime string.
@@ -56,7 +65,7 @@ public class DateTimeHelper {
             return null;
         }
 
-        Matcher m = XML_DATETIME.matcher(s);
+        final Matcher m = XML_DATETIME.matcher(s);
 
         if (!m.matches()) {
             return null;
@@ -81,7 +90,7 @@ public class DateTimeHelper {
                 tz = TimeZone.getTimeZone("GMT" + m.group(10));
             }
 
-            GregorianCalendar result = new GregorianCalendar();
+            final GregorianCalendar result = new GregorianCalendar();
             result.clear();
 
             result.setTimeZone(tz);
@@ -98,7 +107,7 @@ public class DateTimeHelper {
      * Returns a xsd:dateTime string.
      */
     public static String formatXmlDateTime(long millis) {
-        GregorianCalendar cal = new GregorianCalendar(GMT);
+        final GregorianCalendar cal = new GregorianCalendar(GMT);
         cal.setTimeInMillis(millis);
 
         return formatXmlDateTime(cal);
@@ -112,18 +121,26 @@ public class DateTimeHelper {
             throw new IllegalArgumentException();
         }
 
-        StringBuilder sb = new StringBuilder(String.format("%04d-%02d-%02dT%02d:%02d:%02d",
cal.get(Calendar.YEAR),
-                cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY),
-                cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)));
+        final StringBuilder sb = new StringBuilder();
+        add4d(sb, cal.get(Calendar.YEAR));
+        sb.append('-');
+        add2d(sb, cal.get(Calendar.MONTH) + 1);
+        sb.append('-');
+        add2d(sb, cal.get(Calendar.DAY_OF_MONTH));
+        sb.append('T');
+        add2d(sb, cal.get(Calendar.HOUR_OF_DAY));
+        sb.append(':');
+        add2d(sb, cal.get(Calendar.MINUTE));
+        sb.append(':');
+        add2d(sb, cal.get(Calendar.SECOND));
 
         int ms = cal.get(Calendar.MILLISECOND);
         if (ms > 0) {
-            StringBuilder mssb = new StringBuilder(String.format("%03d", ms));
-            while (mssb.charAt(mssb.length() - 1) == '0') {
-                mssb.deleteCharAt(mssb.length() - 1);
+            sb.append('.');
+            add3d(sb, ms);
+            while (sb.charAt(sb.length() - 1) == '0') {
+                sb.deleteCharAt(sb.length() - 1);
             }
-            sb.append(".");
-            sb.append(mssb);
         }
 
         int tz = cal.getTimeZone().getRawOffset();
@@ -136,10 +153,10 @@ public class DateTimeHelper {
                 sb.append("-");
                 tz *= -1;
             }
-            sb.append(String.format("%02d", tz / 3600000));
+            add2d(sb, tz / 3600000);
             sb.append(":");
             int tzm = tz % 3600000;
-            sb.append(String.format("%02d", tzm == 0 ? 0 : tzm / 60000));
+            add2d(sb, tzm == 0 ? 0 : tzm / 60000);
         }
 
         return sb.toString();
@@ -158,14 +175,66 @@ public class DateTimeHelper {
             s = s.substring(1, s.length() - 1);
         }
 
-        for (int i = 0; i < HTTP_DATETIME.length; i++) {
-            SimpleDateFormat sdf = getFormatter(i);
+        final GregorianCalendar cal = new GregorianCalendar(GMT);
+        cal.set(Calendar.MILLISECOND, 0);
+
+        Matcher m = null;
+
+        m = HTTP_DATETIME1.matcher(s);
+        if (m.matches()) {
+            final Integer month = MONTHS_MAP.get(m.group(2));
+            if (month == null) {
+                return null;
+            }
+
+            cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(m.group(1)));
+            cal.set(Calendar.MONTH, month);
+            cal.set(Calendar.YEAR, Integer.parseInt(m.group(3)));
+            cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(m.group(4)));
+            cal.set(Calendar.MINUTE, Integer.parseInt(m.group(5)));
+            cal.set(Calendar.SECOND, Integer.parseInt(m.group(6)));
+
+            return cal.getTime();
+        }
+
+        m = HTTP_DATETIME2.matcher(s);
+        if (m.matches()) {
+            final Integer month = MONTHS_MAP.get(m.group(2));
+            if (month == null) {
+                return null;
+            }
+
+            cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(m.group(1)));
+            cal.set(Calendar.MONTH, month);
+            int year = Integer.parseInt(m.group(3));
+            if (year < 100) {
+                final int thisYear = (new GregorianCalendar(GMT)).get(Calendar.YEAR);
+                final int testYear = year + thisYear - thisYear % 100;
+                year = (testYear < thisYear + 20 ? testYear : testYear - 100);
+            }
+            cal.set(Calendar.YEAR, year);
+            cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(m.group(4)));
+            cal.set(Calendar.MINUTE, Integer.parseInt(m.group(5)));
+            cal.set(Calendar.SECOND, Integer.parseInt(m.group(6)));
+
+            return cal.getTime();
+        }
 
-            try {
-                return sdf.parse(s);
-            } catch (ParseException e) {
-                // try next
+        m = HTTP_DATETIME3.matcher(s);
+        if (m.matches()) {
+            final Integer month = MONTHS_MAP.get(m.group(1));
+            if (month == null) {
+                return null;
             }
+
+            cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(m.group(2).trim()));
+            cal.set(Calendar.MONTH, month);
+            cal.set(Calendar.YEAR, Integer.parseInt(m.group(6)));
+            cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(m.group(3)));
+            cal.set(Calendar.MINUTE, Integer.parseInt(m.group(4)));
+            cal.set(Calendar.SECOND, Integer.parseInt(m.group(5)));
+
+            return cal.getTime();
         }
 
         return null;
@@ -174,47 +243,71 @@ public class DateTimeHelper {
     /**
      * Returns a HTTP date.
      */
-    public static String formateHttpDateTime(long millis) {
-        return getFormatter(0).format(millis);
+    public static String formatHttpDateTime(long millis) {
+        final GregorianCalendar cal = new GregorianCalendar(GMT);
+        cal.setTimeInMillis(millis);
+
+        final StringBuilder sb = new StringBuilder();
+        sb.append(WDAYS[cal.get(Calendar.DAY_OF_WEEK) - 1]);
+        sb.append(", ");
+        add2d(sb, cal.get(Calendar.DAY_OF_MONTH));
+        sb.append(' ');
+        sb.append(MONTHS[cal.get(Calendar.MONTH)]);
+        sb.append(' ');
+        add4d(sb, cal.get(Calendar.YEAR));
+        sb.append(' ');
+        add2d(sb, cal.get(Calendar.HOUR_OF_DAY));
+        sb.append(':');
+        add2d(sb, cal.get(Calendar.MINUTE));
+        sb.append(':');
+        add2d(sb, cal.get(Calendar.SECOND));
+        sb.append(" GMT");
+
+        return sb.toString();
     }
 
     /**
      * Returns a HTTP date.
      */
-    public static String formateHttpDateTime(Date date) {
-        return getFormatter(0).format(date);
+    public static String formatHttpDateTime(final Date date) {
+        return formatHttpDateTime(date.getTime());
     }
 
     /**
      * Returns a HTTP date.
      */
-    public static String formateHttpDateTime(GregorianCalendar cal) {
-        return getFormatter(0).format(cal.getTimeInMillis());
+    public static String formatHttpDateTime(final GregorianCalendar cal) {
+        return formatHttpDateTime(cal.getTimeInMillis());
     }
 
-    /**
-     * Clears out cached formatters.
-     */
-    public static void clear() {
-        THREADLOCAL_HTTP_FORMATS.remove();
+    private static void add2d(final StringBuilder sb, int value) {
+        if (value < 10) {
+            sb.append('0');
+        }
+        sb.append(value);
     }
 
-    private static SimpleDateFormat getFormatter(int x) {
-        SoftReference<SimpleDateFormat[]> ref = THREADLOCAL_HTTP_FORMATS.get();
-        SimpleDateFormat[] sdfs = ref.get();
-        if (sdfs == null) {
-            ref = new SoftReference<SimpleDateFormat[]>(new SimpleDateFormat[HTTP_DATETIME.length]);
-            THREADLOCAL_HTTP_FORMATS.set(ref);
-            sdfs = ref.get();
+    private static void add3d(final StringBuilder sb, int value) {
+        if (value < 10) {
+            sb.append('0');
         }
-
-        SimpleDateFormat sdf = sdfs[x];
-        if (sdf == null) {
-            sdf = new SimpleDateFormat(HTTP_DATETIME[x], Locale.US);
-            sdf.setTimeZone(GMT);
-            sdfs[x] = sdf;
+        if (value < 100) {
+            sb.append('0');
         }
+        sb.append(value);
+    }
 
-        return sdf;
+    private static void add4d(final StringBuilder sb, int value) {
+        if (value < 10) {
+            sb.append('0');
+        }
+        if (value < 100) {
+            sb.append('0');
+        }
+        if (value < 1000) {
+            sb.append('0');
+        }
+        sb.append(value);
     }
+
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
Fri Mar 15 13:53:44 2013
@@ -147,9 +147,13 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.SecondaryTypeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class XMLConverter {
 
+    private static final Logger LOG = LoggerFactory.getLogger(XMLConverter.class);
+
     private XMLConverter() {
     }
 
@@ -184,6 +188,8 @@ public class XMLConverter {
         if (source.getChangesOnType() != null) {
             for (BaseTypeId baseType : source.getChangesOnType()) {
                 if (cmisVersion == CmisVersion.CMIS_1_0 && baseType == BaseTypeId.CMIS_ITEM)
{
+                    LOG.warn("Receiver only understands CMIS 1.0 but the Changes On Type
list in the Repository info contains the base type Item. "
+                            + "The Item base type has been removed from the list.");
                     continue;
                 }
                 XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, TAG_REPINFO_CHANGES_ON_TYPE,
baseType);
@@ -375,10 +381,12 @@ public class XMLConverter {
             return;
         }
 
-        // suppress cmis:item and cmis:secondary type for CMIS 1.0 repositories
-        if (cmisVersion == CmisVersion.CMIS_1_0
-                && (source.getBaseTypeId() == BaseTypeId.CMIS_ITEM || source.getBaseTypeId()
== BaseTypeId.CMIS_SECONDARY)) {
-            return;
+        if (cmisVersion == CmisVersion.CMIS_1_0) {
+            if (source.getBaseTypeId() == BaseTypeId.CMIS_ITEM) {
+                LOG.warn("Receiver only understands CMIS 1.0. It may not able to handle an
Item type definition.");
+            } else if (source.getBaseTypeId() == BaseTypeId.CMIS_SECONDARY) {
+                LOG.warn("Receiver only understands CMIS 1.0. It may not able to handle a
Secondary type definition.");
+            }
         }
 
         writer.writeStartElement(namespace, TAG_TYPE);
@@ -661,6 +669,12 @@ public class XMLConverter {
             return;
         }
 
+        if (cmisVersion == CmisVersion.CMIS_1_0) {
+            if (source.getBaseTypeId() == BaseTypeId.CMIS_ITEM) {
+                LOG.warn("Receiver only understands CMIS 1.0. It may not be able to handle
an Item object.");
+            }
+        }
+
         if (root) {
             writer.writeStartElement(PREFIX_CMIS, name, NAMESPACE_CMIS);
             writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS);
@@ -850,6 +864,8 @@ public class XMLConverter {
         if (source.getAllowableActions() != null) {
             for (Action action : Action.values()) {
                 if (action == Action.CAN_CREATE_ITEM && cmisVersion == CmisVersion.CMIS_1_0)
{
+                    LOG.warn("Receiver only understands CMIS 1.0 but the Allowable Actions
contain the canCreateItem action. "
+                            + "The canCreateItem action has been removed from the Allowable
Actions.");
                     continue;
                 }
                 if (source.getAllowableActions().contains(action)) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
Fri Mar 15 13:53:44 2013
@@ -31,28 +31,36 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class XMLUtils {
 
-    public static final ThreadLocal<XMLInputFactory> THREADLOCAL_XML_INPUT_FACTORY
= new ThreadLocal<XMLInputFactory>() {
-        @Override
-        protected XMLInputFactory initialValue() {
-            XMLInputFactory factory = XMLInputFactory.newInstance();
-            factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
-            factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-            factory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
-            return factory;
-        }
-    };
-
-    public static final ThreadLocal<XMLOutputFactory> THREADLOCAL_XML_OUTPUT_FACTORY
= new ThreadLocal<XMLOutputFactory>() {
-        @Override
-        protected XMLOutputFactory initialValue() {
-            XMLOutputFactory factory = XMLOutputFactory.newInstance();
-            factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);
-            return factory;
+    private static final Logger LOG = LoggerFactory.getLogger(XMLUtils.class);
+
+    private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
+    static {
+        try {
+            XML_INPUT_FACTORY.setProperty("reuse-instance", Boolean.FALSE);
+            LOG.warn("You are using an unsupported StAX parser.");
+        } catch (IllegalArgumentException ex) {
+        }
+
+        XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
+        XML_INPUT_FACTORY.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+        XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
+    }
+
+    private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
+    static {
+        try {
+            XML_OUTPUT_FACTORY.setProperty("reuse-instance", Boolean.FALSE);
+            LOG.warn("You are using an unsupported StAX parser.");
+        } catch (IllegalArgumentException ex) {
         }
-    };
+
+        XML_OUTPUT_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);
+    }
 
     // --------------
     // --- writer ---
@@ -62,7 +70,7 @@ public class XMLUtils {
      * Creates a new XML writer.
      */
     public static XMLStreamWriter createWriter(OutputStream out) throws XMLStreamException
{
-        return THREADLOCAL_XML_OUTPUT_FACTORY.get().createXMLStreamWriter(out, "UTF-8");
+        return XML_OUTPUT_FACTORY.createXMLStreamWriter(out, "UTF-8");
     }
 
     /**
@@ -178,7 +186,7 @@ public class XMLUtils {
      * Creates a new XML parser with OpenCMIS default settings.
      */
     public static XMLStreamReader createParser(InputStream stream) throws XMLStreamException
{
-        return THREADLOCAL_XML_INPUT_FACTORY.get().createXMLStreamReader(stream);
+        return XML_INPUT_FACTORY.createXMLStreamReader(stream);
     }
 
     /**
@@ -277,12 +285,4 @@ public class XMLUtils {
 
         return sb.toString();
     }
-
-    /**
-     * Clears out cached XML factories.
-     */
-    public static void clear() {
-        THREADLOCAL_XML_INPUT_FACTORY.remove();
-        THREADLOCAL_XML_OUTPUT_FACTORY.remove();
-    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java
Fri Mar 15 13:53:44 2013
@@ -143,7 +143,7 @@ public class DateTimeTest {
         cal1.set(2012, 11, 24, 9, 10, 11);
         cal1.set(Calendar.MILLISECOND, 0);
 
-        String dateStr1 = DateTimeHelper.formateHttpDateTime(cal1.getTime());
+        String dateStr1 = DateTimeHelper.formatHttpDateTime(cal1.getTime());
         assertEquals("Mon, 24 Dec 2012 09:10:11 GMT", dateStr1);
 
         Date date1 = DateTimeHelper.parseHttpDateTime(dateStr1);
@@ -154,7 +154,7 @@ public class DateTimeTest {
         cal2.set(2013, 0, 1, 2, 3, 4);
         cal2.set(Calendar.MILLISECOND, 0);
 
-        String dateStr2 = "  '" + DateTimeHelper.formateHttpDateTime(cal2.getTimeInMillis())
+ "' ";
+        String dateStr2 = "  '" + DateTimeHelper.formatHttpDateTime(cal2.getTimeInMillis())
+ "' ";
         Date date2 = DateTimeHelper.parseHttpDateTime(dateStr2);
 
         assertEquals(cal2.getTime(), date2);
@@ -163,7 +163,7 @@ public class DateTimeTest {
         cal3.set(2012, 11, 24, 9, 10, 11);
         cal3.set(Calendar.MILLISECOND, 0);
 
-        String dateStr3 = DateTimeHelper.formateHttpDateTime(cal3);
+        String dateStr3 = DateTimeHelper.formatHttpDateTime(cal3);
         Date date3 = DateTimeHelper.parseHttpDateTime(dateStr3);
 
         assertEquals(cal3.getTime(), date3);
@@ -183,6 +183,14 @@ public class DateTimeTest {
         String dateStr5 = "Sun Nov  6 08:49:37 1994";
 
         assertEquals(cal5.getTime(), DateTimeHelper.parseHttpDateTime(dateStr5));
+
+        GregorianCalendar cal6 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+        cal6.set(1994, 10, 16, 8, 49, 37);
+        cal6.set(Calendar.MILLISECOND, 0);
+
+        String dateStr6 = "Sun Nov 16 08:49:37 1994";
+
+        assertEquals(cal6.getTime(), DateTimeHelper.parseHttpDateTime(dateStr6));
     }
 
     @Test
@@ -204,8 +212,5 @@ public class DateTimeTest {
 
         // invalid day
         assertNull(DateTimeHelper.parseHttpDateTime("Mon, xy Dec 2012 09:10:11 GMT"));
-
-        // invalid week day
-        assertNull(DateTimeHelper.parseHttpDateTime("abc, 24 Dec 2012 09:10:11 GMT"));
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java
Fri Mar 15 13:53:44 2013
@@ -92,7 +92,7 @@ public abstract class AtomDocumentBase e
      * Writes an Atom updated tag.
      */
     public void writeUpdated(long updated) throws XMLStreamException {
-        String updatedStr = DateTimeHelper.formateHttpDateTime(updated);
+        String updatedStr = DateTimeHelper.formatHttpDateTime(updated);
         XMLUtils.write(getWriter(), XMLConstants.PREFIX_APP, XMLConstants.NAMESPACE_APP,
"edited", updatedStr);
         XMLUtils.write(getWriter(), XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM,
"updated", updatedStr);
     }
@@ -109,7 +109,7 @@ public abstract class AtomDocumentBase e
      */
     public void writePublished(long published) throws XMLStreamException {
         XMLUtils.write(getWriter(), XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM,
"published",
-                DateTimeHelper.formateHttpDateTime(published));
+                DateTimeHelper.formatHttpDateTime(published));
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java?rev=1456955&r1=1456954&r2=1456955&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
Fri Mar 15 13:53:44 2013
@@ -562,7 +562,7 @@ public final class ObjectService {
                     }
                 }
 
-                response.setHeader("Last-Modified", DateTimeHelper.formateHttpDateTime(lastModifiedSecs
* 1000));
+                response.setHeader("Last-Modified", DateTimeHelper.formatHttpDateTime(lastModifiedSecs
* 1000));
             }
         }
 



Mime
View raw message