cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpfingsth...@apache.org
Subject svn commit: r366177 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon: components/source/impl/ transformation/
Date Thu, 05 Jan 2006 13:24:18 GMT
Author: mpfingsthorn
Date: Thu Jan  5 05:24:07 2006
New Revision: 366177

URL: http://svn.apache.org/viewcvs?rev=366177&view=rev
Log:
Added some safeguards so that the WebDAV block still works without a correctly set up event
cache.

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/java/org/apache/cocoon/transformation/WebDAVTransformer.java

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=366177&r1=366176&r2=366177&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
Thu Jan  5 05:24:07 2006
@@ -333,15 +333,17 @@
     	
     	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(eventfactory!=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 ) {

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=366177&r1=366176&r2=366177&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
Thu Jan  5 05:24:07 2006
@@ -90,6 +90,9 @@
     }
 
 	public void service(ServiceManager manager) throws ServiceException {
-		eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
+		if(manager.hasService(WebDAVEventFactory.ROLE))
+			eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
+		else
+			eventfactory = null;
 	}
 }

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=366177&r1=366176&r2=366177&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
Thu Jan  5 05:24:07 2006
@@ -18,14 +18,17 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Enumeration;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.xml.transform.OutputKeys;
 
+import org.apache.avalon.framework.parameters.Parameters;
 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.environment.SourceResolver;
 import org.apache.cocoon.xml.XMLUtils;
 import org.apache.cocoon.xml.dom.DOMStreamer;
 import org.apache.commons.httpclient.HttpConnection;
@@ -326,14 +329,7 @@
     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;
-			}
+    		return null;
     	}
     	
     	SourceValidity evalidity = null;
@@ -351,6 +347,20 @@
     	return evalidity;
     }
     
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)

+    throws ProcessingException, SAXException, IOException {
+    	super.setup(resolver, objectModel, src, par);
+    	
+    	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);
+			}
+    	}
+    }
+    
     /**
      * Forget about previous aggregated validity object
      */
@@ -394,6 +404,11 @@
 	public SourceValidity getValidity() {
 		if(getLogger().isDebugEnabled())
 			getLogger().debug("getValidity() called!");
+		
+		// dont do any caching when no event caching is set up
+		if (m_eventfactory == null) {
+			return null;
+		}
 		
         if (m_validity == null) {
             m_validity = new AggregatedValidity();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java?rev=366177&r1=366176&r2=366177&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java
Thu Jan  5 05:24:07 2006
@@ -127,7 +127,8 @@
         	try {
         		m_eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
         	} catch (ServiceException e) {
-				throw new ProcessingException("Couldn't look up event factory!", e);
+				// ignore, no eventcaching configured
+        		m_eventfactory = null;
 			}
         }
     }
@@ -140,6 +141,10 @@
      */
     private SourceValidity makeWebdavEventValidity(HttpURL methodurl) {
     	
+    	if (m_eventfactory == null) {
+    		return null;
+    	}
+    	
     	SourceValidity evalidity = null;
     	try {
     		
@@ -369,6 +374,12 @@
     }
 
     public SourceValidity getValidity() {
+    	
+        // dont do any caching when no event caching is set up
+    	if (m_eventfactory == null) {
+    		return null;
+    	}
+    	
         if (m_validity == null) {
             m_validity = new AggregatedValidity();
         }



Mime
View raw message