jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r506917 - in /jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav: ./ client/methods/ header/ observation/
Date Tue, 13 Feb 2007 09:14:21 GMT
Author: mreutegg
Date: Tue Feb 13 01:14:16 2007
New Revision: 506917

URL: http://svn.apache.org/viewvc?view=rev&rev=506917
Log:
Add PollTimeout header (required for spi2dav)

Added:
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PollMethod.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/TimeoutHeader.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Tue Feb 13 01:14:16 2007
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.webdav.header.LabelHeader;
 import org.apache.jackrabbit.webdav.header.OverwriteHeader;
 import org.apache.jackrabbit.webdav.header.TimeoutHeader;
+import org.apache.jackrabbit.webdav.header.PollTimeoutHeader;
 import org.apache.jackrabbit.webdav.lock.LockInfo;
 import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.lock.Type;
@@ -583,6 +584,13 @@
      */
     public String getSubscriptionId() {
         return CodedUrlHeader.parse(httpRequest, ObservationConstants.HEADER_SUBSCRIPTIONID).getCodedUrl();
+    }
+
+    /**
+     * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletRequest#getPollTimeout()
+     */
+    public long getPollTimeout() {
+        return PollTimeoutHeader.parseHeader(httpRequest, 0).getTimeout();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PollMethod.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PollMethod.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PollMethod.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PollMethod.java
Tue Feb 13 01:14:16 2007
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.webdav.DavMethods;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
@@ -44,8 +43,16 @@
     private EventDiscovery eventDiscovery;
 
     public PollMethod(String uri, String subscriptionId) {
+        this(uri, subscriptionId, 0);
+    }
+
+    public PollMethod(String uri, String subscriptionId, long timeout) {
         super(uri);
         setRequestHeader(ObservationConstants.HEADER_SUBSCRIPTIONID, subscriptionId);
+        if (timeout > 0) {
+            setRequestHeader(ObservationConstants.HEADER_POLL_TIMEOUT,
+                    String.valueOf(timeout));
+        }
     }
 
     public EventDiscovery getResponseAsEventDiscovery() throws IOException, DavException
{

Added: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java?view=auto&rev=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java
(added)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java
Tue Feb 13 01:14:16 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.webdav.header;
+
+import org.apache.jackrabbit.webdav.observation.ObservationConstants;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <code>PollTimeoutHeader</code> implements a timeout header for subscription
+ * polling.
+ */
+public class PollTimeoutHeader extends TimeoutHeader {
+
+    public PollTimeoutHeader(long timeout) {
+        super(timeout);
+    }
+
+    public String getHeaderName() {
+        return ObservationConstants.HEADER_POLL_TIMEOUT;
+    }
+
+    /**
+     * Parses the request timeout header and converts it into a new
+     * <code>PollTimeoutHeader</code> object.<br>The default value is used
as
+     * fallback if the String is not parseable.
+     *
+     * @param request
+     * @param defaultValue
+     * @return a new PollTimeoutHeader object.
+     */
+    public static PollTimeoutHeader parseHeader(HttpServletRequest request, long defaultValue)
{
+        String timeoutStr = request.getHeader(ObservationConstants.HEADER_POLL_TIMEOUT);
+        long timeout = parse(timeoutStr, defaultValue);
+        return new PollTimeoutHeader(timeout);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/PollTimeoutHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/TimeoutHeader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/TimeoutHeader.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/TimeoutHeader.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/TimeoutHeader.java
Tue Feb 13 01:14:16 2007
@@ -67,7 +67,7 @@
      * into a long indicating the number of milliseconds until expiration time
      * is reached.<br>
      * NOTE: If the timeout String equals to {@link #TIMEOUT_INFINITE 'infinite'}
-     * {@link Long.MAX_VALUE} is returned. If the Sting is invalid or is in an
+     * {@link Long#MAX_VALUE} is returned. If the Sting is invalid or is in an
      * invalid format that cannot be parsed, the default value is returned.
      *
      * @param timeoutStr

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
Tue Feb 13 01:14:16 2007
@@ -38,6 +38,11 @@
      */
     public static final String HEADER_SUBSCRIPTIONID = "SubscriptionId";
 
+    /**
+     * The PollTimeout request header.
+     */
+    public static final String HEADER_POLL_TIMEOUT = "PollTimeout";
+
     //---< XML Element, Attribute Names >---------------------------------------
     /**
      * subscription Xml element<br>

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
Tue Feb 13 01:14:16 2007
@@ -34,6 +34,14 @@
     public String getSubscriptionId();
 
     /**
+     * Returns the {@link ObservationConstants#HEADER_POLL_TIMEOUT PollTimeout header}
+     * or 0 (zero) if no such header is present.
+     *
+     * @return milliseconds indicating length of the poll timeout.
+     */
+    public long getPollTimeout();
+
+    /**
      * Return a {@link SubscriptionInfo} object representing the subscription
      * info present in the SUBSCRIBE request body or <code>null</code> if
      * retrieving the subscription info fails.

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
Tue Feb 13 01:14:16 2007
@@ -64,7 +64,10 @@
      *
      * @param subscriptionId as present in the
      * {@link ObservationConstants#HEADER_SUBSCRIPTIONID SubscriptionId} header.
+     * @param timeout as present in the
+     * {@link ObservationConstants#HEADER_POLL_TIMEOUT} header or 0 (zero) if
+     * none is present.
      * @return <code>EventDiscovery</code> object
      */
-    public EventDiscovery poll(String subscriptionId) throws DavException;
+    public EventDiscovery poll(String subscriptionId, long timeout) throws DavException;
 }

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java?view=diff&rev=506917&r1=506916&r2=506917
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java
Tue Feb 13 01:14:16 2007
@@ -59,9 +59,11 @@
      * Retrieve the list of events that occured since the last poll.
      *
      * @param subscriptionId indentifier for the subscription
+     * @param timeout        the time in milliseconds to wait at most for events
+     *                       if none is present currently.
      * @param resource
      * @return
      */
-    public EventDiscovery poll(String subscriptionId, ObservationResource resource)
+    public EventDiscovery poll(String subscriptionId, long timeout, ObservationResource resource)
             throws DavException;
 }



Mime
View raw message