[Yanel-commits] rev 26965 - in
public/yanel/contributions/realms/foaf: data res-configs
src/resources/findfriend src/resources/findfriend/src/build
src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend
michi at wyona.com
michi at wyona.com
Sun Aug 26 23:38:13 CEST 2007
Author: michi
Date: 2007-08-26 23:38:12 +0200 (Sun, 26 Aug 2007)
New Revision: 26965
Modified:
public/yanel/contributions/realms/foaf/data/welcome.xhtml
public/yanel/contributions/realms/foaf/res-configs/advanced-search.html.yanel-rc
public/yanel/contributions/realms/foaf/src/resources/findfriend/resource.xml
public/yanel/contributions/realms/foaf/src/resources/findfriend/src/build/dependencies.xml
public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java
Log:
result set implemented
Modified: public/yanel/contributions/realms/foaf/data/welcome.xhtml
===================================================================
--- public/yanel/contributions/realms/foaf/data/welcome.xhtml 2007-08-26 21:09:43 UTC (rev 26964)
+++ public/yanel/contributions/realms/foaf/data/welcome.xhtml 2007-08-26 21:38:12 UTC (rev 26965)
@@ -26,7 +26,7 @@
<input type="text" name="q"/>
<input type="submit" value="Search"/>
<br/>
-<a href="advanced-search.html?q=TODO">Advanced Search</a>
+<a href="advanced-search.html?q=Michael+Wechner">Advanced Search</a>
</form>
</p>
<p>
Modified: public/yanel/contributions/realms/foaf/res-configs/advanced-search.html.yanel-rc
===================================================================
--- public/yanel/contributions/realms/foaf/res-configs/advanced-search.html.yanel-rc 2007-08-26 21:09:43 UTC (rev 26964)
+++ public/yanel/contributions/realms/foaf/res-configs/advanced-search.html.yanel-rc 2007-08-26 21:38:12 UTC (rev 26965)
@@ -4,6 +4,7 @@
<yanel:rti name="findfriend" namespace="http://www.wyona.org/yanel/resource/1.0"/>
<!--
- <yanel:property name="mime-type" value="application/xhtml+xml"/>
+ <yanel:property name="parser" value="org.wyona.meguni.parser.impl.GoogleParser"/>
-->
+ <yanel:property name="parser" value="org.wyona.meguni.parser.impl.MSNParser"/>
</yanel:resource-config>
Modified: public/yanel/contributions/realms/foaf/src/resources/findfriend/resource.xml
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/findfriend/resource.xml 2007-08-26 21:09:43 UTC (rev 26964)
+++ public/yanel/contributions/realms/foaf/src/resources/findfriend/resource.xml 2007-08-26 21:38:12 UTC (rev 26965)
@@ -10,8 +10,6 @@
</description>
<rtd>
-<!--
- <property name="foo" default-value="bar"/>
--->
+ <property name="parser" default-value="org.wyona.meguni.parser.impl.MSNParser"/>
</rtd>
</resource>
Modified: public/yanel/contributions/realms/foaf/src/resources/findfriend/src/build/dependencies.xml
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/findfriend/src/build/dependencies.xml 2007-08-26 21:09:43 UTC (rev 26964)
+++ public/yanel/contributions/realms/foaf/src/resources/findfriend/src/build/dependencies.xml 2007-08-26 21:38:12 UTC (rev 26965)
@@ -10,6 +10,7 @@
<dependency groupId="wyona-org-yanel" artifactId="yanel-core"
version="${yanel.source.version}"/>
<dependency groupId="wyona-org-meguni" artifactId="wyona-org-meguni" version="0.1-rREVISION"/>
+ <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/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-08-26 21:09:43 UTC (rev 26964)
+++ public/yanel/contributions/realms/foaf/src/resources/findfriend/src/java/org/wyona/yanel/impl/resources/findfriend/FindFriendResource.java 2007-08-26 21:38:12 UTC (rev 26965)
@@ -9,6 +9,7 @@
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.meguni.parser.Parser;
import org.wyona.meguni.util.ResultSet;
/**
@@ -47,9 +48,29 @@
*
*/
public View getView(String viewId) {
- ResultSet resultSet = getSearchResults();
+ StringBuffer sb = new StringBuffer("<foaf>");
+ 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()+"\">");
+ for (int k = 0;k < resultSet.size(); k++) {
+ sb.append("<result number=\"" + (k+1) + "\" source-name=\"" + resultSet.getSourceName() + "\">");
+ sb.append("<title><![CDATA[" + resultSet.get(k).title + "]]></title>");
+ 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("</result>");
+ }
+ sb.append("</provider>");
+ }
+ } catch (Exception e) {
+ sb.append("<exception>" + e.getMessage() + "</exception>");
+ }
+ sb.append("</foaf>");
+
View view = new View();
- view.setInputStream(new java.io.StringBufferInputStream(new StringBuffer("<foaf/>").toString()));
+ view.setInputStream(new java.io.StringBufferInputStream(sb.toString()));
view.setMimeType(getMimeType(viewId));
return view;
}
@@ -64,7 +85,10 @@
/**
*
*/
- private ResultSet getSearchResults() {
- return null;
+ private ResultSet getSearchResults(String queryString) throws Exception {
+ String className = getResourceConfigProperty("parser");
+ if (className == null) className = "org.wyona.meguni.parser.impl.MSNParser";
+ Parser parser = (Parser) Class.forName(className).newInstance();
+ return parser.parse(queryString);
}
}
More information about the Yanel-commits
mailing list