jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r906866 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/...
Date Fri, 05 Feb 2010 09:22:45 GMT
Author: angela
Date: Fri Feb  5 09:22:44 2010
New Revision: 906866

URL: http://svn.apache.org/viewvc?rev=906866&view=rev
Log:
JCR-2013 -  IOUtils - getCreated(...) - SimpleDateFormat is not threadsafe

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/VersionResourceImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/HttpDateFormat.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java
Fri Feb  5 09:22:44 2010
@@ -18,8 +18,7 @@
 
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.webdav.DavConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -36,8 +35,6 @@
  */
 public class IOUtil {
 
-    private static Logger log = LoggerFactory.getLogger(IOUtil.class);
-
     /**
      * Constant for undefined modification/creation time
      */
@@ -52,26 +49,26 @@
      * Return the last modification time as formatted string.
      *
      * @return last modification time as string.
-     * @see DavConstants#modificationDateFormat
+     * @see org.apache.jackrabbit.webdav.util.HttpDateFormat#modificationDateFormat() 
      */
     public static String getLastModified(long modificationTime) {
         if (modificationTime <= IOUtil.UNDEFINED_TIME) {
             modificationTime = new Date().getTime();
         }
-        return DavConstants.modificationDateFormat.format(new Date(modificationTime));
+        return HttpDateFormat.modificationDateFormat().format(new Date(modificationTime));
     }
 
     /**
      * Return the creation time as formatted string.
      *
      * @return creation time as string.
-     * @see DavConstants#creationDateFormat
+     * @see org.apache.jackrabbit.webdav.util.HttpDateFormat#creationDateFormat()
      */
     public static String getCreated(long createdTime) {
         if (createdTime <= IOUtil.UNDEFINED_TIME) {
             createdTime = 0;
         }
-        return DavConstants.creationDateFormat.format(new Date(createdTime));
+        return HttpDateFormat.creationDateFormat().format(new Date(createdTime));
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
Fri Feb  5 09:22:44 2010
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.webdav.jcr;
 
 import org.apache.jackrabbit.server.io.IOUtil;
-import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavLocatorFactory;
 import org.apache.jackrabbit.webdav.DavResource;
@@ -28,6 +27,7 @@
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.DavCompliance;
+import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 import org.apache.jackrabbit.webdav.jcr.search.SearchResourceImpl;
 import org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl;
 import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
@@ -557,7 +557,7 @@
         properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, lastModified));
 
         // default creation time
-        properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, DavConstants.creationDateFormat.format(new
Date(0))));
+        properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, HttpDateFormat.creationDateFormat().format(new
Date(0))));
 
         // supported lock property
         properties.add(supportedLock);

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
Fri Feb  5 09:22:44 2010
@@ -52,7 +52,6 @@
 import org.apache.jackrabbit.server.io.IOUtil;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.webdav.DavCompliance;
-import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
@@ -61,6 +60,7 @@
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.io.OutputContext;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
@@ -881,7 +881,7 @@
                 if (n.hasProperty(JcrConstants.JCR_CREATED)) {
                     long creationTime = n.getProperty(JcrConstants.JCR_CREATED).getValue().getLong();
                     properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE,
-                        DavConstants.creationDateFormat.format(new Date(creationTime))));
+                        HttpDateFormat.creationDateFormat().format(new Date(creationTime))));
                 }
             } catch (RepositoryException e) {
                 log.warn("Error while accessing jcr:created property");

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
Fri Feb  5 09:22:44 2010
@@ -17,11 +17,11 @@
 package org.apache.jackrabbit.webdav.jcr.version;
 
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
@@ -174,7 +174,7 @@
             Version v = (Version)item;
             // created and creationDate properties
             try {
-                String creationDate = DavConstants.creationDateFormat.format(v.getCreated().getTime());
+                String creationDate = HttpDateFormat.creationDateFormat().format(v.getCreated().getTime());
                 // replace dummy creation date from default collection
                 properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, creationDate));
 

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/VersionResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/VersionResourceImpl.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/VersionResourceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/VersionResourceImpl.java
Fri Feb  5 09:22:44 2010
@@ -16,7 +16,6 @@
 package org.apache.jackrabbit.webdav.simple;
 
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
@@ -26,6 +25,7 @@
 import org.apache.jackrabbit.webdav.DavResourceIterator;
 import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.util.HttpDateFormat;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
@@ -237,7 +237,7 @@
             super.initProperties();
             Version v = (Version) getNode();
             try {
-                String creationDate = DavConstants.creationDateFormat.format(v.getCreated().getTime());
+                String creationDate = HttpDateFormat.creationDateFormat().format(v.getCreated().getTime());
                 // replace dummy creation date from default collection
                 properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, creationDate));
 

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavConstants.java
Fri Feb  5 09:22:44 2010
@@ -141,12 +141,14 @@
     public static long UNDEFINED_TIME = -1;
 
     /**
-     * modificationDate date format per RFC 1123
+     * modificationDate date format per RFC 1123.<br>
+     * NOTE: Access to <code>DateFormat</code> isn't thread save.
      */
-    public static DateFormat modificationDateFormat = new HttpDateFormat("EEE, dd MMM yyyy
HH:mm:ss z");
+    public static DateFormat modificationDateFormat = HttpDateFormat.modificationDateFormat();
 
     /**
-     * Simple date format for the creation date ISO representation (partial).
+     * Simple date format for the creation date ISO representation (partial).<br>
+     * NOTE: Access to <code>DateFormat</code> isn't thread save.
      */
-    public static DateFormat creationDateFormat = new HttpDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+    public static DateFormat creationDateFormat = HttpDateFormat.creationDateFormat();
 }

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/HttpDateFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/HttpDateFormat.java?rev=906866&r1=906865&r2=906866&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/HttpDateFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/HttpDateFormat.java
Fri Feb  5 09:22:44 2010
@@ -27,8 +27,38 @@
 
     private static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
 
+    /**
+     * Pattern for the modification date as defined by RFC 1123
+     */
+    public static final String MODIFICATION_DATE_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z";
+
+    /**
+     * Simple date format pattern for the creation date ISO representation (partial).
+     */
+    public static final String CREATION_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
     public HttpDateFormat(String pattern) {
         super(pattern, Locale.ENGLISH);
         super.setTimeZone(GMT_TIMEZONE);
     }
+
+    /**
+     * Creates a new HttpDateFormat using the
+     * {@link #MODIFICATION_DATE_PATTERN modifcation date pattern}.
+     *
+     * @return a new HttpDateFormat.
+     */
+    public static HttpDateFormat modificationDateFormat() {
+        return new HttpDateFormat(MODIFICATION_DATE_PATTERN);
+    }
+
+    /**
+     * Creates a new HttpDateFormat using the
+     * {@link #CREATION_DATE_PATTERN creation date pattern}.
+     *
+     * @return a new HttpDateFormat.
+     */
+    public static HttpDateFormat creationDateFormat() {
+        return new HttpDateFormat(CREATION_DATE_PATTERN);
+    }
 }
\ No newline at end of file



Mime
View raw message