Author: thomas.heute(a)jboss.com
Date: 2009-08-11 07:23:49 -0400 (Tue, 11 Aug 2009)
New Revision: 13733
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/exceptions/WidgetFailure.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVEcosystemFactory.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVQueryResultMetaData.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesQueryResultEntry.java
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
Log:
JBEPP-109: Improved support for Google and Netvibes widgets (Workaround remote API
changes/issues :-/)
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/exceptions/WidgetFailure.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/exceptions/WidgetFailure.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/exceptions/WidgetFailure.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -81,7 +81,7 @@
{
if (cause instanceof WidgetNotSupportedException)
{
- return "This widget type is not supported: "+ urlString;
+ return "This widget is not supported: "+ urlString;
}
else
if (cause instanceof WidgetFetchException)
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -107,7 +107,7 @@
if (info != null)
{
// Generate base params
- tmp.append("&synd=jboss");
+ tmp.append("&synd=open");
tmp.append("&w=").append(info.getWidth());
tmp.append("&h=").append(info.getHeight());
//don's let to override the title param - proper one will be picked up with
i18n support
@@ -141,24 +141,9 @@
tmp.append("&up_").append(encoder.encode(prefName)).append("=").append(encoder.encode(value));
}
}
-
- //
- String clipper = "" +
- "(function(){\n" +
- "var a = document.getElementById('" + id +
"');\n" +
- "var b = a.childNodes.item(2);\n" + // table
- "var c = b.childNodes.item(0);\n" + // tbody
- "var d = c.childNodes.item(0);\n" + // tr
- "var e = c.childNodes.item(1);\n" + // tr
- "var f = c.childNodes.item(3);\n" + // tr
- "c.removeChild(d);\n" +
- "c.removeChild(e);\n" +
- "c.removeChild(f);\n" +
- "})();";
-
+
return "<div id=\"" + id + "\">\n" +
"<script src=\"" + tmp +
"\"></script>\n" +
- "<script>" + clipper + "</script>\n" +
"</div>\n";
}
else
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -39,7 +39,9 @@
{
/** The google categories */
private static final Collection CATEGORIES =
Collections.unmodifiableList((List)CollectionBuilder.arrayList()
- .add(new GGWidgetCategoryInfo("all", "Popular"))
+ .add(new GGWidgetCategoryInfo("", "All"))
+ .add(new GGWidgetCategoryInfo("featured", "Editor's
picks"))
+ .add(new GGWidgetCategoryInfo("celebpicks", "Celebrity
picks"))
.add(new GGWidgetCategoryInfo("news", "News"))
.add(new GGWidgetCategoryInfo("tools", "Tools"))
.add(new GGWidgetCategoryInfo("communication",
"Communication"))
@@ -49,7 +51,6 @@
.add(new GGWidgetCategoryInfo("lifestyle", "Lifestyle"))
.add(new GGWidgetCategoryInfo("technology", "Technology"))
.add(new GGWidgetCategoryInfo("politics", "Politics"))
- .add(new GGWidgetCategoryInfo("new", "New stuff"))
.get());
public Collection getCategories()
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -148,7 +148,7 @@
{
buffer.append("&num=").append(num);
}
- if (cat != null)
+ if (cat != null && !"".equals(cat))
{
buffer.append("&cat=").append(cat);
}
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -43,6 +43,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
@@ -57,6 +59,9 @@
import java.util.Map;
import java.util.HashMap;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
/**
* Build widget meta data from its URL.
@@ -176,7 +181,16 @@
}
catch (Exception e)
{
- throw new WidgetMetaDataParseException("Could not parse
bundles.");
+ log.warn("The XML file: " + url.toString() + " could not be
parsed correctly with the provided encoding, trying with ISO-8859-1");
+ try
+ {
+ bundleDocBuilder = factory.newDocumentBuilder();
+ bundleDoc = bundleDocBuilder.parse(new InputSource(new
InputStreamReader(new ByteArrayInputStream(bundleBytes), "ISO-8859-1")));
+ }
+ catch (Exception e1)
+ {
+ throw new WidgetMetaDataParseException("Could not parse " +
url.toString());
+ }
}
Element messagebundleElt = bundleDoc.getDocumentElement();
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVEcosystemFactory.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVEcosystemFactory.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVEcosystemFactory.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -82,6 +82,10 @@
{
meta.setPubDate(value);
}
+ else if ("type".equals(localName))
+ {
+ meta.setType(value);
+ }
}
}
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVQueryResultMetaData.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVQueryResultMetaData.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/directory/NVQueryResultMetaData.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -42,6 +42,9 @@
private String guid;
/** . */
+ private String type;
+
+ /** . */
private String pubDate;
public String getTitle()
@@ -64,6 +67,16 @@
this.description = description;
}
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
public String getLink()
{
return link;
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -149,7 +149,7 @@
int version = metadata.getInt("apiVersion");
if (version < 1)
{
- throw new WidgetNotSupportedException("Not supported widget
version.");
+ throw new WidgetNotSupportedException("Not supported widget version:
" + url.toString());
}
// Netvibes preferences
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesQueryResultEntry.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesQueryResultEntry.java 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesQueryResultEntry.java 2009-08-11
11:23:49 UTC (rev 13733)
@@ -44,11 +44,15 @@
/** . */
private URL url;
+ /** . */
+ private String type;
+
public NetvibesQueryResultEntry(NVQueryResultMetaData meta) throws
MalformedURLException
{
this.title = meta.getTitle();
this.description = meta.getDescription();
this.url = new URL(meta.getLink());
+ this.type = meta.getType();
}
public String getDescription()
@@ -66,5 +70,10 @@
return this.url;
}
+ public String getType()
+ {
+ return this.type;
+ }
+
}
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp 2009-08-11
11:23:49 UTC (rev 13733)
@@ -20,7 +20,8 @@
<%@page import="org.jboss.portal.widget.DirectoryQueryResult"%>
<%@page
import="org.jboss.portal.widget.netvibes.provider.NetvibesQueryResult"%>
<%@page
import="org.jboss.portal.widget.exceptions.DirectoryResultFailure"%>
-<p:defineObjects/>
+
+<%@page
import="org.jboss.portal.widget.netvibes.provider.NetvibesQueryResultEntry"%><p:defineObjects/>
<div>
<%
NetvibesProvider provider =
(NetvibesProvider)request.getAttribute("provider");
@@ -200,6 +201,7 @@
</tr>
</thead>
<%
+ int j=0;
for (IteratorStatus i = new IteratorStatus(queryResults.entries());
i.hasNext();)
{
if ( (i.getIndex() + 1) >= numberOfResults)
@@ -208,6 +210,12 @@
}
DirectoryQueryResultEntry result = (DirectoryQueryResultEntry) i.next();
+ NetvibesQueryResultEntry nvResult = (NetvibesQueryResultEntry)result;
+
+ // Netvibes API is broken and despite filtering on uwa some non-uwa widget
get through, last chance to filter them out
+ if ("uwa".equals(nvResult.getType()))
+ {
+ j++;
boolean selected = false;
if ( selWidget != null
&& selWidget instanceof NetvibesWidget
@@ -233,18 +241,19 @@
selectURL.setParameter("numberOfResults",
String.valueOf(numberOfResults));
//
- String rowClass = selected ? "portlet-section-selected" :
(i.getIndex() % 2 == 0 ? "portlet-section-body" :
"portlet-section-alternate");
+ String rowClass = selected ? "portlet-section-selected" : (j % 2
== 0 ? "portlet-section-body" : "portlet-section-alternate");
%>
<tr class="<%= rowClass %>">
<td>
+
<a
href="<%= selectURL %>"><%= (result.getTitle() != null)
? result.getTitle() : "Untitled" %>
</a>
</td>
</tr>
<%
- }
+ }}
if ( queryResults.resultSize() == 0 )
{
%><tr>
Modified:
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2009-08-11
08:50:25 UTC (rev 13732)
+++
branches/Enterprise_Portal_Platform_4_3/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2009-08-11
11:23:49 UTC (rev 13733)
@@ -65,7 +65,7 @@
String catTerm = request.getParameter("cat");
if (catTerm == null)
{
- catTerm = "all";
+ catTerm = "";
}
// Compute query