[Yanel-commits] rev 28547 - public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend

michi at wyona.com michi at wyona.com
Tue Nov 6 23:20:24 CET 2007


Author: michi
Date: 2007-11-06 23:20:23 +0100 (Tue, 06 Nov 2007)
New Revision: 28547

Modified:
   public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java
Log:
dummy result added

Modified: public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java	2007-11-06 22:00:36 UTC (rev 28546)
+++ public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java	2007-11-06 22:20:23 UTC (rev 28547)
@@ -45,7 +45,11 @@
      *
      */
     public String getMimeType(String viewId) {
-        return "application/xml";
+        if (viewId != null && viewId.equals("source")) {
+            return "application/xml";
+        } else {
+            return "application/xhtml+xml";
+        }
     }
 
     /**
@@ -60,11 +64,12 @@
      */
     public View getView(String viewId) throws Exception {
         StringBuffer sb = new StringBuffer("<foaf xmlns=\"http://www.wyona.org/foaf/1.0\">");
+        String qs = getRequest().getParameter("q");
         try {
-            String qs = getRequest().getParameter("q");
             ResultSet resultSet = getSearchResults(qs.replaceAll(" ", "+") + "+FOAF");
+
         if (resultSet != null && resultSet.size() > 0) {
-            sb.append("<provider source-name=\"" + resultSet.getSourceName() + "\" source-domain=\"" + resultSet.getSourceDomain() + "\" numberOfResults=\""+resultSet.size()+"\">");
+            sb.append("<provider source-name=\"" + resultSet.getSourceName() + "\" source-domain=\"" + resultSet.getSourceDomain() + "\" numberOfResults=\"" + resultSet.size() + "\">");
             for (int k = 0;k < resultSet.size(); k++) {
                 java.net.URL url = resultSet.get(k).url;
                 if (url.toString().endsWith("rdf")) {
@@ -73,6 +78,7 @@
                     sb.append("<excerpt><![CDATA[" + resultSet.get(k).excerpt + "]]></excerpt>");
                     sb.append("<url><![CDATA[" + resultSet.get(k).url + "]]></url>");
                     sb.append("<last-modified><![CDATA[" + resultSet.get(k).lastModified + "]]></last-modified>");
+                    sb.append("<mime-type suffix=\"rdf\">application/rdf+xml</mime-type>");
                     sb.append("</result>");
                 } else {
                     log.warn("DEBUG: Does not seem to be a RDF: " + url);
@@ -83,6 +89,20 @@
         } catch (Exception e) {
             sb.append("<exception>" + e.getMessage() + "</exception>");
         }
+
+        // TODO: Remove hard-coded ...
+        if (qs != null) {
+            sb.append("<provider source-name=\"" + "Wyona-FOAF" + "\" source-domain=\"" + "http://foaf.wyona.org" + "\" numberOfResults=\"" + "1" + "\">");
+            sb.append("<result number=\"" + "1" + "\" source-name=\"" + "Wyona-FOAF" + "\">");
+            sb.append("<title><![CDATA[" + "Foo Bar" + "]]></title>");
+            sb.append("<excerpt><![CDATA[" + "About Foo Bar ..." + "]]></excerpt>");
+            sb.append("<url><![CDATA[" + "profiles/foo-bar.html" + "]]></url>");
+            sb.append("<last-modified><![CDATA[" + "null" + "]]></last-modified>");
+            sb.append("<mime-type suffix=\"html\">application/xhtml+xml</mime-type>");
+            sb.append("</result>");
+            sb.append("</provider>");
+        }
+
         sb.append("</foaf>");
 
         View view = new View();



More information about the Yanel-commits mailing list