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

michi at wyona.com michi at wyona.com
Sun Jul 26 17:08:48 CEST 2009


Author: michi
Date: 2009-07-26 17:08:48 +0200 (Sun, 26 Jul 2009)
New Revision: 43868

Modified:
   public/yanel/trunk/src/contributions/resources/search/src/build/dependencies.xml
   public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java
Log:
simple repository search added

Modified: public/yanel/trunk/src/contributions/resources/search/src/build/dependencies.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/search/src/build/dependencies.xml	2009-07-26 14:42:21 UTC (rev 43867)
+++ public/yanel/trunk/src/contributions/resources/search/src/build/dependencies.xml	2009-07-26 15:08:48 UTC (rev 43868)
@@ -9,6 +9,7 @@
       <remoteRepository refid="wyona.remote.repository"/>
       <dependency groupId="wyona-org-yanel" artifactId="yanel-core" version="${yanel.source.version}"/>
       <dependency groupId="wyona-org-yanel" artifactId="yanel-impl" version="${yanel.source.version}"/>
+      <dependency groupId="javax.servlet" artifactId="servlet-api" version="2.3"/>
     </artifact:dependencies>
 
     <artifact:dependencies pathId="maven2.resource.classpath" filesetId="maven2.resource.fileset">

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-07-26 14:42:21 UTC (rev 43867)
+++ public/yanel/trunk/src/contributions/resources/search/src/java/org/wyona/yanel/impl/resources/search/SearchResource.java	2009-07-26 15:08:48 UTC (rev 43868)
@@ -21,14 +21,27 @@
     /*
      * @see org.wyona.yanel.impl.resources.BasicXMLResource#getContentXML(String)
      */
-    protected InputStream getContentXML(String viewId) {
+    protected InputStream getContentXML(String viewId) throws Exception {
         if (log.isDebugEnabled()) {
             log.debug("requested viewId: " + viewId);
         }
         StringBuilder sb = new StringBuilder("<?xml version=\"1.0\"?>");
         sb.append("<y:search xmlns:y=\"http://www.wyona.org/yanel/search/1.0\">");
-        sb.append("<y:query>TODO</y:query>");
-        sb.append("<y:results provider=\"google\"/>");
+
+        String query = getRequest().getParameter("q");
+        if (query != null) {
+            sb.append("<y:query>" + query + "</y:query>");
+            org.wyona.yarep.core.Node[] nodes = getRealm().getRepository().search(query);
+            if (nodes != null && nodes.length > 0) {
+                //sb.append("<provider source-name=\"" + "Wyona-FOAF" + "\" source-domain=\"" + "http://foaf.wyona.org" + "\" numberOfResults=\"" + pNodes.length + "\">");
+                sb.append("<y:results provider=\"google\"/>");
+                for (int i = 0; i < nodes.length; i++) {
+                    sb.append("<result repo-path=\""+nodes[i].getPath()+"\">");
+                    sb.append("</result>");
+                }
+                sb.append("</y:results>");
+            }
+        }
         sb.append("</y:search>");
         return new ByteArrayInputStream(sb.toString().getBytes());
     }



More information about the Yanel-commits mailing list