jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r230679 [2/2] - in /incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/src/java/org/apache/jackrabbit/client/ client/src/java/org/apache/jackrabbit/webdav/client/methods/ server/src/java/org/apache/jackrabbit/server/ server/src/java/o...
Date Sun, 07 Aug 2005 16:13:16 GMT
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
Sun Aug  7 09:12:33 2005
@@ -37,6 +37,9 @@
 import org.apache.jackrabbit.webdav.simple.DavSessionProviderImpl;
 import org.apache.jackrabbit.webdav.simple.LocatorFactoryImpl;
 import org.apache.jackrabbit.webdav.simple.ResourceFactoryImpl;
+import org.apache.jackrabbit.webdav.simple.ResourceFilterConfig;
+import org.apache.jackrabbit.webdav.simple.ResourceFilter;
+import org.apache.jackrabbit.webdav.simple.DefaultResourceFilter;
 import org.apache.log4j.Logger;
 
 import javax.jcr.Credentials;
@@ -47,6 +50,7 @@
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.net.URL;
+import java.net.MalformedURLException;
 
 /**
  * WebdavServlet provides webdav support (level 1 and 2 complient) for repository
@@ -80,7 +84,18 @@
      */
     public static final String INIT_PARAM_AUTHENTICATE_HEADER = "authenticate-header";
 
-    public static final String CTX_ATTR_RESOURCE_PATH_PREFIX = "jcr.webdav.resourcepath";
+    /**
+     * Name of the init parameter that specify a separate configuration used
+     * for filtering the resources displayed.
+     */
+    public static final String INIT_PARAM_RESOURCE_FILTER = "resource-filter";
+
+    /**
+     * Servlet context attribute used to store the path prefix instead of
+     * having a static field with this servlet. The latter causes problems
+     * when running multiple
+     */
+    public static final String CTX_ATTR_RESOURCE_PATH_PREFIX = "jackrabbit.webdav.simple.resourcepath";
 
     /**
      * the resource path prefix
@@ -131,6 +146,11 @@
     private SessionProvider sessionProvider;
 
     /**
+     * The resource filter
+     */
+    private ResourceFilter resourceFilter;
+
+    /**
      * Init this servlet
      *
      * @throws ServletException
@@ -165,6 +185,16 @@
             authenticate_header = DEFAULT_AUTHENTICATE_HEADER;
         }
         log.info("WWW-Authenticate header = '" + authenticate_header + "'");
+
+        String filterParam = getInitParameter(INIT_PARAM_RESOURCE_FILTER);
+        if (filterParam != null) {
+            try {
+                ResourceFilterConfig config = new ResourceFilterConfig();
+                setResourceFilter(config.parse(getServletContext().getResource(filterParam)));
+            } catch (MalformedURLException e) {
+                log.debug("Unable to build resource filter provider.");
+            }
+        }
     }
 
     /**
@@ -337,7 +367,7 @@
      */
     public DavResourceFactory getResourceFactory() {
         if (resourceFactory == null) {
-            resourceFactory = new ResourceFactoryImpl(getLockManager());
+            resourceFactory = new ResourceFactoryImpl(getLockManager(), getResourceFilter());
         }
         return resourceFactory;
     }
