Author: thomas.heute(a)jboss.com
Date: 2007-09-23 04:30:17 -0400 (Sun, 23 Sep 2007)
New Revision: 8442
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/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java
Log:
Always encode what Google sends to UTF-8 (since they claim it is in the XML when it is
not)
Softer Error logs
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-09-23
06:18:09 UTC (rev 8441)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-09-23
08:30:17 UTC (rev 8442)
@@ -38,6 +38,7 @@
import java.util.Iterator;
import java.util.ArrayList;
+import org.jboss.logging.Logger;
import org.jboss.portal.widget.google.GGWidget;
import org.jboss.portal.widget.google.info.GGWidgetCategoryInfo;
import org.jboss.portal.widget.google.info.GGWidgetInfo;
@@ -65,6 +66,9 @@
/** . */
private int connectionTimeout = 5000;
+
+ /** . */
+ private Logger logger = Logger.getLogger(GGProvider.class);
/** . */
private static final Collection CATEGORIES = Collections.unmodifiableList(new
CollectionBuilder()
@@ -227,13 +231,22 @@
public Object call() throws Exception
{
GGWidgetInfoBuilder builder = new GGWidgetInfoBuilder(url);
- GGWidgetInfo info = builder.create();
- if (info != null)
+ try
{
- return new GGWidget(url, info);
+ GGWidgetInfo info = builder.create();
+ if (info != null)
+ {
+ return new GGWidget(url, info);
+ }
+ else
+ {
+ return null;
+ }
}
- else
+ catch (Exception e)
{
+ logger.warn("Throwing " + url + " away, we don't support
it yet");
+ logger.debug(e);
return null;
}
}
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-09-23
06:18:09 UTC (rev 8441)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-09-23
08:30:17 UTC (rev 8442)
@@ -116,6 +116,8 @@
throw new Exception("Cannot retrieve " + url);
}
+ String string = new String(bytes);
+
List data = null;
Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
@@ -124,7 +126,7 @@
ObjectModelFactory factory = new GGWidgetDirecotoryFactory();
// let the object model factory to create an instance of List and populate it
with data from XML
- data = (List)unmarshaller.unmarshal(new ByteArrayInputStream(bytes), factory,
null);
+ data = (List)unmarshaller.unmarshal(new
ByteArrayInputStream(string.getBytes("UTF-8")), factory, null);
List entries = new ArrayList();
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2007-09-23
06:18:09 UTC (rev 8441)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2007-09-23
08:30:17 UTC (rev 8442)
@@ -220,7 +220,7 @@
// We don't support that for now
if (urlParamAttr.length() > 0)
{
- throw new Exception();
+ throw new Exception("We don't support that for now");
}
// String is default type when not specified
Show replies by date