jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r156314 [10/15] - in incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/ client/src/ client/src/java/ client/src/java/org/ client/src/java/org/apache/ client/src/java/org/apache/jackrabbit/ client/src/java/org/apache/jackrabbit/client/ server/ server/src/ server/src/java/ server/src/java/org/ server/src/java/org/apache/ server/src/java/org/apache/jackrabbit/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/server/simple/dav/ server/src/java/org/apache/jackrabbit/server/simple/dav/lock/ server/src/java/org/apache/jackrabbit/webdav/ server/src/java/org/apache/jackrabbit/webdav/spi/ server/src/java/org/apache/jackrabbit/webdav/spi/lock/ server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/ server/src/java/org/apache/jackrabbit/webdav/spi/observation/ server/src/java/org/apache/jackrabbit/webdav/spi/search/ server/src/java/org/apache/jackrabbit/webdav/spi/transaction/ server/src/java/org/apache/jackrabbit/webdav/spi/version/ server/src/java/org/apache/jackrabbit/webdav/spi/version/report/ webapp/ webapp/src/ webapp/src/webapp/ webapp/src/webapp/WEB-INF/ webapp/src/webapp/WEB-INF/repository/ webdav/ webdav/src/ webdav/src/java/ webdav/src/java/org/ webdav/src/java/org/apache/ webdav/src/java/org/apache/jackrabbit/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/lock/ webdav/src/java/org/apache/jackrabbit/webdav/observation/ webdav/src/java/org/apache/jackrabbit/webdav/ordering/ webdav/src/java/org/apache/jackrabbit/webdav/property/ webdav/src/java/org/apache/jackrabbit/webdav/search/ webdav/src/java/org/apache/jackrabbit/webdav/transaction/ webdav/src/java/org/apache/jackrabbit/webdav/util/ webdav/src/java/org/apache/jackrabbit/webdav/version/ webdav/src/java/org/apache/jackrabbit/webdav/version/report/
Date Sun, 06 Mar 2005 14:03:11 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import org.jdom.Element;
+import org.jdom.Document;
+import org.jdom.output.XMLOutputter;
+import org.jdom.output.Format;
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.webdav.observation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.ServletOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+/**
+ * WebdavResponseImpl implements the <code>WebdavResponse</code> interface.
+ */
+public class WebdavResponseImpl implements WebdavResponse {
+
+    private static Logger log = Logger.getLogger(WebdavResponseImpl.class);
+
+    private HttpServletResponse httpResponse;
+
+    /**
+     * Create a new <code>WebdavResponse</code>
+     * 
+     * @param httpResponse
+     */
+    public WebdavResponseImpl(HttpServletResponse httpResponse) {
+        this.httpResponse = httpResponse;
+
+        /* set cache control headers in order to deal with non-webdav complient
+        * http1.1 or http1.0 proxies. >> see RFC2518 9.4.5 */
+        addHeader("Pragma", "No-cache");  // http1.0
+        addHeader("Cache-Control", "no-cache"); // http1.1
+    }
+
+    /**
+     *
+     * @param exception
+     * @throws IOException
+     * @see DavServletResponse#sendErrorResponse(org.apache.jackrabbit.webdav.DavException)
+     */
+    public void sendErrorResponse(DavException exception) throws IOException {
+        Element errorElem = exception.getError();
+        if (errorElem == null || errorElem.getChildren().size() == 0) {
+            httpResponse.sendError(exception.getErrorCode(), exception.getStatusPhrase());
+        } else {
+            sendXmlResponse(new Document(exception.getError()), exception.getErrorCode());
+        }
+    }
+
+    /**
+     * Send a multistatus response.
+     *
+     * @param multistatus
+     * @throws IOException
+     * @see DavServletResponse#sendMultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatus)
+     */
+    public void sendMultiStatusResponse(MultiStatus multistatus) throws IOException {
+        sendXmlResponse(multistatus.toXml(), SC_MULTI_STATUS);
+    }
+
+    /**
+     * Send response body for a lock request intended to create a new lock.
+     *
+     * @param lock
+     * @throws java.io.IOException
+     * @see DavServletResponse#sendLockResponse(org.apache.jackrabbit.webdav.lock.ActiveLock)
+     */
+    public void sendLockResponse(ActiveLock lock) throws IOException {
+        httpResponse.setHeader(DavConstants.HEADER_LOCK_TOKEN, "<" + lock.getToken() + ">");
+
+        Element propElem = new Element(DavConstants.XML_PROP, DavConstants.NAMESPACE);
+	propElem.addContent(new LockDiscovery(lock).toXml());
+	sendXmlResponse(new Document(propElem), SC_OK);
+    }
+
+    /**
+     * Send response body for a lock request that was intended to refresh one
+     * or several locks.
+     *
+     * @param locks
+     * @throws java.io.IOException
+     * @see DavServletResponse#sendRefreshLockResponse(org.apache.jackrabbit.webdav.lock.ActiveLock[])
+     */
+    public void sendRefreshLockResponse(ActiveLock[] locks) throws IOException {
+        Element propElem = new Element(DavConstants.XML_PROP, DavConstants.NAMESPACE);
+        propElem.addContent(new LockDiscovery(locks).toXml());
+        sendXmlResponse(new Document(propElem), SC_OK);
+    }
+
+    /**
+     * Send Xml response body.
+     *
+     * @param xmlDoc
+     * @param status
+     * @throws IOException
+     * @see DavServletResponse#sendXmlResponse(Document, int);
+     */
+    public void sendXmlResponse(Document xmlDoc, int status) throws IOException {
+        httpResponse.setStatus(status);
+        if (xmlDoc != null) {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            // Write dom tree into byte array output stream
+            XMLOutputter xmli = new XMLOutputter(Format.getPrettyFormat());
+            xmli.output(xmlDoc, out);
+            byte[] bytes = out.toByteArray();
+            httpResponse.setContentType("text/xml; charset=UTF-8");
+            httpResponse.setContentLength(bytes.length);
+            httpResponse.getOutputStream().write(bytes);
+            out.close();
+            out.flush();
+        }
+    }
+
+    //----------------------------< ObservationDavServletResponse Interface >---
+    /**
+     *
+     * @param subscription
+     * @throws IOException
+     * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletResponse#sendSubscriptionResponse(org.apache.jackrabbit.webdav.observation.Subscription)
+     */
+    public void sendSubscriptionResponse(Subscription subscription) throws IOException {
+        Element propElem = new Element(DavConstants.XML_PROP, DavConstants.NAMESPACE);
+	propElem.addContent(new SubscriptionDiscovery(subscription).toXml());
+	Document doc = new Document(propElem);
+	sendXmlResponse(doc, SC_OK);
+    }
+
+    /**
+     *
+     * @param eventDiscovery
+     * @throws IOException
+     * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletResponse#sendPollResponse(org.apache.jackrabbit.webdav.observation.EventDiscovery)
+     */
+    public void sendPollResponse(EventDiscovery eventDiscovery) throws IOException {
+        Document pollDoc = new Document(eventDiscovery.toXml());
+        sendXmlResponse(pollDoc, SC_OK);
+    }
+
+    //--------------------------------------< HttpServletResponse interface >---
+    public void addCookie(Cookie cookie) {
+        httpResponse.addCookie(cookie);
+    }
+
+    public boolean containsHeader(String s) {
+        return httpResponse.containsHeader(s);
+    }
+
+    public String encodeURL(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public String encodeRedirectURL(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public String encodeUrl(String s) {
+        return httpResponse.encodeUrl(s);
+    }
+
+    public String encodeRedirectUrl(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public void sendError(int i, String s) throws IOException {
+        httpResponse.sendError(i, s);
+    }
+
+    public void sendError(int i) throws IOException {
+        httpResponse.sendError(i);
+    }
+
+    public void sendRedirect(String s) throws IOException {
+        httpResponse.sendRedirect(s);
+    }
+
+    public void setDateHeader(String s, long l) {
+        httpResponse.setDateHeader(s, l);
+    }
+
+    public void addDateHeader(String s, long l) {
+        httpResponse.addDateHeader(s, l);
+    }
+
+    public void setHeader(String s, String s1) {
+        httpResponse.setHeader(s, s1);
+    }
+
+    public void addHeader(String s, String s1) {
+        httpResponse.addHeader(s, s1);
+    }
+
+    public void setIntHeader(String s, int i) {
+        httpResponse.setIntHeader(s, i);
+    }
+
+    public void addIntHeader(String s, int i) {
+        httpResponse.addIntHeader(s, i);
+    }
+
+    public void setStatus(int i) {
+        httpResponse.setStatus(i);
+    }
+
+    public void setStatus(int i, String s) {
+        httpResponse.setStatus(i, s);
+    }
+
+    public String getCharacterEncoding() {
+        return httpResponse.getCharacterEncoding();
+    }
+
+    public ServletOutputStream getOutputStream() throws IOException {
+        return httpResponse.getOutputStream();
+    }
+
+    public PrintWriter getWriter() throws IOException {
+        return httpResponse.getWriter();
+    }
+
+    public void setContentLength(int i) {
+
+    }
+
+    public void setContentType(String s) {
+        httpResponse.setContentType(s);
+    }
+
+    public void setBufferSize(int i) {
+        httpResponse.setBufferSize(i);
+    }
+
+    public int getBufferSize() {
+        return httpResponse.getBufferSize();
+    }
+
+    public void flushBuffer() throws IOException {
+        httpResponse.flushBuffer();
+    }
+
+    public void resetBuffer() {
+        httpResponse.resetBuffer();
+    }
+
+    public boolean isCommitted() {
+        return httpResponse.isCommitted();
+    }
+
+    public void reset() {
+        httpResponse.reset();
+    }
+
+    public void setLocale(Locale locale) {
+        httpResponse.setLocale(locale);
+    }
+
+    public Locale getLocale() {
+        return httpResponse.getLocale();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.jdom.Element;
+
+/**
+ * <code>AbstractActiveLock</code>...
+ */
+public abstract class AbstractActiveLock implements ActiveLock, DavConstants {
+
+    /**
+     * Returns the default Xml representation of the 'activelock' element
+     * as defined by RFC 2518.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        Element activeLock = new Element(XML_ACTIVELOCK, NAMESPACE);
+
+        // locktype property
+        Element property = new Element(XML_LOCKTYPE, NAMESPACE);
+        property.addContent(getType().toXml());
+        activeLock.addContent(property);
+
+        // lockscope property
+        property = new Element(XML_LOCKSCOPE, NAMESPACE);
+        property.addContent(getScope().toXml());
+        activeLock.addContent(property);
+
+        // depth
+        activeLock.addContent(XmlUtil.depthToXml(isDeep()));
+        // timeout
+        long timeout = getTimeout();
+        if (!isExpired() && timeout != UNDEFINED_TIMEOUT) {
+            activeLock.addContent(XmlUtil.timeoutToXml(getTimeout()));
+        }
+
+        // owner
+        if (getOwner() != null) {
+            property = new Element(XML_OWNER, NAMESPACE);
+            property.setText(getOwner());
+            activeLock.addContent(property);
+        }
+
+        // locktoken
+        if (getToken() != null) {
+            property = new Element(XML_LOCKTOKEN, NAMESPACE);
+            Element href = new Element(XML_HREF, NAMESPACE);
+            href.setText(getToken());
+            property.addContent(href);
+            activeLock.addContent(property);
+        }
+        return activeLock;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractActiveLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.jdom.Element;
+
+/**
+ * <code>AbstractLockEntry</code> provides the generic {@link #toXml} method.
+ */
+public abstract class AbstractLockEntry implements LockEntry, DavConstants {
+
+    private static Logger log = Logger.getLogger(AbstractLockEntry.class);
+
+    /**
+     * Returns the Xml representation of this <code>LockEntry</code>.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        Element entry = new Element(XML_LOCKENTRY, NAMESPACE);
+        Element prop = new Element(XML_LOCKSCOPE, NAMESPACE);
+        prop.addContent(getScope().toXml());
+        entry.addContent(prop);
+        prop = new Element(XML_LOCKTYPE, NAMESPACE);
+        prop.addContent(getType().toXml());
+        entry.addContent(prop);
+        return entry;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/AbstractLockEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+
+/**
+ * <code>ActiveLock</code> encapsulates the lock information for a
+ * {@link org.apache.jackrabbit.webdav.DavResource}.
+ */
+public interface ActiveLock {
+
+    /**
+     * Return true, if the given token matches the lock token present in this
+     * lock thus indicating that any lock relevant operation should not fail
+     * due to a lock.
+     *
+     * @param lockToken to be checked
+     * @return true if the given lock token matches.
+     */
+    public boolean isLockedByToken(String lockToken);
+
+    /**
+     * Returns true, if this lock is already expired.
+     *
+     * @return true if the lock is expired
+     */
+    public boolean isExpired();
+
+    /**
+     * Return the lock token.
+     *
+     * @return token string representing the lock token.
+     */
+    public String getToken();
+
+    /**
+     * Return the name (or id) of the lock owner.
+     *
+     * @return name (or id) of the lock owner.
+     */
+    public String getOwner();
+
+    /**
+     * Set the name (or id) of the lock owner
+     *
+     * @param owner
+     */
+    public void setOwner(String owner);
+
+    /**
+     * Return the number of milliseconds the lock will live until it is expired
+     * or -1 if the timeout is not available (or the client is not allowed
+     * to retrieve it).
+     *
+     * @return
+     */
+    public long getTimeout();
+
+    /**
+     * Defines the number of milliseconds until the timeout is reached.
+     *
+     * @param timeout
+     */
+    public void setTimeout(long timeout);
+
+    /**
+     * Return true if the lock is deep.
+     *
+     * @return true if the lock is deep.
+     */
+    public boolean isDeep();
+
+    /**
+     * Set the lock deepness.
+     *
+     * @param isDeep
+     */
+    public void setIsDeep(boolean isDeep);
+
+    /**
+     * Return the type of this lock.
+     *
+     * @return type
+     */
+    public Type getType();
+
+    /**
+     * Return the scope of this lock.
+     *
+     * @return scope
+     */
+    public Scope getScope();
+
+    /**
+     * Return the Xml representation of this lock.
+     *
+     * @return Xml representation of this lock
+     */
+    public Element toXml();
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/ActiveLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.apache.jackrabbit.core.util.uuid.UUID;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+/**
+ * <code>DefaultActiveLock</code> implements the <code>ActiveLock</code> interface
+ * and represents an exclusive write lock with a random uuid lock token.
+ * Lock owner, timeout and depth is retrieved from the {@link LockInfo} object
+ * passed in the constructor. If the lockinfo is null, the following default
+ * values are set:<pre>
+ * - timeout is set to infinity.
+ * - isDeep is set to true.
+ * <pre>
+ */
+public class DefaultActiveLock extends AbstractActiveLock {
+
+    private final String token = DavConstants.OPAQUE_LOCK_TOKEN_PREFIX + UUID.randomUUID().toString();
+    private String owner;
+    private boolean isDeep = true; // deep by default
+    private long expirationTime = DavConstants.INFINITE_TIMEOUT; // never expires by default;
+
+    /**
+     * Create a new <code>DefaultActiveLock</code> with default values.
+     */
+    public DefaultActiveLock() {
+    }
+
+    /**
+     * Create a new lock
+     *
+     * @param lockInfo
+     * @throws IllegalArgumentException if either scope or type is invalid.
+     */
+    public DefaultActiveLock(LockInfo lockInfo) {
+        if (lockInfo != null) {
+            if (!(Type.WRITE.equals(lockInfo.getType()) && Scope.EXCLUSIVE.equals(lockInfo.getScope()))) {
+               throw new IllegalArgumentException("Only 'exclusive write' lock is allowed scope/type pair.");
+            }
+            owner = lockInfo.getOwner();
+            isDeep = lockInfo.isDeep();
+            setTimeout(lockInfo.getTimeout());
+        }
+    }
+
+    /**
+     * @see ActiveLock#isLockedByToken(String)
+     */
+    public boolean isLockedByToken(String lockToken) {
+	return (token != null) && token.equals(lockToken);
+    }
+
+    /**
+     * @see ActiveLock#isExpired()
+     */
+    public boolean isExpired() {
+	return System.currentTimeMillis() > expirationTime;
+    }
+
+    /**
+     * @see ActiveLock#getToken()
+     */
+    public String getToken() {
+	return token;
+    }
+
+    /**
+     * @see ActiveLock#getOwner()
+     */
+    public String getOwner() {
+	return owner;
+    }
+
+    /**
+     * @see ActiveLock#setOwner(String)
+     */
+    public void setOwner(String owner) {
+	this.owner = owner;
+    }
+
+    /**
+     * @see ActiveLock#getTimeout()
+     */
+    public long getTimeout() {
+	return expirationTime - System.currentTimeMillis();
+    }
+
+    /**
+     * @see ActiveLock#setTimeout(long)
+     */
+    public void setTimeout(long timeout) {
+	if (timeout > 0) {
+	    expirationTime = System.currentTimeMillis() + timeout;
+	}
+    }
+
+    /**
+     * @see ActiveLock#isDeep()
+     */
+    public boolean isDeep() {
+	return isDeep;
+    }
+
+    /**
+     * @see ActiveLock#setIsDeep(boolean)
+     */
+    public void setIsDeep(boolean isDeep) {
+	this.isDeep = isDeep;
+    }
+
+    /**
+     * This is always a write lock.
+     *
+     * @return the lock type
+     * @see Type#WRITE
+     */
+    public Type getType() {
+        return Type.WRITE;
+    }
+
+    /**
+     * This is always an exclusive lock.
+     *
+     * @return the lock scope.
+     * @see Scope#EXCLUSIVE
+     */
+    public Scope getScope() {
+        return Scope.EXCLUSIVE;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/DefaultActiveLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The <code>LockDiscovery</code> class encapsulates the webdav lock discovery
+ * property that is sent in the request body (PROPFIND and LOCK) and received
+ * in a LOCK response body.
+ */
+public class LockDiscovery extends AbstractDavProperty {
+
+    /**
+     * Listing of existing locks applied to the resource this discovery was
+     * requested for. Each entry reveals, who has a lock, what type of lock he has,
+     * the timeout type and the time remaining on the timeout, and the lock-type.
+     * NOTE, that any of the information listed may be not availble for the
+     * server is free to withhold any or all of this information.
+     */
+    private List activeLocks = new ArrayList();
+
+    /**
+     * Creates a new empty LockDiscovery property
+     */
+    public LockDiscovery() {
+        super(DavPropertyName.LOCKDISCOVERY, false);
+    }
+
+    /**
+     * Create a new LockDiscovery property
+     *
+     * @param lock
+     */
+    public LockDiscovery(ActiveLock lock) {
+        super(DavPropertyName.LOCKDISCOVERY, false);
+        addActiveLock(lock);
+    }
+
+    /**
+     * Create a new LockDiscovery property
+     *
+     * @param locks
+     */
+    public LockDiscovery(ActiveLock[] locks) {
+        super(DavPropertyName.LOCKDISCOVERY, false);
+        for (int i = 0; i < locks.length; i++) {
+            addActiveLock(locks[i]);
+        }
+    }
+
+    private void addActiveLock(ActiveLock lock) {
+        if (lock != null) {
+            activeLocks.add(lock);
+        }
+    }
+
+    /**
+     * Creates a JDOM  <code>&lt;lockdiscovery&gt;</code> element in order to respond to a LOCK
+     * request or to the lockdiscovery property of a PROPFIND request.<br>
+     * NOTE: if the {@link #activeLocks} list is empty an empty lockdiscovery
+     * property is created ( <code>&lt;lockdiscovery/&gt;</code>)
+     * @return A JDOM element of the &lt;active> lock tag.
+     */
+    public Element toXml() {
+        Element lockdiscovery = getName().toXml();
+        Iterator it = activeLocks.iterator();
+        while (it.hasNext()) {
+            ActiveLock lock = (ActiveLock) it.next();
+            lockdiscovery.addContent(lock.toXml());
+	}
+	return lockdiscovery;
+    }
+
+    /**
+     * Returns the list of active locks.
+     *
+     * @return list of active locks
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
+     */
+    public Object getValue() {
+        return activeLocks;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockDiscovery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+
+/**
+ * <code>LockEntry</code>...
+ */
+public interface LockEntry {
+
+    /**
+     * Returns the type of this lock entry
+     *
+     * @return type of this lock entry.
+     */
+    public Type getType();
+
+    /**
+     * Returns the scope of this lock entry.
+     *
+     * @return scope of this lock entry.
+     */
+    public Scope getScope();
+
+    /**
+     * Returns the Xml representation of this entry.
+     *
+     * @return Xml representation
+     */
+    public Element toXml();
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.jdom.Element;
+
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * <code>LockInfo</code> is a simple utility class encapsulating the information
+ * passed with a LOCK request. It combines both the request body (which if present
+ * is required to by a 'lockinfo' Xml element) and the lock relevant request
+ * headers '{@link DavConstants#HEADER_TIMEOUT Timeout}' and
+ * '{@link DavConstants#HEADER_DEPTH Depth}'.<br>
+ * Note that is class is not intended to perform any validation of the information
+ * given, since this left to those objects responsible for the lock creation
+ * on the requested resource.
+ */
+public class LockInfo {
+
+    private Type type;
+    private Scope scope;
+    private String owner;
+    private boolean isDeep;
+    private long timeout;
+
+    private boolean isRefreshLock;
+
+    /**
+     * Create a new <code>LockInfo</code> object from the given information. If
+     * <code>liElement</code> is <code>null</code> this lockinfo is assumed to
+     * be issued from a 'Refresh Lock' request.
+     *
+     * @param liElement 'lockinfo' element present in the request body of a LOCK request
+     * or <code>null</code> if the request was intended to refresh an existing lock.
+     * @param timeout Requested timespan until the lock should expire. A LOCK
+     * request MUST contain a '{@link DavConstants#HEADER_TIMEOUT Timeout}'
+     * according to RFC 2518.
+     * @param isDeep boolean value indicating whether the lock should be applied
+     * with depth infinity or only to the requested resource.
+     * @throws IllegalArgumentException if the <code>liElement</code> is not
+     * <code>null</null> but does not start with an 'lockinfo' element.
+     */
+    public LockInfo(Element liElement, long timeout, boolean isDeep) {
+        this.timeout = timeout;
+        this.isDeep = isDeep;
+
+        if (liElement != null) {
+            if (!DavConstants.XML_LOCKINFO.equals(liElement.getName())) {
+                throw new IllegalArgumentException("Element must have name 'lockinfo'.");
+            }
+
+            List childList = liElement.getChildren();
+            for (int i = 0; i < childList.size(); i++) {
+                Element child = (Element) childList.get(i);
+                String nodeName = child.getName();
+                if (DavConstants.XML_LOCKTYPE.equals(nodeName)) {
+                    Element typeElement = getFirstChildElement(child);
+                    type = Type.create(typeElement);
+                } else if (DavConstants.XML_LOCKSCOPE.equals(nodeName)) {
+                    Element scopeElement = getFirstChildElement(child);
+                    scope = Scope.create(scopeElement);
+                } else if (DavConstants.XML_OWNER.equals(nodeName)) {
+                    owner = child.getChildTextTrim(DavConstants.XML_HREF);
+                    if (owner==null) {
+                        // check if child is a text element
+                        owner = child.getTextTrim();
+                    }
+                }
+            }
+            isRefreshLock = false;
+        } else {
+            isRefreshLock = true;
+        }
+    }
+
+    /**
+     * Retrieve the first element from the content list of the specified Xml element.
+     *
+     * @param elem
+     * @return
+     */
+    private static Element getFirstChildElement(Element elem) {
+        if (elem.getContentSize() > 0) {
+            Iterator it = elem.getContent().iterator();
+            while (it.hasNext()) {
+                Object content = it.next();
+                if (content instanceof Element) {
+                    return (Element) content;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns the lock type or <code>null</null> if no 'lockinfo' element was
+     * passed to the constructor or did not contain an 'type' element.
+     *
+     * @return type or <code>null</code>
+     */
+    public Type getType() {
+        return type;
+    }
+
+    /**
+     * Return the lock scope or <code>null</null> if no 'lockinfo' element was
+     * passed to the constructor or did not contain an 'scope' element.
+     *
+     * @return scope or <code>null</code>
+     */
+    public Scope getScope() {
+        return scope;
+    }
+
+    /**
+     * Return the owner indicated by the corresponding child element from the
+     * 'lockinfo' element or <code>null</null> if no 'lockinfo' element was
+     * passed to the constructor or did not contain an 'owner' element.
+     *
+     * @return owner or <code>null</code>
+     */
+    public String getOwner() {
+        return owner;
+    }
+
+    /**
+     * Returns true if the lock must be applied with depth infinity.
+     *
+     * @return true if a deep lock must be created.
+     */
+    public boolean isDeep() {
+        return isDeep;
+    }
+
+    /**
+     * Returns the time until the lock is requested to expire.
+     *
+     * @return time until the lock should expire.
+     */
+    public long getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Returns true if this <code>LockInfo</code> was created for a LOCK
+     * request intended to refresh an existing lock rather than creating a
+     * new one.
+     *
+     * @return true if the corresponding LOCK request was intended to refresh
+     * an existing lock.
+     */
+    public boolean isRefreshLock() {
+        return isRefreshLock;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+
+/**
+ * The <code>LockManager</code> interface. 
+ */
+public interface LockManager {
+
+    /**
+     * Create a new lock for the given {@link org.apache.jackrabbit.webdav.DavResource resource}.
+     *
+     * @param lockInfo
+     * @param resource
+     * @return
+     * @throws DavException
+     */
+    public ActiveLock createLock(LockInfo lockInfo, DavResource resource)
+            throws DavException;
+
+    /**
+     * Refresh the lock identified by the given lockToken and initially created
+     * on the specified resouce. The update information can be retrieved from
+     * the lockInfo object passes.
+     *
+     * @param lockInfo
+     * @param lockToken
+     * @param resource
+     * @return
+     * @throws DavException
+     */
+    public ActiveLock refreshLock(LockInfo lockInfo, String lockToken, DavResource resource)
+            throws DavException;
+
+    /**
+     * Release the lock identified by the given lockToken and initially created
+     * on the specified resouce.
+     *
+     * @param lockToken
+     * @param resource
+     * @throws DavException
+     */
+    public void releaseLock(String lockToken, DavResource resource)
+            throws DavException;
+
+    /**
+     * Retrieve the lock with the given type and scope that is applied to the
+     * given resource. The lock may be either initially created on this resource
+     * or might be inherited from an ancestor resource that hold a deep lock.
+     * If no such lock applies to the given resource <code>null</code> must be
+     * returned.
+     *
+     * @param type
+     * @param scope
+     * @param resource
+     * @return lock with the given type and scope applied to the resource or
+     * <code>null</code> if no lock applies.
+     */
+    public ActiveLock getLock(Type type, Scope scope, DavResource resource);
+
+    /**
+     * Returns true, if the the manager contains a lock for the given
+     * resource, that is hold by the specified token.
+     *
+     * @param lockToken
+     * @param resource
+     * @return true if the resource is locked by the specified token.
+     */
+    public boolean hasLock(String lockToken, DavResource resource);
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+import java.util.*;
+
+/**
+ * The <code>Scope</code> class abstracts the lock scope as defined by RFC 2518.
+ */
+public class Scope {
+
+    private static final Map scopes = new HashMap();
+
+    public static final Scope EXCLUSIVE = Scope.create(DavConstants.XML_EXCLUSIVE, DavConstants.NAMESPACE);
+    public static final Scope SHARED = Scope.create(DavConstants.XML_SHARED, DavConstants.NAMESPACE);
+
+    private final String name;
+    private final Namespace namespace;
+
+    /**
+     * Private constructor
+     *
+     * @param name
+     * @param namespace
+     */
+    private Scope(String name, Namespace namespace) {
+        this.name = name;
+        this.namespace = namespace;
+    }
+
+    /**
+     * Return the Xml representation of the lock scope object as present in
+     * the LOCK request and response body and in the {@link LockDiscovery}.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        return new Element(name, namespace);
+    }
+
+    /**
+     * Create a <code>Scope</code> object from the given Xml element.
+     *
+     * @param lockScope
+     * @return Scope object.
+     */
+    public static Scope create(Element lockScope) {
+        if (lockScope == null) {
+            throw new IllegalArgumentException("'null' is not valid lock scope entry.");
+        }
+        return create(lockScope.getName(), lockScope.getNamespace());
+    }
+
+    /**
+     * Create a <code>Scope</code> object from the given name and namespace.
+     *
+     * @param name
+     * @param namespace
+     * @return Scope object.
+     */
+    public static Scope create(String name, Namespace namespace) {
+	String key = "{" + namespace.getURI() + "}" + name;
+        if (scopes.containsKey(key)) {
+            return (Scope) scopes.get(key);
+        } else {
+            Scope scope = new Scope(name, namespace);
+            scopes.put(key, scope);
+            return scope;
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if this Scope is equal to the given one.
+     *
+     * @param obj
+     * @return
+     */
+    public boolean equals(Object obj) {
+	if (this == obj) {
+	    return true;
+	}
+	if (obj instanceof Scope) {
+	    Scope other = (Scope) obj;
+	    return name.equals(other.name) && namespace.equals(other.namespace);
+	}
+	return false;
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Scope.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The <code>SupportedLock</code> class encapsulates the lock capabilties
+ * of a resource. It is mainly responsible for generating the &lt;supportedlock>
+ * property.
+ */
+public class SupportedLock extends AbstractDavProperty {
+
+    /** the list of lock entries */
+    private final ArrayList entries = new ArrayList();
+
+    /**
+     * Creates a new empty SupportedLock property.
+     */
+    public SupportedLock() {
+        super(DavPropertyName.SUPPORTEDLOCK, false);
+    }
+
+    /**
+     * Adds a capability to this lock support.
+     *
+     * @param type Can currently only be 'write'
+     * @param scope Can currently only be 'exclusive' or 'shared'
+     *
+     * @throws IllegalArgumentException If an argument contains invalid string
+     */
+    public void addEntry(Type type, Scope scope) {
+        entries.add(new WriteLockEntry(type, scope));
+    }
+
+    /**
+     * Adds a capability to this lock support.
+     *
+     * @param entry specifying the type of lock that is supported by this entry.
+     * @see LockEntry
+     */
+    public void addEntry(LockEntry entry) {
+        if (entry == null) {
+            throw new IllegalArgumentException("The lock entry cannot be null.");
+        }
+        entries.add(entry);
+    }
+
+    /**
+     * Returns true if this a lock with the given type and scope is supported.
+     *
+     * @param type
+     * @param scope
+     * @return true if applying a lock with the given type and scope is basically
+     * supported.
+     */
+    public boolean isSupportedLock(Type type, Scope scope) {
+        Iterator it = entries.iterator();
+        while (it.hasNext()) {
+            LockEntry le = (LockEntry) it.next();
+            if (le.getType().equals(type) && le.getScope().equals(scope)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns an iterator over all supported locks.
+     *
+     * @return an iterator over all supported locks
+     */
+    public Iterator getSupportedLocks() {
+        return entries.iterator();
+    }
+
+    /**
+     * Creates a JDOM element that represents the &lt;supportedlock> tag.
+     * 
+     * @return A JDOM element of this lock support.
+     */
+    public Element toXml() {
+        Element support = getName().toXml();
+        Iterator iter = entries.iterator();
+        while (iter.hasNext()) {
+            LockEntry le = (LockEntry) iter.next();
+            support.addContent(le.toXml());
+        }
+	return support;
+    }
+
+    /**
+     * Returns the list of supported lock entries.
+     *
+     * @return list of supported lock.
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
+     */
+    public Object getValue() {
+        return entries;
+    }
+
+    /**
+     * Class representing the default lock entries defined by
+     * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>.
+     */
+    private final static class WriteLockEntry extends AbstractLockEntry {
+
+        /** the lock scope */
+        private final Scope scope;
+
+        /**
+         * Creates a new WriteLockEntry
+         *
+         * @param type Can currently only be
+         * {@link Type#WRITE write}
+         * @param scope Can currently only be {@link Scope#EXCLUSIVE exclusive}
+         * or {@link Scope#SHARED shared}.
+         *
+         * @throws IllegalArgumentException If an argument contains invalid string
+         */
+        WriteLockEntry(Type type, Scope scope) {
+            if (!Type.WRITE.equals(type)) {
+                throw new IllegalArgumentException("Invalid Type:" + type);
+            }
+            if (!Scope.EXCLUSIVE.equals(scope) && !Scope.SHARED.equals(scope)) {
+                throw new IllegalArgumentException("Invalid scope:" +scope);
+            }
+            this.scope = scope;
+        }
+
+        /**
+         * @return always returns {@link Type#WRITE write}.
+         * @see LockEntry#getType()
+         */
+        public Type getType() {
+            return Type.WRITE;
+        }
+
+        /**
+         * @return returns {@link Scope#EXCLUSIVE} or {@link Scope#SHARED}.
+         * @see LockEntry#getScope()
+         */
+        public Scope getScope() {
+            return scope;
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/SupportedLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.lock;
+
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+import java.util.*;
+
+/**
+ * The <code>Type</code> class encapsulates the lock type as defined by RFC 2518.
+ */
+public class Type {
+
+    private static Map types = new HashMap();
+
+    public static final Type WRITE = Type.create(DavConstants.XML_WRITE, DavConstants.NAMESPACE);
+
+    private final String name;
+    private final Namespace namespace;
+
+    /**
+     * Private constructor.
+     *
+     * @param name
+     * @param namespace
+     */
+    private Type(String name, Namespace namespace) {
+        this.name = name;
+        this.namespace = namespace;
+    }
+
+    /**
+     * Returns the Xml representation of this lock <code>Type</code>.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        return new Element(name, namespace);
+    }
+
+    /**
+     * Create a <code>Type</code> object from the given Xml element.
+     *
+     * @param lockType
+     * @return <code>Type</code> object.
+     */
+    public static Type create(Element lockType) {
+        if (lockType == null) {
+            throw new IllegalArgumentException("'null' is not valid lock type entry.");
+        }
+        return create(lockType.getName(), lockType.getNamespace());
+    }
+
+    /**
+     * Create a <code>Type</code> object from the given name and namespace.
+     *
+     * @param name
+     * @param namespace
+     * @return <code>Type</code> object.
+     */
+    public static Type create(String name, Namespace namespace) {
+	String key = "{" + namespace.getURI() + "}" + name;
+        if (types.containsKey(key)) {
+            return (Type) types.get(key);
+        } else {
+            Type type = new Type(name, namespace);
+            types.put(key, type);
+            return type;
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if this Type is equal to the given one.
+     *
+     * @param obj
+     * @return
+     */
+    public boolean equals(Object obj) {
+	if (this == obj) {
+	    return true;
+	}
+	if (obj instanceof Type) {
+	    Type other = (Type) obj;
+	    return name.equals(other.name) && namespace.equals(other.namespace);
+	}
+	return false;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/Type.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/package.html?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/package.html Sun Mar  6 06:02:39 2005
@@ -0,0 +1,3 @@
+<body>
+Provides interfaces and classes for locking related issues.
+</body>
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * <code>EventDiscovery</code> represents the request body of a successfull
+ * POLL request. It reveals all events that occured since the last POLL. The
+ * definition what events that particular subscription is interested in was
+ * specified with the initial SUBSCRIPTION that started the event listening.
+ */
+public class EventDiscovery implements ObservationConstants {
+
+    private static Logger log = Logger.getLogger(EventDiscovery.class);
+
+    private List bundles = new ArrayList();
+
+    /**
+     * Add the Xml representation of an single 'eventBundle' listing the
+     * events that resulted from a change in the server, filtered by the
+     * restrictions present in the corresponding subscription.
+     *
+     * @param eventBundle
+     * @see Subscription
+     */
+    public void addEventBundle(Element eventBundle) {
+        if (eventBundle != null) {
+            bundles.add(eventBundle);
+        }
+    }
+
+    /**
+     * Returns the Xml representation of this <code>EventDiscovery</code> as
+     * being present in the POLL response body.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        Element ed = new Element(XML_EVENTDISCOVERY, NAMESPACE);
+        ed.addContent(bundles);
+        return ed;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/EventDiscovery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+
+/**
+ * <code>ObservationConstants</code> interface provide constants for request
+ * and response headers, Xml elements and property names used for handling
+ * observation over WebDAV. There exists no public standard for this
+ * functionality.
+ */
+public interface ObservationConstants {
+
+    /**
+     * The namespace
+     */
+    public static final Namespace NAMESPACE = Namespace.getNamespace("jcr", "http://www.day.com/jcr/webdav/1.0");
+
+    /**
+     * The SubscriptionId request header<br>
+     */
+    public static final String HEADER_SUBSCRIPTIONID = "SubscriptionId";
+
+    /**
+     * subscription Xml element<br>
+     * Mandatory element inside the {@link #SUBSCRIPTIONDISCOVERY subscriptiondiscovery}
+     * property indicating the event listeners present for this session.<br>
+     * NOTE, that this will not reveal any subscription made by another session.
+     */
+    public static final String XML_SUBSCRIPTION = "subscription";
+    
+    /**
+     * Xml elements
+     */
+    public static final String XML_SUBSCRIPTIONINFO = "subscriptioninfo";
+
+    public static final String XML_EVENTTYPE = "eventtype";
+    public static final String XML_NOLOCAL = "nolocal";
+    public static final String XML_FILTER = "filter";
+    public static final String XML_SUBSCRIPTIONID = "subscriptionid";
+    public static final String XML_UUID = "uuid";
+    public static final String XML_NODETYPE_NAME = "nodetype-name";
+
+    public static final String XML_EVENTDISCOVERY = "eventdiscovery";
+    public static final String XML_EVENTBUNDLE = "eventbundle";
+    public static final String XML_EVENT = "event";
+    public static final String XML_EVENTUSERID = "eventuserid";
+
+    /**
+     * Element representing the 'nodeadded' event type.
+     * @see javax.jcr.observation.Event#NODE_ADDED
+     */
+    public static final String EVENT_NODEADDED = "nodeadded";
+
+    /**
+     * Element representing the 'noderemoved' event type.
+     * @see javax.jcr.observation.Event#NODE_REMOVED
+     */
+    public static final String EVENT_NODEREMOVED = "noderemoved";
+
+    /**
+     * Element representing the 'propertyadded' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_ADDED
+     */
+    public static final String EVENT_PROPERTYADDED = "propertyadded";
+
+    /**
+     * Element representing the 'propertyremoved' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_REMOVED
+     */
+    public static final String EVENT_PROPERTYREMOVED = "propertyremoved";
+
+    /**
+     * Element representing the 'propertychanged' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_CHANGED
+     */
+    public static final String EVENT_PROPERTYCHANGED = "propertychanged";
+
+    /**
+     * The protected subscription discovery property is used to find out about
+     * existing subscriptions present on the specified resource.
+     */
+    public static final DavPropertyName SUBSCRIPTIONDISCOVERY = DavPropertyName.create("subscriptiondiscovery", NAMESPACE);
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.apache.jackrabbit.webdav.DavServletRequest;
+
+/**
+ * <code>ObservationDavServletRequest</code> provides extensions to the
+ * {@link DavServletRequest} interface used for dealing with observation.
+ */
+public interface ObservationDavServletRequest extends DavServletRequest {
+
+    /**
+     * Return the {@link ObservationConstants#HEADER_SUBSCRIPTIONID SubscriptionId header}
+     * or <code>null</code> if no such header is present.
+     *
+     * @return the {@link ObservationConstants#HEADER_SUBSCRIPTIONID SubscriptionId header}
+     */
+    public String getSubscriptionId();
+
+    /**
+     * 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.
+     *
+     * @return subscription info object encapsulating the SUBSCRIBE request body
+     * or <code>null</code> if the subscription info cannot be built.
+     */
+    public SubscriptionInfo getSubscriptionInfo();
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.apache.jackrabbit.webdav.DavServletResponse;
+
+import java.io.IOException;
+
+/**
+ * <code>ObservationDavServletResponse</code> provides extensions to the
+ * {@link DavServletResponse} interface used for dealing with observation.
+ */
+public interface ObservationDavServletResponse extends DavServletResponse {
+
+    /**
+     * Send the response to a successful SUBSCRIBE request.
+     *
+     * @param subsription that needs to be represented in the response body.
+     * @throws IOException
+     */
+    public void sendSubscriptionResponse(Subscription subsription) throws IOException;
+
+    /**
+     * Send the response to a sucessful POLL request.
+     *
+     * @param eventdiscovery {@link EventDiscovery} object to be returned in
+     * the response body.
+     * @throws IOException
+     */
+    public void sendPollResponse(EventDiscovery eventdiscovery) throws IOException;
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavSession;
+
+/**
+ * <code>ObservationResource</code> extends the {@link DavResource} interface by
+ * observation relevant METHODS.
+ */
+public interface ObservationResource extends DavResource {
+
+    public String COMPLIANCE_CLASS = "observation";
+    public String METHODS = "SUBSCRIBE, UNSUBSCRIBE, POLL";
+
+    /**
+     * Initializes this resource.
+     *
+     * @param subsMgr subscription manager object
+     */
+    public void init(SubscriptionManager subsMgr);
+
+    /**
+     * Retrieve the <code>DavSession</code> associated with this resource.
+     *
+     * @return session object associated with this resource.
+     */
+    public DavSession getSession();
+
+    /**
+     * Subscribe this resource for event listening defined by the specified
+     * subscription info. A subscriptionId may be specified in case an existing
+     * subscription should be modified.
+     *
+     * @param info <code>SubscriptionInfo</code> object as defined by the
+     * request body and headers.
+     * @param subscriptionId or <code>null</code> if the
+     * {@link ObservationConstants#HEADER_SUBSCRIPTIONID SubscriptionId} header
+     * is missing.
+     * @return <code>Subscription</code> object in case the subscription was
+     * successful.
+     */
+    public Subscription subscribe(SubscriptionInfo info, String subscriptionId) throws DavException;
+
+    /**
+     * Unsubscribe the event listener with the given SubscriptionId.
+     *
+     * @param subscriptionId as present in the {@link ObservationConstants#HEADER_SUBSCRIPTIONID
+     * SubscriptionId} header.
+     */
+    public void unsubscribe(String subscriptionId) throws DavException;
+
+    /**
+     * Retrieve the list of events that where recorded for the event listener
+     * with the given SubscriptionId.
+     *
+     * @param subscriptionId as present in the
+     * {@link ObservationConstants#HEADER_SUBSCRIPTIONID SubscriptionId} header.
+     * @return <code>EventDiscovery</code> object
+     */
+    public EventDiscovery poll(String subscriptionId) throws DavException;
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.jdom.Element;
+
+/**
+ * <code>Subscription</code> represents public representation of the event
+ * listener created (or modified) by a successful SUBSCRIBE request.
+ */
+public interface Subscription {
+
+    /**
+     * Returns the id of this subscription, that must be used for unsubscribing
+     * as well as for event discovery later on.
+     *
+     * @return subscriptionId
+     */
+    public String getSubscriptionId();
+
+    /**
+     * Return the Xml representation of this <code>Subscription</code> that is
+     * returned in the response to a successful SUBSCRIBE request as well
+     * as in a PROPFIND request. In both cases the subscription is packed into
+     * a {@link SubscriptionDiscovery} property object.
+     *
+     * @return Xml representation
+     */
+    public Element toXml();
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/Subscription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.observation;
+
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.jdom.Element;
+
+/**
+ * <code>SubscriptionDiscovery</code> encapsulates the 'subscriptiondiscovery'
+ * property of a webdav resource.
+ */
+public class SubscriptionDiscovery extends AbstractDavProperty {
+
+    Subscription[] subscriptions = new Subscription[0];
+
+    /**
+     * Create a new <code>SubscriptionDiscovery</code> that lists the given
+     * subscriptions.
+     *
+     * @param subscriptions
+     */
+    public SubscriptionDiscovery(Subscription[] subscriptions) {
+        super(ObservationConstants.SUBSCRIPTIONDISCOVERY, true);
+        if (subscriptions != null) {
+            this.subscriptions = subscriptions;
+        }
+    }
+
+    /**
+     * Create a new <code>SubscriptionDiscovery</code> that contains a single
+     * subscription entry.
+     * 
+     * @param subscription
+     */
+    public SubscriptionDiscovery(Subscription subscription) {
+        super(ObservationConstants.SUBSCRIPTIONDISCOVERY, true);
+        if (subscription != null) {
+            this.subscriptions = new Subscription[]{subscription};
+        }
+    }
+
+    /**
+     * Returns the Xml representation of the subscription discovery.
+     *
+     * @return Xml representation
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#toXml()
+     */
+    public Element toXml() {
+        Element elem = getName().toXml();
+        for (int i = 0; i < subscriptions.length; i++) {
+            elem.addContent(subscriptions[i].toXml());
+        }
+        return elem;
+    }
+
+    /**
+     * Returns an array of {@link Subscription}s.
+     *
+     * @return an array of {@link Subscription}s
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
+     */
+    public Object getValue() {
+        return subscriptions;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionDiscovery.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message