You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2007/12/27 15:12:28 UTC
svn commit: r607073 - in /cocoon/trunk:
blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/
core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/
core/cocoon-pipeline/cocoon-pipeline-api/src/main/j...
Author: vgritsenko
Date: Thu Dec 27 06:12:27 2007
New Revision: 607073
URL: http://svn.apache.org/viewvc?rev=607073&view=rev
Log:
Deprecate Constants.NOTIFYING_OBJECT and NotifyingGenerator
Modified:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/CocoonCopletAdapter.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/Constants.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/CocoonCopletAdapter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/CocoonCopletAdapter.java?rev=607073&r1=607072&r2=607073&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/CocoonCopletAdapter.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/coplet/adapter/impl/CocoonCopletAdapter.java Thu Dec 27 06:12:27 2007
@@ -119,7 +119,8 @@
}
/**
- * Render the error content for a coplet
+ * Render the error content for a coplet.
+ *
* @param coplet The coplet instance data
* @param handler The content handler
* @param error The exception that occured
@@ -131,25 +132,25 @@
Exception error)
throws SAXException {
final String uri = (String) this.getConfiguration(coplet, "error-uri");
- if ( uri != null ) {
+ if (uri != null) {
// TODO - if an error occured for this coplet, remember this
// and use directly the error-uri from now on
// Create a Notifying object - if builder is set
Notifying currentNotifying = null;
- if ( this.notifyingBuilder != null ) {
+ if (this.notifyingBuilder != null) {
currentNotifying = notifyingBuilder.build(this, error);
}
- final Map objectModel = this.processInfoProvider.getObjectModel();
// Add it to the object model
- if ( currentNotifying != null ) {
+ final Map objectModel = this.processInfoProvider.getObjectModel();
+ if (currentNotifying != null) {
objectModel.put(org.apache.cocoon.Constants.NOTIFYING_OBJECT, currentNotifying);
- objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, error);
}
+ objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, error);
try {
- this.streamContent( coplet, uri, handler);
+ streamContent(coplet, uri, handler);
} finally {
objectModel.remove(org.apache.cocoon.Constants.NOTIFYING_OBJECT);
objectModel.remove(ObjectModelHelper.THROWABLE_OBJECT);
@@ -157,6 +158,7 @@
return true;
}
+
return false;
}
}
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java?rev=607073&r1=607072&r2=607073&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java Thu Dec 27 06:12:27 2007
@@ -26,13 +26,20 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Constants;
+import org.apache.cocoon.util.Deprecation;
+import org.apache.cocoon.util.location.LocationUtils;
import org.xml.sax.SAXException;
/**
+ * Generates an XML representation of the current notification.
+ *
* @cocoon.sitemap.component.documentation
* Generates an XML representation of the current notification.
+ * @cocoon.sitemap.component.documentation.caching No
*
+ * @deprecated Use <map:handle-errors> without type attribute together with
+ * {@link org.apache.cocoon.generation.ExceptionGenerator}.
* @version $Id$
*/
public class NotifyingGenerator extends AbstractGenerator {
@@ -42,14 +49,17 @@
*/
private Notifying notification;
- public void setup(SourceResolver resolver, Map objectModel, String src,
- Parameters par) throws ProcessingException, SAXException, IOException {
+
+ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+ throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
- this.notification = (Notifying)objectModel.get(Constants.NOTIFYING_OBJECT);
+ Deprecation.logger.warn("NotifyingGenerator is deprecated in favor of ExceptionGenerator, at " +
+ LocationUtils.getLocation(par));
- if ( this.notification == null) {
- throw new ProcessingException("Expected Constants.NOTIFYING_OBJECT not found in object model");
+ this.notification = (Notifying) objectModel.get(Constants.NOTIFYING_OBJECT);
+ if (this.notification == null) {
+ throw new ProcessingException("Expected Constants.NOTIFYING_OBJECT not found in object model.");
}
}
@@ -60,7 +70,7 @@
* output SAX events.
*/
public void generate() throws SAXException {
- Notifier.notify(notification, this.contentHandler, "text/xml");
+ Notifier.notify(this.notification, this.contentHandler, "text/xml");
}
/**
@@ -71,4 +81,3 @@
this.notification = null;
}
}
-
Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/Constants.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/Constants.java?rev=607073&r1=607072&r2=607073&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/Constants.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/Constants.java Thu Dec 27 06:12:27 2007
@@ -140,6 +140,8 @@
/**
* The name of a <code>NotifyingObject</code> in the so called objectModel <code>Map</code>.
+ * @deprecated Usage of Notifying object has been deprecated in favor of using Exception object at
+ * {@link org.apache.cocoon.environment.ObjectModelHelper#THROWABLE_OBJECT}.
*/
public static final String NOTIFYING_OBJECT = "notifying-object";
@@ -208,4 +210,4 @@
* @deprecated Use {@link org.apache.cocoon.configuration.Settings#getFormEncoding()}.
*/
public static final String CONTEXT_DEFAULT_ENCODING = "default-encoding";
-}
\ No newline at end of file
+}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java?rev=607073&r1=607072&r2=607073&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java Thu Dec 27 06:12:27 2007
@@ -190,7 +190,7 @@
private void prepare(InvokeContext context, Environment env, Exception ex)
throws IOException, ServiceException {
Map objectModel = env.getObjectModel();
- if (objectModel.get(Constants.NOTIFYING_OBJECT) == null) {
+ if (objectModel.get(ObjectModelHelper.THROWABLE_OBJECT) == null) {
// error has not been processed by another handler before
// Try to reset the response to avoid mixing already produced output
@@ -199,7 +199,7 @@
env.tryResetResponse();
}
- // Create a Notifying
+ // Create a Notifying (deprecated)
NotifyingBuilder notifyingBuilder = (NotifyingBuilder) this.manager.lookup(NotifyingBuilder.ROLE);
Notifying currentNotifying = null;
try {
@@ -207,11 +207,9 @@
} finally {
this.manager.release(notifyingBuilder);
}
-
- // Add it to the object model
objectModel.put(Constants.NOTIFYING_OBJECT, currentNotifying);
- // Also add the exception
+ // Add it to the object model
objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, ex);
}
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java?rev=607073&r1=607072&r2=607073&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java Thu Dec 27 06:12:27 2007
@@ -16,16 +16,16 @@
*/
package org.apache.cocoon.components.treeprocessor.sitemap;
-import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.commons.lang.SystemUtils;
import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.Constants;
import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode;
import org.apache.cocoon.components.treeprocessor.InvokeContext;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
import org.apache.cocoon.environment.Environment;
-import org.apache.commons.lang.SystemUtils;
+import org.apache.cocoon.environment.ObjectModelHelper;
/**
* Handles <map:handle-errors>
@@ -92,7 +92,7 @@
// explicit ones, in order to provide meaningful messages that will ease the migration
if (e.getMessage().indexOf("Must set a generator before adding") != -1) {
- env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
+ env.getObjectModel().remove(ObjectModelHelper.THROWABLE_OBJECT);
throw new ProcessingException(
"Incomplete pipeline: 'handle-error' without a 'type' must include a generator." +
SystemUtils.LINE_SEPARATOR +
@@ -111,7 +111,7 @@
} catch (ProcessingException e) {
if (e.getMessage().indexOf("Generator already set") != -1){
- env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
+ env.getObjectModel().remove(ObjectModelHelper.THROWABLE_OBJECT);
throw new ProcessingException(
"Error: 'handle-error' with a 'type' attribute has an implicit generator." +
SystemUtils.LINE_SEPARATOR +