From svn-return-8232-apmail-forrest-svn-archive=forrest.apache.org@forrest.apache.org Tue Feb 10 13:11:15 2009 Return-Path: Delivered-To: apmail-forrest-svn-archive@www.apache.org Received: (qmail 30947 invoked from network); 10 Feb 2009 13:11:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Feb 2009 13:11:15 -0000 Received: (qmail 50350 invoked by uid 500); 10 Feb 2009 13:11:15 -0000 Delivered-To: apmail-forrest-svn-archive@forrest.apache.org Received: (qmail 50305 invoked by uid 500); 10 Feb 2009 13:11:15 -0000 Mailing-List: contact svn-help@forrest.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Forrest Developers List" List-Id: Delivered-To: mailing list svn@forrest.apache.org Received: (qmail 50296 invoked by uid 99); 10 Feb 2009 13:11:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2009 05:11:15 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2009 13:11:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5FA472388A50; Tue, 10 Feb 2009 13:10:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r742958 - /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java Date: Tue, 10 Feb 2009 13:10:49 -0000 To: svn@forrest.apache.org From: thorsten@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090210131054.5FA472388A50@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: thorsten Date: Tue Feb 10 13:10:40 2009 New Revision: 742958 URL: http://svn.apache.org/viewvc?rev=742958&view=rev Log: Enhancing error handling by adding name of the contract that has thrown an exception. Adding a try for resolving only. Adding test whether the xpath of the injection point is absolute (warn if not and fixing it on the fly). Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java?rev=742958&r1=742957&r2=742958&view=diff ============================================================================== --- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java (original) +++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java Tue Feb 10 13:10:40 2009 @@ -51,6 +51,7 @@ import org.apache.axiom.om.OMNode; import org.apache.axiom.om.impl.builder.StAXOMBuilder; import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.ResourceNotFoundException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.AbstractSAXTransformer; @@ -583,6 +584,7 @@ // get the children of a part. This children needs to be injected in // the result Iterator children = part.getChildren(); + if (xpath == null) { // when we do not have a xpath to inject we will inject it in the // current loaction @@ -591,6 +593,14 @@ pathNode.addChild(child); } } else { + // make sure the xpath is starting with "/" + if (!xpath.startsWith("/")){ + String message = contract.getName() + + " is using relative injection points which is not permited. "+ + "Please fix this ASAP, for now we will do it for you."; + getLogger().warn(message); + xpath = "/" + xpath; + } // lookup the node where we want to inject the result part xpath = "/" + PATH_PREFIX + xpath; // we need to feed the xpathSelector with the ns we may have @@ -713,7 +723,6 @@ */ private void contractProcessingStart(Attributes attr) throws SAXException { String name = "", data = null; - try { for (int i = 0; i < attr.getLength(); i++) { String localName = attr.getLocalName(i); String value = attr.getValue(i); @@ -727,9 +736,21 @@ } dataStream = null; if (null != data && !data.equals("")) { - // try resoolving the dataUri - dataStream = resolverDispatcher.resolve(data); + // try resolving the dataUri + try { + dataStream = resolverDispatcher.resolve(data); + } catch (Exception e) { + String error = DispatcherException.ERROR_500 + "\n" + + "component: ContractBean" + "\n" + + "message: ContractBean \"" +name+ "\" has thrown an exception " + + "resolving the dataUri \""+data+"\".\n\n" + + "dispatcherErrorStack:\n" + e; + getLogger().error(error); + throw new SAXException(error); + } } + try { + // get the contract contract = contractRep.resolve(name); // prepare empty properties map @@ -737,7 +758,7 @@ } catch (Exception e) { String error = DispatcherException.ERROR_500 + "\n" + "component: ContractBean" + "\n" - + "message: Could not setup contractBean." + "\n" + "\n\n" + + "message: Could not setup contractBean \"" +name+ "\".\n\n" + "dispatcherErrorStack:\n" + e; getLogger().error(error); throw new SAXException(error);