[Yanel-commits] rev 43954 - in public/yanel/trunk/src/contributions/resources/search: htdocs src/java/org/wyona/yanel/impl/resources/search

michi at wyona.com michi at wyona.com
Mon Aug 3 14:32:27 CEST 2009


Author: michi
Date: 2009-08-03 14:32:26 +0200 (Mon, 03 Aug 2009)
New Revision: 43954

Modified:
   public/yanel/trunk/src/contributions/resources/search/htdocs/results2xhtml.xsl
   public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java
Log:
exception handling improved

Modified: public/yanel/trunk/src/contributions/resources/search/htdocs/results2xhtml.xsl
===================================================================
--- public/yanel/trunk/src/contributions/resources/search/htdocs/results2xhtml.xsl	2009-08-03 10:03:01 UTC (rev 43953)
+++ public/yanel/trunk/src/contributions/resources/search/htdocs/results2xhtml.xsl	2009-08-03 12:32:26 UTC (rev 43954)
@@ -39,8 +39,9 @@
 
         <hr/>
 
+        <xsl:apply-templates select="/y:search/y:exception"/>
         <xsl:apply-templates select="/y:search/y:results"/>
-        <xsl:if test="not(/y:search/y:results)">
+        <xsl:if test="not(/y:search/y:results) and not(/y:search/y:exception)">
 <p>
          Your search - <xsl:value-of select="/y:search/y:query"/> - did not match any documents
 </p>
@@ -61,6 +62,13 @@
   <xsl:template match="y:result">
     <li><a href="{$yarep.back2realm}{@repo-path}"><xsl:value-of select="@repo-path"/></a></li>
   </xsl:template>
+
+  <xsl:template match="y:exception">
+    <h2><font color="red">Exception:</font></h2>
+    <p>
+    <xsl:value-of select="."/>
+    </p>
+  </xsl:template>
   
   <xsl:template match="@*|node()" priority="-1">
     <xsl:copy>

Modified: public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java	2009-08-03 10:03:01 UTC (rev 43953)
+++ public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java	2009-08-03 12:32:26 UTC (rev 43954)
@@ -31,6 +31,7 @@
         String query = getRequest().getParameter("q");
         if (query != null) {
             sb.append("<y:query>" + query + "</y:query>");
+            try {
             org.wyona.yarep.core.Node[] nodes = getRealm().getRepository().getSearcher().search(query);
             if (nodes != null && nodes.length > 0) {
                 //sb.append("<provider source-name=\"" + "Wyona-FOAF" + "\" source-domain=\"" + "http://foaf.wyona.org" + "\" numberOfResults=\"" + pNodes.length + "\">");
@@ -41,6 +42,10 @@
                 }
                 sb.append("</y:results>");
             }
+            } catch(org.wyona.yarep.core.search.SearchException e) {
+                log.error(e, e);
+                sb.append("<y:exception>" + e.getMessage() + "</y:exception>");
+            }
         }
         sb.append("</y:search>");
         return new ByteArrayInputStream(sb.toString().getBytes());



More information about the Yanel-commits mailing list