Author: emuckenhuber
Date: 2007-11-30 12:48:16 -0500 (Fri, 30 Nov 2007)
New Revision: 9226
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
Log:
- added 2 new google categories
- had to generalize the character replacement, because not only the category 'Fun
& Games' is affected // now we use the character replacement only when first spot
parsing fails
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-11-30
16:51:47 UTC (rev 9225)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-11-30
17:48:16 UTC (rev 9226)
@@ -41,12 +41,14 @@
private static final Collection CATEGORIES =
Collections.unmodifiableList((List)CollectionBuilder.arrayList()
.add(new GGWidgetCategoryInfo("all", "Popular"))
.add(new GGWidgetCategoryInfo("news", "News"))
+ .add(new GGWidgetCategoryInfo("tools", "Tools"))
.add(new GGWidgetCategoryInfo("communication",
"Communication"))
.add(new GGWidgetCategoryInfo("funandgames", "Fun &
Games"))
.add(new GGWidgetCategoryInfo("finance", "Finance"))
.add(new GGWidgetCategoryInfo("sports", "Sports"))
.add(new GGWidgetCategoryInfo("lifestyle", "Lifestyle"))
.add(new GGWidgetCategoryInfo("technology", "Technology"))
+ .add(new GGWidgetCategoryInfo("politics", "Politics"))
.add(new GGWidgetCategoryInfo("new", "New stuff"))
.get());
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-11-30
16:51:47 UTC (rev 9225)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-11-30
17:48:16 UTC (rev 9226)
@@ -94,7 +94,6 @@
}
else
{
-
InputStream in = url.openStream();
try
{
@@ -112,27 +111,34 @@
throw new WidgetException("Cannot retrieve url: " + url + " -
you can try to increase the connectionTimeout");
}
- // Remove .replace if google rss feed returns correct xml
- String string = new String(bytes).replace("Fun & Games", "Fun
& Games");
-
+ String string = new String(bytes);
List data = null;
Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
-
// create an instance of ObjectModelFactory
ObjectModelFactory factory = new GGWidgetDirectoryFactory();
- // let the object model factory to create an instance of List and populate it
with data from XML
- data = (List) unmarshaller.unmarshal(new
ByteArrayInputStream(string.getBytes("UTF-8")), factory, null);
+ // Populate the List with data from XML
+ try
+ {
+ data = (List) unmarshaller.unmarshal(new
ByteArrayInputStream(string.getBytes("UTF-8")), factory, null);
+ }
+ catch(JBossXBException e)
+ {
+ /**
+ * Remove this block when google rss feed returns correct xml
+ */
+ // Replace incorrect characters and try the parsing a 2nd time - if it fails
again we finally give up
+ String string2 = string.replace("& ", "& ");
+ unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ data = (List) unmarshaller.unmarshal(new
ByteArrayInputStream(string2.getBytes("UTF-8")), factory, null);
+ }
List entries = new ArrayList();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
GGWidgetMetaData md = (GGWidgetMetaData)iterator.next();
-
- log.debug("Adding gadget: " + md);
-
GGQueryResultEntry entry = new GGQueryResultEntry(md);
entries.add(entry);
}
@@ -146,6 +152,7 @@
}
catch (SocketTimeoutException e)
{
+ e.printStackTrace();
throw new WidgetException("Netvibes directory query failed due to timeout.
Try to increase connectionTimeout initial parameter; ", e);
}
catch(JBossXBException e)
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2007-11-30
16:51:47 UTC (rev 9225)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2007-11-30
17:48:16 UTC (rev 9226)
@@ -65,7 +65,7 @@
String catTerm = request.getParameter("cat");
if (catTerm == null)
{
- catTerm = "";
+ catTerm = "all";
}
// Compute query
@@ -134,7 +134,6 @@
<form action="<p:renderURL></p:renderURL>"
method="post">
<input type="text" name="query" value="<%= queryTerm
%>" class="portlet-form-field"/>
<select name="cat" class="portlet-form-field">
- <option value=""> </option>
<%
// Category dropdown
for (Iterator i = provider.getCategories().iterator();
i.hasNext();)
Show replies by date