You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mp...@apache.org on 2005/12/23 16:50:17 UTC
svn commit: r358821 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/webdav:
conf/ java/org/apache/cocoon/components/source/impl/
java/org/apache/cocoon/components/webdav/
java/org/apache/cocoon/components/webdav/impl/
java/org/apache/cocoon/transformatio...
Author: mpfingsthorn
Date: Fri Dec 23 07:49:51 2005
New Revision: 358821
URL: http://svn.apache.org/viewcvs?rev=358821&view=rev
Log:
Implemented basic eventcache support for WebDAVSource and DASLTransformer.
You have to define a WebDAVEventFactory in cocoon.xconf so the classes know how to construct the event object.
You can also use this factory interface in your event source, like a JMSEventMessageListener subclass.
Added:
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/WebDAVEventFactory.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/impl/DefaultWebDAVEventFactory.java
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/dasl/sitemap.xmap
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf?rev=358821&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf Fri Dec 23 07:49:51 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 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.
+-->
+
+<xconf xpath="/cocoon"
+ unless="component[@role='org.apache.cocoon.components.webdav.WebDAVEventFactory']">
+
+ <component logger="core.webdav" class="org.apache.cocoon.components.webdav.impl.DefaultWebDAVEventFactory" role="org.apache.cocoon.components.webdav.WebDAVEventFactory">
+ <host>localhost</host>
+ <port>60000</port>
+ </component>
+
+</xconf>
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav-event-factory.xconf
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java?rev=358821&r1=358820&r2=358821&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java Fri Dec 23 07:49:51 2005
@@ -35,8 +35,12 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.caching.validity.EventValidity;
+import org.apache.cocoon.caching.validity.NameValueEvent;
+import org.apache.cocoon.caching.validity.NamedEvent;
import org.apache.cocoon.components.source.InspectableSource;
import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.components.webdav.WebDAVEventFactory;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
@@ -53,6 +57,7 @@
import org.apache.excalibur.source.SourceUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.TraversableSource;
+import org.apache.excalibur.source.impl.validity.AggregatedValidity;
import org.apache.excalibur.source.impl.validity.TimeStampValidity;
import org.apache.webdav.lib.Property;
import org.apache.webdav.lib.PropertyName;
@@ -71,7 +76,7 @@
* A source implementation to get access to WebDAV repositories.
*
* <h2>Protocol syntax</h2>
- * <p><code>webdav://[usr[:password]@]host[:port][/path][?cocoon:webdav-depth][&cocoon:webdav-action]</code></p>
+ * <p><code>webdav://[user[:password]@]host[:port][/path][?cocoon:webdav-depth][&cocoon:webdav-action]</code></p>
* <p>
* <ul>
* <li>
@@ -106,6 +111,9 @@
// cached uri and secureUri values
private String uri;
private String secureUri;
+
+ // the event factory to get the Event objects from for event caching
+ private WebDAVEventFactory eventfactory = null;
// the SWCL resource
private WebdavResource resource = null;
@@ -159,6 +167,10 @@
this(url, protocol);
this.resource = resource;
}
+
+ private void setWebDAVEventFactory(WebDAVEventFactory factory) {
+ eventfactory = factory;
+ }
/**
* Initialize the SWCL WebdavResource.
@@ -238,10 +250,12 @@
*/
public static WebDAVSource newWebDAVSource(HttpURL url,
String protocol,
- Logger logger)
+ Logger logger,
+ WebDAVEventFactory eventfactory)
throws URIException {
final WebDAVSource source = new WebDAVSource(url, protocol);
source.enableLogging(logger);
+ source.setWebDAVEventFactory(eventfactory);
return source;
}
@@ -251,10 +265,12 @@
private static WebDAVSource newWebDAVSource(WebdavResource resource,
HttpURL url,
String protocol,
- Logger logger)
+ Logger logger,
+ WebDAVEventFactory eventfactory)
throws URIException {
final WebDAVSource source = new WebDAVSource(resource, url, protocol);
source.enableLogging(logger);
+ source.setWebDAVEventFactory(eventfactory);
return source;
}
@@ -311,11 +327,31 @@
* <code>null</code> is returned.
*/
public SourceValidity getValidity() {
- final long lm = getLastModified();
- if (lm > 0) {
- return new TimeStampValidity(lm);
- }
- return null;
+
+ SourceValidity validity = null;
+
+ try {
+ validity = new EventValidity(eventfactory.createEvent(this.url));
+
+ if(getLogger().isDebugEnabled())
+ getLogger().debug("Created EventValidity for source: "+validity);
+
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("could not create EventValidity!",e);
+ }
+
+ if( validity == null ) {
+ if(getLogger().isDebugEnabled())
+ getLogger().debug("Falling back to TimeStampValidity!");
+
+ final long lm = getLastModified();
+ if (lm > 0) {
+ validity = new TimeStampValidity(lm);
+ }
+ }
+
+ return validity;
}
/**
@@ -534,7 +570,7 @@
} else {
childURL = new HttpURL(this.url, childName);
}
- return WebDAVSource.newWebDAVSource(childURL, this.protocol, getLogger());
+ return WebDAVSource.newWebDAVSource(childURL, this.protocol, getLogger(), eventfactory);
} catch (URIException e) {
throw new SourceException("Failed to create child", e);
}
@@ -615,7 +651,7 @@
} else {
parentURL = new HttpURL(this.url, path);
}
- return WebDAVSource.newWebDAVSource(parentURL, this.protocol, getLogger());
+ return WebDAVSource.newWebDAVSource(parentURL, this.protocol, getLogger(), eventfactory);
} catch (URIException e) {
throw new SourceException("Failed to create parent", e);
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java?rev=358821&r1=358820&r2=358821&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java Fri Dec 23 07:49:51 2005
@@ -24,7 +24,11 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.webdav.WebDAVEventFactory;
import org.apache.commons.httpclient.HttpURL;
import org.apache.commons.httpclient.HttpsURL;
import org.apache.excalibur.source.Source;
@@ -34,14 +38,16 @@
/**
* A factory for WebDAV sources
*
- * @version $Id: WebDAVSourceFactory.java,v 1.10 2004/04/13 17:13:29 stephan Exp $
+ * @version $Id$
*/
public class WebDAVSourceFactory extends AbstractLogEnabled
-implements SourceFactory, Configurable, ThreadSafe {
+implements SourceFactory, Serviceable, Configurable, ThreadSafe {
private String protocol;
private boolean secure;
+ private WebDAVEventFactory eventfactory = null;
+
/**
* Read the scheme name.
*/
@@ -76,10 +82,14 @@
url = new HttpURL("http://" + location);
}
- return WebDAVSource.newWebDAVSource(url, this.protocol, getLogger());
+ return WebDAVSource.newWebDAVSource(url, this.protocol, getLogger(), eventfactory);
}
public void release(Source source) {
// do nothing
}
+
+ public void service(ServiceManager manager) throws ServiceException {
+ eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
+ }
}
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/WebDAVEventFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/WebDAVEventFactory.java?rev=358821&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/WebDAVEventFactory.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/WebDAVEventFactory.java Fri Dec 23 07:49:51 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 1999-2004 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.cocoon.components.webdav;
+
+import org.apache.cocoon.caching.validity.Event;
+import org.apache.cocoon.caching.validity.EventFactory;
+import org.apache.commons.httpclient.HttpURL;
+
+/**
+ * Factory interface for constructing Event objects for webdav resources
+ */
+public interface WebDAVEventFactory extends EventFactory {
+
+ public static final String ROLE = WebDAVEventFactory.class.getName();
+
+ public Event createEvent(String url);
+ public Event createEvent(HttpURL url);
+}
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/impl/DefaultWebDAVEventFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/impl/DefaultWebDAVEventFactory.java?rev=358821&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/impl/DefaultWebDAVEventFactory.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/webdav/impl/DefaultWebDAVEventFactory.java Fri Dec 23 07:49:51 2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 1999-2004 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.cocoon.components.webdav.impl;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.caching.validity.Event;
+import org.apache.cocoon.caching.validity.NameValueEvent;
+import org.apache.cocoon.components.webdav.WebDAVEventFactory;
+import org.apache.commons.httpclient.HttpURL;
+
+/**
+ * Default implementation
+ */
+public class DefaultWebDAVEventFactory extends AbstractLogEnabled implements
+ WebDAVEventFactory, Configurable {
+
+ protected static final String HOST_CONFIG_ELEM = "host";
+ protected static final String PORT_CONFIG_ELEM = "port";
+
+ private String host = "localhost";
+ private int port = 60000;
+
+ public void configure(Configuration config) throws ConfigurationException {
+ host = config.getChild(HOST_CONFIG_ELEM).getValue(host);
+ port = config.getChild(PORT_CONFIG_ELEM).getValueAsInteger(port);
+ }
+
+ public Event createEvent(String url) {
+
+ // it might only be the path, supplement with host/port
+ if(url.startsWith("/")) {
+ return createEvent(host, port, url);
+ }
+
+ try {
+ HttpURL newurl = new HttpURL(url);
+
+ return createEvent(newurl);
+
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("Invalid URI, can't create event object!",e);
+ }
+ return null;
+ }
+
+ // optimization for preparsed httpclient url
+ public Event createEvent(HttpURL url) {
+ Event event = null;
+ try {
+ String host = url.getHost();
+ int port = url.getPort();
+ String path = url.getEscapedPathQuery();
+
+ event = createEvent(host, port, path);
+
+ if(getLogger().isDebugEnabled())
+ getLogger().debug("Created event for url: "+event.toString());
+
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("could not create Event!",e);
+ }
+ return event;
+ }
+
+ public Event createEvent(Parameters params) throws ParameterException {
+ return createEvent( params.getParameter("host"),
+ params.getParameterAsInteger("port"),
+ params.getParameter("path"));
+ }
+
+ protected Event createEvent(String host, int port, String path) {
+
+ if(path.endsWith("/"))
+ path = path.substring(0,path.length()-1);
+
+ return new NameValueEvent("webdav", host+"|"+port+"|"+path);
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java?rev=358821&r1=358820&r2=358821&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java Fri Dec 23 07:49:51 2005
@@ -16,12 +16,16 @@
package org.apache.cocoon.transformation;
import java.io.IOException;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Properties;
import javax.xml.transform.OutputKeys;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.caching.validity.EventValidity;
+import org.apache.cocoon.components.webdav.WebDAVEventFactory;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.xml.dom.DOMStreamer;
import org.apache.commons.httpclient.HttpConnection;
@@ -29,6 +33,8 @@
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpURL;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.AggregatedValidity;
import org.apache.webdav.lib.BaseProperty;
import org.apache.webdav.lib.WebdavResource;
import org.apache.webdav.lib.methods.OptionsMethod;
@@ -109,7 +115,7 @@
* @author <a href="mailto:d.madama@pro-netics.com>Daniele Madama</a>
* @version $Id$
*/
-public class DASLTransformer extends AbstractSAXTransformer {
+public class DASLTransformer extends AbstractSAXTransformer implements CacheableProcessingComponent {
/** The prefix for tag */
static final String PREFIX = "dasl";
@@ -124,6 +130,8 @@
static final String WEBDAV_SCHEME = "webdav://";
/** The tag name of root_tag for result */
static final String RESULT_ROOT_TAG = "query-result";
+ /** The tag name of root_tag for errors */
+ static final String ERROR_ROOT_TAG = "error";
/** The tag name for substitution of query parameter */
static final String SUBSTITUTE_TAG = "substitute-value";
/** The tag name for substitution of query parameter */
@@ -134,7 +142,14 @@
/** The target HTTP URL */
String targetUrl;
-
+
+ /** The validity of this dasl transformation run */
+ private AggregatedValidity m_validity = null;
+
+ /** The WebdavEventFactory to abstract Event creation */
+ private WebDAVEventFactory m_eventfactory = null;
+
+
/**
* Intercept the <dasl:query> start tag.
*
@@ -201,16 +216,25 @@
}
protected void performSearchMethod(String query) throws SAXException {
+ OptionsMethod optionsMethod = null;
+ SearchMethod searchMethod = null;
try {
DOMStreamer propertyStreamer = new DOMStreamer(this.xmlConsumer);
- OptionsMethod optionsMethod = new OptionsMethod(this.targetUrl);
- SearchMethod searchMethod = new SearchMethod(this.targetUrl, query);
+ optionsMethod = new OptionsMethod(this.targetUrl);
+ searchMethod = new SearchMethod(this.targetUrl, query);
HttpURL url = new HttpURL(this.targetUrl);
HttpState state = new HttpState();
state.setCredentials(null, new UsernamePasswordCredentials(
url.getUser(),
url.getPassword()));
HttpConnection conn = new HttpConnection(url.getHost(), url.getPort());
+
+ // eventcaching stuff
+ SourceValidity extraValidity = makeWebdavEventValidity(url);
+ if(extraValidity!=null && m_validity!=null)
+ m_validity.add(extraValidity);
+ // end eventcaching stuff
+
WebdavResource resource = new WebdavResource(new HttpURL(this.targetUrl));
if(!resource.exists()) {
throw new SAXException("The WebDAV resource don't exist");
@@ -219,33 +243,57 @@
if(!optionsMethod.isAllowed("SEARCH")) {
throw new SAXException("The server don't support the SEARCH method");
}
- searchMethod.execute(state, conn);
-
- Enumeration enumeration = searchMethod.getAllResponseURLs();
+ int httpstatus = searchMethod.execute(state, conn);
+
+
this.contentHandler.startElement(DASL_QUERY_NS,
RESULT_ROOT_TAG,
PREFIX + ":" + RESULT_ROOT_TAG,
XMLUtils.EMPTY_ATTRIBUTES);
- while (enumeration.hasMoreElements()) {
- String path = (String) enumeration.nextElement();
- Enumeration properties = searchMethod.getResponseProperties(path);
- AttributesImpl attr = new AttributesImpl();
- attr.addAttribute(DASL_QUERY_NS, PATH_NODE_NAME, PREFIX + ":" + PATH_NODE_NAME, "CDATA",path);
-
- this.contentHandler.startElement(DASL_QUERY_NS,
- RESOURCE_NODE_NAME,
- PREFIX + ":" + RESOURCE_NODE_NAME,
- attr);
- while(properties.hasMoreElements()) {
- BaseProperty metadata = (BaseProperty) properties.nextElement();
- Element propertyElement = metadata.getElement();
- propertyStreamer.stream(propertyElement);
- }
-
- this.contentHandler.endElement(DASL_QUERY_NS,
- RESOURCE_NODE_NAME,
- PREFIX + ":" + RESOURCE_NODE_NAME);
+
+ // something might have gone wrong, report it
+ // 207 = multistatus webdav response
+ if(httpstatus != 207) {
+
+ this.contentHandler.startElement(DASL_QUERY_NS,
+ ERROR_ROOT_TAG,
+ PREFIX + ":" + ERROR_ROOT_TAG,
+ XMLUtils.EMPTY_ATTRIBUTES);
+
+ // dump whatever the server said
+ propertyStreamer.stream(searchMethod.getResponseDocument());
+
+ this.contentHandler.endElement(DASL_QUERY_NS,
+ ERROR_ROOT_TAG,
+ PREFIX + ":" + ERROR_ROOT_TAG);
+
+ } else {
+ // show results
+
+ Enumeration enumeration = searchMethod.getAllResponseURLs();
+
+ while (enumeration.hasMoreElements()) {
+ String path = (String) enumeration.nextElement();
+ Enumeration properties = searchMethod.getResponseProperties(path);
+ AttributesImpl attr = new AttributesImpl();
+ attr.addAttribute(DASL_QUERY_NS, PATH_NODE_NAME, PREFIX + ":" + PATH_NODE_NAME, "CDATA",path);
+
+ this.contentHandler.startElement(DASL_QUERY_NS,
+ RESOURCE_NODE_NAME,
+ PREFIX + ":" + RESOURCE_NODE_NAME,
+ attr);
+ while(properties.hasMoreElements()) {
+ BaseProperty metadata = (BaseProperty) properties.nextElement();
+ Element propertyElement = metadata.getElement();
+ propertyStreamer.stream(propertyElement);
+ }
+
+ this.contentHandler.endElement(DASL_QUERY_NS,
+ RESOURCE_NODE_NAME,
+ PREFIX + ":" + RESOURCE_NODE_NAME);
+ }
}
+
this.contentHandler.endElement(DASL_QUERY_NS,
RESULT_ROOT_TAG,
PREFIX + ":" + RESULT_ROOT_TAG);
@@ -260,7 +308,97 @@
throw new SAXException("Unable to fetch the query data:", e);
} catch (Exception e) {
throw new SAXException("Generic Error:", e);
+ } finally {
+ // cleanup
+ if(searchMethod!=null)
+ searchMethod.releaseConnection();
+ if(optionsMethod!=null)
+ optionsMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Helper method to do event caching
+ *
+ * @param methodurl The url to create the EventValidity for
+ * @return an EventValidity object or null
+ */
+ private SourceValidity makeWebdavEventValidity(HttpURL methodurl) {
+
+ if(m_eventfactory == null) {
+ try {
+ m_eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("Couldn't look up WebDAVEventFactory, event caching will not work!", e);
+
+ return null;
+ }
+ }
+
+ SourceValidity evalidity = null;
+ try {
+
+ evalidity = new EventValidity(m_eventfactory.createEvent(methodurl));
+
+ if(getLogger().isDebugEnabled())
+ getLogger().debug("Created eventValidity for dasl: "+evalidity);
+
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("could not create EventValidity!",e);
+ }
+ return evalidity;
+ }
+
+ /**
+ * Forget about previous aggregated validity object
+ */
+ public void recycle() {
+ super.recycle();
+ m_validity = null;
+ }
+
+ /**
+ * generates the cachekey, which is the classname plus any possible COCOON parameters
+ */
+ public Serializable getKey() {
+ if(this.parameters.getNames().length == 0) {
+ return getClass().getName();
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getClass().getName());
+
+ // important for substitution
+ // we don't know yet which ones are relevant, so include all
+ String[] names = this.parameters.getNames();
+ for(int i=0; i<names.length; i++) {
+ buf.append(";");
+ buf.append(names[i]);
+ buf.append("=");
+ try {
+ buf.append(this.parameters.getParameter(names[i]));
+ } catch (Exception e) {
+ if(getLogger().isErrorEnabled())
+ getLogger().error("Could not read parameter '"+names[i]+"'!",e);
+ }
+ }
+
+ return buf.toString();
+ }
+ }
+
+ /**
+ * returns the validity which will be filled during processing of the requests
+ */
+ public SourceValidity getValidity() {
+ if(getLogger().isDebugEnabled())
+ getLogger().debug("getValidity() called!");
+
+ if (m_validity == null) {
+ m_validity = new AggregatedValidity();
}
+ return m_validity;
}
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/dasl/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/dasl/sitemap.xmap?rev=358821&r1=358820&r2=358821&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/dasl/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/dasl/sitemap.xmap Fri Dec 23 07:49:51 2005
@@ -16,27 +16,27 @@
-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-<map:pipelines>
- <map:pipeline>
+ <map:pipelines>
+ <map:pipeline type="event-aware">
- <map:match pattern="">
- <map:generate src="test-dasl.xml"/>
- <map:transform type="dasl"/>
- <map:serialize type="xml"/>
- </map:match>
+ <map:match pattern="">
+ <map:generate src="test-dasl.xml"/>
+ <map:transform type="dasl"/>
+ <map:serialize type="xml"/>
+ </map:match>
- <map:match pattern="src/**">
- <map:generate src="{1}"/>
- <map:serialize type="xml"/>
- </map:match>
+ <map:match pattern="src/**">
+ <map:generate src="{1}"/>
+ <map:serialize type="xml"/>
+ </map:match>
- <map:match pattern="**">
- <map:generate src="{1}"/>
- <map:transform type="dasl"/>
- <map:serialize type="xml"/>
- </map:match>
+ <map:match pattern="**">
+ <map:generate src="{1}"/>
+ <map:transform type="dasl"/>
+ <map:serialize type="xml"/>
+ </map:match>
- </map:pipeline>
-</map:pipelines>
+ </map:pipeline>
+ </map:pipelines>
</map:sitemap>
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap?rev=358821&r1=358820&r2=358821&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap Fri Dec 23 07:49:51 2005
@@ -26,7 +26,7 @@
</map:views>
<map:pipelines>
- <map:pipeline>
+ <map:pipeline type="event-aware">
<map:match pattern="">
<map:redirect-to uri="welcome"/>
@@ -40,6 +40,11 @@
<map:serialize/>
</map:match>
+ <!-- you have to make sure a slide instance is running and reachable on the host/port below -->
+ <map:match pattern="source/**">
+ <map:generate src="webdav://localhost:8080/slide/files/{1}"/>
+ <map:serialize type="xml"/>
+ </map:match>
<map:match pattern="*/**">
<map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>