You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ra...@apache.org on 2005/08/18 09:18:21 UTC

svn commit: r233294 - in /jakarta/taglibs/proper/rdc/trunk/src: META-INF/tags/rdc/configure.tag META-INF/tags/rdc/select1.tag org/apache/taglibs/rdc/GetConfigElemTag.java

Author: rahul
Date: Thu Aug 18 00:18:16 2005
New Revision: 233294

URL: http://svn.apache.org/viewcvs?rev=233294&view=rev
Log:
A fix for BZ# 36168

Modified:
    jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/configure.tag
    jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/select1.tag
    jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java

Modified: jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/configure.tag
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/configure.tag?rev=233294&r1=233293&r2=233294&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/configure.tag (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/configure.tag Thu Aug 18 00:18:16 2005
@@ -37,10 +37,21 @@
     <rdc:get-default-config name="${config}" model="${model}" />
   </c:when>
   <c:otherwise>
-    <c:import varReader="xmlSource" url="${config}">
-      <x:parse var="configuration" doc="${xmlSource}"/> 
-      <c:set target ="${model}" property="configuration"
-      value="${configuration}"/>	
-    </c:import>
+    <c:catch var="parse_failed">
+      <c:import varReader="xmlSource" url="${config}">
+        <x:parse var="configuration" doc="${xmlSource}"/> 
+        <c:set target ="${model}" property="configuration"
+         value="${configuration}"/>	
+      </c:import>
+    </c:catch>
+    <c:if test="${not empty parse_failed}">
+      <c:set var="error_message" 
+       value="Could not parse configuration file at ${config} for R D C with I D ${model.id}" /> 
+      <block>
+        <prompt>An application error has occured. 
+        ${error_message}</prompt>
+        <exit expr="'${error_message}'"/>
+      </block>
+    </c:if>
   </c:otherwise>
 </c:choose>

Modified: jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/select1.tag
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/select1.tag?rev=233294&r1=233293&r2=233294&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/select1.tag (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/META-INF/tags/rdc/select1.tag Thu Aug 18 00:18:16 2005
@@ -66,9 +66,20 @@
       <c:set target="${model}" property="id" value="${id}"/>
       <c:set target="${model}" property="optionList" value="${optionList}"/>
       <c:if test="${model.optionsClass == 'org.w3c.dom.Document'}">
-        <c:import varReader="xmlSource" url="${optionList}">
-          <x:parse var="options" doc="${xmlSource}"/> 
-        </c:import>
+        <c:catch var="parse_failed">
+          <c:import varReader="xmlSource" url="${optionList}">
+            <x:parse var="options" doc="${xmlSource}"/> 
+          </c:import>
+        </c:catch>
+        <c:if test="${not empty parse_failed}">
+          <c:set var="error_message" 
+           value="Could not parse options file at ${optionList} for select 1 with I D ${model.id}" />
+          <block>
+            <prompt>An application error has occured. 
+            ${error_message}</prompt>
+            <exit expr="'${error_message}'"/>
+          </block>
+        </c:if>
         <c:set target="${model}" property="options" value="${options}"/>
       </c:if>
       <c:set target="${model}" property="confirm" value="${confirm}"/>

Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java?rev=233294&r1=233293&r2=233294&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/GetConfigElemTag.java Thu Aug 18 00:18:16 2005
@@ -43,6 +43,9 @@
     extends SimpleTagSupport {
     
     // Error messages (to be i18n'zed)
+    private static final String ERR_NULL_DOCUMENT = "Attempting to obtain " +
+        "element \"{0}\" from null Document, check URLs specified via " +
+        "config attributes of RDCs or optionList attributes of select1 RDCs";
     private static final String ERR_PROCESS_XPATH = "Failed to obtain" +
         " element from configuration file with XPath \"{0}\"";
     
@@ -96,6 +99,11 @@
 
     private static String render(Document configuration, String elementXPath) {
         StringWriter out = new StringWriter();
+        if (configuration == null) {
+            MessageFormat msgFormat = new MessageFormat(ERR_NULL_DOCUMENT);
+            log.error(msgFormat.format(new Object[] {elementXPath}));
+            return out.toString();
+        }
         try {
             NodeList nodesOfInterest = XPathAPI.selectNodeList(configuration.
                 getDocumentElement(), elementXPath);
@@ -105,7 +113,7 @@
             }
         } catch (Exception e) {
             MessageFormat msgFormat = new MessageFormat(ERR_PROCESS_XPATH);
-            log.warn(msgFormat.format(new Object[] {elementXPath}));
+            log.warn(msgFormat.format(new Object[] {elementXPath}), e);
         }        
         return out.toString();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org