@@ -419,6 +449,28 @@
      */
     public String getAuthenticateHeaderValue() {
         return authenticate_header;
+    }
+
+    /**
+     * Returns the resource filter to be applied
+     *
+     * @return
+     */
+    public ResourceFilter getResourceFilter() {
+        // fallback if no config present or invalid: an empty resource filter
+        if (resourceFilter == null) {
+            resourceFilter = new DefaultResourceFilter();
+        }
+        return resourceFilter;
+    }
+
+    /**
+     * Set the resource filter
+     *
+     * @param resourceFilter
+     */
+    public void setResourceFilter(ResourceFilter resourceFilter) {
+        this.resourceFilter = resourceFilter;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/catalog.xml Sun
Aug  7 09:12:33 2005
@@ -46,7 +46,7 @@
 
         <!--
             if the content type matches 'text/xml' the content of the resource
-            i considered as xml and deserialized into the jcr repository.
+            is considered as xml and deserialized into the jcr repository.
             @return false
         -->
         <command

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml?rev=230679&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml Sun
Aug  7 09:12:33 2005
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+<!DOCTYPE filter [
+        <!ELEMENT filter (class, namespaces?, nodetypes?) >
+
+	<!ELEMENT class >
+        <!ATTLIST class
+            name  CDATA #REQUIRED
+        >
+        <!ELEMENT namespaces (prefix | uri)* >
+        <!ELEMENT prefix (CDATA) >
+        <!ELEMENT uri (CDATA) >
+
+        <!ELEMENT nodetypes (nodetype)* >
+        <!ELEMENT nodetype (CDATA) >
+]>
+-->
+<!--
+ Filter that allows to prevent certain items from being displayed.
+ Please note, that this has an effect on PROPFIND calls only and does not
+ provide limited access to those items matching any of the filters.
+ 
+ However specifying a filter may cause problems with PUT or MKCOL if the
+ resource to be created is being filtered out, thus resulting in inconsistent
+ responses (e.g. PUT followed by PROPFIND on parent).
+ -->
+<filter>
+    <!-- class element defines the resource filter to be used. The specified class
+         must implement the ResourceFilter interface -->
+    <class name="org.apache.jackrabbit.webdav.simple.DefaultResourceFilter" />
+    <!-- Nodetype names to be used to filter child nodes.
+         A child node can be filtered if the declaring nodetype of its definition
+         is one of the nodetype names specified in the nodetypes Element.
+         E.g. defining 'rep:root' as filtered nodetype whould result in jcr:system
+         being hidden but no other child node of the root node, since those
+         are defined by the nodetype nt:unstructered.
+    -->
+    <!--
+    <nodetypes>
+        <nodetype>rep:root</nodetype>
+    </nodetypes>
+    -->
+    <!-- Namespace prefixes or uris. Items having a name that matches any of the
+         entries will be filtered.
+    -->
+    <namespaces>
+        <prefix>rep</prefix>
+        <prefix>jcr</prefix>
+        <!--
+        <uri>internal</uri>
+        <uri>http://www.jcp.org/jcr/1.0</uri>
+        -->
+    </namespaces>
+</filter>
+

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/filter.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml Sun Aug
 7 09:12:33 2005
@@ -173,6 +173,19 @@
                 the defines the commons-chain catalog for server tasks.
             </description>
         </init-param>
+        !--
+            Optional parameter defining namespaces (or uri or prefixes) and/or
+            nodetype names that mark hidden resources.
+            If omitted not resources will be filtered out.
+        -->
+        <init-param>
+            <param-name>resource-filter</param-name>
+            <param-value>/WEB-INF/filter.xml</param-value>
+            <description>
+                Defines namespace (uri or prefix) or nodetype names for hidden 
+                resources.
+            </description>
+        </init-param>
         <load-on-startup>3</load-on-startup>
     </servlet>
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
Sun Aug  7 09:12:33 2005
@@ -163,6 +163,16 @@
     public void removeProperty(DavPropertyName propertyName) throws DavException;
 
     /**
+     * Set/add the specified properties and remove the properties with the given
+     * names from this resource respectively.
+     *
+     * @param setProperties Set of properties to be added or modified
+     * @param removePropertyNames Set of property names to be removed
+     * @throws DavException if an error occurs
+     */
+    public void alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames)
throws DavException;
+
+    /**
      * Retrieve the resource this resource is internal member of.
      *
      * @return resource this resource is an internal member of. In case this resource

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Sun Aug  7 09:12:33 2005
@@ -30,6 +30,7 @@
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.transaction.TransactionConstants;
 import org.apache.jackrabbit.webdav.transaction.TransactionInfo;
 import org.apache.jackrabbit.webdav.version.DeltaVConstants;
@@ -481,11 +482,29 @@
         boolean isMatching = false;
         String lockToken = resource.getLock(Type.WRITE, Scope.EXCLUSIVE).getToken();
         if (lockToken != null) {
-            // todo: do not ignore etag
-            isMatching = matchesIfHeader(resource.getHref(), lockToken, "");
+            isMatching = matchesIfHeader(resource.getHref(), lockToken, getStrongETag(resource));
         } // else: lockToken is null >> the if-header will not match.
 
         return isMatching;
+    }
+
+    /**
+     * Returns the strong etag present on the given resource or empty string
+     * if either the resource does not provide any etag or if the etag is weak.
+     *
+     * @param resource
+     * @return strong etag or empty string.
+     */
+    private String getStrongETag(DavResource resource) {
+        DavProperty prop = resource.getProperty(DavPropertyName.GETETAG);
+        if (prop != null) {
+            String etag = prop.getValue().toString();
+            if (etag != null && etag.length() > 0 && !etag.startsWith("W\\"))
{
+                return etag;
+            }
+        }
+        // no strong etag available
+        return "";
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/CodedUrlHeader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/CodedUrlHeader.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/CodedUrlHeader.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/CodedUrlHeader.java
Sun Aug  7 09:12:33 2005
@@ -107,4 +107,4 @@
         String headerValue = request.getHeader(headerName);
         return new CodedUrlHeader(headerName, headerValue);
     }
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java
Sun Aug  7 09:12:33 2005
@@ -112,4 +112,4 @@
 	}
         return d;
     }
-}
+}
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java?rev=230679&r1=230678&r2=230679&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
Sun Aug  7 09:12:33 2005
@@ -84,8 +84,8 @@
             Iterator it = ((List)val).iterator();
             while (it.hasNext()) {
                 Object o = it.next();
-                if (o instanceof Element) {
-                    String href = ((Element)o).getChildText(XML_HREF, NAMESPACE);
+                if (o instanceof Element && XML_HREF.equals(((Element)o).getName()))
{
+                    String href = ((Element)o).getText();
                     if (href != null) {
                         hrefList.add(href);
                     } else {
@@ -95,8 +95,8 @@
                     log.warn("DAV: href element expected in the content of " + getName().toString());
                 }
             }
-        } else if (val instanceof Element) {
-            String href = ((Element)val).getChildText(XML_HREF, NAMESPACE);
+        } else if (val instanceof Element && XML_HREF.equals(((Element)val).getName()))
{
+            String href = ((Element)val).getText();
             if (href != null) {
                 hrefList.add(href);
             } else {



Mime
View raw message