JBoss Portal SVN: r8866 - modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-11 15:40:50 -0500 (Sun, 11 Nov 2007)
New Revision: 8866
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
Log:
beware of hardcoded values...
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2007-11-11 19:19:12 UTC (rev 8865)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2007-11-11 20:40:50 UTC (rev 8866)
@@ -412,11 +412,11 @@
}
}
- public synchronized static Config getConfig(String name) throws Exception
+ public synchronized static Config getConfig(String name, String hibernates) throws Exception
{
if (configs == null)
{
- URL url = Thread.currentThread().getContextClassLoader().getResource("hibernates.xml");
+ URL url = Thread.currentThread().getContextClassLoader().getResource(hibernates);
configs = fromXML(url);
// Remove and merge default with all
@@ -439,4 +439,9 @@
//
return (Config)configs.get(name);
}
+
+ public synchronized static Config getConfig(String name) throws Exception
+ {
+ return getConfig(name, "hibernates.xml");
+ }
}
16 years, 11 months
JBoss Portal SVN: r8865 - modules/test/trunk.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-11 14:19:12 -0500 (Sun, 11 Nov 2007)
New Revision: 8865
Modified:
modules/test/trunk/pom.xml
Log:
...and make it also deploy the root pom
Modified: modules/test/trunk/pom.xml
===================================================================
--- modules/test/trunk/pom.xml 2007-11-11 18:07:16 UTC (rev 8864)
+++ modules/test/trunk/pom.xml 2007-11-11 19:19:12 UTC (rev 8865)
@@ -26,6 +26,7 @@
</distributionManagement>
<modules>
+ <module>build</module>
<module>unit</module>
<module>tooling</module>
<module>mc</module>
16 years, 11 months
JBoss Portal SVN: r8864 - modules/test/trunk/tooling.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-11 13:07:16 -0500 (Sun, 11 Nov 2007)
New Revision: 8864
Modified:
modules/test/trunk/tooling/pom.xml
Log:
make it deploy
Modified: modules/test/trunk/tooling/pom.xml
===================================================================
--- modules/test/trunk/tooling/pom.xml 2007-11-10 02:20:01 UTC (rev 8863)
+++ modules/test/trunk/tooling/pom.xml 2007-11-11 18:07:16 UTC (rev 8864)
@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-aggregator</artifactId>
- <packaging>pom</packaging>
- <name>JBoss Unit Tooling (aggregator)</name>
- <version>1.1.0-SNAPSHOT</version>
- <modules>
- <module>core</module>
- <module>ant</module>
- <module>maven2</module>
- </modules>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-portal-modules-test</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-tooling-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Unit Tooling (aggregator)</name>
+ <version>1.1.0-SNAPSHOT</version>
+ <modules>
+ <module>core</module>
+ <module>ant</module>
+ <module>maven2</module>
+ </modules>
</project>
16 years, 11 months
JBoss Portal SVN: r8863 - branches/JBoss_Portal_Branch_2_6/widget.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2007-11-09 21:20:01 -0500 (Fri, 09 Nov 2007)
New Revision: 8863
Modified:
branches/JBoss_Portal_Branch_2_6/widget/build.xml
Log:
comment socket test case
Modified: branches/JBoss_Portal_Branch_2_6/widget/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/build.xml 2007-11-10 01:41:13 UTC (rev 8862)
+++ branches/JBoss_Portal_Branch_2_6/widget/build.xml 2007-11-10 02:20:01 UTC (rev 8863)
@@ -282,7 +282,9 @@
-->
<x-test>
+ <!--
<test todir="${test.reports}" name="org.jboss.portal.test.widget.google.Foo3TestCase"/>
+ -->
<test todir="${test.reports}" name="org.jboss.portal.test.widget.netvibes.NetvibesProviderTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.widget.netvibes.NetvibesWidgetRenderTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.widget.google.QueryResultParserTestCase"/>
16 years, 11 months
JBoss Portal SVN: r8862 - branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2007-11-09 20:41:13 -0500 (Fri, 09 Nov 2007)
New Revision: 8862
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
Log:
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-10 00:16:51 UTC (rev 8861)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-11-10 01:41:13 UTC (rev 8862)
@@ -25,7 +25,7 @@
import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.widget.WidgetQuery;
-import org.jboss.portal.widget.google.directory.GGWidgetDirecotoryFactory;
+import org.jboss.portal.widget.google.directory.GGWidgetDirectoryFactory;
import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
@@ -117,7 +117,7 @@
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
// create an instance of ObjectModelFactory
- ObjectModelFactory factory = new GGWidgetDirecotoryFactory();
+ 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);
16 years, 11 months
JBoss Portal SVN: r8861 - in branches/UIServer/uiserver: gwt-dev-env/src and 7 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-11-09 19:16:51 -0500 (Fri, 09 Nov 2007)
New Revision: 8861
Added:
branches/UIServer/uiserver/gwt-dev-env/MyGWT(uiserver).launch
branches/UIServer/uiserver/gwt-dev-env/mygwt.jar
branches/UIServer/uiserver/gwt-dev-env/src/cmsPortlet.html
branches/UIServer/uiserver/gwt-dev-env/src/jspPortlet.html
branches/UIServer/uiserver/gwt-dev-env/src/weatherPortlet.html
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/MyGWTPrototype.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/layout/LayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/widget/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/widget/PortletWindow.java
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/MyGWT.gwt.xml
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_maximize.gif
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_minimize.gif
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_normal.gif
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/mygwt.html
Modified:
branches/UIServer/uiserver/gwt-dev-env/AsyncPages(uiserver).launch
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/AsyncPages.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/Portal.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/GWTClientFilter.java
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/Portal.gwt.xml
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/asyncPages.html
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/index.html
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/portal.css
Log:
first pass of integrating MyGWT into the Ajax User Agent
Modified: branches/UIServer/uiserver/gwt-dev-env/AsyncPages(uiserver).launch
===================================================================
--- branches/UIServer/uiserver/gwt-dev-env/AsyncPages(uiserver).launch 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/gwt-dev-env/AsyncPages(uiserver).launch 2007-11-10 00:16:51 UTC (rev 8861)
@@ -8,8 +8,8 @@
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="UIServer" path="1" type="4"/> "/>
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/src/main" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/src" path="3" type="2"/> "/>
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/src/resources/client/ajax/src" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/src" path="3" type="2"/> "/>
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="UIServer"/> </runtimeClasspathEntry> "/>
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/gwt-dev-linux.jar" path="3" type="2"/> "/>
</listAttribute>
Added: branches/UIServer/uiserver/gwt-dev-env/MyGWT(uiserver).launch
===================================================================
--- branches/UIServer/uiserver/gwt-dev-env/MyGWT(uiserver).launch (rev 0)
+++ branches/UIServer/uiserver/gwt-dev-env/MyGWT(uiserver).launch 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="UIServer" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/src/main" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/src/resources/client/ajax/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="UIServer"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/gwt-dev-linux.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/UIServer/uiserver/gwt-dev-env/mygwt.jar" path="3" type="2"/> "/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out www org.jboss.portal.uiserver.ajax.MyGWT/mygwt.html"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="UIServer"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/UIServer"/>
+</listAttribute>
+<mapAttribute key="org.eclipse.debug.core.environmentVariables">
+<mapEntry key="GWT_EXTERNAL_BROWSER" value="/home/soshah/firefox/firefox"/>
+</mapAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:UIServer/uiserver/gwt-dev-env}"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
Added: branches/UIServer/uiserver/gwt-dev-env/mygwt.jar
===================================================================
(Binary files differ)
Property changes on: branches/UIServer/uiserver/gwt-dev-env/mygwt.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/UIServer/uiserver/gwt-dev-env/src/cmsPortlet.html
===================================================================
--- branches/UIServer/uiserver/gwt-dev-env/src/cmsPortlet.html (rev 0)
+++ branches/UIServer/uiserver/gwt-dev-env/src/cmsPortlet.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,81 @@
+<style type="text/css">
+ #welcomelogo {
+ float: left;
+ margin: 30px 0px 30px 15px;
+ }
+
+ #welcometext {
+ margin: 30px 50px 30px 225px;
+ }
+
+ #welcomegreybox {
+ padding: 15px;
+ margin-bottom: 30px;
+ }
+
+ #welcomegreyboxTD {
+ border-left: 1px solid #d5d5d5;
+ padding-left: 15px;
+ }
+
+ #welcomegreybox h3 {
+ color: #5078aa;
+ font: bold 13px Helvetica, Arial, sans-serif;
+ }
+</style>
+
+<!--
+<div>
+ <img src="/portal/content/default/images/homeimg_main.png" width="560" height="160"/>
+</div>
+-->
+
+<!--
+<div id="welcomelogo"><img src="/portal/content/default/images/homeimg_jbosslogo.png" width="143" height="64"/></div>
+-->
+
+
+<p id="welcometext">JBoss Portal provides an open source platform for hosting and serving a portal Web interface,
+ publishing and managing its content, and customizing its experience. While most packaged Portal frameworks help
+ enterprises launch Portals more quickly, only JBoss Portal delivers the benefits of a zero-cost open source license
+ combined with a flexible and scalable underling platform.</p>
+
+<div id="welcomegreybox">
+ <table width="100%">
+ <tr>
+ <td valign="top"><h3>Support Services</h3>
+ <p>
+ JBoss Inc. offers various support services tailored to fit your needs. <a href="portal/index.html">Explore</a>
+ support and service options for JBoss Portal.
+ </p>
+ </td>
+ <td valign="top" id="welcomegreyboxTD"><h3>PortletSwap</h3>
+ <p>
+ <a href="http://www.portletswap.com">Portletswap.com</a> is an open community sponsored by JBoss, Inc. to facilitate the exchange of portlets and layouts for use in JBoss Portal.
+ </p>
+ </td>
+ <td valign="top" id="welcomegreyboxTD"><h3>Project Information</h3>
+ <p>Learn more about the <a href="/portal/index.html">JBoss Portal project</a>, on-going development, open
+ issues, and our
+ user and developer communities.
+ </p>
+ </td>
+ </tr>
+ </table>
+
+</div>
+<p>Thank you for downloading and deploying JBoss Portal. We hope your enjoy working with it as much as we enjoy
+ developing it!</p>
+<p>Baci e abbracci,<br/>
+ The JBoss Portal Team.
+</p>
+
+<br/>
+
+<div>
+ <form name="testForm" method="post" action="portal/index.html">
+ <span>Param1:</span><input type="text" name="param1"/><br/>
+ <span>Param2:</span><input type="text" name="param2"/><br/>
+ <input type="submit"/>
+ </form>
+</div>
\ No newline at end of file
Added: branches/UIServer/uiserver/gwt-dev-env/src/jspPortlet.html
===================================================================
--- branches/UIServer/uiserver/gwt-dev-env/src/jspPortlet.html (rev 0)
+++ branches/UIServer/uiserver/gwt-dev-env/src/jspPortlet.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,42 @@
+<div class="portlet-container"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="portlet-titlebar-left"></td><td class="portlet-titlebar-center"><div class="portlet-titlebar-decoration"></div><span class="portlet-titlebar-title">Greetings!</span><div class="portlet-mode-container"><span title="minimized"><a class="portlet-mode-minimized" href="/portal/portal/default/default/JSPPortletWindow?windowstate=minimized"> </a></span><span title="maximized"><a class="portlet-mode-maximized" href="/portal/portal/default/default/JSPPortletWindow?windowstate=maximized"> </a></span></div></td><td class="portlet-titlebar-right"></td></tr><tr><td class="portlet-content-left"></td><td class="portlet-body"><div class="portlet-content-center">
+
+<table border="0" cellspacing="2" cellpadding="2">
+ <tr>
+ <td align="center"><a href="http://portal.demo.jboss.com" target="_blank"><img
+ src="/portal-jsp-samples/images/dodemo.gif" border="0"
+ alt="Try the latest release of JBoss Portal, live and online."></a>
+ <a href="http://labs.jboss.com/portal/jbossportal/download/index.html" target="_blank"><img
+ src="/portal-jsp-samples/images/getcode.gif" border="0"
+ alt="Download JBoss Portal and have it up and running in minutes."></a>
+ <a href="http://www.portletswap.com" target="_blank"><img
+ src="/portal-jsp-samples/images/accessorize.gif" border="0"
+ alt="Download portlets and layouts for your new JBoss Portal installation."></a></td>
+ </tr>
+ <tr>
+
+ <td></td>
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate">
+ <font class="portlet-font">This is a basic installation of <b>JBoss Portal 2.8.0-SNAPSHOT</b>. You may
+ log in at any time, using the <i>Login</i> link at the top-right of this page, with the following
+ credentials:</font>
+ </td>
+
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate" align="center">
+ <b>user/user</b> or <b>admin/admin</b>
+ </td>
+ </tr>
+ <tr>
+
+ <td align="center">
+ If you are in need of guidance with regards to navigating, configuring, or operating the portal, please view
+ our <a href="http://labs.jboss.com/portal/jbossportal/docs/index.html" target="_blank">online documentation</a>.
+ </td>
+ </tr>
+</table>
+</div></td><td class="portlet-content-right"></td></tr><tr><td class="portlet-footer-left"></td><td class="portlet-footer-center"></td><td class="portlet-footer-right"></td></tr></table>
+
+</div>
\ No newline at end of file
Added: branches/UIServer/uiserver/gwt-dev-env/src/weatherPortlet.html
===================================================================
--- branches/UIServer/uiserver/gwt-dev-env/src/weatherPortlet.html (rev 0)
+++ branches/UIServer/uiserver/gwt-dev-env/src/weatherPortlet.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,76 @@
+<div class="portlet-container"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="portlet-titlebar-left"></td><td class="portlet-titlebar-center"><div class="portlet-titlebar-decoration"></div><span class="portlet-titlebar-title">Weather Portlet</span><div class="portlet-mode-container"><span title="minimized"><a class="portlet-mode-minimized" href="/portal/portal/default/default/2?windowstate=minimized"> </a></span><span title="maximized"><a class="portlet-mode-maximized" href="/portal/portal/default/default/2?windowstate=maximized"> </a></span></div></td><td class="portlet-titlebar-right"></td></tr><tr><td class="portlet-content-left"></td><td class="portlet-body"><div class="portlet-content-center"><br/>
+<div align="center">
+<font>
+<b>Miami, FL, US</b>
+</font>
+
+<br/>
+<br/>
+<table border="0" width="130">
+<tr>
+<td>
+<table height="130" border="0">
+<tr>
+<td align="center" class="portlet-section-header">Currently</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">
+<img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52//28.gif"/>
+</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">Mostly Cloudy</td>
+
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">86F</td>
+</tr>
+</table>
+</td>
+<td>
+<table height="130" border="0">
+<tr>
+<td valign="top" align="center" class="portlet-section-header">Thu</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">
+<img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52//38.gif"/>
+</td>
+
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">Scattered Thunderstorms</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">76F/86F</td>
+</tr>
+</table>
+</td>
+<td>
+<table height="130" border="0">
+<tr>
+<td valign="top" align="center" class="portlet-section-header">Fri</td>
+</tr>
+
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">
+<img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52//38.gif"/>
+</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">Scattered Thunderstorms</td>
+</tr>
+<tr>
+<td valign="top" align="center" class="portlet-section-alternate">78F/89F</td>
+</tr>
+</table>
+</td>
+</tr>
+</table>
+
+<br/>
+<a target="_blank" href="http://us.rd.yahoo.com/dailynews/rss/weather/Miami__FL/*http://weather.ya...">Complete Forecast</a>
+</div>
+</div></td><td class="portlet-content-right"></td></tr><tr><td class="portlet-footer-left"></td><td class="portlet-footer-center"></td><td class="portlet-footer-right"></td></tr></table>
+
+</div>
\ No newline at end of file
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/AsyncPages.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/AsyncPages.java 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/AsyncPages.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -33,11 +33,6 @@
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.TabBar;
import com.google.gwt.user.client.ui.TabListener;
@@ -46,6 +41,15 @@
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import net.mygwt.ui.client.widget.ContentPanel;
+import net.mygwt.ui.client.widget.IconButton;
+import net.mygwt.ui.client.widget.WidgetContainer;
+import net.mygwt.ui.client.widget.Viewport;
+import net.mygwt.ui.client.widget.layout.*;
+import net.mygwt.ui.client.Style;
+import net.mygwt.ui.client.event.Listener;
+import net.mygwt.ui.client.event.BaseEvent;
+
import org.jboss.portal.uiserver.ajax.client.protocol.Page;
import org.jboss.portal.uiserver.ajax.client.protocol.Window;
@@ -56,36 +60,66 @@
*
*/
public class AsyncPages implements EntryPoint
-{
+{
/**
- * This is the entry point method.
+ *
*/
- public void onModuleLoad()
- {
- this.loadPortal();
- }
+ private Viewport viewport = null;
/**
*
- *
*/
- private void loadPortal()
- {
+ private WidgetContainer north = null;
+
+ /**
+ *
+ */
+ private WidgetContainer west = null;
+
+ /**
+ *
+ */
+ private WidgetContainer center = null;
+
+
+ /**
+ * This is the entry point method.
+ */
+ public void onModuleLoad()
+ {
+ //Initialize the Viewport
+ this.viewport = new Viewport();
+
+ //Layout for the viewport
+ BorderLayout pageLayout = new BorderLayout();
+
+ //Layout for the north region (Header/Navigation related content produced by the portal are laid out here)
+ FlowLayout northLayout = new FlowLayout();
+
+ //Setup the layout of the root container of the page
+ this.viewport.setLayout(pageLayout);
+
+ //Setup the north region of the page
+ this.north = new WidgetContainer();
+ this.north.setLayout(northLayout);
+ float northSize = this.viewport.getOffsetHeight() * ((float)0.05);
+ BorderLayoutData northData = new BorderLayoutData(Style.NORTH, northSize);
+ northData.resizeable = true;
+ this.viewport.add(this.north, northData);
+
//Load the navigation bar....use a tabbed bar
TabBar pageNavigator = new TabBar();
pageNavigator.addTab("Page 1");
pageNavigator.addTab("Page 2");
pageNavigator.addTab("Page 3");
- pageNavigator.selectTab(0);
+ pageNavigator.selectTab(0);
pageNavigator.addTabListener(new TabListenerImpl());
- RootPanel.get("pageNavigator").add(pageNavigator);
+ this.north.add(pageNavigator);
+
+ //Load the Portal Page
+ this.loadPartialRefreshPage("Page 1");
+ }
- //Load the main page to be displayed
- HorizontalPanel page = new HorizontalPanel();
- RootPanel.get("currentPage").add(page);
- this.loadPartialRefreshPage("Page 1");
- }
-
/**
*
*
@@ -113,6 +147,197 @@
/**
*
+ * @param portalPage
+ */
+ private void displayPortalPage(Page portalPage)
+ {
+ //A Viewport resizing listener
+
+
+ //Dispalying the fully aggregated page
+ Window[] windows = portalPage.getWindows();
+ int column = 0;
+
+ this.setUpPortletRegions();
+
+ //Fill up the page with portlet windows
+ for(int i=0; i<windows.length; i++)
+ {
+ Window pageWindow = windows[i];
+ if(pageWindow.isVisible())
+ {
+ //Add this window to the Page
+ if(column == 0 && windows.length>1)
+ {
+ this.west.add(this.getPortletWindow(pageWindow.getName(), pageWindow.getContent()));
+ column ++;
+ }
+ else
+ {
+ this.center.add(this.getPortletWindow(pageWindow.getName(), pageWindow.getContent()));
+ column = 0;
+ }
+ }
+ }
+
+ //render the page
+ this.viewport.layout(true);
+ }
+
+ /**
+ *
+ * @param content
+ * @return
+ */
+ private ContentPanel getPortletWindow(String windowName, String content)
+ {
+ ContentPanel portletWindow = new ContentPanel(Style.HEADER);
+ portletWindow.setId(windowName);
+ HTML windowContent = new HTML(content);
+
+
+ //Setup listeners
+ //Event Listener for the decoration components like
+ //Normal, Maximized, Minimized
+ Listener listener = new Listener()
+ {
+ public void handleEvent(BaseEvent event)
+ {
+ IconButton cour = (IconButton)event.widget;
+ String id = cour.getId();
+ String windowName = id.substring(0, id.indexOf(':'));
+ String action = id.substring(id.indexOf(':')+1);
+ if(action.equals("restore"))
+ {
+ handleWindowStateChanged(windowName, Window.NORMAL);
+ }
+ else if(action.equals("minimize"))
+ {
+ handleWindowStateChanged(windowName, Window.MINIMIZED);
+ }
+ else if(action.equals("maximize"))
+ {
+ handleWindowStateChanged(windowName, Window.MAXIMIZED);
+ }
+ else if(action.equals("save"))
+ {
+ handleWindowModeChanged(windowName, Window.EDIT);
+ }
+ }
+ };
+ IconButton save = new IconButton("my-tool-save");
+ save.setId(windowName+":save");
+ IconButton help = new IconButton("my-tool-help");
+ help.setId(windowName+":help");
+ IconButton restore = new IconButton("my-tool-restore");
+ restore.setId(windowName+":restore");
+ IconButton minimize = new IconButton("my-tool-minimize");
+ minimize.setId(windowName+":minimize");
+ IconButton maximize = new IconButton("my-tool-maximize");
+ maximize.setId(windowName+":maximize");
+ portletWindow.addButton(save, listener);
+ portletWindow.addButton(help, listener);
+ portletWindow.addButton(restore, listener);
+ portletWindow.addButton(minimize, listener);
+ portletWindow.addButton(maximize, listener);
+
+ //Event Listener for actions perfomed inside the portlet window content
+ //itself.
+ ClickListener contentListener = new ClickListener()
+ {
+ public void onClick(Widget sender)
+ {
+ Event event = DOM.eventGetCurrentEvent();
+ Element target = DOM.eventGetTarget(event);
+
+ if(target.toString().toUpperCase().trim().indexOf("</A>") != -1)
+ {
+ String link = DOM.getElementAttribute(target, "HREF");
+
+ //A link inside the portlet window was clicked
+ //Load its content asynchronously inside this window
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link);
+ if(isPartialRefreshAllowed)
+ {
+ DOM.eventPreventDefault(event);
+ handlePartialRefreshLink(link, sender);
+ }
+ }
+ else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1 &&
+ target.toString().toUpperCase().trim().indexOf("SUBMIT") != -1
+ )
+ {
+ Element currentForm = DOM.getParent(target);
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String action = DOM.getElementAttribute(currentForm, "action");
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action);
+ if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
+ {
+ DOM.eventPreventDefault(event);
+
+ //Call a native javascript function here
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String serializedForm = serializeForm(currentForm);
+
+ handlePartialRefreshForm(action, method, serializedForm, sender);
+ }
+ }
+ }
+ };
+ windowContent.addClickListener(contentListener);
+
+ //Add the content
+ portletWindow.add(windowContent);
+
+ return portletWindow;
+ }
+
+ /**
+ *
+ *
+ */
+ private void setUpPortletRegions()
+ {
+ if(this.west != null)
+ {
+ this.viewport.remove(this.west);
+ }
+ if(this.center != null)
+ {
+ this.viewport.remove(this.center);
+ }
+
+ //Re-add these two regions
+ //Layout for the west region (Portlet Windows are laid out here)
+ FlowLayout westLayout = new FlowLayout();
+ westLayout.spacing = 5;
+ westLayout.margin = 5;
+
+ //Layout for the center region (Portlet Windows are laid out here)
+ FlowLayout centerLayout = new FlowLayout();
+ centerLayout.spacing = 5;
+ centerLayout.margin = 5;
+
+ //Setup the west region of the page
+ this.west = new WidgetContainer();
+ this.west.setScrollEnabled(true);
+ this.west.setLayout(westLayout);
+ float westSize = this.viewport.getOffsetWidth() * ((float)0.2);
+ BorderLayoutData westData = new BorderLayoutData(Style.WEST, westSize);
+ westData.resizeable = true;
+ this.viewport.add(this.west, westData);
+
+ //Setup the center region of the page
+ this.center = new WidgetContainer();
+ this.center.setScrollEnabled(true);
+ this.center.setLayout(centerLayout);
+ BorderLayoutData centerData = new BorderLayoutData(Style.CENTER);
+ centerData.resizeable = true;
+ this.viewport.add(this.center, centerData);
+ }
+
+ /**
+ *
* @param window
* @param newState
*/
@@ -210,9 +435,10 @@
public void onCompletion(String responseText)
{
HTML html = new HTML(responseText);
- Panel window = (Panel)this.windowContent.getParent();
- this.windowContent.removeFromParent();
+ ContentPanel window = (ContentPanel)this.windowContent.getParent();
+ window.remove(this.windowContent);
window.add(html);
+ window.layout(true);
}
}
@@ -227,6 +453,11 @@
String portalContext = "org.jboss.portal.uiserver.Portal"; //This is hard coded for now, but must be populated from the Portal deployment environment
//If Portal is installed at Root context, this value will be an empty string
+ if(url == null)
+ {
+ return false;
+ }
+
if(url.startsWith(basePortalURL))
{
//This is an Absolute URL, but it points back to
@@ -298,129 +529,7 @@
/*-{
var formData = $wnd.Form.serialize(currentForm);
return formData;
- }-*/;
-
- /**
- *
- * @param portalPage
- */
- private void displayPortalPage(Page portalPage)
- {
- //Event Listener for the decoration components like
- //Normal, Maximized, Minimized
- ClickListener listener = new ClickListener()
- {
- public void onClick(Widget sender)
- {
- Button cour = (Button)sender;
- String windowName = sender.getParent().getTitle();
- if(cour.getText().equals("Normal"))
- {
- handleWindowStateChanged(windowName, Window.NORMAL);
- }
- else if(cour.getText().equals("Minimized"))
- {
- handleWindowStateChanged(windowName, Window.MINIMIZED);
- }
- else if(cour.getText().equals("Maximized"))
- {
- handleWindowStateChanged(windowName, Window.MAXIMIZED);
- }
- else if(cour.getText().equals("Edit"))
- {
- handleWindowModeChanged(windowName, Window.EDIT);
- }
- }
- };
-
- //Event Listener for actions perfomed inside the portlet window content
- //itself.
- ClickListener contentListener = new ClickListener()
- {
- public void onClick(Widget sender)
- {
- Event event = DOM.eventGetCurrentEvent();
- Element target = DOM.eventGetTarget(event);
-
- if(target.toString().toUpperCase().trim().indexOf("</A>") != -1)
- {
- String link = DOM.getElementAttribute(target, "HREF");
-
- //A link inside the portlet window was clicked
- //Load its content asynchronously inside this window
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link);
- if(isPartialRefreshAllowed)
- {
- DOM.eventPreventDefault(event);
- handlePartialRefreshLink(link, sender);
- }
- }
- else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1 &&
- target.toString().toUpperCase().trim().indexOf("SUBMIT") != -1
- )
- {
- Element currentForm = DOM.getParent(target);
- String enctype = DOM.getElementAttribute(currentForm, "enctype");
- String action = DOM.getElementAttribute(currentForm, "action");
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action);
- if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
- {
- DOM.eventPreventDefault(event);
-
- //Call a native javascript function here
- String method = DOM.getElementAttribute(currentForm, "method");
- String serializedForm = serializeForm(currentForm);
-
- handlePartialRefreshForm(action, method, serializedForm, sender);
- }
- }
- }
- };
-
- //Dispalying the fully aggregated page
- Window[] windows = portalPage.getWindows();
- HorizontalPanel page = (HorizontalPanel)RootPanel.get("currentPage").getWidget(0);
- page.clear();
- for(int i=0; i<windows.length; i++)
- {
- Window pageWindow = windows[i];
- if(pageWindow.isVisible())
- {
- VerticalPanel window = new VerticalPanel();
- window.setBorderWidth(2);
-
- //Create the decoration panel
- HorizontalPanel decoration = new HorizontalPanel();
- decoration.setTitle(pageWindow.getName());
-
- Button normal = new Button("Normal");
- Button minimized = new Button("Minimized");
- Button maximized = new Button("Maximized");
- Button edit = new Button("Edit");
-
- decoration.add(normal);
- decoration.add(minimized);
- decoration.add(maximized);
- decoration.add(edit);
- window.add(decoration);
-
- //Create the actual content of the portlet to be displayed inside the window
- HTML windowContent = new HTML(pageWindow.getContent());
- window.add(windowContent);
-
- //Event listeners for this Window
- normal.addClickListener(listener);
- minimized.addClickListener(listener);
- maximized.addClickListener(listener);
- edit.addClickListener(listener);
- windowContent.addClickListener(contentListener);
-
- //Add this window to the Page
- page.add(window);
- }
- }
- }
-
+ }-*/;
//------------Page Navigation related logic-----------------------------------------------------------------------------------------------------
/**
*
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/MyGWTPrototype.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/MyGWTPrototype.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/MyGWTPrototype.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.ajax.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.HTML;
+
+import net.mygwt.ui.client.Style;
+import net.mygwt.ui.client.event.BaseEvent;
+import net.mygwt.ui.client.event.SelectionListener;
+import net.mygwt.ui.client.widget.Button;
+import net.mygwt.ui.client.widget.IconButton;
+import net.mygwt.ui.client.widget.ButtonBar;
+import net.mygwt.ui.client.widget.Info;
+import net.mygwt.ui.client.widget.ContentPanel;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MyGWTPrototype implements EntryPoint
+{
+ /**
+ *
+ */
+ public void onModuleLoad()
+ {
+ VerticalPanel panel = new VerticalPanel();
+ RootPanel.get("currentPage").add(panel);
+
+ // Fillup panel with MyGWT widgets for testing
+ this.createButtonWidget(panel);
+ this.createPortletWindowWidget(panel);
+ }
+
+ /**
+ *
+ * @param container
+ */
+ private void createButtonWidget(VerticalPanel panel)
+ {
+ SelectionListener listener = new SelectionListener()
+ {
+ public void widgetSelected(BaseEvent be)
+ {
+ Button btn = (Button) be.widget;
+ Info.show("Click Event", "The '{0}' button was clicked.", btn
+ .getText());
+ }
+ };
+
+ ButtonBar buttonBar = new ButtonBar(Style.LEFT);
+ buttonBar.add(new Button("Click Me", listener));
+
+ Button iconBtn = new Button("Icon Button", listener);
+ iconBtn.setIconStyle("window-maximize-button");
+ buttonBar.add(iconBtn);
+
+ Button disabled = new Button("Disabled", listener);
+ disabled.setEnabled(false);
+ buttonBar.add(disabled);
+
+ panel.add(buttonBar);
+ }
+
+ /**
+ *
+ * @param panel
+ */
+ private void createPortletWindowWidget(VerticalPanel panel)
+ {
+ HTML html = new HTML("<div class=\"window-normal-button\">Normal</div><br/><div class=\"window-minimize-button\">Minimize</div><br/><div class=\"window-maximize-button\">Maximize</div>");
+
+ ContentPanel contentPanel = new ContentPanel(Style.HEADER);
+ contentPanel.addButton(new IconButton("my-tool-save"), null);
+ contentPanel.addButton(new IconButton("my-tool-help"), null);
+ contentPanel.addButton(new IconButton("my-tool-restore"), null);
+ contentPanel.addButton(new IconButton("my-tool-minimize"), null);
+ contentPanel.addButton(new IconButton("my-tool-maximize"), null);
+
+ Button normalButton = new Button("", null);
+ normalButton.setIconStyle("window-normal-button");
+
+ IconButton iconNormalButton = new IconButton("window-minimize-button");
+
+ contentPanel.add(html);
+ contentPanel.add(normalButton);
+ contentPanel.add(iconNormalButton);
+
+ panel.add(contentPanel);
+ }
+}
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/Portal.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/Portal.java 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/Portal.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -22,32 +22,21 @@
******************************************************************************/
package org.jboss.portal.uiserver.ajax.client;
+import java.util.List;
+import java.util.ArrayList;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.EntryPoint;
-
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.HTTPRequest;
-import com.google.gwt.user.client.ResponseTextHandler;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.FlexTable;
-
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.rpc.AsyncCallback;
+
import org.jboss.portal.uiserver.ajax.client.service.PortalRPC;
import org.jboss.portal.uiserver.ajax.client.service.PortalRPCAsync;
import org.jboss.portal.uiserver.ajax.client.protocol.Page;
import org.jboss.portal.uiserver.ajax.client.protocol.Window;
+import org.jboss.portal.uiserver.ajax.client.widget.PortletWindow;
+import org.jboss.portal.uiserver.ajax.client.layout.LayoutManager;
/**
* This is the Entry Point of the client-side Ajax agent of the Presentation Framework
@@ -61,24 +50,9 @@
* This is the entry point method.
*/
public void onModuleLoad()
- {
- //HorizontalPanel page = new HorizontalPanel();
- //RootPanel.get("currentPage").add(page);
- FlexTable page = new FlexTable();
- RootPanel.get("currentPage").add(page);
-
- this.loadPortal();
- }
-
- /**
- *
- *
- */
- private void loadPortal()
- {
+ {
PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
- ((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
-
+ ((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
AsyncCallback callback = new AsyncCallback()
{
public void onSuccess(Object result)
@@ -90,318 +64,31 @@
public void onFailure(Throwable caught)
{
}
- };
-
+ };
portalRPC.loadPortal(callback);
- }
+ }
/**
*
* @param portalPage
*/
private void displayPortalPage(Page portalPage)
- {
- //Event Listener for the decoration components like
- //Normal, Maximized, Minimized
- /*ClickListener listener = new ClickListener()
- {
- public void onClick(Widget sender)
- {
- Button cour = (Button)sender;
- String windowName = sender.getParent().getTitle();
- if(cour.getText().equals("Normal"))
- {
- handleWindowStateChanged(windowName, Window.NORMAL);
- }
- else if(cour.getText().equals("Minimized"))
- {
- handleWindowStateChanged(windowName, Window.MINIMIZED);
- }
- else if(cour.getText().equals("Maximized"))
- {
- handleWindowStateChanged(windowName, Window.MAXIMIZED);
- }
- else if(cour.getText().equals("Edit"))
- {
- handleWindowModeChanged(windowName, Window.EDIT);
- }
- }
- };
-
- //Event Listener for actions perfomed inside the portlet window content
- //itself.
- ClickListener contentListener = new ClickListener()
- {
- public void onClick(Widget sender)
- {
- Event event = DOM.eventGetCurrentEvent();
- Element target = DOM.eventGetTarget(event);
-
- if(target.toString().toUpperCase().trim().indexOf("</A>") != -1)
- {
- String link = DOM.getElementAttribute(target, "HREF");
-
- //A link inside the portlet window was clicked
- //Load its content asynchronously inside this window
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link);
- if(isPartialRefreshAllowed)
- {
- DOM.eventPreventDefault(event);
- handlePartialRefreshLink(link, sender);
- }
- }
- else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1 &&
- target.toString().toUpperCase().trim().indexOf("SUBMIT") != -1
- )
- {
- Element currentForm = DOM.getParent(target);
- String enctype = DOM.getElementAttribute(currentForm, "enctype");
- String action = DOM.getElementAttribute(currentForm, "action");
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action);
- if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
- {
- DOM.eventPreventDefault(event);
-
- //Call a native javascript function here
- String method = DOM.getElementAttribute(currentForm, "method");
- String serializedForm = serializeForm(currentForm);
-
- handlePartialRefreshForm(action, method, serializedForm, sender);
- }
- }
- }
- };*/
-
+ {
//Dispalying the fully aggregated page
Window[] windows = portalPage.getWindows();
- FlexTable page = (FlexTable)RootPanel.get("currentPage").getWidget(0);
- page.clear();
- for(int i=0; i<windows.length; i++)
+ if(windows != null && windows.length>0)
{
- Window pageWindow = windows[i];
- if(pageWindow.isVisible())
+ List displayWindows = new ArrayList();
+ for(int i=0; i<windows.length; i++)
{
- VerticalPanel window = new VerticalPanel();
- window.setBorderWidth(2);
-
- //Create the decoration panel
- HorizontalPanel decoration = new HorizontalPanel();
- decoration.setTitle(pageWindow.getName());
-
- Button normal = new Button("Normal");
- Button minimized = new Button("Minimized");
- Button maximized = new Button("Maximized");
- Button edit = new Button("Edit");
-
- decoration.add(normal);
- decoration.add(minimized);
- decoration.add(maximized);
- decoration.add(edit);
- window.add(decoration);
-
- //Create the actual content of the portlet to be displayed inside the window
- HTML windowContent = new HTML(pageWindow.getContent());
- window.add(windowContent);
-
- //Event listeners for this Window
- /*normal.addClickListener(listener);
- minimized.addClickListener(listener);
- maximized.addClickListener(listener);
- edit.addClickListener(listener);
- windowContent.addClickListener(contentListener);*/
-
- //Add this window to the Page
- page.setWidget(0,0,window);
- }
- }
- }
- //-------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- *
- * @param window
- * @param newState
- */
- /*private void handleWindowStateChanged(String window, String newState)
- {
- PortletServiceAsync portletService = (PortletServiceAsync)GWT.create(PortletService.class);
- ((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
-
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- Page portalPage = (Page)result;
- displayPortalPage(portalPage);
- }
-
- public void onFailure(Throwable caught)
- {
- }
- };
-
- portletService.setState(window, newState, callback);
- }*/
-
- /**
- *
- * @param window
- * @param newState
- */
- /*private void handleWindowModeChanged(String window, String newMode)
- {
- PortletServiceAsync portletService = (PortletServiceAsync)GWT.create(PortletService.class);
- ((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
-
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- Page portalPage = (Page)result;
- displayPortalPage(portalPage);
- }
-
- public void onFailure(Throwable caught)
- {
- }
- };
-
- portletService.setMode(window, newMode, callback);
- }*/
-
- /**
- *
- * @param url
- * @param portletWindow
- */
- /*private void handlePartialRefreshLink(String url, Widget windowContent)
- {
- HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
- }*/
-
- /**
- *
- * @param url
- * @param portletWindow
- */
- /*private void handlePartialRefreshForm(String url, String method, String postData, Widget windowContent)
- {
- if(method.equalsIgnoreCase("post"))
- {
- HTTPRequest.asyncPost(url, postData, new ResponseTextHandlerImpl(windowContent));
- }
- else if(method.equalsIgnoreCase("get"))
- {
- if(postData != null && postData.trim().length() > 0)
- {
- url = url + "?" + postData;
- }
- HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
- }
- }*/
-
- /**
- *
- * @author soshah
- *
- */
- /*private class ResponseTextHandlerImpl implements ResponseTextHandler
- {
- private Widget windowContent = null;
-
- public ResponseTextHandlerImpl(Widget windowContent)
- {
- this.windowContent = windowContent;
- }
- public void onCompletion(String responseText)
- {
- HTML html = new HTML(responseText);
- Panel window = (Panel)this.windowContent.getParent();
- this.windowContent.removeFromParent();
- window.add(html);
- }
- }*/
-
- /**
- *
- * @param url
- * @return
- */
- /*private boolean isPartialRefreshAllowed(String url)
- {
- String basePortalURL = GWT.getModuleBaseURL();
- String portalContext = "org.jboss.portal.uiserver.Portal"; //This is hard coded for now, but must be populated from the Portal deployment environment
- //If Portal is installed at Root context, this value will be an empty string
-
- if(url.startsWith(basePortalURL))
- {
- //This is an Absolute URL, but it points back to
- //the Portal
- //An Async Page Refresh call should be allowed in this case
- return true;
- }
-
- if(url.startsWith("http://"))
- {
- //This is an Absolute URL and does not point back
- //to the Portal
- //Async Page Refresh call should not be allowed
- return false;
- }
- else
- {
- //This is a relative URL.
-
- //Make sure it points back to the Portal for an Async Page Refresh
- //If it points to some other resource like another third-party web application etc, the response
- //has nothing to do with Portal
- //(unless ofcourse the client side processor of the Portal, wants to
- //take this response and aggregate this inside the current Portal Page and Window being displayed. This is an exceptional usecase
- //and not desired behavior for every scenario from end user standpoint)
- //As standard behavior, Async Page Refresh to be done, only when Portlet Markup is sending a request back to the Portal
- if(url.startsWith("/"))
- {
- if(!portalContext.equals(""))
+ Window pageWindow = windows[i];
+ if(pageWindow.isVisible())
{
- String urlContext = null;
- int index = url.indexOf('/', 1);
- if(index != -1)
- {
- urlContext = url.substring(1, index);
- }
- else
- {
- urlContext = url.substring(1);
- }
-
- if(!portalContext.equals(urlContext))
- {
- //This request is not being sent to the Portal. It is being sent to some other web application
- return false;
- }
+ PortletWindow portletWindow = new PortletWindow(pageWindow);
+ displayWindows.add(portletWindow);
}
- else
- {
- //If Portal is running on root context, there is no way to tell from client side, if this request is actually
- //to be sent to the Portal or some other web application. Hence, in the interest of functional safety/correctness
- //no Async Page Refresh here
- //If Portal is running on Root context, Partial Refresh will happen only for pure relative links
- return false;
- }
}
-
- //If I get here, Async Page Refresh through the Portal should be allowed
- return true;
- }
- }*/
-
- /**
- *
- * @param currentForm
- * @return
- */
- public native String serializeForm(Element currentForm)
- /*-{
- var formData = $wnd.Form.serialize(currentForm);
- return formData;
- }-*/;
+ LayoutManager.doLayout(displayWindows);
+ }
+ }
}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/layout/LayoutManager.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/layout/LayoutManager.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/layout/LayoutManager.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.ajax.client.layout;
+
+import java.util.List;
+
+import com.google.gwt.user.client.ui.Widget;
+
+import net.mygwt.ui.client.widget.Viewport;
+import net.mygwt.ui.client.widget.WidgetContainer;
+import net.mygwt.ui.client.widget.layout.BorderLayout;
+import net.mygwt.ui.client.widget.layout.BorderLayoutData;
+import net.mygwt.ui.client.widget.layout.FlowLayout;
+import net.mygwt.ui.client.Style;
+
+import org.jboss.portal.uiserver.ajax.client.widget.PortletWindow;
+
+/**
+ * This layout manager provides a Flexible Grid for laying out the UI components (which would be Portlet Windows)
+ * inside a flexible coordinates based Grid
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class LayoutManager
+{
+ /**
+ *
+ */
+ private static Viewport viewport = null;
+
+ /**
+ *
+ */
+ private static WidgetContainer north = null;
+
+ /**
+ *
+ */
+ private static WidgetContainer west = null;
+
+ /**
+ *
+ */
+ private static WidgetContainer center = null;
+
+
+ /**
+ *
+ */
+ static
+ {
+ LayoutManager.viewport = new Viewport();
+
+ //Layout for the viewport
+ BorderLayout pageLayout = new BorderLayout();
+
+ //Layout for the north region (Header/Navigation related content produced by the portal are laid out here)
+ FlowLayout northLayout = new FlowLayout();
+
+ //Setup the layout of the root container of the page
+ LayoutManager.viewport.setLayout(pageLayout);
+
+ //Setup the north region of the page
+ LayoutManager.north = new WidgetContainer();
+ LayoutManager.north.setLayout(northLayout);
+ float northSize = LayoutManager.viewport.getOffsetHeight() * ((float)0.05);
+ BorderLayoutData northData = new BorderLayoutData(Style.NORTH, northSize);
+ northData.resizeable = true;
+ LayoutManager.viewport.add(LayoutManager.north, northData);
+ }
+
+ /**
+ *
+ * @param displayWindows
+ */
+ public static void doLayout(List displayWindows)
+ {
+ LayoutManager.setUpPortletRegions();
+
+ int column = 0;
+ for(int i=0; i<displayWindows.size(); i++)
+ {
+ PortletWindow portletWindow = (PortletWindow)displayWindows.get(i);
+ Widget window = portletWindow.create();
+ //Add this window to the Page
+ if(column == 0 && displayWindows.size()>1)
+ {
+ LayoutManager.west.add(window);
+ column ++;
+ }
+ else
+ {
+ LayoutManager.center.add(window);
+ column = 0;
+ }
+ }
+ LayoutManager.viewport.layout(true);
+ }
+
+ /**
+ *
+ *
+ */
+ private static void setUpPortletRegions()
+ {
+ if(LayoutManager.west != null)
+ {
+ LayoutManager.viewport.remove(LayoutManager.west);
+ }
+ if(LayoutManager.center != null)
+ {
+ LayoutManager.viewport.remove(LayoutManager.center);
+ }
+
+ //Re-add these two regions
+ //Layout for the west region (Portlet Windows are laid out here)
+ FlowLayout westLayout = new FlowLayout();
+ westLayout.spacing = 5;
+ westLayout.margin = 5;
+
+ //Layout for the center region (Portlet Windows are laid out here)
+ FlowLayout centerLayout = new FlowLayout();
+ centerLayout.spacing = 5;
+ centerLayout.margin = 5;
+
+ //Setup the west region of the page
+ LayoutManager.west = new WidgetContainer();
+ LayoutManager.west.setScrollEnabled(true);
+ LayoutManager.west.setLayout(westLayout);
+ float westSize = LayoutManager.viewport.getOffsetWidth() * ((float)0.2);
+ BorderLayoutData westData = new BorderLayoutData(Style.WEST, westSize);
+ westData.resizeable = true;
+ LayoutManager.viewport.add(LayoutManager.west, westData);
+
+ //Setup the center region of the page
+ LayoutManager.center = new WidgetContainer();
+ LayoutManager.center.setScrollEnabled(true);
+ LayoutManager.center.setLayout(centerLayout);
+ BorderLayoutData centerData = new BorderLayoutData(Style.CENTER);
+ centerData.resizeable = true;
+ LayoutManager.viewport.add(LayoutManager.center, centerData);
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/widget/PortletWindow.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/widget/PortletWindow.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ajax/client/widget/PortletWindow.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,383 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.ajax.client.widget;
+
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.HTTPRequest;
+import com.google.gwt.user.client.ResponseTextHandler;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.Panel;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.FlexTable;
+
+import net.mygwt.ui.client.widget.ContentPanel;
+import net.mygwt.ui.client.Style;
+import net.mygwt.ui.client.widget.IconButton;
+import net.mygwt.ui.client.widget.Info;
+import net.mygwt.ui.client.event.Listener;
+import net.mygwt.ui.client.event.Listener;
+import net.mygwt.ui.client.event.BaseEvent;
+
+import org.jboss.portal.uiserver.ajax.client.protocol.Window;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PortletWindow
+{
+ /**
+ *
+ */
+ private Window window = null;
+
+ /**
+ *
+ *
+ */
+ public PortletWindow(Window window)
+ {
+ this.window = window;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public ContentPanel create()
+ {
+ ContentPanel portletWindow = new ContentPanel(Style.HEADER);
+ String windowName = this.window.getName();
+ String content = this.window.getContent();
+ portletWindow.setId(windowName);
+ HTML windowContent = new HTML(content);
+
+
+ //Setup listeners
+ //Event Listener for the decoration components like
+ //Normal, Maximized, Minimized
+ Listener listener = new Listener()
+ {
+ public void handleEvent(BaseEvent event)
+ {
+ IconButton cour = (IconButton)event.widget;
+ String id = cour.getId();
+ String windowName = id.substring(0, id.indexOf(':'));
+ String action = id.substring(id.indexOf(':')+1);
+ if(action.equals("restore"))
+ {
+ //handleWindowStateChanged(windowName, Window.NORMAL);
+ Info.show("Normal", "Loading Normal Mode....", "Loading Normal Mode....");
+ }
+ else if(action.equals("minimize"))
+ {
+ //handleWindowStateChanged(windowName, Window.MINIMIZED);
+ Info.show("Minimize", "Loading Minimize Mode....", "Loading Minimize Mode....");
+ }
+ else if(action.equals("maximize"))
+ {
+ //handleWindowStateChanged(windowName, Window.MAXIMIZED);
+ Info.show("Maximize", "Loading Maximize Mode....", "Loading Maximize Mode....");
+ }
+ else if(action.equals("save"))
+ {
+ //handleWindowModeChanged(windowName, Window.EDIT);
+ Info.show("Save", "Loading Save Mode....", "Loading Save Mode....");
+ }
+ else if(action.equals("help"))
+ {
+ //handleWindowModeChanged(windowName, Window.EDIT);
+ Info.show("Help", "Loading Help Mode....", "Loading Help Mode....");
+ }
+ }
+ };
+ IconButton save = new IconButton("my-tool-save");
+ save.setId(windowName+":save");
+ save.setToolTip("Edit");
+ IconButton help = new IconButton("my-tool-help");
+ help.setId(windowName+":help");
+ help.setToolTip("Help");
+ IconButton restore = new IconButton("my-tool-restore");
+ restore.setId(windowName+":restore");
+ restore.setToolTip("Normal");
+ IconButton minimize = new IconButton("my-tool-minimize");
+ minimize.setId(windowName+":minimize");
+ minimize.setToolTip("Minimize");
+ IconButton maximize = new IconButton("my-tool-maximize");
+ maximize.setId(windowName+":maximize");
+ maximize.setToolTip("Maximize");
+ portletWindow.addButton(save, listener);
+ portletWindow.addButton(help, listener);
+ portletWindow.addButton(restore, listener);
+ portletWindow.addButton(minimize, listener);
+ portletWindow.addButton(maximize, listener);
+
+ //Event Listener for actions perfomed inside the portlet window content
+ //itself. Used for performing Partial Refresh of a Portal Page
+ /*ClickListener contentListener = new ClickListener()
+ {
+ public void onClick(Widget sender)
+ {
+ Event event = DOM.eventGetCurrentEvent();
+ Element target = DOM.eventGetTarget(event);
+
+ if(target.toString().toUpperCase().trim().indexOf("</A>") != -1)
+ {
+ String link = DOM.getElementAttribute(target, "HREF");
+
+ //A link inside the portlet window was clicked
+ //Load its content asynchronously inside this window
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link);
+ if(isPartialRefreshAllowed)
+ {
+ DOM.eventPreventDefault(event);
+ handlePartialRefreshLink(link, sender);
+ }
+ }
+ else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1 &&
+ target.toString().toUpperCase().trim().indexOf("SUBMIT") != -1
+ )
+ {
+ Element currentForm = DOM.getParent(target);
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String action = DOM.getElementAttribute(currentForm, "action");
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action);
+ if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
+ {
+ DOM.eventPreventDefault(event);
+
+ //Call a native javascript function here
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String serializedForm = serializeForm(currentForm);
+
+ handlePartialRefreshForm(action, method, serializedForm, sender);
+ }
+ }
+ }
+ };
+ windowContent.addClickListener(contentListener);*/
+
+ //Add the content
+ portletWindow.add(windowContent);
+
+ return portletWindow;
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param window
+ * @param newState
+ */
+ /*private void handleWindowStateChanged(String window, String newState)
+ {
+ PortletServiceAsync portletService = (PortletServiceAsync)GWT.create(PortletService.class);
+ ((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
+
+ AsyncCallback callback = new AsyncCallback()
+ {
+ public void onSuccess(Object result)
+ {
+ Page portalPage = (Page)result;
+ displayPortalPage(portalPage);
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ }
+ };
+
+ portletService.setState(window, newState, callback);
+ }*/
+
+ /**
+ *
+ * @param window
+ * @param newState
+ */
+ /*private void handleWindowModeChanged(String window, String newMode)
+ {
+ PortletServiceAsync portletService = (PortletServiceAsync)GWT.create(PortletService.class);
+ ((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
+
+ AsyncCallback callback = new AsyncCallback()
+ {
+ public void onSuccess(Object result)
+ {
+ Page portalPage = (Page)result;
+ displayPortalPage(portalPage);
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ }
+ };
+
+ portletService.setMode(window, newMode, callback);
+ }*/
+
+ /**
+ *
+ * @param url
+ * @param portletWindow
+ */
+ /*private void handlePartialRefreshLink(String url, Widget windowContent)
+ {
+ HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
+ }*/
+
+ /**
+ *
+ * @param url
+ * @param portletWindow
+ */
+ /*private void handlePartialRefreshForm(String url, String method, String postData, Widget windowContent)
+ {
+ if(method.equalsIgnoreCase("post"))
+ {
+ HTTPRequest.asyncPost(url, postData, new ResponseTextHandlerImpl(windowContent));
+ }
+ else if(method.equalsIgnoreCase("get"))
+ {
+ if(postData != null && postData.trim().length() > 0)
+ {
+ url = url + "?" + postData;
+ }
+ HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
+ }
+ }*/
+
+ /**
+ *
+ * @author soshah
+ *
+ */
+ /*private class ResponseTextHandlerImpl implements ResponseTextHandler
+ {
+ private Widget windowContent = null;
+
+ public ResponseTextHandlerImpl(Widget windowContent)
+ {
+ this.windowContent = windowContent;
+ }
+ public void onCompletion(String responseText)
+ {
+ HTML html = new HTML(responseText);
+ Panel window = (Panel)this.windowContent.getParent();
+ this.windowContent.removeFromParent();
+ window.add(html);
+ }
+ }*/
+
+ /**
+ *
+ * @param url
+ * @return
+ */
+ /*private boolean isPartialRefreshAllowed(String url)
+ {
+ String basePortalURL = GWT.getModuleBaseURL();
+ String portalContext = "org.jboss.portal.uiserver.Portal"; //This is hard coded for now, but must be populated from the Portal deployment environment
+ //If Portal is installed at Root context, this value will be an empty string
+
+ if(url.startsWith(basePortalURL))
+ {
+ //This is an Absolute URL, but it points back to
+ //the Portal
+ //An Async Page Refresh call should be allowed in this case
+ return true;
+ }
+
+ if(url.startsWith("http://"))
+ {
+ //This is an Absolute URL and does not point back
+ //to the Portal
+ //Async Page Refresh call should not be allowed
+ return false;
+ }
+ else
+ {
+ //This is a relative URL.
+
+ //Make sure it points back to the Portal for an Async Page Refresh
+ //If it points to some other resource like another third-party web application etc, the response
+ //has nothing to do with Portal
+ //(unless ofcourse the client side processor of the Portal, wants to
+ //take this response and aggregate this inside the current Portal Page and Window being displayed. This is an exceptional usecase
+ //and not desired behavior for every scenario from end user standpoint)
+ //As standard behavior, Async Page Refresh to be done, only when Portlet Markup is sending a request back to the Portal
+ if(url.startsWith("/"))
+ {
+ if(!portalContext.equals(""))
+ {
+ String urlContext = null;
+ int index = url.indexOf('/', 1);
+ if(index != -1)
+ {
+ urlContext = url.substring(1, index);
+ }
+ else
+ {
+ urlContext = url.substring(1);
+ }
+
+ if(!portalContext.equals(urlContext))
+ {
+ //This request is not being sent to the Portal. It is being sent to some other web application
+ return false;
+ }
+ }
+ else
+ {
+ //If Portal is running on root context, there is no way to tell from client side, if this request is actually
+ //to be sent to the Portal or some other web application. Hence, in the interest of functional safety/correctness
+ //no Async Page Refresh here
+ //If Portal is running on Root context, Partial Refresh will happen only for pure relative links
+ return false;
+ }
+ }
+
+ //If I get here, Async Page Refresh through the Portal should be allowed
+ return true;
+ }
+ }*/
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public native String serializeForm(Element currentForm)
+ /*-{
+ var formData = $wnd.Form.serialize(currentForm);
+ return formData;
+ }-*/;
+}
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/GWTClientFilter.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/GWTClientFilter.java 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/GWTClientFilter.java 2007-11-10 00:16:51 UTC (rev 8861)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -45,6 +46,13 @@
/**
*
*/
+ public void init(FilterConfig arg0) throws ServletException
+ {
+ }
+
+ /**
+ *
+ */
public void destroy()
{
}
@@ -81,50 +89,48 @@
//Now make sure the resource requested is a GWT resource
if( resource.equals("index.html") ||
resource.equals("portal.css") ||
+ resource.equals("mygwt-all.css") ||
+ resource.equals("mygwt-all-gray.css") ||
resource.equals("gwt.js") ||
resource.equals("prototype.js") ||
resource.contains(".cache.") ||
resource.contains(".nocache.") ||
- resource.contains(".gwt.rpc")
+ resource.contains(".gwt.rpc") ||
+ resource.contains("images/default") ||
+ resource.contains("images/gray")
)
{
- String gwtResource = this.readContent(resource);
- response.getOutputStream().write(gwtResource.getBytes());
+ byte[] gwtResource = this.readContent(resource);
+ response.getOutputStream().write(gwtResource);
response.getOutputStream().flush();
return;
}
}
-
- /**
- *
- */
- public void init(FilterConfig arg0) throws ServletException
- {
- }
/**
*
* @param path
* @return
*/
- private String readContent(String path)
+ private byte[] readContent(String path)
{
- String content = null;
+ byte[] content = null;
InputStream is = null;
+ ByteArrayOutputStream bos = null;
try
{
+ bos = new ByteArrayOutputStream();
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
- StringBuffer contentBuffer = new StringBuffer();
int bytesRead = 0;
byte[] data = new byte[1024];
while((bytesRead=is.read(data)) != -1)
{
byte[] cour = new byte[bytesRead];
System.arraycopy(data, 0, cour, 0, bytesRead);
- contentBuffer.append(new String(cour));
+ bos.write(cour);
+ bos.flush();
}
- content = contentBuffer.toString();
}
catch(Exception e)
{
@@ -136,6 +142,11 @@
{
try{is.close();}catch(Exception e){}
}
+ if(bos != null)
+ {
+ content = bos.toByteArray();
+ try{bos.close();}catch(Exception e){}
+ }
}
return content;
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml 2007-11-10 00:16:51 UTC (rev 8861)
@@ -1,6 +1,8 @@
<module>
<!-- Inherit the core Web Toolkit stuff -->
<inherits name="com.google.gwt.user.User"/>
+ <!-- Inherit the MyGWT toolkit -->
+ <inherits name='net.mygwt.ui.MyGWT'/>
<!-- Specify the app entry point class -->
<entry-point class="org.jboss.portal.uiserver.ajax.client.AsyncPages"/>
Added: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/MyGWT.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/MyGWT.gwt.xml (rev 0)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/MyGWT.gwt.xml 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,9 @@
+<module>
+ <!-- Inherit the core Web Toolkit stuff -->
+ <inherits name="com.google.gwt.user.User"/>
+ <!-- Inherit the MyGWT toolkit -->
+ <inherits name='net.mygwt.ui.MyGWT'/>
+
+ <!-- Specify the app entry point class -->
+ <entry-point class="org.jboss.portal.uiserver.ajax.client.MyGWTPrototype"/>
+</module>
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/Portal.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/Portal.gwt.xml 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/Portal.gwt.xml 2007-11-10 00:16:51 UTC (rev 8861)
@@ -1,6 +1,8 @@
<module>
<!-- Inherit the core Web Toolkit stuff -->
<inherits name="com.google.gwt.user.User"/>
+ <!-- Inherit the MyGWT toolkit -->
+ <inherits name='net.mygwt.ui.MyGWT'/>
<!-- Specify the app entry point class -->
<entry-point class="org.jboss.portal.uiserver.ajax.client.Portal"/>
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/asyncPages.html
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/asyncPages.html 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/asyncPages.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -22,23 +22,6 @@
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic ui -->
<!-- -->
- <body>
- <!-- OPTIONAL: include this if you want history support -->
- <iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
-
- <h1>JBoss Portal</h1>
-
- <!-- Asynchronous Portal Page Management Proof of Concept -->
- <p>
- Asynchronous Page Management
- </p>
- <table align="center">
- <tr>
- <td id="pageNavigator"></td>
- </tr>
- <tr>
- <td id="currentPage"></td>
- </tr>
- </table>
+ <body>
</body>
</html>
Added: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_maximize.gif
===================================================================
(Binary files differ)
Property changes on: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_maximize.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_minimize.gif
===================================================================
(Binary files differ)
Property changes on: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_minimize.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_normal.gif
===================================================================
(Binary files differ)
Property changes on: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/images/ico_16_normal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/index.html
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/index.html 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/index.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -22,20 +22,6 @@
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic ui -->
<!-- -->
- <body>
- <!-- OPTIONAL: include this if you want history support -->
- <iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
-
- <h1>JBoss Portal</h1>
-
- <!-- AJAX Client for Portal Proof of Concept -->
- <p>
- JBoss Portal
- </p>
- <table align="center">
- <tr>
- <td id="currentPage"></td>
- </tr>
- </table>
+ <body>
</body>
</html>
Added: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/mygwt.html
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/mygwt.html (rev 0)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/mygwt.html 2007-11-10 00:16:51 UTC (rev 8861)
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <title>JBoss Portal</title>
+
+ <!-- portal styles defined here -->
+ <link href="portal.css" rel="stylesheet" type="text/css">
+
+ <!-- -->
+ <!-- This script loads your compiled module. -->
+ <!-- If you add any GWT meta tags, they must -->
+ <!-- be added before this line. -->
+ <!-- -->
+ <script language='javascript' src='org.jboss.portal.uiserver.ajax.MyGWT.nocache.js'></script>
+ </head>
+
+ <!-- -->
+ <!-- The body can have arbitrary html, or -->
+ <!-- you can leave the body empty if you want -->
+ <!-- to create a completely dynamic ui -->
+ <!-- -->
+ <body>
+ <!-- MyGWT Proof of Concept -->
+ <h1>MyGWT Prototype</h1><br/>
+ <table align="center">
+ <tr>
+ <td id="currentPage"></td>
+ </tr>
+ </table>
+ </body>
+</html>
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/portal.css
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/portal.css 2007-11-09 20:47:23 UTC (rev 8860)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/public/portal.css 2007-11-10 00:16:51 UTC (rev 8861)
@@ -25,7 +25,19 @@
a:visited {
color: darkblue;
}
+/*----------------Client-Side Ajax Agent styles-------------------------------------------------------------------------------------------------------------------------------*/
+.window-normal-button{
+ background: url(images/ico_16_normal.gif);
+}
+.window-minimize-button{
+ background: url(images/ico_16_minimize.gif);
+}
+
+.window-maximize-button{
+ background: url(images/ico_16_maximize.gif);
+}
+/*-------------Core GWT styles------------------------------------------------------------------------------------------------------------------------------------*/
.gwt-BorderedPanel {
}
@@ -353,7 +365,6 @@
padding: 2px;
}
-/* -------------------------------------------------------------------------- */
.ks-Sink {
width: 100%;
height: 24em;
16 years, 11 months
JBoss Portal SVN: r8860 - in modules/test/trunk: build and 12 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-09 15:47:23 -0500 (Fri, 09 Nov 2007)
New Revision: 8860
Modified:
modules/test/trunk/build/pom.xml
modules/test/trunk/mc/pom.xml
modules/test/trunk/pom.xml
modules/test/trunk/remote/pom.xml
modules/test/trunk/test/agent/pom.xml
modules/test/trunk/test/core/pom.xml
modules/test/trunk/test/generic/pom.xml
modules/test/trunk/test/jboss/pom.xml
modules/test/trunk/tooling/ant/pom.xml
modules/test/trunk/tooling/core/pom.xml
modules/test/trunk/tooling/examples/maven2/pom.xml
modules/test/trunk/tooling/maven2/pom.xml
modules/test/trunk/tooling/pom.xml
modules/test/trunk/unit/pom.xml
Log:
fix poms in jboss unit module
Modified: modules/test/trunk/build/pom.xml
===================================================================
--- modules/test/trunk/build/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/build/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -16,7 +16,7 @@
<version>3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
Modified: modules/test/trunk/mc/pom.xml
===================================================================
--- modules/test/trunk/mc/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/mc/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-mc</artifactId>
<packaging>jar</packaging>
<name>JBoss Unit Microcontainer</name>
Modified: modules/test/trunk/pom.xml
===================================================================
--- modules/test/trunk/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Modules Test</name>
@@ -26,7 +26,6 @@
</distributionManagement>
<modules>
- <module>build</module>
<module>unit</module>
<module>tooling</module>
<module>mc</module>
@@ -40,4 +39,4 @@
-</project>
\ No newline at end of file
+</project>
Modified: modules/test/trunk/remote/pom.xml
===================================================================
--- modules/test/trunk/remote/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/remote/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-remote</artifactId>
<packaging>jar</packaging>
<name>JBoss Unit Remote</name>
@@ -17,8 +17,9 @@
<artifactId>jboss-unit</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>portal-test</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
@@ -56,4 +57,4 @@
<properties>
</properties>
-</project>
\ No newline at end of file
+</project>
Modified: modules/test/trunk/test/agent/pom.xml
===================================================================
--- modules/test/trunk/test/agent/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/test/agent/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,9 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>portal-test-agent</artifactId>
@@ -52,12 +53,14 @@
<artifactId>jboss</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>portal-test</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>portal-test-jboss</artifactId>
+ <version>${project.version}</version>
</dependency>
</dependencies>
Modified: modules/test/trunk/test/core/pom.xml
===================================================================
--- modules/test/trunk/test/core/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/test/core/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,9 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>portal-test</artifactId>
Modified: modules/test/trunk/test/generic/pom.xml
===================================================================
--- modules/test/trunk/test/generic/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/test/generic/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,9 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>portal-test-generic</artifactId>
Modified: modules/test/trunk/test/jboss/pom.xml
===================================================================
--- modules/test/trunk/test/jboss/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/test/jboss/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,9 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>portal-test-jboss</artifactId>
Modified: modules/test/trunk/tooling/ant/pom.xml
===================================================================
--- modules/test/trunk/tooling/ant/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/tooling/ant/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -2,8 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-aggregator</artifactId>
+ <artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-unit-tooling-ant</artifactId>
Modified: modules/test/trunk/tooling/core/pom.xml
===================================================================
--- modules/test/trunk/tooling/core/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/tooling/core/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -2,8 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-aggregator</artifactId>
+ <artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-unit-tooling</artifactId>
Modified: modules/test/trunk/tooling/examples/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/examples/maven2/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/tooling/examples/maven2/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-unit-tooling-maven2-example</artifactId>
<version>0.1</version>
@@ -9,9 +9,8 @@
<dependencies>
<dependency>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
- <version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
@@ -37,7 +36,7 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
<executions>
<execution>
Modified: modules/test/trunk/tooling/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/maven2/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/tooling/maven2/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -2,8 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-aggregator</artifactId>
+ <artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-unit-tooling-maven2</artifactId>
Modified: modules/test/trunk/tooling/pom.xml
===================================================================
--- modules/test/trunk/tooling/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/tooling/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,16 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.portal.test</groupId>
- <artifactId>jboss-portal-modules-test</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Unit Tooling (aggregator)</name>
+ <version>1.1.0-SNAPSHOT</version>
<modules>
<module>core</module>
<module>ant</module>
Modified: modules/test/trunk/unit/pom.xml
===================================================================
--- modules/test/trunk/unit/pom.xml 2007-11-09 17:42:36 UTC (rev 8859)
+++ modules/test/trunk/unit/pom.xml 2007-11-09 20:47:23 UTC (rev 8860)
@@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.jboss.portal.test</groupId>
+ <groupId>org.jboss.unit</groupId>
<artifactId>jboss-portal-modules-test</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
<packaging>jar</packaging>
<name>JBoss Unit</name>
16 years, 11 months
JBoss Portal SVN: r8859 - in branches/JBoss_Portal_Branch_2_6/widget: src/main/org/jboss/portal/test/widget and 20 other directories.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2007-11-09 12:42:36 -0500 (Fri, 09 Nov 2007)
New Revision: 8859
Added:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/Foo3TestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/JSONBuilderTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractServer.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractSynchronizedServer.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/TestQuery.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResult.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResultEntry.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/ExpiringFutureTask.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetQuery.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirectoryFactory.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGDirectoryQueryMapEntry.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetMapEntry.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesMetaData.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferenceInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferencesInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidget.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONArray.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONException.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObject.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObjectWrapper.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONString.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONStringer.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONTokener.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONWriter.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesWidgetMapEntry.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVBooleanType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVDataType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVHiddenType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVListType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVPasswordType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVRangeType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextType.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextareaType.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet-instances.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/web.xml
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/test/google/gadget1_fail.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget3.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget4.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget5.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget6.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget7.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget8.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult2.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult3_fail.xml
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response1
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response2
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response3
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response4
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response5
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response6
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response7
branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response8
Removed:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit.jsp
Modified:
branches/JBoss_Portal_Branch_2_6/widget/build.xml
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/PreferencesTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/QueryResultParserTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
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/GGQuery.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResult.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/GGQueryResultEntry.java
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/resources/portal-widget-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1558: do not append default parameter values when rendering gadget
JBPORTAL-1573: pagination of the query result with a fix amount of results
JBPORTAL-1613: more interfaces
JBPORTAL-1613: initial netvibes widget support
Modified: branches/JBoss_Portal_Branch_2_6/widget/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/build.xml 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/build.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -91,7 +91,6 @@
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
<path refid="jbossas/core.libs.classpath"/>
- <path refid="jboss/backport.concurrent.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="junit.junit.classpath"/>
</path>
@@ -168,17 +167,35 @@
<!-- portal-widget-lib.jar -->
<mkdir dir="${build.lib}"/>
<jar jarfile="${build.lib}/portal-widget-lib.jar">
- <fileset dir="${build.classes}"/>
+ <fileset dir="${build.classes}" includes="org/jboss/portal/widget/*.class"/>
</jar>
+ <jar jarfile="${build.lib}/portal-widget-google-lib.jar">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/widget/google/**"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/portal-widget-netvibes-lib.jar">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/widget/netvibes/**"/>
+ </jar>
+
<!-- portal-widget.war -->
<copy todir="${build.resources}/portal-widget.war">
<fileset dir="${build.resources}/portal-widget-war"/>
</copy>
<copy todir="${build.resources}/portal-widget.war/WEB-INF/lib">
<fileset dir="${build.lib}" includes="portal-widget-lib.jar"/>
+ <fileset dir="${build.lib}" includes="portal-widget-google-lib.jar"/>
</copy>
+ <!-- portal-netvibes-widget.war -->
+ <copy todir="${build.resources}/portal-widget-netvibes.war">
+ <fileset dir="${build.resources}/portal-widget-netvibes-war"/>
+ </copy>
+ <copy todir="${build.resources}/portal-widget-netvibes.war/WEB-INF/lib">
+ <fileset dir="${build.lib}" includes="portal-widget-lib.jar"/>
+ <fileset dir="${build.lib}" includes="portal-widget-netvibes-lib.jar"/>
+ </copy>
+
</target>
@@ -189,6 +206,10 @@
<implode
dir="${build.resources}/portal-widget.war"
tofile="${build.lib}/portal-widget.war"/>
+
+ <implode
+ dir="${build.resources}/portal-widget-netvibes.war"
+ tofile="${build.lib}/portal-widget-netvibes.war"/>
</target>
@@ -229,6 +250,7 @@
depends="output">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<copy file="${build.lib}/portal-widget.war" todir="${jboss.home}/server/${portal.deploy.dir}"/>
+ <copy file="${build.lib}/portal-widget-netvibes.war" todir="${jboss.home}/server/${portal.deploy.dir}"/>
</target>
<target name="undeploy"
@@ -236,6 +258,7 @@
depends="init">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<delete file="${jboss.home}/server/${portal.deploy.dir}/portal-widget.war"/>
+ <delete file="${jboss.home}/server/${portal.deploy.dir}/portal-widget-netvibes.war"/>
</target>
<target name="package-tests" depends="init, output">
@@ -259,22 +282,27 @@
-->
<x-test>
-<!--
+ <test todir="${test.reports}" name="org.jboss.portal.test.widget.google.Foo3TestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.widget.netvibes.NetvibesProviderTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.widget.netvibes.NetvibesWidgetRenderTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.widget.google.QueryResultParserTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.widget.google.PreferencesTestCase"/>
--->
- <test todir="${test.reports}" name="org.jboss.portal.test.widget.google.QueryResultParserTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.widget.netvibes.JSONBuilderTestCase"/>
</x-test>
<x-classpath>
+ <!--
<pathelement location="${build.lib}/portal-widget-lib.jar"/>
+ -->
+ <pathelement location="${build.classes}"/>
<pathelement location="${build.resources}/test"/>
<path refid="beanshell.beanshell.classpath"/>
<path refid="apache.commons.classpath"/>
<path refid="dom4j.dom4j.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
<path refid="jboss.microcontainer.classpath"/>
<path refid="jboss.jbossxb.classpath"/>
<path refid="apache.xerces.classpath"/>
- <path refid="oswego.concurrent.classpath"/>
<path refid="apache.logging.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="antlr.antlr.classpath"/>
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/Foo3TestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/Foo3TestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/Foo3TestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,227 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.google;
+
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.test.widget.support.AbstractSynchronizedServer;
+import org.jboss.portal.test.widget.support.TestQuery;
+import org.jboss.portal.widget.DirectoryQueryResultEntry;
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.WidgetProvider;
+import org.jboss.portal.widget.google.provider.GGProvider;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class Foo3TestCase extends TestCase
+{
+
+ public void test01() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractReturnFileServer(8080, "google/queryresult1.xml")
+ {
+ protected void doClient() throws Exception
+ {
+
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ TestQuery q = new TestQuery();
+
+ List<DirectoryQueryResultEntry> w = provider.search(q);
+
+ provider.stop();
+
+ }
+ };
+ server.performInteraction();
+ }
+
+
+ public void test02() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractReturnFileServer(8080, "google/queryresult2.xml")
+ {
+ protected void doClient() throws Exception
+ {
+
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ TestQuery q = new TestQuery();
+
+ List<DirectoryQueryResultEntry> w = provider.search(q);
+
+ provider.stop();
+
+ }
+ };
+ server.performInteraction();
+ }
+
+ public void test03_fail() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractReturnFileServer(8080, "google/queryresult3_fail.xml")
+ {
+ protected void doClient() throws Exception
+ {
+
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ TestQuery q = new TestQuery();
+
+ List<DirectoryQueryResultEntry> w = provider.search(q);
+
+ provider.stop();
+
+ }
+ };
+ server.performInteraction();
+ }
+
+
+ public void test03_timeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+ TestQuery q = new TestQuery();
+ List<DirectoryQueryResultEntry> w = provider.search(q);
+
+ assertEquals(0, w.size());
+
+ provider.stop();
+ }
+ };
+ server.performInteraction();
+ }
+
+ public void test404() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.Abstract404Server(8080)
+ {
+ protected void doClient() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+ TestQuery q = new TestQuery();
+ List<DirectoryQueryResultEntry> w = provider.search(q);
+
+ assertEquals(0, w.size());
+
+ provider.stop();
+ }
+ };
+ server.performInteraction();
+ }
+
+
+ public void test_widget404() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.Abstract404Server(8080)
+ {
+ protected void doClient() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ URL url = new URL("http://localhost:8080");
+ Widget w = provider.getWidget(url);
+
+ provider.stop();
+
+ assertNull(w);
+ }
+ };
+ server.performInteraction();
+ }
+
+ public void test_widget_wrong_content() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractReturnFileServer(8080, "google/gadget1_fail.xml")
+ {
+ protected void doClient() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ URL url = new URL("http://localhost:8080");
+ Widget w = provider.getWidget(url);
+
+ provider.stop();
+
+ assertNull(w);
+ }
+ };
+ server.performInteraction();
+ }
+
+ public void test_widget_timeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+ provider.start();
+
+ URL url = new URL("http://localhost:8080");
+ Widget w = provider.getWidget(url);
+ assertNull(w);
+ provider.stop();
+
+
+ }
+ };
+ server.performInteraction();
+ }
+
+
+ public void test_widget_no_server() throws Exception
+ {
+ WidgetProvider provider = new GGProvider();
+
+ try
+ {
+ provider.start();
+
+ URL url= new URL("http://localhost:8181");
+ Widget w = provider.getWidget(url);
+ assertNull(w);
+ }
+ finally
+ {
+ provider.stop();
+ }
+ }
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/PreferencesTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/PreferencesTestCase.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/PreferencesTestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -51,8 +51,8 @@
GGWidgetInfo ggw = ggwb.create();
assertNotNull(ggw);
-// assertEquals("TestTitle",ggw.getTitle().getDefaultString());
-// assertEquals("TestDescription",ggw.getDescription().getDefaultString());
+ assertEquals("TestTitle",ggw.getTitle().getDefaultString());
+ assertEquals("TestDescription",ggw.getDescription().getDefaultString());
}
public void testUserPrefs() throws Exception
@@ -132,9 +132,115 @@
assertEquals("one|two|three|four|five", pi.getDefaultValue());
assertEquals(DataType.LIST, pi.getType().getOrdinal());
+ // Location
+ pi = prefs.getPreference("testLocation");
+ assertNotNull(pi);
+ assertEquals("Test Location", pi.getDisplayName());
+ assertEquals("1 1", pi.getDefaultValue());
+ assertEquals(DataType.LOCATION, pi.getType().getOrdinal());
+
+ }
+ /* - urlparam not supported for now
+ public void testUserPrefs03() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("google/gadget3.xml");
+ GGWidgetInfoBuilder ggwb = constructBuilder(url);
+ GGWidgetInfo ggw = ggwb.create();
+
+ assertNotNull(ggw);
}
+
+ // same here
+ public void testUserPrefs05() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("google/gadget5.xml");
+ GGWidgetInfoBuilder ggwb = constructBuilder(url);
+ GGWidgetInfo ggw = ggwb.create();
+
+ assertNotNull(ggw);
+ }
+*/
+
+ public void testUserPrefs04() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("google/gadget4.xml");
+
+ GGWidgetInfoBuilder ggwb = constructBuilder(url);
+ GGWidgetInfo ggw = ggwb.create();
+
+ assertNotNull(ggw);
+
+ assertEquals("Interesting Photos of the Day", ggw.getTitle().getDefaultString());
+ assertEquals("Displays a slideshow of the most interesting photos of the day, as determined by Flickr's interestingness algorithm.", ggw.getDescription().getDefaultString());
+ assertEquals(395, ggw.getHeight());
+ GGPreferenceInfo pi = ggw.getPreferences().getPreference("count");
+ assertNotNull(pi);
+ assertEquals("Show", pi.getDisplayName());
+ assertEquals("25 photos", pi.getDefaultValue());
+
+ assertEquals(DataType.ENUM, pi.getType().getOrdinal());
+ EnumType et = (EnumType) pi.getType();
+ assertEquals(4, et.getSize());
+
+ EnumType.Value etv = et.getValue(0);
+ assertEquals("1 photo", etv.getValue());
+ assertNull(etv.getDisplayValue());
+
+ etv = et.getValue(1);
+ assertEquals("5 photos", etv.getValue());
+ assertNull(etv.getDisplayValue());
+
+ etv = et.getValue(2);
+ assertEquals("10 photos", etv.getValue());
+ assertNull(etv.getDisplayValue());
+
+ etv = et.getValue(3);
+ assertEquals("25 photos", etv.getValue());
+ assertNull(etv.getDisplayValue());
+
+ pi = ggw.getPreferences().getPreference("delay");
+ assertNotNull(pi);
+
+ assertEquals(DataType.ENUM, pi.getType().getOrdinal());
+ et = (EnumType) pi.getType();
+ assertEquals(7, et.getSize());
+
+ etv = et.getValue(0);
+ assertEquals("1 second", etv.getValue());
+ assertNull(etv.getDisplayValue());
+
+ etv = et.getValue(6);
+ assertEquals("60 seconds", etv.getValue());
+ assertNull(etv.getDisplayValue());
+ }
+
+ public void testUserPrefs06() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("google/gadget6.xml");
+
+ GGWidgetInfoBuilder ggwb = constructBuilder(url);
+ GGWidgetInfo ggw = ggwb.create();
+
+ assertNotNull(ggw);
+ }
+
+ public void testUserPrefs07() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("google/gadget7.xml");
+
+ GGWidgetInfoBuilder ggwb = constructBuilder(url);
+ GGWidgetInfo ggw = ggwb.create();
+
+ assertNotNull(ggw);
+ }
+
public GGWidgetInfoBuilder constructBuilder(URL url) throws Exception
{
return new GGWidgetInfoBuilder(url)
@@ -149,6 +255,4 @@
}
};
}
-
-
}
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/QueryResultParserTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/QueryResultParserTestCase.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/QueryResultParserTestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -40,12 +40,13 @@
public void testA() throws MalformedURLException
{
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- URL url = tcl.getResource("google/queryresult1.xml");
+
+ URL url = this.getFileURL("google/queryresult1.xml");
assertNotNull(url);
GGQueryResultBuilder builder = new GGQueryResultBuilder(url);
GGQueryResult result = builder.build(5000);
assertNotNull(result);
+ assertEquals(24, result.collection().size());
Iterator i = result.entries();
assertNotNull(i);
assertTrue(i.hasNext());
@@ -59,5 +60,59 @@
assertEquals(320, entry.getWidth());
assertEquals(136, entry.getHeight());
assertEquals(new URL("http://www.google.com/ig/modules/datetime.xml"), entry.getURL());
+
+ GGQueryResultEntry entry2 = (GGQueryResultEntry)i.next();
+ assertNotNull(entry2);
+ assertEquals("Search YouTube", entry2.getTitle());
+ assertEquals("A search module, which searches YouTube by tags.", entry2.getDescription());
+ assertEquals("http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc.png", entry2.getScreenshot());
+ assertEquals("http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc-thm...", entry2.getThumbnail());
+ assertEquals("http://throttled.org/googlegadgets/youtubesearch.xml", entry2.getURL().toString());
+
+ GGQueryResultEntry entry3 = (GGQueryResultEntry)i.next();
+ assertNotNull(entry3);
+ assertEquals("PacMan v2.4", entry3.getTitle());
+ assertEquals(new URL("http://www.schulz.dk/pacman.xml"), entry3.getURL());
}
+
+ public void test02() throws MalformedURLException
+ {
+ URL url = this.getFileURL("google/queryresult2.xml");
+ assertNotNull(url);
+ GGQueryResultBuilder builder = new GGQueryResultBuilder(url);
+ GGQueryResult result = builder.build(5000);
+ assertNotNull(result);
+ Iterator i = result.entries();
+ assertNotNull(i);
+ assertEquals(24, result.collection().size());
+ assertTrue(i.hasNext());
+ GGQueryResultEntry entry = (GGQueryResultEntry)i.next();
+ assertNotNull(entry);
+ assertEquals("Wikipedia", entry.getTitle());
+ assertEquals(new URL("http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wpsearchba..."), entry.getURL());
+ assertEquals("A Wikipedia Search and Go widget. Language choice.", entry.getDescription());
+ assertEquals("http://www.google.com/ig/modules/ov/module_wikipedia_full.png", entry.getScreenshot());
+ assertEquals("http://www.google.com/ig/modules/ov/module_wikipedia.png", entry.getThumbnail());
+ assertEquals("bennokr+be_gone_spammers(a)gmail.com", entry.getAuthor());
+ assertEquals(320, entry.getWidth());
+ assertEquals(40, entry.getHeight());
+
+ GGQueryResultEntry entry2 = (GGQueryResultEntry)i.next();
+ assertNotNull(entry2);
+ }
+
+ public void test03()
+ {
+ URL url = this.getFileURL("google/queryresult3_fail.xml");
+ assertNotNull(url);
+ GGQueryResultBuilder builder = new GGQueryResultBuilder(url);
+ GGQueryResult result = builder.build(5000);
+ assertNotNull(result);
+ assertEquals(0, result.collection().size());
+ }
+
+ private URL getFileURL(String filename)
+ {
+ return Thread.currentThread().getContextClassLoader().getResource(filename);
+ }
}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/JSONBuilderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/JSONBuilderTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/JSONBuilderTestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.netvibes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.widget.netvibes.NetvibesPreferenceInfo;
+import org.jboss.portal.widget.netvibes.NetvibesPreferencesInfo;
+import org.jboss.portal.widget.netvibes.NetvibesWidgetInfo;
+import org.jboss.portal.widget.netvibes.provider.NetvibesJSONInfoBuilder;
+import org.jboss.portal.widget.netvibes.type.NVDataType;
+import org.jboss.portal.widget.netvibes.type.NVListType;
+import org.jboss.portal.widget.netvibes.type.NVRangeType;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JSONBuilderTestCase extends TestCase
+{
+
+ public void test01()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response1");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ assertEquals("Digg", info.getTitle().getDefaultString());
+ assertEquals("http://digg.com/favicon.ico", info.getIcons().get(0));
+
+ // metadata
+ assertEquals("Fran\u00e7ois Hodierne", info.getMetaData().getAuthor());
+ assertEquals("digg", info.getMetaData().getKeywords());
+ assertEquals("1.0", info.getMetaData().getApiVersion());
+ assertEquals(false, info.getMetaData().isInline());
+ assertEquals(false, info.getMetaData().isDebugMode());
+ assertEquals(20, info.getMetaData().getAutoRefresh());
+
+ // preferences
+ NetvibesPreferencesInfo pref = info.getPreferencesInfo();
+ assertEquals("category", pref.getPreference("category").getName());
+ assertEquals(NVDataType.HIDDEN, pref.getPreference("category").getType().getOrdinal());
+ assertEquals("all", pref.getPreference("category").getDefaultValue());
+
+ assertEquals(NVDataType.HIDDEN, pref.getPreference("openlinks").getType().getOrdinal());
+ assertEquals("true", pref.getPreference("openlinks").getDefaultValue());
+
+ assertEquals(NVDataType.HIDDEN, pref.getPreference("offset").getType().getOrdinal());
+ assertEquals("0", pref.getPreference("offset").getDefaultValue());
+
+ NVRangeType range1 = (NVRangeType) pref.getPreference("minimal").getType();
+ assertEquals("reParse", pref.getPreference("minimal").getOnChange());
+ assertEquals(NVDataType.RANGE, range1.getOrdinal());
+ assertEquals(0, range1.getMin());
+ assertEquals(1000, range1.getMax());
+ assertEquals(100, range1.getStep());
+ assertEquals("0", pref.getPreference("minimal").getDefaultValue());
+ assertEquals("Minimum number of diggs", pref.getPreference("minimal").getLabel());
+
+ //{"name":"limit","type":"range","label":"Number of items to display","defaultValue":"3","step":"1","min":"1","max":"25","onchange":"rePaint"},
+ NVRangeType range2 = (NVRangeType) pref.getPreference("limit").getType();
+ assertEquals(1, range2.getMin());
+ assertEquals(25, range2.getMax());
+ assertEquals(1, range2.getStep());
+ assertEquals("Number of items to display", pref.getPreference("limit").getLabel());
+ assertEquals("3", pref.getPreference("limit").getDefaultValue());
+ assertEquals("rePaint", pref.getPreference("limit").getOnChange());
+
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test02()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response2");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test03()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response3");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test04()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response4");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test06()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response6");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+
+ assertEquals("Weather", info.getTitle().getDefaultString());
+ assertEquals(NVDataType.TEXT, info.getPreferencesInfo().getPreference("townName").getType().getOrdinal());
+
+ NetvibesPreferenceInfo pref = info.getPreferencesInfo().getPreference("unit");
+ assertNotNull(pref);
+ assertEquals("0", pref.getDefaultValue());
+ assertEquals(NVDataType.LIST, pref.getType().getOrdinal());
+ NVListType list = (NVListType) pref.getType();
+ assertEquals("Fahrenheit", list.getValue(0).getLabel().getDefaultString());
+ assertEquals("Celsius", list.getValue(1).getLabel().getDefaultString());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test05()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response5");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void test07()
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource("netvibes/json.response7");
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ assertNotNull(info);
+ assertNotNull(info.getMetaData());
+ assertEquals("RSS Reader", info.getTitle().getDefaultString());
+ assertEquals("Fran\u00e7ois Hodierne (Netvibes)", info.getMetaData().getAuthor());
+ assertEquals("1.0.2", info.getMetaData().getVersion());
+ assertEquals(true, info.getMetaData().isInline());
+ assertEquals(20, info.getMetaData().getAutoRefresh());
+ assertEquals(true, info.getMetaData().isDebugMode());
+
+ NetvibesPreferenceInfo pi = info.getPreferencesInfo().getPreference("feedUrl");
+ assertNotNull(pi);
+ assertEquals(NVDataType.TEXT, pi.getType().getOrdinal());
+ assertEquals("URL", pi.getLabel());
+ assertEquals("http://feeds.feedburner.com/NetvibesDevBlog", pi.getDefaultValue());
+
+ pi = info.getPreferencesInfo().getPreference("nbTitles");
+ assertNotNull(pi);
+ assertEquals(NVDataType.RANGE, pi.getType().getOrdinal());
+ assertEquals("Number of items to display", pi.getLabel());
+ assertEquals("10", pi.getDefaultValue());
+ NVRangeType rt = (NVRangeType) pi.getType();
+ assertEquals(1, rt.getStep());
+ assertEquals(1, rt.getMin());
+ assertEquals(25, rt.getMax());
+
+ pi = info.getPreferencesInfo().getPreference("search");
+ assertNotNull(pi);
+ assertEquals(NVDataType.HIDDEN, pi.getType().getOrdinal());
+ assertEquals("", pi.getDefaultValue());
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+
+
+ public NetvibesJSONInfoBuilder constructBuilder(URL url)
+ {
+ return new NetvibesJSONInfoBuilder(url)
+ {
+ @Override
+ protected byte[] obtainWidget(URL url) throws Exception
+ {
+ File file = new File(url.getPath());
+ InputStream io = new FileInputStream(file);
+ byte[] bytes = IOTools.getBytes(io);
+ io.close();
+ return bytes;
+ }
+ };
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.netvibes;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.netvibes.provider.NetvibesProvider;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesProviderTestCase extends TestCase
+{
+
+ public void test01()
+ {
+ NetvibesProvider provider = new NetvibesProvider();
+ provider.start();
+
+ Widget widget = provider.getWidget("http://www.netvibes.com/api/uwa/examples/alexa.html");
+ assertNotNull(widget);
+// System.out.println(widget.render(new HashMap()));
+
+ provider.stop();
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.netvibes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.widget.netvibes.NetvibesWidget;
+import org.jboss.portal.widget.netvibes.NetvibesWidgetInfo;
+import org.jboss.portal.widget.netvibes.provider.NetvibesJSONInfoBuilder;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesWidgetRenderTestCase extends TestCase
+{
+
+ public void test01()
+ {
+ try
+ {
+ NetvibesWidget widget = new NetvibesWidget(
+ new URL("http://www.netvibes.com/api/uwa/examples/alexa.html"),
+ getWidgetInfo("netvibes/json.response1")
+ );
+ assertNotNull(widget);
+// System.out.println(widget.render(new HashMap()));
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+
+ private NetvibesWidgetInfo getWidgetInfo(String file) throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL url = tcl.getResource( file );
+
+ NetvibesJSONInfoBuilder builder = constructBuilder(url);
+ return builder.create();
+ }
+
+ public NetvibesJSONInfoBuilder constructBuilder(URL url)
+ {
+ return new NetvibesJSONInfoBuilder(url)
+ {
+
+ protected byte[] obtainWidget(URL url) throws Exception
+ {
+ File file = new File(url.getPath());
+ InputStream io = new FileInputStream(file);
+ byte[] bytes = IOTools.getBytes(io);
+ io.close();
+ return bytes;
+ }
+ };
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractServer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractServer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractServer.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.support;
+
+import java.net.ServerSocket;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractServer implements Runnable
+{
+
+ /** . */
+ private int port;
+
+ /** . */
+ private ServerSocket server;
+
+ public AbstractServer(int port)
+ {
+ this.port = port;
+ }
+
+ public final void start() throws Exception
+ {
+ server = new ServerSocket(port, 1);
+ new Thread(this).start();
+ }
+
+ public final void run()
+ {
+ try
+ {
+ run(server);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (!server.isClosed())
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+ }
+
+ protected abstract void run(ServerSocket server) throws Exception;
+
+ public final void stop()
+ {
+ if (server != null)
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractSynchronizedServer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractSynchronizedServer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/AbstractSynchronizedServer.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,264 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.support;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.BufferedOutputStream;
+import java.io.OutputStreamWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSynchronizedServer extends AbstractServer
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(AbstractSynchronizedServer.class);
+
+ /** . */
+ private final Object lock = new Object();
+
+ /** . */
+ private final AtomicInteger b = new AtomicInteger(0);
+
+ /** . */
+ private Throwable failure;
+
+ protected AbstractSynchronizedServer(int port)
+ {
+ super(port);
+ }
+
+ protected void run(ServerSocket server) throws Exception
+ {
+ synchronized (lock)
+ {
+ b.set(1);
+ lock.notifyAll();
+ }
+
+ //
+ log.debug("Ready for accept");
+
+ //
+ try
+ {
+ doServer(server);
+ }
+ catch (Throwable throwable)
+ {
+ failure = throwable;
+ }
+
+ //
+ synchronized (lock)
+ {
+ lock.wait();
+ }
+
+ //
+ log.debug("Shutting down");
+ }
+
+ protected abstract void doServer(ServerSocket server) throws Exception;
+
+ protected abstract void doClient() throws Exception;
+
+ public void performInteraction() throws Exception
+ {
+ try
+ {
+ start();
+
+ // Wait until the we know the server will accept
+ synchronized (lock)
+ {
+ while (b.get() != 1)
+ {
+ lock.wait();
+ }
+ }
+
+ // Perform client action
+ doClient();
+ }
+ finally
+ {
+ synchronized (lock)
+ {
+ lock.notify();
+ }
+ stop();
+ }
+
+ //
+ if (failure != null)
+ {
+ log.error("The server reported a failure", failure);
+
+ ExtendedAssert.fail("The server reported a failure");
+ }
+ }
+
+ public static abstract class AbstractTimeoutServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractTimeoutServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ server.accept();
+ }
+
+ }
+
+ public static abstract class AbstractOKServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractOKServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ //
+ Socket s = server.accept();
+ BufferedInputStream in = new BufferedInputStream(s.getInputStream());
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "ISO-8859-1"));
+ for (String line = reader.readLine();line.length() > 0;line = reader.readLine())
+ {
+ log.debug("server received = " + line);
+ }
+
+ //
+ log.debug("Finished reading");
+
+ //
+ BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.write("HTTP/1.1 200 OK\r\n");
+ writer.write("\r\n");
+ writer.flush();
+ out.write("CAFEBABE".getBytes("UTF-8"));
+ out.close();
+ }
+ }
+
+ public static abstract class AbstractReturnFileServer extends AbstractSynchronizedServer
+ {
+
+ /** . */
+ private final String file;
+
+ protected AbstractReturnFileServer(int port, String file)
+ {
+ super(port);
+ this.file = file;
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ //
+ Socket s = server.accept();
+ BufferedInputStream in = new BufferedInputStream(s.getInputStream());
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "ISO-8859-1"));
+ for (String line = reader.readLine();line.length() > 0;line = reader.readLine())
+ {
+ log.debug("server received = " + line);
+ }
+
+ //
+ log.debug("Finished reading");
+
+ // get file content
+ byte[] bytes = getFileContent();
+
+ //
+ BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.write("HTTP/1.1 200 OK\r\n");
+ writer.write("\r\n");
+ writer.flush();
+ out.write(bytes);
+ out.close();
+ }
+
+ private byte[] getFileContent() throws IllegalArgumentException, IOException
+ {
+ InputStream io = Thread.currentThread().getContextClassLoader().getResourceAsStream(this.file);
+ byte[] bytes = IOTools.getBytes(io);
+ io.close();
+ return bytes;
+ }
+
+ }
+
+ public static abstract class Abstract404Server extends AbstractSynchronizedServer
+ {
+
+ protected Abstract404Server(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ //
+ Socket s = server.accept();
+ BufferedInputStream in = new BufferedInputStream(s.getInputStream());
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "ISO-8859-1"));
+ for (String line = reader.readLine();line.length() > 0;line = reader.readLine())
+ {
+ log.debug("server received = " + line);
+ }
+
+ //
+ log.debug("Finished reading");
+
+ //
+ BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.write("HTTP/1.1 404 Not Found\r\n");
+ writer.write("\r\n");
+ writer.flush();
+ out.close();
+ }
+ }
+
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/TestQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/TestQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/support/TestQuery.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.widget.support;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.portal.widget.WidgetQuery;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestQuery implements WidgetQuery
+{
+
+ public URL buildQueryURL() throws MalformedURLException
+ {
+ return new URL("http://localhost:8080");
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,275 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractWidgetProvider implements WidgetProvider
+{
+
+ /** The widget entry map */
+ protected ConcurrentMap<URL, ExpiringFutureTask<Widget>> entries = new ConcurrentHashMap<URL, ExpiringFutureTask<Widget>>();
+
+ /** The query result map */
+ protected ConcurrentMap<WidgetQuery, ExpiringFutureTask<DirectoryQueryResult>> queries = new ConcurrentHashMap<WidgetQuery, ExpiringFutureTask<DirectoryQueryResult>>();
+
+ /** The executor */
+ protected ExecutorService executor;
+
+ /** The scheduled executor */
+ protected ScheduledExecutorService scheduledExecutor;
+
+ /** The entry expiration time in millis */
+ protected long entryExpiration = TimeUnit.MILLISECONDS.convert(120, TimeUnit.SECONDS);
+
+ /** The query expiration time in millis */
+ protected long queryExpiration = TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS);
+
+ /** Fetch all widgets in on the directory lookup */
+ private boolean fetchWidgetsOnDirectoryLookup = false;
+
+ /** The connection timeout */
+ protected long connectionTimeout;
+
+ /** Eviction thread timing */
+ protected long timing = TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS);
+
+
+ public void start()
+ {
+ executor = new ThreadPoolExecutor(4, 4, 0, TimeUnit.SECONDS, new LinkedBlockingQueue());
+ scheduledExecutor = new ScheduledThreadPoolExecutor(2);
+
+ scheduledExecutor.scheduleAtFixedRate(new EntryEvictionThread(), timing, timing, TimeUnit.MILLISECONDS);
+ scheduledExecutor.scheduleAtFixedRate(new QueryEvictionThread(), timing, timing, TimeUnit.MILLISECONDS);
+ }
+
+ public void stop()
+ {
+ executor.shutdownNow();
+ scheduledExecutor.shutdownNow();
+ executor = null;
+ scheduledExecutor = null;
+ }
+
+
+ public long getConnectionTimeout()
+ {
+ return connectionTimeout;
+ }
+
+ public void setConnectionTimeout(long connectionTimeout)
+ {
+ this.connectionTimeout = connectionTimeout;
+ }
+
+ // TODO entryExpiration
+ // TODO queryExpiration
+ // TODO fetchwidgetsonDirectoryLookup
+
+ /*
+ private void addWidget(URL url)
+ {
+ ExpiringFutureTask<Widget> ft = new ExpiringFutureTask<Widget>(entryExpiration, new WidgetMapEntry(url));
+ ExpiringFutureTask<Widget> e = entries.putIfAbsent(url, ft);
+ if (e == null)
+ {
+ e = ft;
+ executor.submit(e);
+ }
+ }
+ */
+ public Widget getWidget(URL url) throws InterruptedException, ExecutionException
+ {
+ addWidget(url);
+ ExpiringFutureTask<Widget> e = entries.get(url);
+ return e.get();
+ }
+
+ public Widget getWidget(String string)
+ {
+ try
+ {
+ URL url = new URL(string);
+ return getWidget(url);
+ }
+ catch(Exception e)
+ {
+ return null;
+ }
+ }
+
+ /*
+ private void addDirectoryResult(WidgetQuery query)
+ {
+ ExpiringFutureTask<DirectoryQueryResult> dt = new ExpiringFutureTask<DirectoryQueryResult>(queryExpiration, new DirectoryQueryMapEntry(query));
+ ExpiringFutureTask<DirectoryQueryResult> e = queries.putIfAbsent(query, dt);
+ if (e == null)
+ {
+ e = dt;
+ executor.submit(e);
+ }
+ }
+ */
+ protected abstract void addDirectoryResult(WidgetQuery query);
+
+ protected abstract void addWidget(URL url);
+
+ private DirectoryQueryResult getDirectoryResult(WidgetQuery query) throws InterruptedException, ExecutionException
+ {
+ addDirectoryResult(query);
+ ExpiringFutureTask<DirectoryQueryResult> e = queries.get(query);
+ return e.get();
+ }
+
+ public List<Widget> getWidgets(List<URL> list)
+ {
+// long millis = System.currentTimeMillis();
+ if (list == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for(URL url : list)
+ {
+ addWidget(url);
+ }
+ List<Widget> widgets = new ArrayList<Widget>();
+
+ for(URL url : list)
+ {
+ try
+ {
+ Widget widget = getWidget(url);
+ if ( widget != null)
+ {
+ widgets.add(widget);
+ }
+ }
+ catch( InterruptedException e )
+ {
+ // log.err
+ entries.remove(url);
+ }
+ catch( ExecutionException e )
+ {
+ // log.err
+ entries.remove(url);
+ }
+ }
+// System.out.println("fetchting 3 took: " + NumberFormat.getInstance().format((System.currentTimeMillis() - millis) / 1000.0));
+ return widgets;
+ }
+
+
+ public List<DirectoryQueryResultEntry> search(WidgetQuery q)
+ {
+ if (q == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<DirectoryQueryResultEntry> list = new ArrayList<DirectoryQueryResultEntry>();
+ DirectoryQueryResult result = null;
+ try
+ {
+ result = getDirectoryResult(q);
+ for(Iterator<? extends DirectoryQueryResultEntry> i = result.entries(); i.hasNext(); )
+ {
+ list.add(i.next() );
+ }
+
+ }
+ catch(InterruptedException e)
+ {
+ //
+ }
+ catch(ExecutionException e)
+ {
+ //
+ }
+
+ if( this.fetchWidgetsOnDirectoryLookup )
+ {
+ for(URL url : result.collection())
+ {
+ // add widgets and submit to executor if necessary
+ addWidget(url);
+ }
+ }
+
+ return list;
+ }
+
+ private class EntryEvictionThread implements Runnable
+ {
+ public void run()
+ {
+ if(entries != null && entries.size() > 0)
+ {
+ for(URL url : entries.keySet())
+ {
+ ExpiringFutureTask<Widget> w = entries.get(url);
+ if (w.isExpired())
+ {
+ entries.remove(url);
+ System.out.println("removing entry: " + url.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private class QueryEvictionThread implements Runnable
+ {
+ public void run()
+ {
+ if (queries != null && queries.size() > 0)
+ {
+ for(WidgetQuery query : queries.keySet())
+ {
+ ExpiringFutureTask<DirectoryQueryResult> e = queries.get(query);
+ if (e.isExpired())
+ {
+ queries.remove(query);
+ System.out.println("removing query: " + query.toString());
+ }
+ }
+ }
+ }
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResult.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResult.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResult.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface DirectoryQueryResult
+{
+
+ public Iterator<? extends DirectoryQueryResultEntry> entries();
+
+ public List<URL> collection();
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResultEntry.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResultEntry.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/DirectoryQueryResultEntry.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface DirectoryQueryResultEntry
+{
+
+ public URL getURL();
+
+ public String getTitle();
+
+ public String getDescription();
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/ExpiringFutureTask.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/ExpiringFutureTask.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/ExpiringFutureTask.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ExpiringFutureTask<V> extends FutureTask<V>
+{
+ /** . */
+ private long expires = 0;
+
+ public ExpiringFutureTask(long expires, Callable<V> callable)
+ {
+ super(callable);
+ this.expires = System.currentTimeMillis() + expires;
+ }
+
+ public boolean isExpired()
+ {
+ if (this.isCancelled())
+ {
+ return true;
+ }
+ if (this.isDone())
+ {
+ return System.currentTimeMillis() > expires ? true : false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -44,10 +44,12 @@
* @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
* @version $Revision$
*/
-public class WidgetPortlet extends GenericPortlet
+public abstract class WidgetPortlet extends GenericPortlet
{
+ /** . */
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(WidgetPortlet.class);
+ /** . */
public final static String INIT_PARAM_CONNECTION_TIMEOUT = "connectionTimeout";
/** . */
@@ -164,7 +166,7 @@
req.setAttribute("provider", provider);
//
- PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit_content.jsp");
dispatcher.include(req, resp);
}
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,17 +22,28 @@
******************************************************************************/
package org.jboss.portal.widget;
-import java.util.Collection;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public interface WidgetProvider
{
+
+ public void start();
+
+ public void stop();
- Collection getKeys();
+ public Widget getWidget(URL url) throws InterruptedException, ExecutionException;
+
+ public List<Widget> getWidgets(List<URL> list);
+
+// public List<Widget> search(WidgetQuery query);
+
+ public List<DirectoryQueryResultEntry> search(WidgetQuery query);
+
+}
- Widget getWidget(String key);
-
-}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetQuery.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface WidgetQuery
+{
+
+ /** . */
+// public int getStart();
+
+ /** . */
+// public int getNum();
+
+ /** . */
+// public String getCat();
+
+ /** . */
+// public String getQ();
+
+ /** . */
+// public int hashCode();
+
+ /** . */
+ public boolean equals(Object foo);
+
+ /** . */
+ public URL buildQueryURL() throws MalformedURLException;
+
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -124,14 +124,16 @@
//
GGPreferencesInfo prefsInfo = info.getPreferences();
- // Append default values
for (Iterator i = prefsInfo.getPreferences().iterator(); i.hasNext();)
{
GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
String prefName = prefInfo.getName();
+ String defaultValue = prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "";
String[] values = (String[])parameters.get(prefName);
- String value = values != null ? values[0] : prefInfo.getDefaultValue();
- if (value != null)
+ String value = values != null ? values[0] : defaultValue;
+
+ // if value is present and not a default parameter
+ if (value != null && !defaultValue.equals(value))
{
FastURLEncoder encoder = FastURLEncoder.getUTF8Instance();
tmp.append("&up_").append(encoder.encode(prefName)).append("=").append(encoder.encode(value));
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,183 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.google;
+
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.google.provider.GGProvider;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 8784 $
+ */
+public class GGWidgetPortlet extends GenericPortlet
+{
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(GGWidgetPortlet.class);
+
+ /** . */
+ public final static String INIT_PARAM_CONNECTION_TIMEOUT = "connectionTimeout";
+
+ /** . */
+ private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
+
+ /** . */
+ private GGProvider provider = new GGProvider();
+
+
+ public void init() throws PortletException
+ {
+ provider.start();
+ String timeout = getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
+ if (timeout != null && timeout.length() > 0)
+ {
+ try
+ {
+ provider.setConnectionTimeout(Integer.parseInt(timeout));
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("Failed to parse connectionTimeout init parameter - should be integer number: ", e);
+ }
+ }
+ }
+
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (req.getParameter("content.action.select") != null)
+ {
+ String contentURI = req.getParameter("content.uri");
+ if (contentURI != null)
+ {
+ // Will contain the next render params
+ Map params = new HashMap();
+
+ //
+ params.put("content.uri", new String[]{contentURI});
+
+ //
+ for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String contentParamName = (String)entry.getKey();
+ if (contentParamName.startsWith("content.param"))
+ {
+ String[] contentParamValue = (String[])entry.getValue();
+ params.put(contentParamName, contentParamValue);
+ }
+ }
+
+ //
+ String catParam = req.getParameter("cat");
+ if (catParam != null)
+ {
+ params.put("cat", new String[]{catParam});
+ }
+
+ String currentPage = req.getParameter("currentPage");
+ if (currentPage != null)
+ {
+ params.put("currentPage", new String[]{currentPage});
+ }
+
+ //
+ String queryParam = req.getParameter("query");
+ if (queryParam != null)
+ {
+ params.put("query", new String[]{queryParam});
+ }
+
+ String pickMethod = req.getParameter("gg_pick_method");
+ if (pickMethod != null)
+ {
+ params.put("gg_pick_method", new String[]{pickMethod});
+ }
+
+ //
+ resp.setRenderParameters(params);
+ }
+ }
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ String uri = req.getParameter("uri");
+ Widget widget = provider.getWidget(uri);
+ if (widget != null)
+ {
+ writer.print(widget.render(req.getParameterMap(), req.getLocale()));
+ }
+ else
+ {
+ writer.print("Widget is not available");
+ }
+ writer.close();
+ }
+
+ protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
+ {
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+ }
+
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+
+ //
+ req.setAttribute("provider", provider);
+
+ //
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit_content.jsp");
+ dispatcher.include(req, resp);
+ }
+
+ public void destroy()
+ {
+ provider.stop();
+ }
+}
Deleted: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -1,159 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.portal.widget.google.directory;
-
-import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
-import org.jboss.xb.binding.GenericObjectModelFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
- * @version $Revision$
- */
-public class GGWidgetDirecotoryFactory implements GenericObjectModelFactory
-{
-
- public static final String GHAPI_URI = "http://www.google.com/apis/homepage";
-
- public Object newRoot(Object root, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname, Attributes attributes)
- {
- return new ArrayList();
- }
-
- public Object completeRoot(Object root, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname)
- {
- return root;
- }
-
-
- public Object newChild(Object parent, UnmarshallingContext unmarshallingContext, String namespaceURI, String localName, Attributes attributes)
- {
- if ("channel".equals(localName))
- {
- return parent;
- }
- if ("item".equals(localName))
- {
- return new GGWidgetMetaData();
- }
- return null;
- }
-
- public void addChild(Object parent, Object child, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname)
- {
- if (child instanceof GGWidgetMetaData)
- {
- ((List)parent).add(child);
- }
- }
-
- public void setValue(Object object, UnmarshallingContext unmarshallingContext, String namespaceURI, String localName, String value)
- {
- if (object instanceof GGWidgetMetaData)
- {
- GGWidgetMetaData widget = (GGWidgetMetaData)object;
- if (GHAPI_URI.equals(namespaceURI))
- {
- if ("author_email".equals(localName))
- {
- widget.setAuthorEmail(value);
- }
- else if ("screenshot".equals(localName))
- {
- widget.setScreenshot(value);
- }
- else if ("thumbnail".equals(localName))
- {
- widget.setThumbnail(value);
- }
- else if ("author_location".equals(localName))
- {
- widget.setAuthorLocaltion(value);
- }
- else if ("author_affiliation".equals(localName))
- {
- widget.setAuthorAffiliation(value);
- }
- else if ("title_url".equals(localName))
- {
- widget.setTitleURL(value);
- }
- else if ("directory_title".equals(localName))
- {
- widget.setDirectoryTitle(value);
- }
- else if ("author_photo".equals(localName))
- {
- widget.setAuthorPhoto(value);
- }
- else if ("author_aboutme".equals(localName))
- {
- widget.setAuthorAboutme(value);
- }
- else if ("author_link".equals(localName))
- {
- widget.setAuthorLink(value);
- }
- else if ("author_quote".equals(localName))
- {
- widget.setAuthorQuote(value);
- }
- if ("width".equals(localName))
- {
- widget.setWidth(value);
- }
- if ("height".equals(localName))
- {
- widget.setHeight(value);
- }
- }
- else
- {
- if ("title".equals(localName))
- {
- widget.setTitle(value);
- }
- else if ("link".equals(localName))
- {
- widget.setLink(value);
- }
- else if ("guid".equals(localName))
- {
- //doubles 'link' tag
- }
- else if ("description".equals(localName))
- {
- widget.setDescription(value);
- }
- else if ("author".equals(localName))
- {
- widget.setAuthor(value);
- }
- }
- }
- }
-}
Copied: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirectoryFactory.java (from rev 8752, branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirectoryFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirectoryFactory.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,173 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.widget.google.directory;
+
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
+import org.xml.sax.Attributes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class GGWidgetDirectoryFactory implements GenericObjectModelFactory
+{
+
+ public static final String GHAPI_URI = "http://www.google.com/apis/homepage";
+
+ public Object newRoot(Object root, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname, Attributes attributes)
+ {
+ return new ArrayList();
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname)
+ {
+ return root;
+ }
+
+
+ public Object newChild(Object parent, UnmarshallingContext unmarshallingContext, String namespaceURI, String localName, Attributes attributes)
+ {
+ if ("channel".equals(localName))
+ {
+ return parent;
+ }
+ if ("item".equals(localName))
+ {
+ return new GGWidgetMetaData();
+ }
+ return null;
+ }
+
+ public void addChild(Object parent, Object child, UnmarshallingContext unmarshallingContext, String namespaceURI, String localname)
+ {
+ if (child instanceof GGWidgetMetaData)
+ {
+ ((List)parent).add(child);
+ }
+ }
+
+ public void setValue(Object object, UnmarshallingContext unmarshallingContext, String namespaceURI, String localName, String value)
+ {
+ if (object instanceof GGWidgetMetaData)
+ {
+ GGWidgetMetaData widget = (GGWidgetMetaData)object;
+ if (GHAPI_URI.equals(namespaceURI))
+ {
+ if ("author_email".equals(localName))
+ {
+ widget.setAuthorEmail(value);
+ }
+ else
+ if ("screenshot".equals(localName))
+ {
+ widget.setScreenshot(value);
+ }
+ else
+ if ("thumbnail".equals(localName))
+ {
+ widget.setThumbnail(value);
+ }
+ else
+ if ("author_location".equals(localName))
+ {
+ widget.setAuthorLocaltion(value);
+ }
+ else
+ if ("author_affiliation".equals(localName))
+ {
+ widget.setAuthorAffiliation(value);
+ }
+ else
+ if ("title_url".equals(localName))
+ {
+ widget.setTitleURL(value);
+ }
+ else
+ if ("directory_title".equals(localName))
+ {
+ widget.setDirectoryTitle(value);
+ }
+ else
+ if ("author_photo".equals(localName))
+ {
+ widget.setAuthorPhoto(value);
+ }
+ else
+ if ("author_aboutme".equals(localName))
+ {
+ widget.setAuthorAboutme(value);
+ }
+ else
+ if ("author_link".equals(localName))
+ {
+ widget.setAuthorLink(value);
+ }
+ else
+ if ("author_quote".equals(localName))
+ {
+ widget.setAuthorQuote(value);
+ }
+ if ("width".equals(localName))
+ {
+ widget.setWidth(value);
+ }
+ if ("height".equals(localName))
+ {
+ widget.setHeight(value);
+ }
+ }
+ else
+ {
+ if ("title".equals(localName))
+ {
+ widget.setTitle(value);
+ }
+ else
+ if ("link".equals(localName))
+ {
+ widget.setLink(value);
+ }
+ else
+ if ("guid".equals(localName))
+ {
+ //doubles 'link' tag
+ }
+ else
+ if ("description".equals(localName))
+ {
+ widget.setDescription(value);
+ }
+ else
+ if ("author".equals(localName))
+ {
+ widget.setAuthor(value);
+ }
+ }
+ }
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGDirectoryQueryMapEntry.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGDirectoryQueryMapEntry.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGDirectoryQueryMapEntry.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.google.provider;
+
+import java.util.concurrent.Callable;
+
+import org.jboss.portal.widget.DirectoryQueryResult;
+import org.jboss.portal.widget.WidgetQuery;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class GGDirectoryQueryMapEntry implements Callable<DirectoryQueryResult>
+{
+ /** The widget URL */
+ private final WidgetQuery query;
+
+ public GGDirectoryQueryMapEntry(WidgetQuery query)
+ {
+ this.query = query;
+ }
+
+ public DirectoryQueryResult call() throws Exception
+ {
+ return new GGQueryResultBuilder(query).build(5000); // todo
+ }
+}
+
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-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,54 +22,21 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentMap;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingDeque;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.CollectionBuilder;
-import org.jboss.portal.widget.google.GGWidget;
-import org.jboss.portal.widget.google.info.GGWidgetCategoryInfo;
-import org.jboss.portal.widget.google.info.GGWidgetInfo;
-
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
- * @version $Revision$
- */
-public class GGProvider
-{
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.widget.AbstractWidgetProvider;
+import org.jboss.portal.widget.DirectoryQueryResult;
+import org.jboss.portal.widget.ExpiringFutureTask;
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.WidgetQuery;
+import org.jboss.portal.widget.google.info.GGWidgetCategoryInfo;
- /** . */
- public static final GGQuery INITIAL_QUERY = new GGQuery(0, null, null, null);
-
- /** The different descriptors. */
- private final ConcurrentMap entries = new ConcurrentHashMap();
-
- /** The query searches. */
- private final ConcurrentMap searches = new ConcurrentHashMap();
-
- /** . */
- private ExecutorService executor;
-
- /** . */
- private int connectionTimeout = 5000;
-
- /** . */
- private Logger logger = Logger.getLogger(GGProvider.class);
-
- /** . */
+public final class GGProvider extends AbstractWidgetProvider
+{
+ /** The google categories */
private static final Collection CATEGORIES = Collections.unmodifiableList(new CollectionBuilder()
.add(new GGWidgetCategoryInfo("all", "Popular"))
.add(new GGWidgetCategoryInfo("news", "News"))
@@ -81,215 +48,33 @@
.add(new GGWidgetCategoryInfo("technology", "Technology"))
.add(new GGWidgetCategoryInfo("new", "New stuff"))
.toArrayList());
-
- public void start()
- {
- executor = new ThreadPoolExecutor(4, 4, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
- }
-
- public void stop()
- {
- executor.shutdownNow();
- executor = null;
- }
-
+
public Collection getCategories()
{
return CATEGORIES;
}
-
-
- /** Returns a specified widget. */
- public GGWidget getWidget(String id)
+
+ @Override
+ protected final void addDirectoryResult(WidgetQuery query)
{
- if (id == null)
+ ExpiringFutureTask<DirectoryQueryResult> dt = new ExpiringFutureTask<DirectoryQueryResult>(queryExpiration, new GGDirectoryQueryMapEntry(query));
+ ExpiringFutureTask<DirectoryQueryResult> e = queries.putIfAbsent(query, dt);
+ if (e == null)
{
- throw new IllegalArgumentException();
+ e = dt;
+ executor.submit(e);
}
-
- //
- try
- {
- URL url = new URL(id);
- return getWidget(url);
- }
- catch (MalformedURLException e)
- {
- e.printStackTrace();
-
- //
- return null;
- }
}
-
- /** Returns a specified widget. */
- private GGWidget getWidget(URL url)
+
+ @Override
+ protected final void addWidget(URL url)
{
- GGProvider.GGWidgetEntry tmp = new GGProvider.GGWidgetEntry(url);
- GGProvider.GGWidgetEntry entry = (GGProvider.GGWidgetEntry)entries.putIfAbsent(url, tmp);
- if (entry == null)
+ ExpiringFutureTask<Widget> ft = new ExpiringFutureTask<Widget>(entryExpiration, new GGWidgetMapEntry(url));
+ ExpiringFutureTask<Widget> e = entries.putIfAbsent(url, ft);
+ if (e == null)
{
- entry = tmp;
- entry.retrieve();
+ e = ft;
+ executor.submit(e);
}
- return entry.getWidget();
}
-
- /** Returns a collection of widgets from a query. */
- public Collection search(GGQuery query)
- {
- if (query == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- GGQueryEntry tmp = new GGQueryEntry(query);
- GGQueryEntry entry = (GGQueryEntry)searches.putIfAbsent(query, tmp);
-
- // Check if query wasn't performed yet or if it is empty (probably failed)
-
- if (entry == null || !entry.getResult().entries().hasNext())
- {
- entry = tmp;
- entry.retrieve();
- }
-
- GGQueryResult result = entry.getResult();
-
- //
- Collection widgets = new ArrayList();
- for (Iterator i = result.entries(); i.hasNext();)
- {
- GGQueryResultEntry resultEntry = (GGQueryResultEntry)i.next();
- GGWidget widget = getWidget(resultEntry.getURL());
- if (widget != null)
- {
- widgets.add(widget);
- }
- }
-
- //
- return widgets;
- }
-
-
- public int getConnectionTimeout()
- {
- return connectionTimeout;
- }
-
- public void setConnectionTimeout(int connectionTimeout)
- {
- this.connectionTimeout = connectionTimeout;
- }
-
- private class GGWidgetEntry implements Callable
- {
-
- /** The widget id. */
- private final URL url;
-
- /** . */
- private FutureTask future;
-
- public GGWidgetEntry(URL url)
- {
- this.url = url;
- this.future = new FutureTask(this);
- }
-
- public void retrieve()
- {
- executor.submit(future);
- }
-
- public GGWidget getWidget()
- {
- try
- {
- return (GGWidget)future.get();
- }
- catch (Exception e)
- {
- e.printStackTrace();
-
- //
- return null;
- }
- }
-
- public Object call() throws Exception
- {
- GGWidgetInfoBuilder builder = new GGWidgetInfoBuilder(url);
- try
- {
- GGWidgetInfo info = builder.create();
- if (info != null)
- {
- return new GGWidget(url, info);
- }
- else
- {
- return null;
- }
- }
- catch (Exception e)
- {
- logger.warn("Throwing " + url + " away, we don't support it yet");
- logger.debug(e);
- return null;
- }
- }
- }
-
- private class GGQueryEntry implements Callable
- {
-
- /** . */
- private final GGQuery query;
-
- /** . */
- private FutureTask future;
-
- public GGQueryEntry(GGQuery query)
- {
- this.query = query;
- this.future = new FutureTask(this);
- }
-
- public void retrieve()
- {
- executor.submit(future);
- }
-
- public GGQueryResult getResult()
- {
- GGQueryResult result = null;
-
- //
- try
- {
- result = (GGQueryResult)future.get();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- //
- if (result == null)
- {
- result = new GGQueryResult(Collections.EMPTY_LIST);
- }
-
- //
- return result;
- }
-
- public Object call() throws MalformedURLException
- {
- return new GGQueryResultBuilder(query).build(getConnectionTimeout());
- }
- }
-}
+}
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -26,13 +26,16 @@
import java.net.URL;
import java.util.Locale;
+import org.jboss.portal.widget.WidgetQuery;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public final class GGQuery
+public final class GGQuery implements WidgetQuery
{
+ /** . */
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(GGQuery.class);
/** . */
@@ -74,10 +77,22 @@
this.cat = cat;
this.q = q;
this.locale = locale;
- this.hashCode = start + (cat == null ? 0 : 1 + cat.hashCode()) + (q == null ? 0 : 1 + q.hashCode()) + (locale == null ? 0 : 1 + locale.hashCode());
+ this.hashCode = start + 10 + (cat == null ? 0 : 1 + cat.hashCode()) + (q == null ? 0 : 1 + q.hashCode()) + (locale == null ? 0 : 1 + locale.hashCode());
}
+ public GGQuery(int start, int num, String cat, String q, Locale locale)
+ {
+ this(start, cat, q, locale);
+
+ if (num < 1)
+ {
+ throw new IllegalArgumentException("No zero or negative num.");
+ }
+ this.num = num;
+ this.hashCode = start + num + (cat == null ? 0 : 1 + cat.hashCode()) + (q == null ? 0 : 1 + q.hashCode()) + (locale == null ? 0 : 1 + locale.hashCode());
+ }
+
public int getStart()
{
return start;
@@ -109,6 +124,7 @@
GGQuery that = (GGQuery)obj;
return
(this.start == that.start) &&
+ (this.num == that.num) &&
(this.cat == null ? that.cat == null : this.cat.equals(that.cat)) &&
(this.q == null ? that.q == null : this.q.equals(that.q));
}
@@ -120,7 +136,7 @@
return hashCode;
}
- URL buildQueryURL() throws MalformedURLException
+ public URL buildQueryURL() throws MalformedURLException
{
StringBuffer buffer = new StringBuffer("http://www.google.com/ig/directory?synd=jboss&output=rss");
if (start > 0)
@@ -154,7 +170,6 @@
buffer.append("&country=").append(locale.getLanguage());
}
-
log.debug("Google Gadgets Directory query URL: " + buffer.toString());
return new URL(buffer.toString());
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResult.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResult.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResult.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,18 +22,23 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.jboss.portal.widget.DirectoryQueryResult;
+import org.jboss.portal.widget.DirectoryQueryResultEntry;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public final class GGQueryResult
+public final class GGQueryResult implements DirectoryQueryResult
{
- /** . */
- private List entries;
+ /** The GG query result entries */
+ private List<GGQueryResultEntry> entries;
GGQueryResult(List entries)
{
@@ -46,8 +51,18 @@
this.entries = entries;
}
- public Iterator entries()
+ public Iterator<? extends DirectoryQueryResultEntry> entries()
{
return entries.iterator();
}
+
+ public List<URL> collection()
+ {
+ List<URL> list = new ArrayList<URL>();
+ for(GGQueryResultEntry e : entries)
+ {
+ list.add(e.getURL());
+ }
+ return list;
+ }
}
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-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,29 +22,32 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.widget.WidgetQuery;
import org.jboss.portal.widget.google.directory.GGWidgetDirecotoryFactory;
import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
-import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
+import java.net.URL;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
-import java.net.URL;
+import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
/**
+ * @todo make the timeouts parameterizable
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
* @version $Revision$
- * @todo make the timeouts parameterizable
*/
public class GGQueryResultBuilder
{
@@ -57,7 +60,7 @@
/** . */
private final URL url;
- public GGQueryResultBuilder(GGQuery query) throws MalformedURLException
+ public GGQueryResultBuilder(WidgetQuery query) throws MalformedURLException
{
if (query == null)
{
@@ -81,6 +84,7 @@
try
{
// Read fully the URL content first
+ long millis = System.currentTimeMillis();
byte[] bytes;
if ("http".equals(url.getProtocol()))
{
@@ -107,7 +111,7 @@
}
String string = new String(bytes);
-
+
List data = null;
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
@@ -117,7 +121,6 @@
// 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);
-
List entries = new ArrayList();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
@@ -125,11 +128,11 @@
GGWidgetMetaData md = (GGWidgetMetaData)iterator.next();
log.debug("Adding gadget: " + md);
-
+
GGQueryResultEntry entry = new GGQueryResultEntry(md);
entries.add(entry);
}
-
+ System.out.println("fetchting directory took: " + NumberFormat.getInstance().format((System.currentTimeMillis() - millis) / 1000.0));
//
return new GGQueryResult(entries);
}
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultEntry.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultEntry.java 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultEntry.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
+import org.jboss.portal.widget.DirectoryQueryResultEntry;
import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
import java.net.URL;
@@ -31,7 +32,7 @@
* @version $Revision$
* @todo parse all meta data
*/
-public class GGQueryResultEntry
+public class GGQueryResultEntry implements DirectoryQueryResultEntry
{
/** . */
@@ -103,7 +104,6 @@
this.height = 0;
}
-
}
public URL getURL()
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-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -22,34 +22,35 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.net.URLTools;
-import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.widget.google.type.DataType;
+import org.jboss.portal.widget.google.type.StringType;
+import org.jboss.portal.widget.google.type.LocationType;
+import org.jboss.portal.widget.google.type.HiddenType;
+import org.jboss.portal.widget.google.type.BoolType;
+import org.jboss.portal.widget.google.type.ListType;
+import org.jboss.portal.widget.google.type.EnumType;
import org.jboss.portal.widget.google.info.GGPreferenceInfo;
import org.jboss.portal.widget.google.info.GGPreferencesInfo;
import org.jboss.portal.widget.google.info.GGWidgetInfo;
-import org.jboss.portal.widget.google.type.BoolType;
-import org.jboss.portal.widget.google.type.DataType;
-import org.jboss.portal.widget.google.type.EnumType;
-import org.jboss.portal.widget.google.type.HiddenType;
-import org.jboss.portal.widget.google.type.ListType;
-import org.jboss.portal.widget.google.type.LocationType;
-import org.jboss.portal.widget.google.type.StringType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
+import java.text.NumberFormat;
import java.util.Iterator;
import java.util.Locale;
+import java.util.Collection;
+import java.util.ArrayList;
import java.util.Map;
+import java.util.HashMap;
+import java.io.ByteArrayInputStream;
/**
* Build widget meta data from its URL.
@@ -81,14 +82,13 @@
/**
* Build the widget info from the url or return null if it is not possible.
- *
* @return the widget info
* @throws Exception
*/
public GGWidgetInfo create() throws Exception
{
+ long millis = System.currentTimeMillis();
byte[] bytes = obtainWidget(url);
-
// No response was obtained
if (bytes == null)
{
@@ -113,7 +113,7 @@
Map messages = new HashMap();
- while (localeEltIterator.hasNext())
+ while(localeEltIterator.hasNext())
{
Element localeElt = (Element)localeEltIterator.next();
@@ -137,7 +137,6 @@
locale = new Locale(langAttr, countryAttr);
}
-
URL bundleURL = new URL(url, messagesAttr);
byte[] bundleBytes = obtainLocaleBundle(bundleURL);
@@ -151,10 +150,9 @@
DocumentBuilder bundleDocBuilder = factory.newDocumentBuilder();
Document bundleDoc = bundleDocBuilder.parse(new ByteArrayInputStream(bundleBytes));
Element messagebundleElt = bundleDoc.getDocumentElement();
-
Iterator messagesEltIterator = XMLTools.getChildrenIterator(messagebundleElt, "msg");
- while (messagesEltIterator.hasNext())
+ while(messagesEltIterator.hasNext())
{
Element msgElt = (Element)messagesEltIterator.next();
@@ -164,12 +162,10 @@
//create value from the tag content
NodeList nodes = msgElt.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
+ for (int i = 0; i < nodes.getLength(); i++) {
Node n = nodes.item(i);
- if (n.getNodeType() == Element.TEXT_NODE)
- {
+ if (n.getNodeType() == Element.TEXT_NODE) {
value.append(n.getNodeValue());
}
}
@@ -196,7 +192,7 @@
String name = (String)iterator.next();
Map entries = (Map)messages.get(name);
- messagesBundle.put(name, new LocalizedString(entries, Locale.ENGLISH));
+ messagesBundle.put(name, new LocalizedString(entries, Locale.ENGLISH));
}
}
@@ -221,7 +217,7 @@
// We don't support that for now
if (urlParamAttr.length() > 0)
{
- throw new Exception("We don't support that for now");
+ throw new Exception("We don't support the attibute ("+ urlParamAttr + ") for now.");
}
// String is default type when not specified
@@ -229,7 +225,7 @@
if (dataTypeAttr.length() > 0)
{
int dataTypeOrdinal = DataType.parseDataTypeLiteral(dataTypeAttr);
- switch (dataTypeOrdinal)
+ switch(dataTypeOrdinal)
{
case DataType.HIDDEN:
dataType = HiddenType.getInstance();
@@ -245,7 +241,7 @@
break;
case DataType.ENUM:
Collection values = new ArrayList();
- for (Iterator i = XMLTools.getChildrenIterator(userPref, "EnumValue"); i.hasNext();)
+ for (Iterator i = XMLTools.getChildrenIterator(userPref, "EnumValue");i.hasNext();)
{
Element enumValueElt = (Element)i.next();
String valueAttr = enumValueElt.getAttribute("value");
@@ -304,6 +300,7 @@
int width = (widthAttr != null && widthAttr.length() > 0) ? Integer.parseInt(widthAttr) : 320;
int height = (heightAttr != null && heightAttr.length() > 0) ? Integer.parseInt(heightAttr) : 200;
+ System.out.println("fetchting & building gadget: " + url.toString() + " took: " + NumberFormat.getInstance().format((System.currentTimeMillis() - millis) / 1000.0));
return new GGWidgetInfo(title, directoryTitle, description, width, height, prefsInfo);
}
else
@@ -314,7 +311,7 @@
private LocalizedString resolveLocalizedStringValue(String value, Map bundle)
{
- if (value != null)
+ if(value != null)
{
if (value.startsWith("__MSG_"))
{
@@ -337,7 +334,7 @@
{
LocalizedString out = resolveLocalizedStringValue(value, bundle);
- if (out != null)
+ if (out != null && !"".equals(out.getDefaultString()))
{
return out.getDefaultString();
}
@@ -347,13 +344,18 @@
}
- /** needed for testing */
+
+ /**
+ * needed for testing
+ */
protected byte[] obtainWidget(URL url) throws Exception
{
return obtainURL(url);
}
- /** needed for testing */
+ /**
+ * needed for testing
+ */
protected byte[] obtainLocaleBundle(URL url) throws Exception
{
return obtainURL(url);
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetMapEntry.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetMapEntry.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetMapEntry.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.google.provider;
+
+import java.net.URL;
+import java.util.concurrent.Callable;
+
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.google.GGWidget;
+import org.jboss.portal.widget.google.info.GGWidgetInfo;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class GGWidgetMapEntry implements Callable<Widget>
+{
+ /** The widget URL */
+ public final URL url;
+
+ public GGWidgetMapEntry(URL url)
+ {
+ this.url = url;
+ }
+
+ public Widget call() throws Exception
+ {
+ GGWidgetInfoBuilder builder = new GGWidgetInfoBuilder(url);
+ try
+ {
+ GGWidgetInfo info = builder.create();
+ if (info != null)
+ {
+ // expires
+ return new GGWidget(url, info);
+ }
+ else
+ {
+ // expires
+ return null;
+ }
+ }
+ catch (Exception e)
+ {
+ // logging && expiration
+ return null;
+ }
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesMetaData.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesMetaData.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesMetaData.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesMetaData
+{
+
+ /** The author */
+ private String author;
+
+ /** The website */
+ private String website;
+
+ /** The description */
+ private LocalizedString description;
+
+ /** The version */
+ private String version;
+
+ /** The keywords */
+ private String keywords;
+
+ /** The screenshot */
+ private String screenshot;
+
+ /** The thumbnail */
+ private String thumbnail;
+
+ /** The apiVersion */
+ private String apiVersion;
+
+ /** The debug mode */
+ private boolean debugMode;
+
+ /** autoRefresh */
+ private int autoRefresh;
+
+ /** The inline (deprecated) */
+ private boolean inline;
+
+ public NetvibesMetaData(
+ String author,
+ String website,
+ LocalizedString description,
+ String version,
+ String keywords,
+ String screenshot,
+ String thumbnail,
+ String apiVersion,
+ boolean debugMode,
+ int autoRefresh,
+ boolean inline)
+ {
+ this.author = author;
+ this.website = website;
+ this.description = description;
+ this.version = version;
+ this.keywords = keywords;
+ this.screenshot = screenshot;
+ this.thumbnail = thumbnail;
+ this.apiVersion = apiVersion;
+ this.debugMode = debugMode;
+ this.autoRefresh = autoRefresh;
+ this.inline = inline;
+ }
+
+
+ public String getAuthor()
+ {
+ return author;
+ }
+
+ public String getWebsite()
+ {
+ return website;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public String getKeywords()
+ {
+ return keywords;
+ }
+
+ public String getScreenshot()
+ {
+ return screenshot;
+ }
+
+ public String getThumbnail()
+ {
+ return thumbnail;
+ }
+
+ public String getApiVersion()
+ {
+ return apiVersion;
+ }
+
+ public boolean isDebugMode()
+ {
+ return debugMode;
+ }
+
+ public int getAutoRefresh()
+ {
+ return autoRefresh;
+ }
+
+ public boolean isInline()
+ {
+ return inline;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferenceInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferenceInfo.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferenceInfo.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import org.jboss.portal.widget.netvibes.type.NVDataType;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesPreferenceInfo
+{
+
+ /** The preference name */
+ private String name;
+
+ /** The preference label */
+ private String label;
+
+ /** The preference type */
+ private NVDataType type;
+
+ /** The onChange JavaScript callback */
+ private String onChange;
+
+ /** The preference default value */
+ private String defaultValue;
+
+ public NetvibesPreferenceInfo(
+ String name,
+ String label,
+ NVDataType type,
+ String onChange,
+ String defaultValue)
+ {
+ this.name = name;
+ this.label = label;
+ this.type = type;
+ this.onChange = onChange;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public NVDataType getType()
+ {
+ return type;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getOnChange()
+ {
+ return onChange;
+ }
+
+ public String getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferencesInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferencesInfo.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesPreferencesInfo.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesPreferencesInfo
+{
+
+ /** The preferences */
+ private Map<String, NetvibesPreferenceInfo> preferences;
+
+ public NetvibesPreferencesInfo(Collection<NetvibesPreferenceInfo> preferences)
+ {
+ if ( preferences == null)
+ {
+ throw new IllegalArgumentException("Preferences must not be null.");
+ }
+ this.preferences = new HashMap<String, NetvibesPreferenceInfo>();
+ for(NetvibesPreferenceInfo preference : preferences)
+ {
+ this.preferences.put(preference.getName(), preference);
+ }
+ }
+
+ public Collection<String> getPreferences()
+ {
+ return this.preferences == null ? Collections.EMPTY_SET : this.preferences.keySet();
+ }
+
+ public NetvibesPreferenceInfo getPreference(String key)
+ {
+ if ( key == null)
+ {
+ throw new IllegalArgumentException("Preference key must not be null.");
+ }
+ return this.preferences == null ? null : (NetvibesPreferenceInfo) this.preferences.get(key);
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidget.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidget.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidget.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,143 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.UUIDGenerator;
+import org.jboss.portal.widget.Widget;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesWidget implements Widget
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** The Widget url */
+ private final URL url;
+
+ /** The Widget id */
+ private final String id;
+
+ /** The default widget height */
+ private final static String defaultHeight = "200";
+
+ /** The netvibes widget info */
+ private final NetvibesWidgetInfo widgetInfo;
+
+ public NetvibesWidget(
+ URL url,
+ NetvibesWidgetInfo widgetInfo )
+ {
+ this.url = url;
+ this.id = url.toString();
+ this.widgetInfo = widgetInfo;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return this.widgetInfo.getMetaData().getDescription();
+ }
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public LocalizedString getTitle()
+ {
+ return this.widgetInfo.getTitle();
+ }
+
+ public NetvibesWidgetInfo getWidgetInfo()
+ {
+ return widgetInfo;
+ }
+
+ public String render(Map parameters)
+ {
+ return render(parameters, null);
+ }
+
+ public String render(Map parameters, Locale locale)
+ {
+ NetvibesWidgetInfo widgetInfo = getWidgetInfo();
+ if (widgetInfo != null)
+ {
+ String id = generator.generateKey();
+
+ String tempHeight = null;
+
+ StringBuffer frameUrl = new StringBuffer();
+ frameUrl.append("http://www.netvibes.com/api/uwa/frame/uwa_generic.php?id="+ id);
+ frameUrl.append("&moduleUrl="+ FastURLEncoder.getUTF8Instance().encode(url.toString()));
+
+ if ( parameters.size() > 0 )
+ {
+ NetvibesPreferencesInfo preferences = widgetInfo.getPreferencesInfo();
+ for(Iterator i = preferences.getPreferences().iterator(); i.hasNext();)
+ {
+ NetvibesPreferenceInfo info = preferences.getPreference((String) i.next());
+ String name = info.getName();
+ String[] values = (String[]) parameters.get(name);
+ String value = values != null ? values[0] : info.getDefaultValue();
+ if (value != null)
+ {
+ int index = name.toLowerCase().indexOf("height");
+ // for now getting height information like this, because there is no other implementation
+ if (index != -1)
+ {
+ tempHeight = value;
+ }
+ frameUrl.append("&" + FastURLEncoder.getUTF8Instance().encode(name) + "=" + FastURLEncoder.getUTF8Instance().encode(value));
+ }
+ }
+ }
+
+ String actualHeight = tempHeight != null ? tempHeight : defaultHeight;
+
+ StringBuffer output = new StringBuffer();
+ output.append("<iframe id=\"frame_"+ id +"\" frameborder=\"0\" width=\"100%\" height=\""+ actualHeight +"\" ");
+ output.append("src=\"");
+ output.append(frameUrl);
+ output.append("\"></iframe>");
+
+ return output.toString();
+ }
+ else
+ {
+ return "Error";
+ }
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetInfo.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetInfo.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesWidgetInfo
+{
+
+ /** The Widget title */
+ private LocalizedString title;
+
+ /** private List icons */
+ private List icons;
+
+ /** The widget metadata */
+ private NetvibesMetaData metaData;
+
+ /** The widget preferences */
+ private NetvibesPreferencesInfo preferencesInfo;
+
+ public NetvibesWidgetInfo(
+ LocalizedString title,
+ List icons,
+ NetvibesMetaData meta,
+ NetvibesPreferencesInfo preferences)
+ {
+ this.metaData = meta;
+ this.preferencesInfo = preferences;
+ this.title = title;
+ this.icons = icons;
+ }
+
+ public NetvibesMetaData getMetaData()
+ {
+ return this.metaData;
+ }
+
+ public NetvibesPreferencesInfo getPreferencesInfo()
+ {
+ return this.preferencesInfo;
+ }
+
+ public LocalizedString getTitle()
+ {
+ return title;
+ }
+
+ public List getIcons()
+ {
+ return icons;
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.netvibes.provider.NetvibesProvider;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesWidgetPortlet extends GenericPortlet
+{
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(NetvibesWidgetPortlet.class);
+
+ /** . */
+ public final static String INIT_PARAM_CONNECTION_TIMEOUT = "connectionTimeout";
+
+ /** . */
+ private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
+
+ /** . */
+ private NetvibesProvider provider = new NetvibesProvider();
+
+
+ public void init() throws PortletException
+ {
+ provider.start();
+ String timeout = getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
+ if (timeout != null && timeout.length() > 0)
+ {
+ try
+ {
+ provider.setConnectionTimeout(Integer.parseInt(timeout));
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("Failed to parse connectionTimeout init parameter - should be integer number: ", e);
+ }
+ }
+ }
+
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (req.getParameter("content.action.select") != null)
+ {
+ String contentURI = req.getParameter("content.uri");
+ if (contentURI != null)
+ {
+ // Will contain the next render params
+ Map params = new HashMap();
+
+ //
+ params.put("content.uri", new String[]{contentURI});
+
+ //
+ for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String contentParamName = (String)entry.getKey();
+ if (contentParamName.startsWith("content.param"))
+ {
+ String[] contentParamValue = (String[])entry.getValue();
+ params.put(contentParamName, contentParamValue);
+ }
+ }
+
+ //
+ String catParam = req.getParameter("cat");
+ if (catParam != null)
+ {
+ params.put("cat", new String[]{catParam});
+ }
+
+ //
+ String queryParam = req.getParameter("query");
+ if (queryParam != null)
+ {
+ params.put("query", new String[]{queryParam});
+ }
+
+ String pickMethod = req.getParameter("gg_pick_method");
+ if (pickMethod != null)
+ {
+ params.put("gg_pick_method", new String[]{pickMethod});
+ }
+
+ //
+ resp.setRenderParameters(params);
+ }
+ }
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ String uri = req.getParameter("uri");
+ Widget widget = provider.getWidget(uri);
+ if (widget != null)
+ {
+ writer.print(widget.render(req.getParameterMap(), req.getLocale()));
+ }
+ else
+ {
+ writer.print("Widget is not available");
+ }
+ writer.close();
+ }
+
+
+ protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
+ {
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+ }
+
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+
+ //
+ req.setAttribute("provider", provider);
+
+ //
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit_content.jsp");
+ dispatcher.include(req, resp);
+ }
+
+ public void destroy()
+ {
+ provider.stop();
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONArray.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONArray.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONArray.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,889 @@
+package org.jboss.portal.widget.netvibes.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * A JSONArray is an ordered sequence of values. Its external text form is a
+ * string wrapped in square brackets with commas separating the values. The
+ * internal form is an object having <code>get</code> and <code>opt</code>
+ * methods for accessing the values by index, and <code>put</code> methods for
+ * adding or replacing values. The values can be any of these types:
+ * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
+ * <code>Number</code>, <code>String</code>, or the
+ * <code>JSONObject.NULL object</code>.
+ * <p>
+ * The constructor can convert a JSON text into a Java object. The
+ * <code>toString</code> method converts to JSON text.
+ * <p>
+ * A <code>get</code> method returns a value if one can be found, and throws an
+ * exception if one cannot be found. An <code>opt</code> method returns a
+ * default value instead of throwing an exception, and so is useful for
+ * obtaining optional values.
+ * <p>
+ * The generic <code>get()</code> and <code>opt()</code> methods return an
+ * object which you can cast or query for type. There are also typed
+ * <code>get</code> and <code>opt</code> methods that do type checking and type
+ * coersion for you.
+ * <p>
+ * The texts produced by the <code>toString</code> methods strictly conform to
+ * JSON syntax rules. The constructors are more forgiving in the texts they will
+ * accept:
+ * <ul>
+ * <li>An extra <code>,</code> <small>(comma)</small> may appear just
+ * before the closing bracket.</li>
+ * <li>The <code>null</code> value will be inserted when there
+ * is <code>,</code> <small>(comma)</small> elision.</li>
+ * <li>Strings may be quoted with <code>'</code> <small>(single
+ * quote)</small>.</li>
+ * <li>Strings do not need to be quoted at all if they do not begin with a quote
+ * or single quote, and if they do not contain leading or trailing spaces,
+ * and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
+ * and if they are not the reserved words <code>true</code>,
+ * <code>false</code>, or <code>null</code>.</li>
+ * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
+ * well as by <code>,</code> <small>(comma)</small>.</li>
+ * <li>Numbers may have the <code>0-</code> <small>(octal)</small> or
+ * <code>0x-</code> <small>(hex)</small> prefix.</li>
+ * <li>Comments written in the slashshlash, slashstar, and hash conventions
+ * will be ignored.</li>
+ * </ul>
+
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONArray {
+
+
+ /**
+ * The arrayList where the JSONArray's properties are kept.
+ */
+ private ArrayList myArrayList;
+
+
+ /**
+ * Construct an empty JSONArray.
+ */
+ public JSONArray() {
+ this.myArrayList = new ArrayList();
+ }
+
+ /**
+ * Construct a JSONArray from a JSONTokener.
+ * @param x A JSONTokener
+ * @throws JSONException If there is a syntax error.
+ */
+ public JSONArray(JSONTokener x) throws JSONException {
+ this();
+ if (x.nextClean() != '[') {
+ throw x.syntaxError("A JSONArray text must start with '['");
+ }
+ if (x.nextClean() == ']') {
+ return;
+ }
+ x.back();
+ for (;;) {
+ if (x.nextClean() == ',') {
+ x.back();
+ this.myArrayList.add(null);
+ } else {
+ x.back();
+ this.myArrayList.add(x.nextValue());
+ }
+ switch (x.nextClean()) {
+ case ';':
+ case ',':
+ if (x.nextClean() == ']') {
+ return;
+ }
+ x.back();
+ break;
+ case ']':
+ return;
+ default:
+ throw x.syntaxError("Expected a ',' or ']'");
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONArray from a source JSON text.
+ * @param source A string that begins with
+ * <code>[</code> <small>(left bracket)</small>
+ * and ends with <code>]</code> <small>(right bracket)</small>.
+ * @throws JSONException If there is a syntax error.
+ */
+ public JSONArray(String source) throws JSONException {
+ this(new JSONTokener(source));
+ }
+
+
+ /**
+ * Construct a JSONArray from a Collection.
+ * @param collection A Collection.
+ */
+ public JSONArray(Collection collection) {
+ this.myArrayList = (collection == null) ?
+ new ArrayList() :
+ new ArrayList(collection);
+ }
+
+
+ /**
+ * Construct a JSONArray from an array
+ * @throws JSONException If not an array.
+ */
+ public JSONArray(Object array) throws JSONException {
+ this();
+ if (array.getClass().isArray()) {
+ int length = Array.getLength(array);
+ for (int i = 0; i < length; i += 1) {
+ this.put(Array.get(array, i));
+ }
+ } else {
+ throw new JSONException("JSONArray initial value should be a string or collection or array.");
+ }
+ }
+
+
+ /**
+ * Get the object value associated with an index.
+ * @param index
+ * The index must be between 0 and length() - 1.
+ * @return An object value.
+ * @throws JSONException If there is no value for the index.
+ */
+ public Object get(int index) throws JSONException {
+ Object o = opt(index);
+ if (o == null) {
+ throw new JSONException("JSONArray[" + index + "] not found.");
+ }
+ return o;
+ }
+
+
+ /**
+ * Get the boolean value associated with an index.
+ * The string values "true" and "false" are converted to boolean.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The truth.
+ * @throws JSONException If there is no value for the index or if the
+ * value is not convertable to boolean.
+ */
+ public boolean getBoolean(int index) throws JSONException {
+ Object o = get(index);
+ if (o.equals(Boolean.FALSE) ||
+ (o instanceof String &&
+ ((String)o).equalsIgnoreCase("false"))) {
+ return false;
+ } else if (o.equals(Boolean.TRUE) ||
+ (o instanceof String &&
+ ((String)o).equalsIgnoreCase("true"))) {
+ return true;
+ }
+ throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
+ }
+
+
+ /**
+ * Get the double value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ */
+ public double getDouble(int index) throws JSONException {
+ Object o = get(index);
+ try {
+ return o instanceof Number ?
+ ((Number)o).doubleValue() :
+ Double.valueOf((String)o).doubleValue();
+ } catch (Exception e) {
+ throw new JSONException("JSONArray[" + index +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the int value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ * if the value cannot be converted to a number.
+ */
+ public int getInt(int index) throws JSONException {
+ Object o = get(index);
+ return o instanceof Number ?
+ ((Number)o).intValue() : (int)getDouble(index);
+ }
+
+
+ /**
+ * Get the JSONArray associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return A JSONArray value.
+ * @throws JSONException If there is no value for the index. or if the
+ * value is not a JSONArray
+ */
+ public JSONArray getJSONArray(int index) throws JSONException {
+ Object o = get(index);
+ if (o instanceof JSONArray) {
+ return (JSONArray)o;
+ }
+ throw new JSONException("JSONArray[" + index +
+ "] is not a JSONArray.");
+ }
+
+
+ /**
+ * Get the JSONObject associated with an index.
+ * @param index subscript
+ * @return A JSONObject value.
+ * @throws JSONException If there is no value for the index or if the
+ * value is not a JSONObject
+ */
+ public JSONObject getJSONObject(int index) throws JSONException {
+ Object o = get(index);
+ if (o instanceof JSONObject) {
+ return (JSONObject)o;
+ }
+ throw new JSONException("JSONArray[" + index +
+ "] is not a JSONObject.");
+ }
+
+
+ /**
+ * Get the long value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ */
+ public long getLong(int index) throws JSONException {
+ Object o = get(index);
+ return o instanceof Number ?
+ ((Number)o).longValue() : (long)getDouble(index);
+ }
+
+
+ /**
+ * Get the string associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return A string value.
+ * @throws JSONException If there is no value for the index.
+ */
+ public String getString(int index) throws JSONException {
+ return get(index).toString();
+ }
+
+
+ /**
+ * Determine if the value is null.
+ * @param index The index must be between 0 and length() - 1.
+ * @return true if the value at the index is null, or if there is no value.
+ */
+ public boolean isNull(int index) {
+ return JSONObject.NULL.equals(opt(index));
+ }
+
+
+ /**
+ * Make a string from the contents of this JSONArray. The
+ * <code>separator</code> string is inserted between each element.
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param separator A string that will be inserted between the elements.
+ * @return a string.
+ * @throws JSONException If the array contains an invalid number.
+ */
+ public String join(String separator) throws JSONException {
+ int len = length();
+ StringBuffer sb = new StringBuffer();
+
+ for (int i = 0; i < len; i += 1) {
+ if (i > 0) {
+ sb.append(separator);
+ }
+ sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
+ }
+ return sb.toString();
+ }
+
+
+ /**
+ * Get the number of elements in the JSONArray, included nulls.
+ *
+ * @return The length (or size).
+ */
+ public int length() {
+ return this.myArrayList.size();
+ }
+
+
+ /**
+ * Get the optional object value associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return An object value, or null if there is no
+ * object at that index.
+ */
+ public Object opt(int index) {
+ return (index < 0 || index >= length()) ?
+ null : this.myArrayList.get(index);
+ }
+
+
+ /**
+ * Get the optional boolean value associated with an index.
+ * It returns false if there is no value at that index,
+ * or if the value is not Boolean.TRUE or the String "true".
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The truth.
+ */
+ public boolean optBoolean(int index) {
+ return optBoolean(index, false);
+ }
+
+
+ /**
+ * Get the optional boolean value associated with an index.
+ * It returns the defaultValue if there is no value at that index or if
+ * it is not a Boolean or the String "true" or "false" (case insensitive).
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue A boolean default.
+ * @return The truth.
+ */
+ public boolean optBoolean(int index, boolean defaultValue) {
+ try {
+ return getBoolean(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional double value associated with an index.
+ * NaN is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public double optDouble(int index) {
+ return optDouble(index, Double.NaN);
+ }
+
+
+ /**
+ * Get the optional double value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index subscript
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public double optDouble(int index, double defaultValue) {
+ try {
+ return getDouble(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional int value associated with an index.
+ * Zero is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public int optInt(int index) {
+ return optInt(index, 0);
+ }
+
+
+ /**
+ * Get the optional int value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public int optInt(int index, int defaultValue) {
+ try {
+ return getInt(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional JSONArray associated with an index.
+ * @param index subscript
+ * @return A JSONArray value, or null if the index has no value,
+ * or if the value is not a JSONArray.
+ */
+ public JSONArray optJSONArray(int index) {
+ Object o = opt(index);
+ return o instanceof JSONArray ? (JSONArray)o : null;
+ }
+
+
+ /**
+ * Get the optional JSONObject associated with an index.
+ * Null is returned if the key is not found, or null if the index has
+ * no value, or if the value is not a JSONObject.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return A JSONObject value.
+ */
+ public JSONObject optJSONObject(int index) {
+ Object o = opt(index);
+ return o instanceof JSONObject ? (JSONObject)o : null;
+ }
+
+
+ /**
+ * Get the optional long value associated with an index.
+ * Zero is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public long optLong(int index) {
+ return optLong(index, 0);
+ }
+
+
+ /**
+ * Get the optional long value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public long optLong(int index, long defaultValue) {
+ try {
+ return getLong(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional string value associated with an index. It returns an
+ * empty string if there is no value at that index. If the value
+ * is not a string and is not null, then it is coverted to a string.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return A String value.
+ */
+ public String optString(int index) {
+ return optString(index, "");
+ }
+
+
+ /**
+ * Get the optional string associated with an index.
+ * The defaultValue is returned if the key is not found.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return A String value.
+ */
+ public String optString(int index, String defaultValue) {
+ Object o = opt(index);
+ return o != null ? o.toString() : defaultValue;
+ }
+
+
+ /**
+ * Append a boolean value. This increases the array's length by one.
+ *
+ * @param value A boolean value.
+ * @return this.
+ */
+ public JSONArray put(boolean value) {
+ put(value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param value A Collection value.
+ * @return this.
+ */
+ public JSONArray put(Collection value) {
+ put(new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Append a double value. This increases the array's length by one.
+ *
+ * @param value A double value.
+ * @throws JSONException if the value is not finite.
+ * @return this.
+ */
+ public JSONArray put(double value) throws JSONException {
+ Double d = new Double(value);
+ JSONObject.testValidity(d);
+ put(d);
+ return this;
+ }
+
+
+ /**
+ * Append an int value. This increases the array's length by one.
+ *
+ * @param value An int value.
+ * @return this.
+ */
+ public JSONArray put(int value) {
+ put(new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Append an long value. This increases the array's length by one.
+ *
+ * @param value A long value.
+ * @return this.
+ */
+ public JSONArray put(long value) {
+ put(new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONObject which is produced from a Map.
+ * @param value A Map value.
+ * @return this.
+ */
+ public JSONArray put(Map value) {
+ put(new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Append an object value. This increases the array's length by one.
+ * @param value An object value. The value should be a
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+ * JSONObject.NULL object.
+ * @return this.
+ */
+ public JSONArray put(Object value) {
+ this.myArrayList.add(value);
+ return this;
+ }
+
+
+ /**
+ * Put or replace a boolean value in the JSONArray. If the index is greater
+ * than the length of the JSONArray, then null elements will be added as
+ * necessary to pad it out.
+ * @param index The subscript.
+ * @param value A boolean value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, boolean value) throws JSONException {
+ put(index, value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param index The subscript.
+ * @param value A Collection value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the value is
+ * not finite.
+ */
+ public JSONArray put(int index, Collection value) throws JSONException {
+ put(index, new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace a double value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value A double value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the value is
+ * not finite.
+ */
+ public JSONArray put(int index, double value) throws JSONException {
+ put(index, new Double(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace an int value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value An int value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, int value) throws JSONException {
+ put(index, new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace a long value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value A long value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, long value) throws JSONException {
+ put(index, new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONObject which is produced from a Map.
+ * @param index The subscript.
+ * @param value The Map value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the the value is
+ * an invalid number.
+ */
+ public JSONArray put(int index, Map value) throws JSONException {
+ put(index, new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace an object value in the JSONArray. If the index is greater
+ * than the length of the JSONArray, then null elements will be added as
+ * necessary to pad it out.
+ * @param index The subscript.
+ * @param value The value to put into the array. The value should be a
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+ * JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the index is negative or if the the value is
+ * an invalid number.
+ */
+ public JSONArray put(int index, Object value) throws JSONException {
+ JSONObject.testValidity(value);
+ if (index < 0) {
+ throw new JSONException("JSONArray[" + index + "] not found.");
+ }
+ if (index < length()) {
+ this.myArrayList.set(index, value);
+ } else {
+ while (index != length()) {
+ put(JSONObject.NULL);
+ }
+ put(value);
+ }
+ return this;
+ }
+
+
+ /**
+ * Produce a JSONObject by combining a JSONArray of names with the values
+ * of this JSONArray.
+ * @param names A JSONArray containing a list of key strings. These will be
+ * paired with the values.
+ * @return A JSONObject, or null if there are no names or if this JSONArray
+ * has no values.
+ * @throws JSONException If any of the names are null.
+ */
+ public JSONObject toJSONObject(JSONArray names) throws JSONException {
+ if (names == null || names.length() == 0 || length() == 0) {
+ return null;
+ }
+ JSONObject jo = new JSONObject();
+ for (int i = 0; i < names.length(); i += 1) {
+ jo.put(names.getString(i), this.opt(i));
+ }
+ return jo;
+ }
+
+
+ /**
+ * Make a JSON text of this JSONArray. For compactness, no
+ * unnecessary whitespace is added. If it is not possible to produce a
+ * syntactically correct JSON text then null will be returned instead. This
+ * could occur if the array contains an invalid number.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return a printable, displayable, transmittable
+ * representation of the array.
+ */
+ public String toString() {
+ try {
+ return '[' + join(",") + ']';
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONArray.
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>[</code> <small>(left bracket)</small> and ending
+ * with <code>]</code> <small>(right bracket)</small>.
+ * @throws JSONException
+ */
+ public String toString(int indentFactor) throws JSONException {
+ return toString(indentFactor, 0);
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONArray.
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @param indent The indention of the top level.
+ * @return a printable, displayable, transmittable
+ * representation of the array.
+ * @throws JSONException
+ */
+ String toString(int indentFactor, int indent) throws JSONException {
+ int len = length();
+ if (len == 0) {
+ return "[]";
+ }
+ int i;
+ StringBuffer sb = new StringBuffer("[");
+ if (len == 1) {
+ sb.append(JSONObject.valueToString(this.myArrayList.get(0),
+ indentFactor, indent));
+ } else {
+ int newindent = indent + indentFactor;
+ sb.append('\n');
+ for (i = 0; i < len; i += 1) {
+ if (i > 0) {
+ sb.append(",\n");
+ }
+ for (int j = 0; j < newindent; j += 1) {
+ sb.append(' ');
+ }
+ sb.append(JSONObject.valueToString(this.myArrayList.get(i),
+ indentFactor, newindent));
+ }
+ sb.append('\n');
+ for (i = 0; i < indent; i += 1) {
+ sb.append(' ');
+ }
+ }
+ sb.append(']');
+ return sb.toString();
+ }
+
+
+ /**
+ * Write the contents of the JSONArray as JSON text to a writer.
+ * For compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return The writer.
+ * @throws JSONException
+ */
+ public Writer write(Writer writer) throws JSONException {
+ try {
+ boolean b = false;
+ int len = length();
+
+ writer.write('[');
+
+ for (int i = 0; i < len; i += 1) {
+ if (b) {
+ writer.write(',');
+ }
+ Object v = this.myArrayList.get(i);
+ if (v instanceof JSONObject) {
+ ((JSONObject)v).write(writer);
+ } else if (v instanceof JSONArray) {
+ ((JSONArray)v).write(writer);
+ } else {
+ writer.write(JSONObject.valueToString(v));
+ }
+ b = true;
+ }
+ writer.write(']');
+ return writer;
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ }
+}
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONException.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONException.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONException.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,27 @@
+package org.jboss.portal.widget.netvibes.json;
+
+/**
+ * The JSONException is thrown by the JSON.org classes then things are amiss.
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONException extends Exception {
+ private Throwable cause;
+
+ /**
+ * Constructs a JSONException with an explanatory message.
+ * @param message Detail about the reason for the exception.
+ */
+ public JSONException(String message) {
+ super(message);
+ }
+
+ public JSONException(Throwable t) {
+ super(t.getMessage());
+ this.cause = t;
+ }
+
+ public Throwable getCause() {
+ return this.cause;
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObject.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObject.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObject.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,1380 @@
+package org.jboss.portal.widget.netvibes.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A JSONObject is an unordered collection of name/value pairs. Its
+ * external form is a string wrapped in curly braces with colons between the
+ * names and values, and commas between the values and names. The internal form
+ * is an object having <code>get</code> and <code>opt</code> methods for
+ * accessing the values by name, and <code>put</code> methods for adding or
+ * replacing values by name. The values can be any of these types:
+ * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
+ * <code>Number</code>, <code>String</code>, or the <code>JSONObject.NULL</code>
+ * object. A JSONObject constructor can be used to convert an external form
+ * JSON text into an internal form whose values can be retrieved with the
+ * <code>get</code> and <code>opt</code> methods, or to convert values into a
+ * JSON text using the <code>put</code> and <code>toString</code> methods.
+ * A <code>get</code> method returns a value if one can be found, and throws an
+ * exception if one cannot be found. An <code>opt</code> method returns a
+ * default value instead of throwing an exception, and so is useful for
+ * obtaining optional values.
+ * <p>
+ * The generic <code>get()</code> and <code>opt()</code> methods return an
+ * object, which you can cast or query for type. There are also typed
+ * <code>get</code> and <code>opt</code> methods that do type checking and type
+ * coersion for you.
+ * <p>
+ * The <code>put</code> methods adds values to an object. For example, <pre>
+ * myString = new JSONObject().put("JSON", "Hello, World!").toString();</pre>
+ * produces the string <code>{"JSON": "Hello, World"}</code>.
+ * <p>
+ * The texts produced by the <code>toString</code> methods strictly conform to
+ * the JSON sysntax rules.
+ * The constructors are more forgiving in the texts they will accept:
+ * <ul>
+ * <li>An extra <code>,</code> <small>(comma)</small> may appear just
+ * before the closing brace.</li>
+ * <li>Strings may be quoted with <code>'</code> <small>(single
+ * quote)</small>.</li>
+ * <li>Strings do not need to be quoted at all if they do not begin with a quote
+ * or single quote, and if they do not contain leading or trailing spaces,
+ * and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
+ * and if they are not the reserved words <code>true</code>,
+ * <code>false</code>, or <code>null</code>.</li>
+ * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as
+ * by <code>:</code>.</li>
+ * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as
+ * well as by <code>,</code> <small>(comma)</small>.</li>
+ * <li>Numbers may have the <code>0-</code> <small>(octal)</small> or
+ * <code>0x-</code> <small>(hex)</small> prefix.</li>
+ * <li>Comments written in the slashshlash, slashstar, and hash conventions
+ * will be ignored.</li>
+ * </ul>
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONObject {
+
+ /**
+ * JSONObject.NULL is equivalent to the value that JavaScript calls null,
+ * whilst Java's null is equivalent to the value that JavaScript calls
+ * undefined.
+ */
+ private static final class Null {
+
+ /**
+ * There is only intended to be a single instance of the NULL object,
+ * so the clone method returns itself.
+ * @return NULL.
+ */
+ protected final Object clone() {
+ return this;
+ }
+
+
+ /**
+ * A Null object is equal to the null value and to itself.
+ * @param object An object to test for nullness.
+ * @return true if the object parameter is the JSONObject.NULL object
+ * or null.
+ */
+ public boolean equals(Object object) {
+ return object == null || object == this;
+ }
+
+
+ /**
+ * Get the "null" string value.
+ * @return The string "null".
+ */
+ public String toString() {
+ return "null";
+ }
+ }
+
+
+ /**
+ * The hash map where the JSONObject's properties are kept.
+ */
+ private HashMap myHashMap;
+
+
+ /**
+ * It is sometimes more convenient and less ambiguous to have a
+ * <code>NULL</code> object than to use Java's <code>null</code> value.
+ * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
+ * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
+ */
+ public static final Object NULL = new Null();
+
+
+ /**
+ * Construct an empty JSONObject.
+ */
+ public JSONObject() {
+ this.myHashMap = new HashMap();
+ }
+
+
+ /**
+ * Construct a JSONObject from a subset of another JSONObject.
+ * An array of strings is used to identify the keys that should be copied.
+ * Missing keys are ignored.
+ * @param jo A JSONObject.
+ * @param names An array of strings.
+ * @exception JSONException If a value is a non-finite number.
+ */
+ public JSONObject(JSONObject jo, String[] names) throws JSONException {
+ this();
+ for (int i = 0; i < names.length; i += 1) {
+ putOpt(names[i], jo.opt(names[i]));
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a JSONTokener.
+ * @param x A JSONTokener object containing the source string.
+ * @throws JSONException If there is a syntax error in the source string.
+ */
+ public JSONObject(JSONTokener x) throws JSONException {
+ this();
+ char c;
+ String key;
+
+ if (x.nextClean() != '{') {
+ throw x.syntaxError("A JSONObject text must begin with '{'");
+ }
+ for (;;) {
+ c = x.nextClean();
+ switch (c) {
+ case 0:
+ throw x.syntaxError("A JSONObject text must end with '}'");
+ case '}':
+ return;
+ default:
+ x.back();
+ key = x.nextValue().toString();
+ }
+
+ /*
+ * The key is followed by ':'. We will also tolerate '=' or '=>'.
+ */
+
+ c = x.nextClean();
+ if (c == '=') {
+ if (x.next() != '>') {
+ x.back();
+ }
+ } else if (c != ':') {
+ throw x.syntaxError("Expected a ':' after a key");
+ }
+ put(key, x.nextValue());
+
+ /*
+ * Pairs are separated by ','. We will also tolerate ';'.
+ */
+
+ switch (x.nextClean()) {
+ case ';':
+ case ',':
+ if (x.nextClean() == '}') {
+ return;
+ }
+ x.back();
+ break;
+ case '}':
+ return;
+ default:
+ throw x.syntaxError("Expected a ',' or '}'");
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a Map.
+ * @param map A map object that can be used to initialize the contents of
+ * the JSONObject.
+ */
+ public JSONObject(Map map) {
+ this.myHashMap = (map == null) ?
+ new HashMap() :
+ new HashMap(map);
+ }
+
+
+ /**
+ * Construct a JSONObject from an Object using bean getters.
+ * It reflects on all of the public methods of the object.
+ * For each of the methods with no parameters and a name starting
+ * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
+ * the method is invoked, and a key and the value returned from the getter method
+ * are put into the new JSONObject.
+ *
+ * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the second remaining
+ * character is not upper case, then the first
+ * character is converted to lower case.
+ *
+ * For example, if an object has a method named <code>"getName"</code>, and
+ * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
+ * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
+ *
+ * @param bean An object that has getter methods that should be used
+ * to make a JSONObject.
+ */
+ public JSONObject(Object bean) {
+ this();
+ Class klass = bean.getClass();
+ Method[] methods = klass.getMethods();
+ for (int i = 0; i < methods.length; i += 1) {
+ try {
+ Method method = methods[i];
+ String name = method.getName();
+ String key = "";
+ if (name.startsWith("get")) {
+ key = name.substring(3);
+ } else if (name.startsWith("is")) {
+ key = name.substring(2);
+ }
+ if (key.length() > 0 &&
+ Character.isUpperCase(key.charAt(0)) &&
+ method.getParameterTypes().length == 0) {
+ if (key.length() == 1) {
+ key = key.toLowerCase();
+ } else if (!Character.isUpperCase(key.charAt(1))) {
+ key = key.substring(0, 1).toLowerCase() +
+ key.substring(1);
+ }
+ this.put(key, method.invoke(bean, null));
+ }
+ } catch (Exception e) {
+ /* forget about it */
+ }
+ }
+ }
+
+ /**
+ * Construct a JSONObject from an Object, using reflection to find the
+ * public members. The resulting JSONObject's keys will be the strings
+ * from the names array, and the values will be the field values associated
+ * with those keys in the object. If a key is not found or not visible,
+ * then it will not be copied into the new JSONObject.
+ * @param object An object that has fields that should be used to make a
+ * JSONObject.
+ * @param names An array of strings, the names of the fields to be obtained
+ * from the object.
+ */
+ public JSONObject(Object object, String names[]) {
+ this();
+ Class c = object.getClass();
+ for (int i = 0; i < names.length; i += 1) {
+ String name = names[i];
+ try {
+ Field field = c.getField(name);
+ Object value = field.get(object);
+ this.put(name, value);
+ } catch (Exception e) {
+ /* forget about it */
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a source JSON text string.
+ * This is the most commonly used JSONObject constructor.
+ * @param source A string beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @exception JSONException If there is a syntax error in the source string.
+ */
+ public JSONObject(String source) throws JSONException {
+ this(new JSONTokener(source));
+ }
+
+
+ /**
+ * Accumulate values under a key. It is similar to the put method except
+ * that if there is already an object stored under the key then a
+ * JSONArray is stored under the key to hold all of the accumulated values.
+ * If there is already a JSONArray, then the new value is appended to it.
+ * In contrast, the put method replaces the previous value.
+ * @param key A key string.
+ * @param value An object to be accumulated under the key.
+ * @return this.
+ * @throws JSONException If the value is an invalid number
+ * or if the key is null.
+ */
+ public JSONObject accumulate(String key, Object value)
+ throws JSONException {
+ testValidity(value);
+ Object o = opt(key);
+ if (o == null) {
+ put(key, value instanceof JSONArray ?
+ new JSONArray().put(value) :
+ value);
+ } else if (o instanceof JSONArray) {
+ ((JSONArray)o).put(value);
+ } else {
+ put(key, new JSONArray().put(o).put(value));
+ }
+ return this;
+ }
+
+
+ /**
+ * Append values to the array under a key. If the key does not exist in the
+ * JSONObject, then the key is put in the JSONObject with its value being a
+ * JSONArray containing the value parameter. If the key was already
+ * associated with a JSONArray, then the value parameter is appended to it.
+ * @param key A key string.
+ * @param value An object to be accumulated under the key.
+ * @return this.
+ * @throws JSONException If the key is null or if the current value
+ * associated with the key is not a JSONArray.
+ */
+ public JSONObject append(String key, Object value)
+ throws JSONException {
+ testValidity(value);
+ Object o = opt(key);
+ if (o == null) {
+ put(key, new JSONArray().put(value));
+ } else if (o instanceof JSONArray) {
+ put(key, ((JSONArray)o).put(value));
+ } else {
+ throw new JSONException("JSONObject[" + key +
+ "] is not a JSONArray.");
+ }
+ return this;
+ }
+
+
+ /**
+ * Produce a string from a double. The string "null" will be returned if
+ * the number is not finite.
+ * @param d A double.
+ * @return A String.
+ */
+ static public String doubleToString(double d) {
+ if (Double.isInfinite(d) || Double.isNaN(d)) {
+ return "null";
+ }
+
+// Shave off trailing zeros and decimal point, if possible.
+
+ String s = Double.toString(d);
+ if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
+ while (s.endsWith("0")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ if (s.endsWith(".")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ }
+ return s;
+ }
+
+
+ /**
+ * Get the value object associated with a key.
+ *
+ * @param key A key string.
+ * @return The object associated with the key.
+ * @throws JSONException if the key is not found.
+ */
+ public Object get(String key) throws JSONException {
+ Object o = opt(key);
+ if (o == null) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] not found.");
+ }
+ return o;
+ }
+
+
+ /**
+ * Get the boolean value associated with a key.
+ *
+ * @param key A key string.
+ * @return The truth.
+ * @throws JSONException
+ * if the value is not a Boolean or the String "true" or "false".
+ */
+ public boolean getBoolean(String key) throws JSONException {
+ Object o = get(key);
+ if (o.equals(Boolean.FALSE) ||
+ (o instanceof String &&
+ ((String)o).equalsIgnoreCase("false"))) {
+ return false;
+ } else if (o.equals(Boolean.TRUE) ||
+ (o instanceof String &&
+ ((String)o).equalsIgnoreCase("true"))) {
+ return true;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a Boolean.");
+ }
+
+
+ /**
+ * Get the double value associated with a key.
+ * @param key A key string.
+ * @return The numeric value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a Number object and cannot be converted to a number.
+ */
+ public double getDouble(String key) throws JSONException {
+ Object o = get(key);
+ try {
+ return o instanceof Number ?
+ ((Number)o).doubleValue() :
+ Double.valueOf((String)o).doubleValue();
+ } catch (Exception e) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the int value associated with a key. If the number value is too
+ * large for an int, it will be clipped.
+ *
+ * @param key A key string.
+ * @return The integer value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to an integer.
+ */
+ public int getInt(String key) throws JSONException {
+ Object o = get(key);
+ return o instanceof Number ?
+ ((Number)o).intValue() : (int)getDouble(key);
+ }
+
+
+ /**
+ * Get the JSONArray value associated with a key.
+ *
+ * @param key A key string.
+ * @return A JSONArray which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONArray.
+ */
+ public JSONArray getJSONArray(String key) throws JSONException {
+ Object o = get(key);
+ if (o instanceof JSONArray) {
+ return (JSONArray)o;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a JSONArray.");
+ }
+
+
+ /**
+ * Get the JSONObject value associated with a key.
+ *
+ * @param key A key string.
+ * @return A JSONObject which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONObject.
+ */
+ public JSONObject getJSONObject(String key) throws JSONException {
+ Object o = get(key);
+ if (o instanceof JSONObject) {
+ return (JSONObject)o;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a JSONObject.");
+ }
+
+
+ /**
+ * Get the long value associated with a key. If the number value is too
+ * long for a long, it will be clipped.
+ *
+ * @param key A key string.
+ * @return The long value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to a long.
+ */
+ public long getLong(String key) throws JSONException {
+ Object o = get(key);
+ return o instanceof Number ?
+ ((Number)o).longValue() : (long)getDouble(key);
+ }
+
+
+ /**
+ * Get an array of field names from a JSONObject.
+ *
+ * @return An array of field names, or null if there are no names.
+ */
+ public static String[] getNames(JSONObject jo) {
+ int length = jo.length();
+ if (length == 0) {
+ return null;
+ }
+ Iterator i = jo.keys();
+ String[] names = new String[length];
+ int j = 0;
+ while (i.hasNext()) {
+ names[j] = (String)i.next();
+ j += 1;
+ }
+ return names;
+ }
+
+
+ /**
+ * Get an array of field names from an Object.
+ *
+ * @return An array of field names, or null if there are no names.
+ */
+ public static String[] getNames(Object object) {
+ if (object == null) {
+ return null;
+ }
+ Class klass = object.getClass();
+ Field[] fields = klass.getFields();
+ int length = fields.length;
+ if (length == 0) {
+ return null;
+ }
+ String[] names = new String[length];
+ for (int i = 0; i < length; i += 1) {
+ names[i] = fields[i].getName();
+ }
+ return names;
+ }
+
+
+ /**
+ * Get the string associated with a key.
+ *
+ * @param key A key string.
+ * @return A string which is the value.
+ * @throws JSONException if the key is not found.
+ */
+ public String getString(String key) throws JSONException {
+ return get(key).toString();
+ }
+
+
+ /**
+ * Determine if the JSONObject contains a specific key.
+ * @param key A key string.
+ * @return true if the key exists in the JSONObject.
+ */
+ public boolean has(String key) {
+ return this.myHashMap.containsKey(key);
+ }
+
+
+ /**
+ * Determine if the value associated with the key is null or if there is
+ * no value.
+ * @param key A key string.
+ * @return true if there is no value associated with the key or if
+ * the value is the JSONObject.NULL object.
+ */
+ public boolean isNull(String key) {
+ return JSONObject.NULL.equals(opt(key));
+ }
+
+
+ /**
+ * Get an enumeration of the keys of the JSONObject.
+ *
+ * @return An iterator of the keys.
+ */
+ public Iterator keys() {
+ return this.myHashMap.keySet().iterator();
+ }
+
+
+ /**
+ * Get the number of keys stored in the JSONObject.
+ *
+ * @return The number of keys in the JSONObject.
+ */
+ public int length() {
+ return this.myHashMap.size();
+ }
+
+
+ /**
+ * Produce a JSONArray containing the names of the elements of this
+ * JSONObject.
+ * @return A JSONArray containing the key strings, or null if the JSONObject
+ * is empty.
+ */
+ public JSONArray names() {
+ JSONArray ja = new JSONArray();
+ Iterator keys = keys();
+ while (keys.hasNext()) {
+ ja.put(keys.next());
+ }
+ return ja.length() == 0 ? null : ja;
+ }
+
+ /**
+ * Produce a string from a Number.
+ * @param n A Number
+ * @return A String.
+ * @throws JSONException If n is a non-finite number.
+ */
+ static public String numberToString(Number n)
+ throws JSONException {
+ if (n == null) {
+ throw new JSONException("Null pointer");
+ }
+ testValidity(n);
+
+// Shave off trailing zeros and decimal point, if possible.
+
+ String s = n.toString();
+ if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
+ while (s.endsWith("0")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ if (s.endsWith(".")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ }
+ return s;
+ }
+
+
+ /**
+ * Get an optional value associated with a key.
+ * @param key A key string.
+ * @return An object which is the value, or null if there is no value.
+ */
+ public Object opt(String key) {
+ return key == null ? null : this.myHashMap.get(key);
+ }
+
+
+ /**
+ * Get an optional boolean associated with a key.
+ * It returns false if there is no such key, or if the value is not
+ * Boolean.TRUE or the String "true".
+ *
+ * @param key A key string.
+ * @return The truth.
+ */
+ public boolean optBoolean(String key) {
+ return optBoolean(key, false);
+ }
+
+
+ /**
+ * Get an optional boolean associated with a key.
+ * It returns the defaultValue if there is no such key, or if it is not
+ * a Boolean or the String "true" or "false" (case insensitive).
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return The truth.
+ */
+ public boolean optBoolean(String key, boolean defaultValue) {
+ try {
+ return getBoolean(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param key A key string.
+ * @param value A Collection value.
+ * @return this.
+ * @throws JSONException
+ */
+ public JSONObject put(String key, Collection value) throws JSONException {
+ put(key, new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Get an optional double associated with a key,
+ * or NaN if there is no such key or if its value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A string which is the key.
+ * @return An object which is the value.
+ */
+ public double optDouble(String key) {
+ return optDouble(key, Double.NaN);
+ }
+
+
+ /**
+ * Get an optional double associated with a key, or the
+ * defaultValue if there is no such key or if its value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public double optDouble(String key, double defaultValue) {
+ try {
+ Object o = opt(key);
+ return o instanceof Number ? ((Number)o).doubleValue() :
+ new Double((String)o).doubleValue();
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional int value associated with a key,
+ * or zero if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @return An object which is the value.
+ */
+ public int optInt(String key) {
+ return optInt(key, 0);
+ }
+
+
+ /**
+ * Get an optional int value associated with a key,
+ * or the default if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public int optInt(String key, int defaultValue) {
+ try {
+ return getInt(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional JSONArray associated with a key.
+ * It returns null if there is no such key, or if its value is not a
+ * JSONArray.
+ *
+ * @param key A key string.
+ * @return A JSONArray which is the value.
+ */
+ public JSONArray optJSONArray(String key) {
+ Object o = opt(key);
+ return o instanceof JSONArray ? (JSONArray)o : null;
+ }
+
+
+ /**
+ * Get an optional JSONObject associated with a key.
+ * It returns null if there is no such key, or if its value is not a
+ * JSONObject.
+ *
+ * @param key A key string.
+ * @return A JSONObject which is the value.
+ */
+ public JSONObject optJSONObject(String key) {
+ Object o = opt(key);
+ return o instanceof JSONObject ? (JSONObject)o : null;
+ }
+
+
+ /**
+ * Get an optional long value associated with a key,
+ * or zero if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @return An object which is the value.
+ */
+ public long optLong(String key) {
+ return optLong(key, 0);
+ }
+
+
+ /**
+ * Get an optional long value associated with a key,
+ * or the default if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public long optLong(String key, long defaultValue) {
+ try {
+ return getLong(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional string associated with a key.
+ * It returns an empty string if there is no such key. If the value is not
+ * a string and is not null, then it is coverted to a string.
+ *
+ * @param key A key string.
+ * @return A string which is the value.
+ */
+ public String optString(String key) {
+ return optString(key, "");
+ }
+
+
+ /**
+ * Get an optional string associated with a key.
+ * It returns the defaultValue if there is no such key.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return A string which is the value.
+ */
+ public String optString(String key, String defaultValue) {
+ Object o = opt(key);
+ return o != null ? o.toString() : defaultValue;
+ }
+
+
+ /**
+ * Put a key/boolean pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A boolean which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, boolean value) throws JSONException {
+ put(key, value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a key/double pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A double which is the value.
+ * @return this.
+ * @throws JSONException If the key is null or if the number is invalid.
+ */
+ public JSONObject put(String key, double value) throws JSONException {
+ put(key, new Double(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/int pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value An int which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, int value) throws JSONException {
+ put(key, new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/long pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A long which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, long value) throws JSONException {
+ put(key, new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, where the value will be a
+ * JSONObject which is produced from a Map.
+ * @param key A key string.
+ * @param value A Map value.
+ * @return this.
+ * @throws JSONException
+ */
+ public JSONObject put(String key, Map value) throws JSONException {
+ put(key, new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject. If the value is null,
+ * then the key will be removed from the JSONObject if it is present.
+ * @param key A key string.
+ * @param value An object which is the value. It should be of one of these
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
+ * or the JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the value is non-finite number
+ * or if the key is null.
+ */
+ public JSONObject put(String key, Object value) throws JSONException {
+ if (key == null) {
+ throw new JSONException("Null key.");
+ }
+ if (value != null) {
+ testValidity(value);
+ this.myHashMap.put(key, value);
+ } else {
+ remove(key);
+ }
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, but only if the
+ * key and the value are both non-null.
+ * @param key A key string.
+ * @param value An object which is the value. It should be of one of these
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
+ * or the JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the value is a non-finite number.
+ */
+ public JSONObject putOpt(String key, Object value) throws JSONException {
+ if (key != null && value != null) {
+ put(key, value);
+ }
+ return this;
+ }
+
+
+ /**
+ * Produce a string in double quotes with backslash sequences in all the
+ * right places. A backslash will be inserted within </, allowing JSON
+ * text to be delivered in HTML. In JSON text, a string cannot contain a
+ * control character or an unescaped quote or backslash.
+ * @param string A String
+ * @return A String correctly formatted for insertion in a JSON text.
+ */
+ public static String quote(String string) {
+ if (string == null || string.length() == 0) {
+ return "\"\"";
+ }
+
+ char b;
+ char c = 0;
+ int i;
+ int len = string.length();
+ StringBuffer sb = new StringBuffer(len + 4);
+ String t;
+
+ sb.append('"');
+ for (i = 0; i < len; i += 1) {
+ b = c;
+ c = string.charAt(i);
+ switch (c) {
+ case '\\':
+ case '"':
+ sb.append('\\');
+ sb.append(c);
+ break;
+ case '/':
+ if (b == '<') {
+ sb.append('\\');
+ }
+ sb.append(c);
+ break;
+ case '\b':
+ sb.append("\\b");
+ break;
+ case '\t':
+ sb.append("\\t");
+ break;
+ case '\n':
+ sb.append("\\n");
+ break;
+ case '\f':
+ sb.append("\\f");
+ break;
+ case '\r':
+ sb.append("\\r");
+ break;
+ default:
+ if (c < ' ' || (c >= '\u0080' && c < '\u00a0') ||
+ (c >= '\u2000' && c < '\u2100')) {
+ t = "000" + Integer.toHexString(c);
+ sb.append("\\u" + t.substring(t.length() - 4));
+ } else {
+ sb.append(c);
+ }
+ }
+ }
+ sb.append('"');
+ return sb.toString();
+ }
+
+ /**
+ * Remove a name and its value, if present.
+ * @param key The name to be removed.
+ * @return The value that was associated with the name,
+ * or null if there was no value.
+ */
+ public Object remove(String key) {
+ return this.myHashMap.remove(key);
+ }
+
+
+ /**
+ * Throw an exception if the object is an NaN or infinite number.
+ * @param o The object to test.
+ * @throws JSONException If o is a non-finite number.
+ */
+ static void testValidity(Object o) throws JSONException {
+ if (o != null) {
+ if (o instanceof Double) {
+ if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
+ throw new JSONException(
+ "JSON does not allow non-finite numbers.");
+ }
+ } else if (o instanceof Float) {
+ if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
+ throw new JSONException(
+ "JSON does not allow non-finite numbers.");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Produce a JSONArray containing the values of the members of this
+ * JSONObject.
+ * @param names A JSONArray containing a list of key strings. This
+ * determines the sequence of the values in the result.
+ * @return A JSONArray of values.
+ * @throws JSONException If any of the values are non-finite numbers.
+ */
+ public JSONArray toJSONArray(JSONArray names) throws JSONException {
+ if (names == null || names.length() == 0) {
+ return null;
+ }
+ JSONArray ja = new JSONArray();
+ for (int i = 0; i < names.length(); i += 1) {
+ ja.put(this.opt(names.getString(i)));
+ }
+ return ja;
+ }
+
+ /**
+ * Make a JSON text of this JSONObject. For compactness, no whitespace
+ * is added. If this would not result in a syntactically correct JSON text,
+ * then null will be returned instead.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return a printable, displayable, portable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ */
+ public String toString() {
+ try {
+ Iterator keys = keys();
+ StringBuffer sb = new StringBuffer("{");
+
+ while (keys.hasNext()) {
+ if (sb.length() > 1) {
+ sb.append(',');
+ }
+ Object o = keys.next();
+ sb.append(quote(o.toString()));
+ sb.append(':');
+ sb.append(valueToString(this.myHashMap.get(o)));
+ }
+ sb.append('}');
+ return sb.toString();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONObject.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @return a printable, displayable, portable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the object contains an invalid number.
+ */
+ public String toString(int indentFactor) throws JSONException {
+ return toString(indentFactor, 0);
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONObject.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @param indent The indentation of the top level.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the object contains an invalid number.
+ */
+ String toString(int indentFactor, int indent) throws JSONException {
+ int i;
+ int n = length();
+ if (n == 0) {
+ return "{}";
+ }
+ Iterator keys = keys();
+ StringBuffer sb = new StringBuffer("{");
+ int newindent = indent + indentFactor;
+ Object o;
+ if (n == 1) {
+ o = keys.next();
+ sb.append(quote(o.toString()));
+ sb.append(": ");
+ sb.append(valueToString(this.myHashMap.get(o), indentFactor,
+ indent));
+ } else {
+ while (keys.hasNext()) {
+ o = keys.next();
+ if (sb.length() > 1) {
+ sb.append(",\n");
+ } else {
+ sb.append('\n');
+ }
+ for (i = 0; i < newindent; i += 1) {
+ sb.append(' ');
+ }
+ sb.append(quote(o.toString()));
+ sb.append(": ");
+ sb.append(valueToString(this.myHashMap.get(o), indentFactor,
+ newindent));
+ }
+ if (sb.length() > 1) {
+ sb.append('\n');
+ for (i = 0; i < indent; i += 1) {
+ sb.append(' ');
+ }
+ }
+ }
+ sb.append('}');
+ return sb.toString();
+ }
+
+
+ /**
+ * Make a JSON text of an Object value. If the object has an
+ * value.toJSONString() method, then that method will be used to produce
+ * the JSON text. The method is required to produce a strictly
+ * conforming text. If the object does not contain a toJSONString
+ * method (which is the most common case), then a text will be
+ * produced by other means. If the value is an array or Collection,
+ * then a JSONArray will be made from it and its toJSONString method
+ * will be called. If the value is a MAP, then a JSONObject will be made
+ * from it and its toJSONString method will be called. Otherwise, the
+ * value's toString method will be called, and the result will be quoted.
+ *
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param value The value to be serialized.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the value is or contains an invalid number.
+ */
+ static String valueToString(Object value) throws JSONException {
+ if (value == null || value.equals(null)) {
+ return "null";
+ }
+ if (value instanceof JSONString) {
+ Object o;
+ try {
+ o = ((JSONString)value).toJSONString();
+ } catch (Exception e) {
+ throw new JSONException(e);
+ }
+ if (o instanceof String) {
+ return (String)o;
+ }
+ throw new JSONException("Bad value from toJSONString: " + o);
+ }
+ if (value instanceof Number) {
+ return numberToString((Number) value);
+ }
+ if (value instanceof Boolean || value instanceof JSONObject ||
+ value instanceof JSONArray) {
+ return value.toString();
+ }
+ if (value instanceof Map) {
+ return new JSONObject((Map)value).toString();
+ }
+ if (value instanceof Collection) {
+ return new JSONArray((Collection)value).toString();
+ }
+ if (value.getClass().isArray()) {
+ return new JSONArray(value).toString();
+ }
+ return quote(value.toString());
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of an object value.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param value The value to be serialized.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @param indent The indentation of the top level.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the object contains an invalid number.
+ */
+ static String valueToString(Object value, int indentFactor, int indent)
+ throws JSONException {
+ if (value == null || value.equals(null)) {
+ return "null";
+ }
+ try {
+ if (value instanceof JSONString) {
+ Object o = ((JSONString)value).toJSONString();
+ if (o instanceof String) {
+ return (String)o;
+ }
+ }
+ } catch (Exception e) {
+ /* forget about it */
+ }
+ if (value instanceof Number) {
+ return numberToString((Number) value);
+ }
+ if (value instanceof Boolean) {
+ return value.toString();
+ }
+ if (value instanceof JSONObject) {
+ return ((JSONObject)value).toString(indentFactor, indent);
+ }
+ if (value instanceof JSONArray) {
+ return ((JSONArray)value).toString(indentFactor, indent);
+ }
+ if (value instanceof Map) {
+ return new JSONObject((Map)value).toString(indentFactor, indent);
+ }
+ if (value instanceof Collection) {
+ return new JSONArray((Collection)value).toString(indentFactor, indent);
+ }
+ if (value.getClass().isArray()) {
+ return new JSONArray(value).toString(indentFactor, indent);
+ }
+ return quote(value.toString());
+ }
+
+
+ /**
+ * Write the contents of the JSONObject as JSON text to a writer.
+ * For compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return The writer.
+ * @throws JSONException
+ */
+ public Writer write(Writer writer) throws JSONException {
+ try {
+ boolean b = false;
+ Iterator keys = keys();
+ writer.write('{');
+
+ while (keys.hasNext()) {
+ if (b) {
+ writer.write(',');
+ }
+ Object k = keys.next();
+ writer.write(quote(k.toString()));
+ writer.write(':');
+ Object v = this.myHashMap.get(k);
+ if (v instanceof JSONObject) {
+ ((JSONObject)v).write(writer);
+ } else if (v instanceof JSONArray) {
+ ((JSONArray)v).write(writer);
+ } else {
+ writer.write(valueToString(v));
+ }
+ b = true;
+ }
+ writer.write('}');
+ return writer;
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ }
+}
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObjectWrapper.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObjectWrapper.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONObjectWrapper.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.json;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JSONObjectWrapper extends JSONObject
+{
+
+ public JSONObjectWrapper(String string) throws JSONException
+ {
+ super(string);
+ }
+
+ public JSONObjectWrapper(JSONObject o) throws JSONException
+ {
+ super(o.toString());
+ }
+
+ public String getString(String key){
+ try
+ {
+ return super.getString(key);
+ }
+ catch(JSONException e)
+ {
+ return null;
+ }
+ }
+
+ public boolean getBoolean(String key) throws JSONException
+ {
+ try
+ {
+ return super.getBoolean(key);
+ }
+ catch(JSONException e)
+ {
+ return false;
+ }
+ }
+
+ public int getInt(String key)
+ {
+ try
+ {
+ return super.getInt(key);
+ }
+ catch(JSONException e)
+ {
+ return 0;
+ }
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONString.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONString.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONString.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,18 @@
+package org.jboss.portal.widget.netvibes.json;
+/**
+ * The <code>JSONString</code> interface allows a <code>toJSONString()</code>
+ * method so that a class can change the behavior of
+ * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
+ * and <code>JSONWriter.value(</code>Object<code>)</code>. The
+ * <code>toJSONString</code> method will be used instead of the default behavior
+ * of using the Object's <code>toString()</code> method and quoting the result.
+ */
+public interface JSONString {
+ /**
+ * The <code>toJSONString</code> method allows a class to produce its own JSON
+ * serialization.
+ *
+ * @return A strictly syntactically correct JSON text.
+ */
+ public String toJSONString();
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONStringer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONStringer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONStringer.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,78 @@
+package org.jboss.portal.widget.netvibes.json;
+
+/*
+Copyright (c) 2006 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+import java.io.StringWriter;
+
+/**
+ * JSONStringer provides a quick and convenient way of producing JSON text.
+ * The texts produced strictly conform to JSON syntax rules. No whitespace is
+ * added, so the results are ready for transmission or storage. Each instance of
+ * JSONStringer can produce one JSON text.
+ * <p>
+ * A JSONStringer instance provides a <code>value</code> method for appending
+ * values to the
+ * text, and a <code>key</code>
+ * method for adding keys before values in objects. There are <code>array</code>
+ * and <code>endArray</code> methods that make and bound array values, and
+ * <code>object</code> and <code>endObject</code> methods which make and bound
+ * object values. All of these methods return the JSONWriter instance,
+ * permitting cascade style. For example, <pre>
+ * myString = new JSONStringer()
+ * .object()
+ * .key("JSON")
+ * .value("Hello, World!")
+ * .endObject()
+ * .toString();</pre> which produces the string <pre>
+ * {"JSON":"Hello, World!"}</pre>
+ * <p>
+ * The first method called must be <code>array</code> or <code>object</code>.
+ * There are no methods for adding commas or colons. JSONStringer adds them for
+ * you. Objects and arrays can be nested up to 20 levels deep.
+ * <p>
+ * This can sometimes be easier than using a JSONObject to build a string.
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONStringer extends JSONWriter {
+ /**
+ * Make a fresh JSONStringer. It can be used to build one JSON text.
+ */
+ public JSONStringer() {
+ super(new StringWriter());
+ }
+
+ /**
+ * Return the JSON text. This method is used to obtain the product of the
+ * JSONStringer instance. It will return <code>null</code> if there was a
+ * problem in the construction of the JSON text (such as the calls to
+ * <code>array</code> were not properly balanced with calls to
+ * <code>endArray</code>).
+ * @return The JSON text.
+ */
+ public String toString() {
+ return this.mode == 'd' ? this.writer.toString() : null;
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONTokener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONTokener.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONTokener.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,462 @@
+package org.jboss.portal.widget.netvibes.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/**
+ * A JSONTokener takes a source string and extracts characters and tokens from
+ * it. It is used by the JSONObject and JSONArray constructors to parse
+ * JSON source strings.
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONTokener {
+
+ /**
+ * The index of the next character.
+ */
+ private int myIndex;
+
+
+ /**
+ * The source string being tokenized.
+ */
+ private String mySource;
+
+
+ /**
+ * Construct a JSONTokener from a string.
+ *
+ * @param s A source string.
+ */
+ public JSONTokener(String s) {
+ this.myIndex = 0;
+ this.mySource = s;
+ }
+
+
+ /**
+ * Back up one character. This provides a sort of lookahead capability,
+ * so that you can test for a digit or letter before attempting to parse
+ * the next number or identifier.
+ */
+ public void back() {
+ if (this.myIndex > 0) {
+ this.myIndex -= 1;
+ }
+ }
+
+
+
+ /**
+ * Get the hex value of a character (base16).
+ * @param c A character between '0' and '9' or between 'A' and 'F' or
+ * between 'a' and 'f'.
+ * @return An int between 0 and 15, or -1 if c was not a hex digit.
+ */
+ public static int dehexchar(char c) {
+ if (c >= '0' && c <= '9') {
+ return c - '0';
+ }
+ if (c >= 'A' && c <= 'F') {
+ return c - ('A' - 10);
+ }
+ if (c >= 'a' && c <= 'f') {
+ return c - ('a' - 10);
+ }
+ return -1;
+ }
+
+
+ /**
+ * Determine if the source string still contains characters that next()
+ * can consume.
+ * @return true if not yet at the end of the source.
+ */
+ public boolean more() {
+ return this.myIndex < this.mySource.length();
+ }
+
+
+ /**
+ * Get the next character in the source string.
+ *
+ * @return The next character, or 0 if past the end of the source string.
+ */
+ public char next() {
+ if (more()) {
+ char c = this.mySource.charAt(this.myIndex);
+ this.myIndex += 1;
+ return c;
+ }
+ return 0;
+ }
+
+
+ /**
+ * Consume the next character, and check that it matches a specified
+ * character.
+ * @param c The character to match.
+ * @return The character.
+ * @throws JSONException if the character does not match.
+ */
+ public char next(char c) throws JSONException {
+ char n = next();
+ if (n != c) {
+ throw syntaxError("Expected '" + c + "' and instead saw '" +
+ n + "'");
+ }
+ return n;
+ }
+
+
+ /**
+ * Get the next n characters.
+ *
+ * @param n The number of characters to take.
+ * @return A string of n characters.
+ * @throws JSONException
+ * Substring bounds error if there are not
+ * n characters remaining in the source string.
+ */
+ public String next(int n) throws JSONException {
+ int i = this.myIndex;
+ int j = i + n;
+ if (j >= this.mySource.length()) {
+ throw syntaxError("Substring bounds error");
+ }
+ this.myIndex += n;
+ return this.mySource.substring(i, j);
+ }
+
+
+ /**
+ * Get the next char in the string, skipping whitespace
+ * and comments (slashslash, slashstar, and hash).
+ * @throws JSONException
+ * @return A character, or 0 if there are no more characters.
+ */
+ public char nextClean() throws JSONException {
+ for (;;) {
+ char c = next();
+ if (c == '/') {
+ switch (next()) {
+ case '/':
+ do {
+ c = next();
+ } while (c != '\n' && c != '\r' && c != 0);
+ break;
+ case '*':
+ for (;;) {
+ c = next();
+ if (c == 0) {
+ throw syntaxError("Unclosed comment");
+ }
+ if (c == '*') {
+ if (next() == '/') {
+ break;
+ }
+ back();
+ }
+ }
+ break;
+ default:
+ back();
+ return '/';
+ }
+ } else if (c == '#') {
+ do {
+ c = next();
+ } while (c != '\n' && c != '\r' && c != 0);
+ } else if (c == 0 || c > ' ') {
+ return c;
+ }
+ }
+ }
+
+
+ /**
+ * Return the characters up to the next close quote character.
+ * Backslash processing is done. The formal JSON format does not
+ * allow strings in single quotes, but an implementation is allowed to
+ * accept them.
+ * @param quote The quoting character, either
+ * <code>"</code> <small>(double quote)</small> or
+ * <code>'</code> <small>(single quote)</small>.
+ * @return A String.
+ * @throws JSONException Unterminated string.
+ */
+ public String nextString(char quote) throws JSONException {
+ char c;
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ c = next();
+ switch (c) {
+ case 0:
+ case '\n':
+ case '\r':
+ throw syntaxError("Unterminated string");
+ case '\\':
+ c = next();
+ switch (c) {
+ case 'b':
+ sb.append('\b');
+ break;
+ case 't':
+ sb.append('\t');
+ break;
+ case 'n':
+ sb.append('\n');
+ break;
+ case 'f':
+ sb.append('\f');
+ break;
+ case 'r':
+ sb.append('\r');
+ break;
+ case 'u':
+ sb.append((char)Integer.parseInt(next(4), 16));
+ break;
+ case 'x' :
+ sb.append((char) Integer.parseInt(next(2), 16));
+ break;
+ default:
+ sb.append(c);
+ }
+ break;
+ default:
+ if (c == quote) {
+ return sb.toString();
+ }
+ sb.append(c);
+ }
+ }
+ }
+
+
+ /**
+ * Get the text up but not including the specified character or the
+ * end of line, whichever comes first.
+ * @param d A delimiter character.
+ * @return A string.
+ */
+ public String nextTo(char d) {
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ char c = next();
+ if (c == d || c == 0 || c == '\n' || c == '\r') {
+ if (c != 0) {
+ back();
+ }
+ return sb.toString().trim();
+ }
+ sb.append(c);
+ }
+ }
+
+
+ /**
+ * Get the text up but not including one of the specified delimeter
+ * characters or the end of line, whichever comes first.
+ * @param delimiters A set of delimiter characters.
+ * @return A string, trimmed.
+ */
+ public String nextTo(String delimiters) {
+ char c;
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ c = next();
+ if (delimiters.indexOf(c) >= 0 || c == 0 ||
+ c == '\n' || c == '\r') {
+ if (c != 0) {
+ back();
+ }
+ return sb.toString().trim();
+ }
+ sb.append(c);
+ }
+ }
+
+
+ /**
+ * Get the next value. The value can be a Boolean, Double, Integer,
+ * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
+ * @throws JSONException If syntax error.
+ *
+ * @return An object.
+ */
+ public Object nextValue() throws JSONException {
+ char c = nextClean();
+ String s;
+
+ switch (c) {
+ case '"':
+ case '\'':
+ return nextString(c);
+ case '{':
+ back();
+ return new JSONObject(this);
+ case '[':
+ back();
+ return new JSONArray(this);
+ }
+
+ /*
+ * Handle unquoted text. This could be the values true, false, or
+ * null, or it can be a number. An implementation (such as this one)
+ * is allowed to also accept non-standard forms.
+ *
+ * Accumulate characters until we reach the end of the text or a
+ * formatting character.
+ */
+
+ StringBuffer sb = new StringBuffer();
+ char b = c;
+ while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
+ sb.append(c);
+ c = next();
+ }
+ back();
+
+ /*
+ * If it is true, false, or null, return the proper value.
+ */
+
+ s = sb.toString().trim();
+ if (s.equals("")) {
+ throw syntaxError("Missing value");
+ }
+ if (s.equalsIgnoreCase("true")) {
+ return Boolean.TRUE;
+ }
+ if (s.equalsIgnoreCase("false")) {
+ return Boolean.FALSE;
+ }
+ if (s.equalsIgnoreCase("null")) {
+ return JSONObject.NULL;
+ }
+
+ /*
+ * If it might be a number, try converting it. We support the 0- and 0x-
+ * conventions. If a number cannot be produced, then the value will just
+ * be a string. Note that the 0-, 0x-, plus, and implied string
+ * conventions are non-standard. A JSON parser is free to accept
+ * non-JSON forms as long as it accepts all correct JSON forms.
+ */
+
+ if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
+ if (b == '0') {
+ if (s.length() > 2 &&
+ (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
+ try {
+ return new Integer(Integer.parseInt(s.substring(2),
+ 16));
+ } catch (Exception e) {
+ /* Ignore the error */
+ }
+ } else {
+ try {
+ return new Integer(Integer.parseInt(s, 8));
+ } catch (Exception e) {
+ /* Ignore the error */
+ }
+ }
+ }
+ try {
+ return new Integer(s);
+ } catch (Exception e) {
+ try {
+ return new Long(s);
+ } catch (Exception f) {
+ try {
+ return new Double(s);
+ } catch (Exception g) {
+ return s;
+ }
+ }
+ }
+ }
+ return s;
+ }
+
+
+ /**
+ * Skip characters until the next character is the requested character.
+ * If the requested character is not found, no characters are skipped.
+ * @param to A character to skip to.
+ * @return The requested character, or zero if the requested character
+ * is not found.
+ */
+ public char skipTo(char to) {
+ char c;
+ int index = this.myIndex;
+ do {
+ c = next();
+ if (c == 0) {
+ this.myIndex = index;
+ return c;
+ }
+ } while (c != to);
+ back();
+ return c;
+ }
+
+
+ /**
+ * Skip characters until past the requested string.
+ * If it is not found, we are left at the end of the source.
+ * @param to A string to skip past.
+ */
+ public boolean skipPast(String to) {
+ this.myIndex = this.mySource.indexOf(to, this.myIndex);
+ if (this.myIndex < 0) {
+ this.myIndex = this.mySource.length();
+ return false;
+ }
+ this.myIndex += to.length();
+ return true;
+
+ }
+
+
+ /**
+ * Make a JSONException to signal a syntax error.
+ *
+ * @param message The error message.
+ * @return A JSONException object, suitable for throwing
+ */
+ public JSONException syntaxError(String message) {
+ return new JSONException(message + toString());
+ }
+
+
+ /**
+ * Make a printable string of this JSONTokener.
+ *
+ * @return " at character [this.myIndex] of [this.mySource]"
+ */
+ public String toString() {
+ return " at character " + this.myIndex + " of " + this.mySource;
+ }
+}
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONWriter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONWriter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/json/JSONWriter.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,318 @@
+package org.jboss.portal.widget.netvibes.json;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/*
+Copyright (c) 2006 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/**
+ * JSONWriter provides a quick and convenient way of producing JSON text.
+ * The texts produced strictly conform to JSON syntax rules. No whitespace is
+ * added, so the results are ready for transmission or storage. Each instance of
+ * JSONWriter can produce one JSON text.
+ * <p>
+ * A JSONWriter instance provides a <code>value</code> method for appending
+ * values to the
+ * text, and a <code>key</code>
+ * method for adding keys before values in objects. There are <code>array</code>
+ * and <code>endArray</code> methods that make and bound array values, and
+ * <code>object</code> and <code>endObject</code> methods which make and bound
+ * object values. All of these methods return the JSONWriter instance,
+ * permitting a cascade style. For example, <pre>
+ * new JSONWriter(myWriter)
+ * .object()
+ * .key("JSON")
+ * .value("Hello, World!")
+ * .endObject();</pre> which writes <pre>
+ * {"JSON":"Hello, World!"}</pre>
+ * <p>
+ * The first method called must be <code>array</code> or <code>object</code>.
+ * There are no methods for adding commas or colons. JSONWriter adds them for
+ * you. Objects and arrays can be nested up to 20 levels deep.
+ * <p>
+ * This can sometimes be easier than using a JSONObject to build a string.
+ * @author JSON.org
+ * @version 2
+ */
+public class JSONWriter {
+ private static final int maxdepth = 20;
+
+ /**
+ * The comma flag determines if a comma should be output before the next
+ * value.
+ */
+ private boolean comma;
+
+ /**
+ * The current mode. Values:
+ * 'a' (array),
+ * 'd' (done),
+ * 'i' (initial),
+ * 'k' (key),
+ * 'o' (object).
+ */
+ protected char mode;
+
+ /**
+ * The object/array stack.
+ */
+ private char stack[];
+
+ /**
+ * The stack top index. A value of 0 indicates that the stack is empty.
+ */
+ private int top;
+
+ /**
+ * The writer that will receive the output.
+ */
+ protected Writer writer;
+
+ /**
+ * Make a fresh JSONWriter. It can be used to build one JSON text.
+ */
+ public JSONWriter(Writer w) {
+ this.comma = false;
+ this.mode = 'i';
+ this.stack = new char[maxdepth];
+ this.top = 0;
+ this.writer = w;
+ }
+
+ /**
+ * Append a value.
+ * @param s A string value.
+ * @return this
+ * @throws JSONException If the value is out of sequence.
+ */
+ private JSONWriter append(String s) throws JSONException {
+ if (s == null) {
+ throw new JSONException("Null pointer");
+ }
+ if (this.mode == 'o' || this.mode == 'a') {
+ try {
+ if (this.comma && this.mode == 'a') {
+ this.writer.write(',');
+ }
+ this.writer.write(s);
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ if (this.mode == 'o') {
+ this.mode = 'k';
+ }
+ this.comma = true;
+ return this;
+ }
+ throw new JSONException("Value out of sequence.");
+ }
+
+ /**
+ * Begin appending a new array. All values until the balancing
+ * <code>endArray</code> will be appended to this array. The
+ * <code>endArray</code> method must be called to mark the array's end.
+ * @return this
+ * @throws JSONException If the nesting is too deep, or if the object is
+ * started in the wrong place (for example as a key or after the end of the
+ * outermost array or object).
+ */
+ public JSONWriter array() throws JSONException {
+ if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
+ this.push('a');
+ this.append("[");
+ this.comma = false;
+ return this;
+ }
+ throw new JSONException("Misplaced array.");
+ }
+
+ /**
+ * End something.
+ * @param m Mode
+ * @param c Closing character
+ * @return this
+ * @throws JSONException If unbalanced.
+ */
+ private JSONWriter end(char m, char c) throws JSONException {
+ if (this.mode != m) {
+ throw new JSONException(m == 'o' ? "Misplaced endObject." :
+ "Misplaced endArray.");
+ }
+ this.pop(m);
+ try {
+ this.writer.write(c);
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ this.comma = true;
+ return this;
+ }
+
+ /**
+ * End an array. This method most be called to balance calls to
+ * <code>array</code>.
+ * @return this
+ * @throws JSONException If incorrectly nested.
+ */
+ public JSONWriter endArray() throws JSONException {
+ return this.end('a', ']');
+ }
+
+ /**
+ * End an object. This method most be called to balance calls to
+ * <code>object</code>.
+ * @return this
+ * @throws JSONException If incorrectly nested.
+ */
+ public JSONWriter endObject() throws JSONException {
+ return this.end('k', '}');
+ }
+
+ /**
+ * Append a key. The key will be associated with the next value. In an
+ * object, every value must be preceded by a key.
+ * @param s A key string.
+ * @return this
+ * @throws JSONException If the key is out of place. For example, keys
+ * do not belong in arrays or if the key is null.
+ */
+ public JSONWriter key(String s) throws JSONException {
+ if (s == null) {
+ throw new JSONException("Null key.");
+ }
+ if (this.mode == 'k') {
+ try {
+ if (this.comma) {
+ this.writer.write(',');
+ }
+ this.writer.write(JSONObject.quote(s));
+ this.writer.write(':');
+ this.comma = false;
+ this.mode = 'o';
+ return this;
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ }
+ throw new JSONException("Misplaced key.");
+ }
+
+
+ /**
+ * Begin appending a new object. All keys and values until the balancing
+ * <code>endObject</code> will be appended to this object. The
+ * <code>endObject</code> method must be called to mark the object's end.
+ * @return this
+ * @throws JSONException If the nesting is too deep, or if the object is
+ * started in the wrong place (for example as a key or after the end of the
+ * outermost array or object).
+ */
+ public JSONWriter object() throws JSONException {
+ if (this.mode == 'i') {
+ this.mode = 'o';
+ }
+ if (this.mode == 'o' || this.mode == 'a') {
+ this.append("{");
+ this.push('k');
+ this.comma = false;
+ return this;
+ }
+ throw new JSONException("Misplaced object.");
+
+ }
+
+
+ /**
+ * Pop an array or object scope.
+ * @param c The scope to close.
+ * @throws JSONException If nesting is wrong.
+ */
+ private void pop(char c) throws JSONException {
+ if (this.top <= 0 || this.stack[this.top - 1] != c) {
+ throw new JSONException("Nesting error.");
+ }
+ this.top -= 1;
+ this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1];
+ }
+
+ /**
+ * Push an array or object scope.
+ * @param c The scope to open.
+ * @throws JSONException If nesting is too deep.
+ */
+ private void push(char c) throws JSONException {
+ if (this.top >= maxdepth) {
+ throw new JSONException("Nesting too deep.");
+ }
+ this.stack[this.top] = c;
+ this.mode = c;
+ this.top += 1;
+ }
+
+
+ /**
+ * Append either the value <code>true</code> or the value
+ * <code>false</code>.
+ * @param b A boolean.
+ * @return this
+ * @throws JSONException
+ */
+ public JSONWriter value(boolean b) throws JSONException {
+ return this.append(b ? "true" : "false");
+ }
+
+ /**
+ * Append a double value.
+ * @param d A double.
+ * @return this
+ * @throws JSONException If the number is not finite.
+ */
+ public JSONWriter value(double d) throws JSONException {
+ return this.value(new Double(d));
+ }
+
+ /**
+ * Append a long value.
+ * @param l A long.
+ * @return this
+ * @throws JSONException
+ */
+ public JSONWriter value(long l) throws JSONException {
+ return this.append(Long.toString(l));
+ }
+
+
+ /**
+ * Append an object value.
+ * @param o The object to append. It can be null, or a Boolean, Number,
+ * String, JSONObject, or JSONArray, or an object with a toJSONString()
+ * method.
+ * @return this
+ * @throws JSONException If the value is out of sequence.
+ */
+ public JSONWriter value(Object o) throws JSONException {
+ return this.append(JSONObject.valueToString(o));
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,247 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.provider;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.widget.netvibes.NetvibesMetaData;
+import org.jboss.portal.widget.netvibes.NetvibesPreferenceInfo;
+import org.jboss.portal.widget.netvibes.NetvibesPreferencesInfo;
+import org.jboss.portal.widget.netvibes.NetvibesWidgetInfo;
+import org.jboss.portal.widget.netvibes.json.JSONArray;
+import org.jboss.portal.widget.netvibes.json.JSONException;
+import org.jboss.portal.widget.netvibes.json.JSONObject;
+import org.jboss.portal.widget.netvibes.json.JSONObjectWrapper;
+import org.jboss.portal.widget.netvibes.type.NVBooleanType;
+import org.jboss.portal.widget.netvibes.type.NVDataType;
+import org.jboss.portal.widget.netvibes.type.NVHiddenType;
+import org.jboss.portal.widget.netvibes.type.NVListType;
+import org.jboss.portal.widget.netvibes.type.NVPasswordType;
+import org.jboss.portal.widget.netvibes.type.NVRangeType;
+import org.jboss.portal.widget.netvibes.type.NVTextType;
+import org.jboss.portal.widget.netvibes.type.NVTextareaType;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesJSONInfoBuilder
+{
+
+ /** The URL */
+ private final URL url;
+
+ public NetvibesJSONInfoBuilder(URL url)
+ {
+ if ( url == null)
+ {
+ throw new IllegalArgumentException("Url must not be null.");
+ }
+
+ this.url = url;
+ }
+
+ private URL buildNetvibesJSONUrl(URL url) throws MalformedURLException
+ {
+ StringBuffer jsonUrl = new StringBuffer();
+ jsonUrl.append("http://www.netvibes.com/api/uwa/compile/uwa_json.php?moduleUrl=");
+ jsonUrl.append(FastURLEncoder.getUTF8Instance().encode(url.toString()));
+
+ return new URL(jsonUrl.toString());
+ }
+
+ public NetvibesWidgetInfo create()
+ {
+ try
+ {
+ byte[] bytes = obtainWidget(this.url);
+ if(bytes == null)
+ {
+ return null;
+ }
+
+ // Create JSONObject
+ JSONObject jsonResponse = new JSONObject(new String(bytes));
+
+ // Getting the title
+ LocalizedString title = new LocalizedString(jsonResponse.getString("title"));
+
+ if(title == null)
+ {
+ // log unsupported format
+ return null;
+ }
+
+ // Getting the icons
+ List iconList = null;
+ try
+ {
+ iconList = this.parseIcons(jsonResponse.getJSONObject("icon"));
+ }
+ catch(JSONException e)
+ {
+ iconList = new ArrayList();
+ }
+
+ // Parsing the metadata
+ JSONObject metadata = new JSONObjectWrapper(jsonResponse.getJSONObject("metas"));
+
+ LocalizedString description = null;
+ if(metadata.getString("description") != null)
+ {
+ description = new LocalizedString(metadata.getString("description"));
+ }
+
+ NetvibesMetaData md = new NetvibesMetaData(
+ metadata.getString("author"),
+ metadata.getString("website"),
+ description,
+ metadata.getString("version"),
+ metadata.getString("keywords"),
+ metadata.getString("screenshot"),
+ metadata.getString("thumbnail"),
+ metadata.getString("apiVersion"),
+ metadata.getBoolean("debugMode"),
+ metadata.getInt("autoRefresh"),
+ metadata.getBoolean("inline")
+ );
+
+ // Netvibes preferences
+ List<NetvibesPreferenceInfo> preferences = new ArrayList<NetvibesPreferenceInfo>();
+ JSONArray array = jsonResponse.getJSONArray("preferences");
+ for(int i = 0; i < array.length(); i++)
+ {
+ JSONObject preference = new JSONObjectWrapper(array.getJSONObject(i));
+
+ NVDataType type = null;
+
+ int dataType = NVDataType.parseDataTypeLiteral(preference.getString("type"));
+ switch(dataType)
+ {
+ case NVDataType.TEXT:
+ type = NVTextType.getInstance();
+ break;
+ case NVDataType.BOOLEAN:
+ type = NVBooleanType.getInstance();
+ break;
+ case NVDataType.HIDDEN:
+ type = NVHiddenType.getInstance();
+ break;
+ case NVDataType.PASSWORD:
+ type = NVPasswordType.getInstance();
+ break;
+ case NVDataType.TEXTAREA:
+ type = NVTextareaType.getInstance();
+ break;
+ case NVDataType.RANGE:
+ type = new NVRangeType(
+ preference.getInt("min"),
+ preference.getInt("max"),
+ preference.getInt("step"));
+ break;
+ case NVDataType.LIST:
+ List<NVListType.NVListValue> valueList = new ArrayList();
+ JSONArray values = preference.getJSONArray("options");
+ for(int j = 0; j < values.length(); j++)
+ {
+ JSONObject value = values.getJSONObject(j);
+ String key = value.getString("value");
+ LocalizedString label = new LocalizedString(value.getString("label"));
+ NVListType.NVListValue nvValue = new NVListType.NVListValue(key, label);
+ valueList.add(nvValue);
+ }
+ type = new NVListType(valueList);
+ break;
+ }
+
+ NetvibesPreferenceInfo info = new NetvibesPreferenceInfo(
+ preference.getString("name"),
+ preference.getString("label"),
+ type,
+ preference.getString("onchange"),
+ preference.getString("defaultValue")
+ );
+
+ preferences.add(info);
+ }
+
+ NetvibesPreferencesInfo preferencesInfo = new NetvibesPreferencesInfo(preferences);
+
+ NetvibesWidgetInfo info = new NetvibesWidgetInfo(title, iconList, md, preferencesInfo);
+
+ return info;
+ }
+ catch(JSONException e)
+ {
+ // log.error("Can not parse widget information: "+ url, e);
+ return null;
+ }
+ catch(Exception e)
+ {
+ // log.error("Can not obtain widget information: "+ url, e);
+ return null;
+ }
+
+ }
+
+ private List parseIcons(JSONObject icons) throws JSONException
+ {
+ List iconList = new ArrayList();
+ for(int i = 0; i < icons.length(); i++ )
+ {
+ iconList.add(icons.getString(String.valueOf(i)));
+ }
+ return iconList;
+ }
+
+
+ public URL getUrl()
+ {
+ return url;
+ }
+
+ /**
+ * needed for testing
+ */
+ protected byte[] obtainWidget(URL url) throws Exception
+ {
+ return obtainURL(url);
+ }
+
+ /**
+ * creating correct url here to be able to also get local sources for testing
+ */
+ private byte[] obtainURL(URL url) throws Exception
+ {
+ return URLTools.getContent(this.buildNetvibesJSONUrl(url), 5000, 5000);
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesProvider.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesProvider.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.provider;
+
+import java.net.URL;
+
+import org.jboss.portal.widget.AbstractWidgetProvider;
+import org.jboss.portal.widget.ExpiringFutureTask;
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.WidgetQuery;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+
+public class NetvibesProvider extends AbstractWidgetProvider
+{
+
+ @Override
+ protected void addDirectoryResult(WidgetQuery query)
+ {
+ throw new IllegalArgumentException("Not yet implemented");
+ }
+
+ @Override
+ protected void addWidget(URL url)
+ {
+ ExpiringFutureTask<Widget> ft = new ExpiringFutureTask<Widget>(entryExpiration, new NetvibesWidgetMapEntry(url));
+ ExpiringFutureTask<Widget> e = entries.putIfAbsent(url, ft);
+ if(e == null)
+ {
+ e = ft;
+ executor.submit(e);
+ }
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesWidgetMapEntry.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesWidgetMapEntry.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesWidgetMapEntry.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.provider;
+
+import java.net.URL;
+import java.util.concurrent.Callable;
+
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.netvibes.NetvibesWidget;
+import org.jboss.portal.widget.netvibes.NetvibesWidgetInfo;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NetvibesWidgetMapEntry implements Callable<Widget>
+{
+ /** The widget URL */
+ public final URL url;
+
+ public NetvibesWidgetMapEntry(URL url)
+ {
+ this.url = url;
+ }
+
+ public Widget call() throws Exception
+ {
+ NetvibesJSONInfoBuilder builder = new NetvibesJSONInfoBuilder(url);
+ NetvibesWidgetInfo info = builder.create();
+ if ( info != null )
+ {
+ return new NetvibesWidget(url, info);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVBooleanType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVBooleanType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVBooleanType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVBooleanType extends NVDataType
+{
+
+ /** . */
+ private final static NVBooleanType INSTANCE = new NVBooleanType();
+
+ public static NVBooleanType getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NVBooleanType()
+ {
+ }
+
+ public int getOrdinal()
+ {
+ return BOOLEAN;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVDataType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVDataType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVDataType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class NVDataType
+{
+ /** . */
+ public final static int TEXT = 0;
+
+ /** . */
+ public final static int BOOLEAN = 1;
+
+ /** . */
+ public final static int HIDDEN = 2;
+
+ /** . */
+ public final static int RANGE = 3;
+
+ /** . */
+ public final static int LIST = 4;
+
+ /** . */
+ public final static int PASSWORD = 5;
+
+ /** data type under construction :) */
+ public final static int TEXTAREA = 6;
+
+
+ public abstract int getOrdinal();
+
+ public static int parseDataTypeLiteral(String literal)
+ {
+ if("text".equals(literal))
+ {
+ return TEXT;
+ }
+ else if ("boolean".equals(literal))
+ {
+ return BOOLEAN;
+ }
+ else if ("hidden".equals(literal))
+ {
+ return HIDDEN;
+ }
+ else if ("range".equals(literal))
+ {
+ return RANGE;
+ }
+ else if ("list".equals(literal))
+ {
+ return LIST;
+ }
+ else if ("password".equals(literal))
+ {
+ return PASSWORD;
+ }
+ else if ("textarea".equals(literal))
+ {
+ return TEXTAREA;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown data type: " + literal);
+ }
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVHiddenType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVHiddenType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVHiddenType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVHiddenType extends NVDataType
+{
+
+ /** . */
+ private final static NVHiddenType INSTANCE = new NVHiddenType();
+
+ public static NVHiddenType getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NVHiddenType()
+ {
+ }
+
+ public int getOrdinal()
+ {
+ return HIDDEN;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVListType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVListType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVListType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVListType extends NVDataType
+{
+
+ /** The value list */
+ private List<NVListValue> values;
+
+ public NVListType(List<NVListValue> values)
+ {
+ this.values = values;
+ }
+
+ public int getOrdinal()
+ {
+ return LIST;
+ }
+
+ public int getSize()
+ {
+ return values.size();
+ }
+
+ public NVListValue getValue(int index)
+ {
+ return (NVListValue) this.values.get(index);
+ }
+
+ public static class NVListValue
+ {
+ /** The value */
+ private String value;
+
+ /** The label */
+ private LocalizedString label;
+
+ public NVListValue(String value, LocalizedString label)
+ {
+ this.value = value;
+ this.label = label;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public LocalizedString getLabel()
+ {
+ return label;
+ }
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVPasswordType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVPasswordType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVPasswordType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVPasswordType extends NVDataType
+{
+
+ /** . */
+ private final static NVPasswordType INSTANCE = new NVPasswordType();
+
+ public static NVPasswordType getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NVPasswordType()
+ {
+ }
+
+ public int getOrdinal()
+ {
+ return PASSWORD;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVRangeType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVRangeType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVRangeType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVRangeType extends NVDataType
+{
+
+ /** The minimal int possible */
+ private final int min;
+
+ /** The maximal int possible */
+ private final int max;
+
+ /** The step between two values */
+ private final int step;
+
+ public NVRangeType(int min, int max, int step)
+ {
+ this.min = min;
+ this.max = max;
+ this.step = step;
+ }
+
+ public int getOrdinal()
+ {
+ return RANGE;
+ }
+
+ public int getMin()
+ {
+ return min;
+ }
+
+ public int getMax()
+ {
+ return max;
+ }
+
+ public int getStep()
+ {
+ return step;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVTextType extends NVDataType
+{
+
+ /** . */
+ private final static NVTextType INSTANCE = new NVTextType();
+
+ public static NVTextType getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NVTextType()
+ {
+ }
+
+ public int getOrdinal()
+ {
+ return TEXT;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextareaType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextareaType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/type/NVTextareaType.java 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.netvibes.type;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public final class NVTextareaType extends NVDataType
+{
+
+ /** . */
+ private final static NVTextareaType INSTANCE = new NVTextareaType();
+
+ public static NVTextareaType getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private NVTextareaType()
+ {
+ }
+
+ public int getOrdinal()
+ {
+ return TEXTAREA;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/jsp/edit_content.jsp 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,159 @@
+<%@page import="org.jboss.portal.widget.netvibes.provider.NetvibesProvider"%>
+<%@page import="org.jboss.portal.widget.netvibes.NetvibesPreferenceInfo"%>
+<%@page import="org.jboss.portal.widget.netvibes.NetvibesWidget"%>
+<%@page import="org.jboss.portal.widget.netvibes.type.NVDataType"%>
+<%@page import="org.jboss.portal.widget.netvibes.type.NVRangeType"%>
+<%@page import="javax.portlet.PortletURL"%>
+<%@page import="java.util.Iterator"%>
+<%@ page language="java" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="p" %>
+<%@ page isELIgnored="false" %>
+<%@page import="org.jboss.portal.widget.netvibes.type.NVListType"%>
+<p:defineObjects/>
+<div>
+<%
+ NetvibesProvider provider = (NetvibesProvider)request.getAttribute("provider");
+
+ NetvibesWidget selWidget = null;
+ String uri = request.getParameter("content.uri");
+ if (uri != null)
+ {
+ selWidget = (NetvibesWidget) provider.getWidget(uri);
+ }
+
+ // no directory lookup available
+ boolean uriPickMethod = true;
+
+%>
+<div id="<p:namespace/>gadget_url_div" style="display: <%= uriPickMethod ? "block" : "none" %>;">
+ <%
+ PortletURL contentURL = renderResponse.createActionURL();
+ contentURL.setParameter("content.action.select", "content.action.select");
+ contentURL.setParameter("gg_pick_method", "uri");
+ %>
+ <form action="<%= contentURL %>" method="post">
+ <%
+ if (uri != null && selWidget == null)
+ {
+ %>
+ <p style="color: red;">
+ <%
+ out.println("Failed to obtain widget with URI: " + uri);
+ %>
+ </p>
+ <%
+ }
+ else if (selWidget != null)
+ {
+ %>
+ <p style="color: blue;">
+ Selected Widget:
+ <%= selWidget.getTitle().getDefaultString() %>
+ </p>
+ <%
+ }
+ %>
+ <input type="text" name="content.uri" value="<%= uri != null ? uri : "" %>" class="portlet-form-field"/>
+ <input type="submit" value="Select Widget" class="portlet-form-button"/>
+ </form>
+</div>
+<%
+ if (selWidget != null && !selWidget.getWidgetInfo().getPreferencesInfo().getPreferences().isEmpty())
+ {
+
+ PortletURL selectURL = renderResponse.createActionURL();
+
+ // Set parameters for selection
+ selectURL.setParameter("content.action.select", "content.action.select");
+ selectURL.setParameter("content.uri", selWidget.getId());
+
+%>
+<div>
+ <p>
+ <form action="<%= selectURL %>" method="post"><%
+ for(Iterator i = selWidget.getWidgetInfo().getPreferencesInfo().getPreferences().iterator(); i.hasNext(); )
+ {
+ // hidden preferences
+ NetvibesPreferenceInfo prefInfo = (NetvibesPreferenceInfo) selWidget.getWidgetInfo().getPreferencesInfo().getPreference((String) i.next());
+ if ( NVDataType.HIDDEN == prefInfo.getType().getOrdinal())
+ {
+ %><input type="hidden" name="content.param.<%= prefInfo.getName() %>"
+ value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/><%
+ }
+ }
+ %>
+ <table><%
+ for(Iterator i = selWidget.getWidgetInfo().getPreferencesInfo().getPreferences().iterator(); i.hasNext(); )
+ {
+ String key = (String) i.next();
+ NetvibesPreferenceInfo prefInfo = (NetvibesPreferenceInfo) selWidget.getWidgetInfo().getPreferencesInfo().getPreference(key);
+
+ int prefDataType = prefInfo.getType().getOrdinal();
+ // If preference is not hidden
+ if ( prefDataType != NVDataType.HIDDEN )
+ {
+
+ String prefValue = request.getParameter("content.param." + prefInfo.getName());
+ if ( prefValue == null )
+ {
+ prefValue = prefInfo.getDefaultValue();
+ }
+ %><tr>
+ <td><%= prefInfo.getLabel() != null ? prefInfo.getLabel() : prefInfo.getName() %></td>
+ <td><% // input
+ switch(prefDataType) {
+ // RANGE
+ case NVDataType.RANGE: %><select name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"><%
+ NVRangeType range = (NVRangeType) prefInfo.getType();
+ int start = range.getMin();
+ int end = range.getMax();
+ int step = range.getStep();
+
+ for ( int ri = start; ri <= end; ri = ri + step )
+ {
+ boolean selected = String.valueOf(ri).equals(prefValue);
+ %><option <%= selected ? "selected=\"selected\"" : "" %>
+ value="<%= ri %>"><%= ri %></option><%
+ }
+ %></select><%
+ break;
+ // BOOLEAN
+ case NVDataType.BOOLEAN:
+ boolean checked = "true".equals(prefValue);
+ %><input type="checkbox" name="content.param.<%= prefInfo.getName() %>" value="true" <%= checked ? "checked=\"checked\"" : "" %>/><%
+ break;
+ // LIST
+ case NVDataType.LIST: %><select name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"><%
+ NVListType list = (NVListType) prefInfo.getType();
+ for(int j = 0; j < list.getSize(); j++)
+ {
+ NVListType.NVListValue value = list.getValue(j);
+ boolean selected = value.getValue().equals(prefValue);
+ %><option <%= selected ? "selected=\"selected\"" : "" %>
+ value="<%= value.getValue() %>"><%= value.getLabel().getDefaultString() %></option><%
+ }
+ %></select><%
+ break;
+ // PASSWORD
+ case NVDataType.PASSWORD: %><input type="password" name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"
+ value="<%= prefValue != null ? prefValue : "" %>" maxlength="255"/><%
+ break;
+ // DEFAULT TEXT
+ default: %><input type="text" name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"
+ value="<%= prefValue != null ? prefValue : "" %>" maxlength="255"/><%
+ break;
+ }
+ %></td>
+ </tr><%
+ } // end if != HIDDEN
+ } // end for preferences
+ %>
+ <tr>
+ <td colspan="2"><input type="submit" value="Update" class="portlet-form-button"/></td>
+ </tr>
+ </table>
+ </form>
+ </p>
+</div><%
+ }
+%></div>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet-instances.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet-instances.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet-instances.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,36 @@
+<?xml version="1.0" standalone="yes"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE deployments PUBLIC
+ "-//JBoss Portal//DTD Portlet Instances 2.6//EN"
+ "http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
+
+<deployments>
+ <deployment>
+ <instance>
+ <instance-id>NetvibesWidgetPortletInstance</instance-id>
+ <portlet-ref>NetvibesWidgetPortlet</portlet-ref>
+ </instance>
+ </deployment>
+</deployments>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/portlet.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app
+ xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ version="1.0">
+ <portlet>
+ <description>Netvibes Widget Portlet</description>
+ <portlet-name>NetvibesWidgetPortlet</portlet-name>
+ <display-name>Netvibes Widget Portlet</display-name>
+ <portlet-class>org.jboss.portal.widget.netvibes.NetvibesWidgetPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>EDIT_CONTENT</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Netvibes Widget</title>
+ <keywords>widget,netvibes</keywords>
+ </portlet-info>
+ </portlet>
+</portlet-app>
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/web.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-netvibes-war/WEB-INF/web.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <context-param>
+ <param-name>org.jboss.portal.content_type</param-name>
+ <param-value>widget/netvibes</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.jboss.portal.portlet_instance</param-name>
+ <param-value>NetvibesWidgetPortletInstance</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portlet.content.ContentTypeRegistration</listener-class>
+ </listener>
+</web-app>
Deleted: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit.jsp 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit.jsp 2007-11-09 17:42:36 UTC (rev 8859)
@@ -1,275 +0,0 @@
-<%@ page import="org.jboss.portal.common.util.IteratorStatus" %>
-<%@ page import="org.jboss.portal.widget.google.GGWidget" %>
-<%@ page import="org.jboss.portal.widget.google.info.GGPreferenceInfo" %>
-<%@ page import="org.jboss.portal.widget.google.info.GGWidgetCategoryInfo" %>
-<%@ page import="org.jboss.portal.widget.google.provider.GGProvider" %>
-<%@ page import="org.jboss.portal.widget.google.provider.GGQuery" %>
-<%@ page import="org.jboss.portal.widget.google.provider.GGQueryResult" %>
-<%@ page import="org.jboss.portal.widget.google.type.DataType" %>
-<%@ page import="org.jboss.portal.widget.google.type.EnumType" %>
-<%@ page import="javax.portlet.PortletURL" %>
-<%@ page import="java.util.Collection" %>
-<%@ page import="java.util.Iterator" %>
-<%@ page language="java" %>
-<%@ taglib uri="http://java.sun.com/portlet" prefix="p" %>
-<%@ page isELIgnored="false" %>
-
-<p:defineObjects/>
-<div>
-
-<%
- // Get useful request attributes
- GGProvider provider = (GGProvider)request.getAttribute("provider");
-
- // Get the selected widget if any
- GGWidget selWidget = null;
- String uri = request.getParameter("content.uri");
- if (uri != null)
- {
- selWidget = provider.getWidget(uri);
- }
-
- // Get query term
- String queryTerm = request.getParameter("query");
- if (queryTerm == null)
- {
- queryTerm = "";
- }
-
- // Get category term
- String catTerm = request.getParameter("cat");
- if (catTerm == null)
- {
- catTerm = "";
- }
-
- // Compute query
- GGQuery query = new GGQuery(0, catTerm, queryTerm, request.getLocale());
- Collection widgets = provider.search(query);
-
- String ggPickMethod = request.getParameter("gg_pick_method");
- boolean uriPickMethod = false;
- if (ggPickMethod != null && ggPickMethod.equals("uri"))
- {
- uriPickMethod = true;
- }
- else
- {
- }
-%>
-<div id="<p:namespace/>selection">
- <input type="RADIO" name="gg_pick_method" value="directory" <%= !uriPickMethod ? "CHECKED" : "" %>
- onclick="document.getElementById('<p:namespace/>directory_search_div').style.display = 'block'; document.getElementById('<p:namespace/>gadget_url_div').style.display = 'none'; ">
- Gadget Directory
- <input type="RADIO" name="gg_pick_method" value="uri" <%= uriPickMethod ? "CHECKED" : "" %>
- onclick="document.getElementById('<p:namespace/>directory_search_div').style.display = 'none'; document.getElementById('<p:namespace/>gadget_url_div').style.display = 'block'; ">
- Gadget URI
- <br>
- <hr>
-</div>
-
-<div id="<p:namespace/>gadget_url_div" style="display: <%= uriPickMethod ? "block" : "none" %>;">
- <%
- PortletURL contentURL = renderResponse.createActionURL();
- contentURL.setParameter("content.action.select", "content.action.select");
- contentURL.setParameter("gg_pick_method", "uri");
- %>
- <form action="<%= contentURL %>" method="post">
-
- <%
- if (uri != null && selWidget == null)
- {
-
- %>
- <p style="color: red;">
- <%
- out.println("Failed to obtain widget with URI: " + uri);
- %>
- </p>
- <%
- }
- else if (selWidget != null)
- {
- %>
- <p style="color: blue;">
- Selected
- Widget: <%= selWidget.getDirectoryTitle().getDefaultString().length() > 0 ? selWidget.getDirectoryTitle().getDefaultString() : selWidget.getTitle().getDefaultString() %>
- </p>
- <%
- }
- %>
-
- <input type="text" name="content.uri" value="<%= uri != null ? uri : "" %>" class="portlet-form-field"/>
- <input type="submit" value="Select Gadget" class="portlet-form-button"/>
- </form>
-</div>
-
-<div id="<p:namespace/>directory_search_div" style="display: <%= !uriPickMethod ? "block" : "none" %>;">
-
- <form action="<p:renderURL></p:renderURL>" method="post">
- <input type="text" name="query" class="portlet-form-field"/>
- <select name="cat" class="portlet-form-field">
- <option value=""> </option>
- <%
- for (Iterator i = provider.getCategories().iterator(); i.hasNext();)
- {
- GGWidgetCategoryInfo cat = (GGWidgetCategoryInfo)i.next();
- boolean selected = cat.getName().equals(catTerm);
- %>
- <option value="<%= cat.getName() %>" <%= selected ? "selected=\"selected\"" : "" %>><%= cat.getDisplayName() %>
- </option>
- <%
- }
- %>
- </select>
- <input type="submit" value="Search Gadgets" class="portlet-form-button"/>
- </form>
-
- <p>
- <table style="width:100%;border:1px solid" cellspacing="0" cellpadding="0">
- <%
- for (IteratorStatus i = new IteratorStatus(widgets.iterator()); i.hasNext();)
- {
- GGWidget widget = (GGWidget)i.next();
- boolean selected = selWidget != null && selWidget.getId().equals(widget.getId());
- PortletURL selectURL = renderResponse.createActionURL();
-
- // Set parameters for selection
- selectURL.setParameter("content.action.select", "content.action.select");
- selectURL.setParameter("content.uri", widget.getId());
-
- // Set default parametrization state
- for (Iterator j = widget.getInfo().getPreferences().getPreferences().iterator(); j.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)j.next();
- String paramName = "content.param." + prefInfo.getName();
- String defaultValue = prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "";
- selectURL.setParameter(paramName, defaultValue);
- }
-
- // Propagage search nav state
- selectURL.setParameter("cat", catTerm);
- selectURL.setParameter("query", queryTerm);
-
- //
- String rowClass = selected ? "portlet-section-selected" : (i.getIndex() % 2 == 0 ? "portlet-section-body" : "portlet-section-alternate");
- %>
- <tr class="<%= rowClass %>">
- <td><a
- href="<%= selectURL %>"><%= widget.getDirectoryTitle().getDefaultString().length() > 0 ? widget.getDirectoryTitle().getDefaultString() : widget.getTitle().getDefaultString() %>
- </a></td>
- </tr>
- <%
- }
- %>
- </table>
- </p>
-
-</div>
-<div>
-<%
- if (selWidget != null && !selWidget.getInfo().getPreferences().getPreferences().isEmpty())
- {
- PortletURL selectURL = renderResponse.createActionURL();
-
- // Set parameters for selection
- selectURL.setParameter("content.action.select", "content.action.select");
- selectURL.setParameter("content.uri", selWidget.getId());
-
- // Propagage search nav state
- selectURL.setParameter("cat", catTerm);
- selectURL.setParameter("query", queryTerm);
-
- //propagate visable div
- if (uriPickMethod)
- {
- selectURL.setParameter("gg_pick_method", "uri");
- }
-%>
-<p>
-
-<form action="<%= selectURL %>" method="post">
- <%
- for (Iterator i = selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
- if (prefInfo.getType().getOrdinal() == DataType.HIDDEN)
- {
-
- %>
- <input type="hidden" name="content.param.<%= prefInfo.getName() %>"
- value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/>
- <%
- }
- }
- %>
- <table>
- <tbody>
- <%
- for (Iterator i = selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
-
- // Get param value from nav state otherwise we use the default value
- String prefValue = request.getParameter("content.param." + prefInfo.getName());
- if (prefValue == null)
- {
- prefInfo.getDefaultValue();
- }
- if (prefValue == null)
- {
- prefValue = "";
- }
- %>
- <tr>
- <td><%= prefInfo.getDisplayName() != null ? prefInfo.getDisplayName() : prefInfo.getName() %>:</td>
- <%
- switch (prefInfo.getType().getOrdinal())
- {
- case DataType.HIDDEN:
- break;
- case DataType.ENUM:
- %>
- <td><select name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field">
- <%
- EnumType e = (EnumType)prefInfo.getType();
- for (int j = 0; j < e.getSize(); j++)
- {
- EnumType.Value value = e.getValue(j);
- boolean selected = value.getValue().equals(prefValue);
- %>
- <option <%= selected ? "selected=\"selected\"" : "" %>
- value="<%= value.getValue() %>"><%= value.getDisplayValue() != null ? value.getDisplayValue() : value.getValue() %>
- </option>
- <%
- }
- %>
- </select></td>
- <%
- break;
- default:
- %>
- <td><input type="text" name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"
- value="<%= prefValue %>"/></td>
- <%
- break;
- }
- %>
- </tr>
- <%
- }
- %>
- <tr>
- <td colspan="2"><input type="submit" value="Update" class="portlet-form-button"/></td>
- </tr>
- </tbody>
- </table>
-</form>
-</p>
-<%
- }
-%>
-</div>
-
-</div>
-
\ No newline at end of file
Added: 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 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,324 @@
+<%@ page import="org.jboss.portal.common.util.IteratorStatus" %>
+<%@ page import="org.jboss.portal.widget.DirectoryQueryResultEntry" %>
+<%@ page import="org.jboss.portal.widget.google.GGWidget" %>
+<%@ page import="org.jboss.portal.widget.google.info.GGPreferenceInfo" %>
+<%@ page import="org.jboss.portal.widget.google.info.GGWidgetCategoryInfo" %>
+<%@ page import="org.jboss.portal.widget.google.provider.GGProvider" %>
+<%@ page import="org.jboss.portal.widget.google.provider.GGQuery" %>
+<%@ page import="org.jboss.portal.widget.google.provider.GGQueryResult" %>
+<%@ page import="org.jboss.portal.widget.google.type.DataType" %>
+<%@ page import="org.jboss.portal.widget.google.type.EnumType" %>
+<%@ page import="javax.portlet.PortletURL" %>
+<%@ page import="java.lang.Integer" %>
+<%@ page import="java.util.List" %>
+<%@ page import="java.util.Collection" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page language="java" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="p" %>
+<%@ page isELIgnored="false" %>
+
+<p:defineObjects/>
+<div>
+
+<%
+ // Get useful request attributes
+ GGProvider provider = (GGProvider)request.getAttribute("provider");
+
+ // Get the selected widget if any
+ GGWidget selWidget = null;
+ String uri = request.getParameter("content.uri");
+ if (uri != null)
+ {
+ selWidget = (GGWidget) provider.getWidget(uri);
+ }
+
+ // Pagination
+ int numberOfResults = 10;
+ int currentPage = 0;
+ String tempPage = request.getParameter("currentPage");
+ if ( tempPage != null && !tempPage.equals(""))
+ {
+ int temp = Integer.parseInt(tempPage);
+ currentPage = temp < 0 ? 0 : temp;
+ }
+
+
+ // Get query term
+ String queryTerm = request.getParameter("query");
+ if (queryTerm == null)
+ {
+ queryTerm = "";
+ }
+
+ // Get category term
+ String catTerm = request.getParameter("cat");
+ if (catTerm == null)
+ {
+ catTerm = "";
+ }
+
+ // Compute query
+ int queryStart = currentPage * numberOfResults;
+ GGQuery query = new GGQuery(queryStart, numberOfResults, catTerm, queryTerm, request.getLocale());
+ List queryResults = provider.search(query);
+
+ String ggPickMethod = request.getParameter("gg_pick_method");
+ boolean uriPickMethod = false;
+ if (ggPickMethod != null && ggPickMethod.equals("uri"))
+ {
+ uriPickMethod = true;
+ }
+ else
+ {
+ }
+%>
+<div id="<p:namespace/>selection">
+ <input type="RADIO" name="gg_pick_method" value="directory" <%= !uriPickMethod ? "CHECKED" : "" %>
+ onclick="document.getElementById('<p:namespace/>directory_search_div').style.display = 'block'; document.getElementById('<p:namespace/>gadget_url_div').style.display = 'none'; ">
+ Gadget Directory
+ <input type="RADIO" name="gg_pick_method" value="uri" <%= uriPickMethod ? "CHECKED" : "" %>
+ onclick="document.getElementById('<p:namespace/>directory_search_div').style.display = 'none'; document.getElementById('<p:namespace/>gadget_url_div').style.display = 'block'; ">
+ Gadget URI
+ <br>
+ <hr>
+</div>
+
+<div id="<p:namespace/>gadget_url_div" style="display: <%= uriPickMethod ? "block" : "none" %>;">
+ <%
+ PortletURL contentURL = renderResponse.createActionURL();
+ contentURL.setParameter("content.action.select", "content.action.select");
+ contentURL.setParameter("gg_pick_method", "uri");
+ %>
+ <form action="<%= contentURL %>" method="post">
+
+ <%
+ if (uri != null && selWidget == null)
+ {
+ %>
+ <p style="color: red;">
+ <%
+ out.println("Failed to obtain widget with URI: " + uri);
+ %>
+ </p>
+ <%
+ }
+ else if (selWidget != null)
+ {
+ %>
+ <p style="color: blue;">
+ Selected
+ Widget: <%=selWidget.getDirectoryTitle().getDefaultString().length() > 0 ? selWidget.getDirectoryTitle().getDefaultString() : selWidget.getTitle().getDefaultString()%>
+ </p>
+ <%
+ }
+ %>
+
+ <input type="text" name="content.uri" value="<%= uri != null ? uri : "" %>" class="portlet-form-field"/>
+ <input type="submit" value="Select Gadget" class="portlet-form-button"/>
+ </form>
+</div>
+
+<div id="<p:namespace/>directory_search_div" style="display: <%= !uriPickMethod ? "block" : "none" %>;">
+
+ <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>
+ <%
+ for (Iterator i = provider.getCategories().iterator(); i.hasNext();)
+ {
+ GGWidgetCategoryInfo cat = (GGWidgetCategoryInfo)i.next();
+ boolean selected = cat.getName().equals(catTerm);
+ %>
+ <option value="<%= cat.getName() %>" <%= selected ? "selected=\"selected\"" : "" %>><%=cat.getDisplayName()%>
+ </option>
+ <%
+ }
+ %>
+ </select>
+ <input type="submit" value="Search Gadgets" class="portlet-form-button"/>
+ </form>
+
+ <p>
+ <table style="width:100%; border: 1px solid;" cellspacing="0" cellpadding="0">
+ <%
+ for (IteratorStatus i = new IteratorStatus(queryResults.iterator()); i.hasNext();)
+ {
+ DirectoryQueryResultEntry result = (DirectoryQueryResultEntry) i.next();
+ boolean selected = selWidget != null && selWidget.getId().equals(result.getURL().toString());
+ PortletURL selectURL = renderResponse.createActionURL();
+
+ // Set parameters for selection
+ selectURL.setParameter("content.action.select", "content.action.select");
+ selectURL.setParameter("content.uri", result.getURL().toString());
+
+ // Set default parametrization state
+ // TODO ? really needed
+
+ // Propagage search nav state
+ selectURL.setParameter("cat", catTerm);
+ selectURL.setParameter("query", queryTerm);
+ selectURL.setParameter("currentPage", String.valueOf(currentPage));
+
+ //
+ String rowClass = selected ? "portlet-section-selected" : (i.getIndex() % 2 == 0 ? "portlet-section-body" : "portlet-section-alternate");
+ %>
+ <tr class="<%= rowClass %>">
+ <td><a
+ href="<%= selectURL %>"><%= result.getTitle() %>
+ </a></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ <table style="width:100%; border: none;" cellspacing="0" cellpadding="0">
+ <tr>
+ <td style="test-align: left;">
+ <% // previous page
+ if ( currentPage > 0 )
+ {
+ PortletURL prevURL = renderResponse.createRenderURL();
+ prevURL.setParameter("cat", catTerm);
+ prevURL.setParameter("query", queryTerm);
+
+ String prevPage = String.valueOf(currentPage - 1);
+
+ prevURL.setParameter("currentPage", prevPage);
+ %><a href="<%=prevURL %>">previous page</a><%
+ }
+ %>
+ </td>
+ <td style="text-align: right;">
+ <% // next page
+ if ( queryResults.size() >= numberOfResults )
+ {
+ PortletURL nextURL = renderResponse.createRenderURL();
+ nextURL.setParameter("cat", catTerm);
+ nextURL.setParameter("query", queryTerm);
+
+ String nextPage = String.valueOf(currentPage + 1);
+
+ nextURL.setParameter("currentPage", nextPage);
+ %><a href="<%= nextURL %>">next page</a><%
+ }
+ %>
+ </td>
+ </tr>
+ </table>
+ </p>
+
+</div>
+<div>
+<%
+ if (selWidget != null && !selWidget.getInfo().getPreferences().getPreferences().isEmpty())
+ {
+ PortletURL selectURL = renderResponse.createActionURL();
+
+ // Set parameters for selection
+ selectURL.setParameter("content.action.select", "content.action.select");
+ selectURL.setParameter("content.uri", selWidget.getId());
+
+ // Propagage search nav state
+ selectURL.setParameter("cat", catTerm);
+ selectURL.setParameter("query", queryTerm);
+ selectURL.setParameter("currentPage", String.valueOf(currentPage));
+
+ //propagate visable div
+ if (uriPickMethod)
+ {
+ selectURL.setParameter("gg_pick_method", "uri");
+ }
+%>
+<p>
+
+<form action="<%= selectURL %>" method="post">
+ <%
+ for (Iterator i = selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
+ {
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
+ if (prefInfo.getType().getOrdinal() == DataType.HIDDEN)
+ {
+
+ %>
+ <input type="hidden" name="content.param.<%= prefInfo.getName() %>"
+ value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/>
+ <%
+ }
+ }
+ %>
+ <table>
+ <tbody>
+ <%
+ for (Iterator i = selWidget.getInfo().getPreferences().getPreferences().iterator(); i.hasNext();)
+ {
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
+
+ // Get param value from nav state otherwise we use the default value
+ String prefValue = request.getParameter("content.param." + prefInfo.getName());
+ int prefType = prefInfo.getType().getOrdinal();
+ if (prefValue == null)
+ {
+ prefInfo.getDefaultValue();
+ }
+ if (prefValue == null)
+ {
+ prefValue = "";
+ }
+
+ if ( prefType != DataType.HIDDEN )
+ {
+ %>
+ <tr>
+ <td><%= prefInfo.getDisplayName() != null ? prefInfo.getDisplayName() : prefInfo.getName() %>:</td>
+ <%
+ switch (prefType)
+ {
+ case DataType.HIDDEN:
+ break;
+ case DataType.ENUM:
+ %>
+ <td><select name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field">
+ <%
+ EnumType e = (EnumType)prefInfo.getType();
+ for (int j = 0; j < e.getSize(); j++)
+ {
+ EnumType.Value value = e.getValue(j);
+ boolean selected = value.getValue().equals(prefValue);
+ %>
+ <option <%= selected ? "selected=\"selected\"" : "" %>
+ value="<%= value.getValue() %>"><%= value.getDisplayValue() != null ? value.getDisplayValue() : value.getValue() %>
+ </option>
+ <%
+ }
+ %>
+ </select></td>
+ <%
+ break;
+ default:
+ %>
+ <td><input type="text" name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field"
+ value="<%= prefValue %>"/></td>
+ <%
+ break;
+ } // endof switch
+ } // endof if != hidden
+ %>
+ </tr>
+ <%
+ } // for preferences
+ %>
+ <tr>
+ <td colspan="2"><input type="submit" value="Update" class="portlet-form-button"/></td>
+ </tr>
+ </tbody>
+ </table>
+</form>
+</p>
+<%
+ }
+%>
+</div>
+
+</div>
+
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/portlet.xml 2007-11-09 15:24:46 UTC (rev 8858)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/portlet.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -31,12 +31,12 @@
<description>Google Widget Portlet</description>
<portlet-name>GoogleWidgetPortlet</portlet-name>
<display-name>Google Widget Portlet</display-name>
- <portlet-class>org.jboss.portal.widget.WidgetPortlet</portlet-class>
+ <portlet-class>org.jboss.portal.widget.google.GGWidgetPortlet</portlet-class>
<init-param>
<description>Connection timeout when retreiving gadgets from google directory</description>
<name>connectionTimeout</name>
<value>5000</value>
- </init-param>
+ </init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
@@ -44,7 +44,7 @@
</supports>
<portlet-info>
<title>Google Widget</title>
- <keywords>widget</keywords>
+ <keywords>widget,google</keywords>
</portlet-info>
</portlet>
</portlet-app>
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget1_fail.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget1_fail.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget1_fail.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1 @@
+wrdlbrmpft
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget3.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget3.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget3.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <UserPref name="difficulty" display_name="Difficulty" datatype="enum" default_value="easiest" urlparam="difficulty">
+ <EnumValue value="easiest" display_value="easiest"/>
+ <EnumValue value="easy" display_value="easy"/>
+ <EnumValue value="medium" display_value="medium"/>
+ <EnumValue value="hard" display_value="hard"/>
+ <EnumValue value="hardest" display_value="hardest"/>
+ </UserPref>
+ <!-- <UserPref name="size" display_name="Size" datatype="enum" default_value="small" urlparam="squareSize">
+ <EnumValue value="small" display_value="small" />
+ <EnumValue value="medium" display_value="medium" />
+ <EnumValue value="large" display_value="large" />
+ </UserPref>
+ <UserPref name="ads" display_name="Display Ads" datatype="enum" default_value="true" urlparam="displayAds">
+ <EnumValue value="true" display_value="true" />
+ <EnumValue value="false" display_value="false" />
+ </UserPref>
+ -->
+ <ModulePrefs title="Sudoku" directory_title="Free Sudoku Puzzles" description="Play Sudoku on your Personalized Google Homepage." screenshot="http://www.counttonine.com/images/google-screenshot.gif" title_url="http://www.counttonine.com" author="Wayne Crosby" author_email="wcrosby(a)gmail.com" author_link="http://www.counttonine.com/aboutUs.htm" author_location="Scottsdale, AZ" author_affiliation="Count to Nine" height="370" scrolling="false" author_aboutme="Count to Nine was created by Wayne and Christi Crosby who reside in Scottsdale, AZ. Wayne is a software engineer for www.amazon.com and Christi works with local transplant teams as an organ preservation coordinator, in addition to riding hunter/jumpers with www.goodcharacterfarm.com." author_photo="http://www.counttonine.com/images/google-author-picture.png" author_quote="Why be normal when you can be notable?"/>
+ <Content type="url" href="http://www.counttonine.com/displayGoogleAjaxGame.html"/>
+</Module>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget4.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget4.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget4.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs
+ title="Interesting Photos of the Day"
+ height="395"
+ title_url="http://gadgets.zytu.com/indexNew.html"
+ description="Displays a slideshow of the most interesting photos of the day, as determined by Flickr's interestingness algorithm."
+ author="David Olsen"
+ category="lifestyle"
+ author_photo="http://www.zytu.com/Gadgets/images/me.png"
+ author_aboutme="Addicted to technology and development"
+ author_quote="Keep it simple!"
+ author_link="http://www.zytu.com"
+ author_email="whistled(a)gmail.com"
+ author_location="Philadelphia, PA"
+ author_affiliation="Zytu Inc."
+ screenshot="http://phillip132.googlepages.com/most_ss.png"
+ thumbnail="http://phillip132.googlepages.com/most_thumb.png">
+ <Require feature="analytics"/>
+ </ModulePrefs>
+ <UserPref name="count" display_name="Show" default_value="25 photos" datatype="enum">
+ <EnumValue value="1 photo"/>
+ <EnumValue value="5 photos"/>
+ <EnumValue value="10 photos"/>
+ <EnumValue value="25 photos"/>
+ </UserPref>
+ <UserPref name="delay" display_name="Delay" default_value="5 seconds" datatype="enum">
+ <EnumValue value="1 second"/>
+ <EnumValue value="3 seconds"/>
+ <EnumValue value="5 seconds"/>
+ <EnumValue value="10 seconds"/>
+ <EnumValue value="15 seconds"/>
+ <EnumValue value="30 seconds"/>
+ <EnumValue value="60 seconds"/>
+ </UserPref>
+ <Content type="html">
+ <![CDATA[
+ <script>
+ _IG_Analytics("UA-193144-3", "/mostinteresting");
+ </script>
+ <head>
+
+ <script type="text/javascript" src="http://phillip132.googlepages.com/interesting-photos-slide.js"></script>
+ <script type="text/javascript" src="http://www.zytu.com/Gadgets/google/interesting-photos/interesting-photos.js"></script>
+ <script type="text/javascript">
+ s=interestingness();
+ slides=new slideshow("slides");
+ prefs=new _IG_Prefs(__MODULE_ID__);
+ slides.timeout=(prefs.getString("delay").split(' '))[0]*1000;
+ x=(prefs.getString("count").split(' '))[0]*1;
+ for(i=0;i<x;i++)
+ slides.add_slide(s[i]);
+ function flip(id,name)
+ {
+ document.getElementById(id).src="http://www.zytu.com/Gadgets/images/"+name;
+ }
+ function pause_me()
+ {
+ slides.pause();
+ flip('pause','iplay.png');
+ document.getElementById("pause").onmouseover=function(){flip('pause','iplay.png')};
+ document.getElementById("pause").onmouseout=function(){flip('pause','play.png')};
+ document.getElementById("pause").onclick=function(){play_me()};
+ }
+ function play_me()
+ {
+ slides.play();
+ flip('pause','ipause.png');
+ document.getElementById("pause").onmouseover=function(){flip('pause','ipause.png')};
+ document.getElementById("pause").onmouseout=function(){flip('pause','pause.png')};
+ document.getElementById("pause").onclick=function(){pause_me()};
+ }
+ </script>
+ </head>
+ <body onLoad="slides.update()">
+ <center>
+ <img id="back" src="http://phillip132.googlepages.com/back.png" border="0" onClick="slides.previous()" onMouseOver="flip('back','iback.png')" onMouseOut="flip('back','back.png')">
+ <img id="pause" src="http://phillip132.googlepages.com/pause.png" border="0" onClick="pause_me()" onMouseOver="flip('pause','ipause.png')" onMouseOut="flip('pause','pause.png')">
+ <img id="forward" src="http://phillip132.googlepages.com/forward.png" border="0" onClick="slides.next()" onMouseOver="flip('forward','iforward.png')" onMouseOut="flip('forward','forward.png')"><br>
+ <font size="2"><a href="http://photos.zytu.com/exploreNew.php?year=2007&month=9&day=3&limit=10&set=0" target="_blank">Browse Past Interesting Photos</a></font><br>
+ <a id="slide_link" href="" target="_blank">
+ <img name="slide_img" src="http://phillip132.googlepages.com/spacer.png" border="0"></a><br>
+ <div id="slide_text" style="position: relative; height: 56; overflow: hidden;">
+ Loading...
+ </div><br>
+ <img id="spacer" src="http://phillip132.googlepages.com/spacer.png" border="0" width="1" height="1"><br>
+ <iframe src="http://zytu.com/gadgets_ad.php" scrolling="no" frameborder="0" width="96%" height="50px"></iframe>
+ <img src="http://www.tqlkg.com/image-2239496-10431539" width="1" height="1" border="0"/>
+ </center>
+ <script type="text/javascript">
+ <!--
+ if(document.images)
+ {
+ slides.image=document.images.slide_img;
+ slides.textid="slide_text";
+ slides.linkid="slide_link";
+ slides.update();
+ slides.play();
+ }
+ //-->
+ </script>
+ </body>
+ ]]>
+ </Content>
+</Module>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget5.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget5.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget5.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs title="Currency Converter" screenshot="http://dob.ireland.googlepages.com/curr_prv.png" thumbnail="http://dob.ireland.googlepages.com/curr_thm.png" author="Donal O'Brien" author_email="dob.ireland+gadgets(a)gmail.com" author_location="Dublin, Ireland" author_photo="http://dob.ireland.googlepages.com/avatar.png" author_link="http://www.donalobrien.net/" title_url="http://www.donalobrien.net/" height="170"/>
+ <UserPref name="def_from" display_name="Default "From" Symbol" default_value="USD" urlparam="def_from"/>
+ <UserPref name="def_to" display_name="Default "To" Symbol" default_value="EUR" urlparam="def_to"/>
+ <Content type="url" href="http://www.donalobrien.net/apps/currency/"/>
+</Module>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget6.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget6.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget6.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs
+ title="Muay Thai"
+ render_inline="optional"
+ description="This cool fighting Muay Thai game is easy to control. Use your LEFT and RIGHT ARROW KEYS to move your warrior left or right. And press Z key to BLOCK, X KEY to PUNCH, and C KEY to KICK. Play Training mode to learn some special punches and kicks."
+ screenshot="http://games.uflaz.com//images/muaythai.jpg"
+ thumbnail="http://games.uflaz.com//images/muaythai.jpg"
+ author="Wielee"
+ author_email="wielee(a)gmail.com"
+ author_affiliation="None"
+ author_location="Bogor City, State of West Java Country Indonesia"
+ author_aboutme="webmaster Uflaz.com"
+ height="400"
+ title_url="http://games.uflaz.com">
+<Require feature="analytics"/>
+</ModulePrefs>
+<Content type="url" href="http://games.uflaz.com/play-167-Muay_Thai.html"/>
+</Module>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget7.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget7.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget7.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs
+ title="__MSG_wikipedia__"
+ height="40"
+ description="__MSG_description__"
+ author="Benno Kruit"
+ author_email="bennokr+be_gone_spammers(a)gmail.com"
+ screenshot="http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wikipedia.gif"
+ author_location="Delft, The Netherlands"
+ title_url="http://www.wikipedia.org/">
+ <Locale messages="wpsearchbar_content/wk_msg_en.xml"/>
+ <Locale lang="ja" messages="wpsearchbar_content/wk_msg_ja.xml"/>
+ <Locale lang="pt-BR" messages="wpsearchbar_content/wk_msg_pt-br.xml"/>
+ <Locale lang="ko" messages="wpsearchbar_content/wk_msg_ko.xml"/>
+ <Locale lang="es" messages="wpsearchbar_content/wk_msg_es.xml"/>
+ <Locale lang="fr" messages="wpsearchbar_content/wk_msg_fr.xml"/>
+ <Locale lang="ru" messages="wpsearchbar_content/wk_msg_ru.xml"/>
+ <Locale lang="zh-CN" messages="wpsearchbar_content/wk_msg_zh-cn.xml"/>
+ <Locale lang="nl" messages="wpsearchbar_content/wk_msg_nl.xml"/>
+ <Locale lang="de" messages="wpsearchbar_content/wk_msg_de.xml"/>
+ <Locale lang="it" messages="wpsearchbar_content/wk_msg_it.xml"/>
+ <Require feature="analytics"/>
+</ModulePrefs>
+<UserPref name="mylang" display_name="__MSG_language__" default_value="" datatype="enum">
+ <EnumValue display_value="__MSG_en__" value="en"/>
+ <EnumValue display_value="__MSG_de__" value="de"/>
+ <EnumValue display_value="__MSG_fr__" value="fr"/>
+ <EnumValue display_value="__MSG_ja__" value="ja"/>
+ <EnumValue display_value="__MSG_pl__" value="pl"/>
+ <EnumValue display_value="__MSG_it__" value="it"/>
+ <EnumValue display_value="__MSG_sv__" value="sv"/>
+ <EnumValue display_value="__MSG_nl__" value="nl"/>
+ <EnumValue display_value="__MSG_pt__" value="pt"/>
+ <EnumValue display_value="__MSG_es__" value="es"/>
+ <EnumValue display_value="__MSG_zh__" value="zh"/>
+ <EnumValue display_value="__MSG_ru__" value="ru"/>
+ <EnumValue display_value="__MSG_no__" value="no"/>
+ <EnumValue display_value="__MSG_fi__" value="fi"/>
+ <EnumValue display_value="__MSG_da__" value="da"/>
+ <EnumValue display_value="__MSG_eo__" value="eo"/>
+ <EnumValue display_value="__MSG_he__" value="he"/>
+ <EnumValue display_value="__MSG_hu__" value="hu"/>
+ <EnumValue display_value="__MSG_ca__" value="ca"/>
+ <EnumValue display_value="__MSG_uk__" value="uk"/>
+ <EnumValue display_value="__MSG_cs__" value="cs"/>
+ <EnumValue display_value="__MSG_bg__" value="bg"/>
+ <EnumValue display_value="__MSG_sl__" value="sl"/>
+ <EnumValue display_value="__MSG_sk__" value="sk"/>
+ <EnumValue display_value="__MSG_ko__" value="ko"/>
+ <EnumValue display_value="__MSG_sr__" value="sr"/>
+ <EnumValue display_value="__MSG_ro__" value="ro"/>
+ <EnumValue display_value="__MSG_id__" value="id"/>
+ <EnumValue display_value="__MSG_et__" value="et"/>
+ <EnumValue display_value="__MSG_io__" value="io"/>
+ <EnumValue display_value="__MSG_tr__" value="tr"/>
+ <EnumValue display_value="__MSG_nn__" value="nn"/>
+ <EnumValue display_value="__MSG_hr__" value="hr"/>
+ <EnumValue display_value="__MSG_gl__" value="gl"/>
+ <EnumValue display_value="__MSG_lt__" value="lt"/>
+</UserPref>
+<Content type="html"><![CDATA[
+<style>
+ #subLang {
+ font-family:arial, sans-serif;
+ font-size:10px;
+ color:#676767;
+ }
+ #wikiLink {
+ font-family:Garamond, serif;
+ font-size:32px;
+ color:black;
+ text-decoration:none;
+ }
+ #searchGoButton {
+ font-weight:bold;
+ }
+</style>
+<script>
+function displaySearchBar (prefs) {
+ var lang = _hesc( prefs.getString("mylang"));
+ if (lang == "") {
+ lang = prefs.getString(".lang");
+ }
+ var html =
+ '<form target="_parent" name="searchform" action="http://' + lang +
+ '.wikipedia.org/wiki/Special:Search" id="searchform">' +
+ '<table style="width:100%">' +
+ '<tr>' +
+ '<td style="padding-bottom:4px">' +
+ '<a target="_parent" id=wikiLink href="http://' + lang +
+ '.wikipedia.org/wiki/">W</a>' +
+ '<span style="vertical-align: sub;">' + lang + '</span>' +
+ '</td>' +
+ '<td width=100%>' +
+ '<input id="searchInput" style="width:100%" name="search" type="text" accesskey="f" value="" />' +
+ '</td>' +
+ '<td>' +
+ '<input type="submit" name="go" id="searchGoButton" value="__MSG_go__" />' +
+ '</td>' +
+ '<td>' +
+ '<input type="submit" name="fulltext" value="__MSG_search__" />' +
+ '</td>' +
+ '</tr>' +
+ '</table>'
+ '<form>';
+ document.write(html);
+}
+ displaySearchBar(new _IG_Prefs(__MODULE_ID__));
+ _IG_Analytics("UA-1459042-2", "/wpsearchbar");
+</script>
+ ]]>
+</Content>
+</Module>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget8.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget8.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/gadget8.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,16 @@
+<html><head></head><body><module>
+<moduleprefs title="A Joke A Day" directory_title="A Joke A Day" title_url="http://happy-gods.com/jokes" description="Every day a new joke. What more could you want? Maybe being able to vote for the jokes you like? You got it! WARNING: NOT ALL JOKES CHILDREN FRIENDLY. We are currently working on implementing content rating" author="Craig Bennett" author_email="theclyde\(a)happy-gods.com" author_affiliation="happy-gods.com" author_location="Winnipeg, MB Canada" screenshot="http://happy-gods.com/jokes/images/googlesreencap.png" thumbnail="http://happy-gods.com/jokes/images/googlesmile.png" render_inline="optional" scrolling="true" author_photo="http://happy-gods.com/jokes/images/googleauthor.png" author_aboutme="If you need to know - try my blog (theclyde.livejournal.com)" author_link="http://www.happy-gods.com" author_quote="When I use a word, Humpty Dumpty said, in a rather scornful tone, it means just what I choose it to mean-neither more nor less">
+<content type="html">
+<!--[CDATA[
+<FONT SIZE=-1>A man was driving down the road, and was pulled over by a police office.
+<br>The office said, "you're drunk."
+<br>The driver said, "thank god for that, I thought the steering had gone."
+<HR>
+<CENTER>
+<A TARGET=_NEW HREF="http://happy-gods.com/jokes/vote.php?id=4504">Vote</A> / <A TARGET=_NEW HREF="http://happy-gods.com/jokes/share.php?id=4504">Share</A>
+</CENTER>
+</FONT>
+]]-->
+</content>
+</moduleprefs>
+ </module></body></html>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult2.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult2.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult2.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,447 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"
+xmlns="http://backend.userland.com/rss2"
+xmlns:ghapi="http://www.google.com/apis/homepage">
+<channel>
+<title>Homepage Content</title>
+<link>http://www.google.com/ig/</link>
+<image>http://www.google.com/ig/images/igoogle_logo_sm.gif</image>
+<description>Homepage Content search results.</description>
+<language>en</language>
+<copyright>Copyright 2007 and onwards Google, Inc.</copyright>
+<!-- number of items total, the actual items are affected by pagination --><ghapi:num_items>23449</ghapi:num_items>
+<ghapi:search_example>e.g. calendar, Dilbert, Washington Post</ghapi:search_example>
+<ghapi:weekly_pageviews_info>Gadget pageview statistics are approximate only-- for precise statistics, we recommend the use of Google Analytics inside your gadgets. Gadget pageviews represent the actual number of times that the gadget was rendered, including Google Personalized Homepage, Google Pages, Google Desktop and across thousands of independent pages around the web.</ghapi:weekly_pageviews_info>
+<item>
+<title>Wikipedia</title>
+<link>http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wpsearchba...</link>
+<guid>http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wpsearchba...</guid>
+<description>A Wikipedia Search and Go widget. Language choice.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_wikipedia_full.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_wikipedia.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>bennokr+be_gone_spammers(a)gmail.com</author>
+<ghapi:author_name>Benno Kruit</ghapi:author_name>
+<ghapi:author_location>Delft, The Netherlands</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>40</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>ToDo</title>
+<link>http://www.labpixies.com/campaigns/todo/todo.xml</link>
+<guid>http://www.labpixies.com/campaigns/todo/todo.xml</guid>
+<description>ToDo Gadget, easily manage and track your daily to-do list. ToDo gadget lets you add up to 7 tasks, the average amount of concurrent tasks the human brain can handle effectively (yes Dave, you can do more, we know). You can highlight tasks in different colors and change their priorities, everything ...</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/ed/6b/ed6ba0dd0740da2f7a0115bbe64b9f27.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/ed/6b/ed6ba0dd0740da2f7a0115bbe64b9f27-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>info+todo(a)labpixies.com</author>
+<ghapi:author_name>LabPixes</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>260</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Weather Forecasts</title>
+<link>http://www.labpixies.com/campaigns/weather/weather.xml</link>
+<guid>http://www.labpixies.com/campaigns/weather/weather.xml</guid>
+<description>Live Weather. View local weather conditions and forecasts provided by WeatherBug. Enjoy a great international weather service right on your homepage. Simply edit the settings to enter your local city</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/39/52/39526825c5ff68e37e9a89848d123dc8.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/39/52/39526825c5ff68e37e9a89848d123dc8-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>news</ghapi:category2>
+<author>info+weather(a)labpixies.com</author>
+<ghapi:author_name>LabPixies</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>240</ghapi:height>
+<ghapi:num_userprefs>3</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Date & Time</title>
+<link>http://www.google.com/ig/modules/datetime.xml</link>
+<guid>http://www.google.com/ig/modules/datetime.xml</guid>
+<description>Add a clock to your page. Click edit to change it to the color of your choice.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/datetime.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/datetime-thm.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>matt.feedback+datetime(a)gmail.com</author>
+<ghapi:author_name>Matt M.</ghapi:author_name>
+<ghapi:author_location>Mountain View, CA</ghapi:author_location>
+<ghapi:author_affiliation>Google Inc.</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>true</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>136</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Dictionary</title>
+<link>http://manikarthik84.googlepages.com/alldictgadget.xml</link>
+<guid>http://manikarthik84.googlepages.com/alldictgadget.xml</guid>
+<description>This will give the meaning of the Keyword entered using the selected Dictionary (Dictionary.com, Wordweb, Wiktionary, Cambridge or Etymologyonline.com) in a new Window. (Customizable)</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>manikarthik84(a)gmail.com</author>
+<ghapi:author_name>Karthik</ghapi:author_name>
+<ghapi:author_location>Chennai, India</ghapi:author_location>
+<ghapi:author_affiliation>Google-Widgets.blogspot.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>79</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Current Moon Phase</title>
+<link>http://www.calculatorcat.com/gmodules/current_moon.xml</link>
+<guid>http://www.calculatorcat.com/gmodules/current_moon.xml</guid>
+<description>See the current moon phase, phase name, percent of full, and date, based on your local time and hemisphere.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/1d/9c/1d9c433e52142ff3ba8d984ac38e3761.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/1d/9c/1d9c433e52142ff3ba8d984ac38e3761-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>technology</ghapi:category2>
+<author>bm.gmodules(a)gmail.com</author>
+<ghapi:author_name>CalculatorCat.com</ghapi:author_name>
+<ghapi:author_location>Tooele, UT</ghapi:author_location>
+<ghapi:author_affiliation>CalculatorCat.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>180</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>This Day in History</title>
+<link>http://sitesure.com/gadget/gadget.xml</link>
+<guid>http://sitesure.com/gadget/gadget.xml</guid>
+<ghapi:screenshot>http://www.google.com/ig/cache/95/b9/95b94d9747a5dd7efbc99d92f0aa83b5.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/95/b9/95b94d9747a5dd7efbc99d92f0aa83b5-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<ghapi:category2>lifestyle</ghapi:category2>
+<author>sitesure(a)gmail.com</author>
+<ghapi:author_name>Bill Hall</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>370</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Things to Ponder</title>
+<link>http://phillip132.googlepages.com/ponder.xml</link>
+<guid>http://phillip132.googlepages.com/ponder.xml</guid>
+<description>Random Things to Ponder</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/2a/39/2a39fee2ea5d00b3ec6631d02a194532.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/2a/39/2a39fee2ea5d00b3ec6631d02a194532-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_location>Elkton, MD</ghapi:author_location>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>169</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Garfield of the day</title>
+<link>http://www.listen-project.de/garfield/garfield.xml</link>
+<guid>http://www.listen-project.de/garfield/garfield.xml</guid>
+<description>Add Garfield to your page.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/df/5d/df5d43543124437c14b66f9c42b62f7e.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/df/5d/df5d43543124437c14b66f9c42b62f7e-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>mail(a)listen-project.de</author>
+<ghapi:author_name>telekommander</ghapi:author_name>
+<ghapi:author_location>Remscheid, Germany</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>330</ghapi:width>
+<ghapi:height>340</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Brain Teasers</title>
+<link>http://brainden.com/gadgets/brainteasers-gadget.xml</link>
+<guid>http://brainden.com/gadgets/brainteasers-gadget.xml</guid>
+<description>Brain teasers, riddles, logic puzzles, paradoxes, optical illusions, IQ tests, logical games etc.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/7f/e4/7fe40970e1f99526f70ba4bea479f785.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/7f/e4/7fe40970e1f99526f70ba4bea479f785-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>rookie1ja+coolgadget(a)googlemail.com</author>
+<ghapi:author_name>Jan Adamovic</ghapi:author_name>
+<ghapi:author_location>Slovakia</ghapi:author_location>
+<ghapi:author_affiliation>None</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>220</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Top 5 movies at the box office</title>
+<link>http://www.pramodfanda.info/gadget/top5movies.xml</link>
+<guid>http://www.pramodfanda.info/gadget/top5movies.xml</guid>
+<description>Get a list of top 5 hollywood movies at the box office this week</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/39/81/3981c5aee689de4ce4c931cba2321ef2.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/39/81/3981c5aee689de4ce4c931cba2321ef2-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>pramodfanda(a)gmail.com</author>
+<ghapi:author_name>Pramod Fanda</ghapi:author_name>
+<ghapi:author_location>Dubai</ghapi:author_location>
+<ghapi:author_affiliation>none</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>185</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Bible Verse of the Day</title>
+<link>http://www.believer.com/outreach/versetoday.xml</link>
+<guid>http://www.believer.com/outreach/versetoday.xml</guid>
+<description>Bible Verse of the Day with teachings to inspire and guide.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/fa/84/fa84b748f5ceddb772438b17c30b0fc2.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/fa/84/fa84b748f5ceddb772438b17c30b0fc2-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<author>today(a)Believer.com</author>
+<ghapi:author_name>Believer.com</ghapi:author_name>
+<ghapi:author_location>Sutherlin, OR</ghapi:author_location>
+<ghapi:author_affiliation>Believer.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>120</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Einstein Quote of the Day</title>
+<link>http://charles447.googlepages.com/albert-einstein.xml</link>
+<guid>http://charles447.googlepages.com/albert-einstein.xml</guid>
+<description>Albert Einstein Quote of the Day</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>technology</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_location>Elkton, MD</ghapi:author_location>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>140</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Fitness Tip of the Day</title>
+<link>http://phillip132.googlepages.com/fitness.xml</link>
+<guid>http://phillip132.googlepages.com/fitness.xml</guid>
+<description>Daily tips and quotes about fitness and exercise.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/c2/5d/c25dc64c96b128a50c313cb3ddf20be4.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/c2/5d/c25dc64c96b128a50c313cb3ddf20be4-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>140</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Search YouTube</title>
+<link>http://throttled.org/googlegadgets/youtubesearch.xml</link>
+<guid>http://throttled.org/googlegadgets/youtubesearch.xml</guid>
+<description>A search module, which searches YouTube by tags.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>whistled(a)gmail.com</author>
+<ghapi:author_name>David Olsen</ghapi:author_name>
+<ghapi:author_location>Philadelphia</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>250</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>A Joke A Day</title>
+<link>http://www.happy-gods.com/jokes/joke.xml</link>
+<guid>http://www.happy-gods.com/jokes/joke.xml</guid>
+<description>Every day a new joke. What more could you want? Maybe being able to vote for the jokes you like? You got it! WARNING: NOT ALL JOKES CHILDREN FRIENDLY. We are currently working on implementing content rating</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/64/d7/64d71e73322ca8ce9f614e51a36a8232.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/64/d7/64d71e73322ca8ce9f614e51a36a8232-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>theclyde\(a)happy-gods.com</author>
+<ghapi:author_name>Craig Bennett</ghapi:author_name>
+<ghapi:author_location>Winnipeg, MB Canada</ghapi:author_location>
+<ghapi:author_affiliation>happy-gods.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>200</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>National Geographic Photo of the Day</title>
+<link>http://drbeagledotcom.googlepages.com/ngpod.xml</link>
+<guid>http://drbeagledotcom.googlepages.com/ngpod.xml</guid>
+<description>National Geographic Photo of the Day</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<author>drbeagledotcom+modulefeedback(a)gmail.com</author>
+<ghapi:author_name>Cameron Hall</ghapi:author_name>
+<ghapi:author_location>Ithaca, NY, USA</ghapi:author_location>
+<ghapi:author_affiliation>Cornell University Student</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>200</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Funny Cat Photos</title>
+<link>http://blog.esaba.com/projects/catphotos/catphotos.xml</link>
+<guid>http://blog.esaba.com/projects/catphotos/catphotos.xml</guid>
+<description>This gadget displays a random funny cat photo everytime it loads. With over 2,300 photos to pick from, it is likely you will see a new photo everytime it loads. Click photos to enlarge.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>elias2+catphotos(a)gmail.com</author>
+<ghapi:author_name>Elias Saba</ghapi:author_name>
+<ghapi:author_location>Los Angeles, CA</ghapi:author_location>
+<ghapi:author_affiliation>http://blog.esaba.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>215</ghapi:height>
+<ghapi:num_userprefs>2</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Hangman (word game)</title>
+<link>http://www.thefreedictionary.com/_/WoD/hangman-module.xml</link>
+<guid>http://www.thefreedictionary.com/_/WoD/hangman-module.xml</guid>
+<description>Hangman - word game provided by TheFreeDictionary.com</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>info(a)farlex.com</author>
+<ghapi:author_name>Farlex</ghapi:author_name>
+<ghapi:author_affiliation>Farlex, Inc.</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>110</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Calendar</title>
+<link>http://members.aol.com/markjson/calendar.xml</link>
+<guid>http://members.aol.com/markjson/calendar.xml</guid>
+<description>Simple calendar shows three months and tracks important dates.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_calendar_20060413.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_calendar_20060413-thm.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2></ghapi:category2>
+<author>markjson(a)gmail.com</author>
+<ghapi:author_name>Mark Johnson</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>125</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Horoscope</title>
+<link>http://publish.clearspring.com/current/g/Google/464366710616c822/clearspr...</link>
+<guid>http://publish.clearspring.com/current/g/Google/464366710616c822/clearspr...</guid>
+<description>What is in your love life? Find out with this specialized astrology widget!</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/53/b7/53b795247e2d4750e3007c2cd272fbb4.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/53/b7/53b795247e2d4750e3007c2cd272fbb4-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>nbcu.widgets(a)gmail.com</author>
+<ghapi:author_name>iVillage</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>459</ghapi:width>
+<ghapi:height>277</ghapi:height>
+<ghapi:num_userprefs>2</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Spellcheck - AskAWord.com</title>
+<link>http://www.openinventions.com/spellcheck/openinventions_spellcheck.xml</link>
+<guid>http://www.openinventions.com/spellcheck/openinventions_spellcheck.xml</guid>
+<description>Free English spell checker, thesaurus, dictionary, and encyclopedia for your Google homepage or desktop.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/78/43/7843d6960efca96de3b186a25e0303be.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/78/43/7843d6960efca96de3b186a25e0303be-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>ivar(a)openinventions.com</author>
+<ghapi:author_name>Ivar Chan</ghapi:author_name>
+<ghapi:author_location>Arcadia, CA, USA</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>300</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Free Sudoku Puzzles</title>
+<link>http://www.counttonine.com/google-sudoku.xml</link>
+<guid>http://www.counttonine.com/google-sudoku.xml</guid>
+<description>Play Sudoku on your Personalized Google Homepage.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_sudoku2_full.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_sudoku2.png</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>wcrosby(a)gmail.com</author>
+<ghapi:author_name>Wayne Crosby</ghapi:author_name>
+<ghapi:author_location>Scottsdale, AZ</ghapi:author_location>
+<ghapi:author_affiliation>Count to Nine</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/4f/d3/4fd39a6bb3c617eef0f1c13eb3f56293-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>370</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Bart Simpson Phrase of the Day</title>
+<link>http://andrewgadget.googlepages.com/bart-simpson.xml</link>
+<guid>http://andrewgadget.googlepages.com/bart-simpson.xml</guid>
+<description>Bart Simpson Quote of the Day.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>andrewgadget(a)gmail.com</author>
+<ghapi:author_name>Andrew Gadget</ghapi:author_name>
+<ghapi:author_photo>/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>195</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item></channel></rss>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult3_fail.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult3_fail.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/google/queryresult3_fail.xml 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,448 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"
+xmlns="http://backend.userland.com/rss2"
+xmlns:ghapi="http://www.google.com/apis/homepage">
+<channel>
+<title>Homepage Content</title>
+<link>http://www.google.com/ig/</link>
+<image>http://www.google.com/ig/images/igoogle_logo_sm.gif</image>
+<description>Homepage Content search results.</description>
+<language>en</language>
+<copyright>Copyright 2007 and onwards Google, Inc.</copyright>
+<!-- number of items total, the actual items are affected by pagination --><ghapi:num_items>23449</ghapi:num_items>
+<ghapi:search_example>e.g. calendar, Dilbert, Washington Post</ghapi:search_example>
+<ghapi:weekly_pageviews_info>Gadget pageview statistics are approximate only-- for precise statistics, we recommend the use of Google Analytics inside your gadgets. Gadget pageviews represent the actual number of times that the gadget was rendered, including Google Personalized Homepage, Google Pages, Google Desktop and across thousands of independent pages around the web.</ghapi:weekly_pageviews_info>
+<!-- <item> -->
+
+<title>Wikipedia</title>
+<link>http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wpsearchba...</link>
+<guid>http://homepages.ipact.nl/~kruit/benno/folder/Documents/Google/wpsearchba...</guid>
+<description>A Wikipedia Search and Go widget. Language choice.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_wikipedia_full.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_wikipedia.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>bennokr+be_gone_spammers(a)gmail.com</author>
+<ghapi:author_name>Benno Kruit</ghapi:author_name>
+<ghapi:author_location>Delft, The Netherlands</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>40</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>ToDo</title>
+<link>http://www.labpixies.com/campaigns/todo/todo.xml</link>
+<guid>http://www.labpixies.com/campaigns/todo/todo.xml</guid>
+<description>ToDo Gadget, easily manage and track your daily to-do list. ToDo gadget lets you add up to 7 tasks, the average amount of concurrent tasks the human brain can handle effectively (yes Dave, you can do more, we know). You can highlight tasks in different colors and change their priorities, everything ...</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/ed/6b/ed6ba0dd0740da2f7a0115bbe64b9f27.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/ed/6b/ed6ba0dd0740da2f7a0115bbe64b9f27-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>info+todo(a)labpixies.com</author>
+<ghapi:author_name>LabPixes</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>260</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Weather Forecasts</title>
+<link>http://www.labpixies.com/campaigns/weather/weather.xml</link>
+<guid>http://www.labpixies.com/campaigns/weather/weather.xml</guid>
+<description>Live Weather. View local weather conditions and forecasts provided by WeatherBug. Enjoy a great international weather service right on your homepage. Simply edit the settings to enter your local city</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/39/52/39526825c5ff68e37e9a89848d123dc8.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/39/52/39526825c5ff68e37e9a89848d123dc8-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>news</ghapi:category2>
+<author>info+weather(a)labpixies.com</author>
+<ghapi:author_name>LabPixies</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>240</ghapi:height>
+<ghapi:num_userprefs>3</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Date & Time</title>
+<link>http://www.google.com/ig/modules/datetime.xml</link>
+<guid>http://www.google.com/ig/modules/datetime.xml</guid>
+<description>Add a clock to your page. Click edit to change it to the color of your choice.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/datetime.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/datetime-thm.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>matt.feedback+datetime(a)gmail.com</author>
+<ghapi:author_name>Matt M.</ghapi:author_name>
+<ghapi:author_location>Mountain View, CA</ghapi:author_location>
+<ghapi:author_affiliation>Google Inc.</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>true</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>136</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Dictionary</title>
+<link>http://manikarthik84.googlepages.com/alldictgadget.xml</link>
+<guid>http://manikarthik84.googlepages.com/alldictgadget.xml</guid>
+<description>This will give the meaning of the Keyword entered using the selected Dictionary (Dictionary.com, Wordweb, Wiktionary, Cambridge or Etymologyonline.com) in a new Window. (Customizable)</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>manikarthik84(a)gmail.com</author>
+<ghapi:author_name>Karthik</ghapi:author_name>
+<ghapi:author_location>Chennai, India</ghapi:author_location>
+<ghapi:author_affiliation>Google-Widgets.blogspot.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/d3/46/d3467955c8e87da903fcebc7c9939639-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>79</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Current Moon Phase</title>
+<link>http://www.calculatorcat.com/gmodules/current_moon.xml</link>
+<guid>http://www.calculatorcat.com/gmodules/current_moon.xml</guid>
+<description>See the current moon phase, phase name, percent of full, and date, based on your local time and hemisphere.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/1d/9c/1d9c433e52142ff3ba8d984ac38e3761.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/1d/9c/1d9c433e52142ff3ba8d984ac38e3761-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>technology</ghapi:category2>
+<author>bm.gmodules(a)gmail.com</author>
+<ghapi:author_name>CalculatorCat.com</ghapi:author_name>
+<ghapi:author_location>Tooele, UT</ghapi:author_location>
+<ghapi:author_affiliation>CalculatorCat.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>180</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>This Day in History</title>
+<link>http://sitesure.com/gadget/gadget.xml</link>
+<guid>http://sitesure.com/gadget/gadget.xml</guid>
+<ghapi:screenshot>http://www.google.com/ig/cache/95/b9/95b94d9747a5dd7efbc99d92f0aa83b5.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/95/b9/95b94d9747a5dd7efbc99d92f0aa83b5-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<ghapi:category2>lifestyle</ghapi:category2>
+<author>sitesure(a)gmail.com</author>
+<ghapi:author_name>Bill Hall</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>370</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Things to Ponder</title>
+<link>http://phillip132.googlepages.com/ponder.xml</link>
+<guid>http://phillip132.googlepages.com/ponder.xml</guid>
+<description>Random Things to Ponder</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/2a/39/2a39fee2ea5d00b3ec6631d02a194532.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/2a/39/2a39fee2ea5d00b3ec6631d02a194532-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_location>Elkton, MD</ghapi:author_location>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>169</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Garfield of the day</title>
+<link>http://www.listen-project.de/garfield/garfield.xml</link>
+<guid>http://www.listen-project.de/garfield/garfield.xml</guid>
+<description>Add Garfield to your page.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/df/5d/df5d43543124437c14b66f9c42b62f7e.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/df/5d/df5d43543124437c14b66f9c42b62f7e-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>mail(a)listen-project.de</author>
+<ghapi:author_name>telekommander</ghapi:author_name>
+<ghapi:author_location>Remscheid, Germany</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>330</ghapi:width>
+<ghapi:height>340</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Brain Teasers</title>
+<link>http://brainden.com/gadgets/brainteasers-gadget.xml</link>
+<guid>http://brainden.com/gadgets/brainteasers-gadget.xml</guid>
+<description>Brain teasers, riddles, logic puzzles, paradoxes, optical illusions, IQ tests, logical games etc.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/7f/e4/7fe40970e1f99526f70ba4bea479f785.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/7f/e4/7fe40970e1f99526f70ba4bea479f785-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>rookie1ja+coolgadget(a)googlemail.com</author>
+<ghapi:author_name>Jan Adamovic</ghapi:author_name>
+<ghapi:author_location>Slovakia</ghapi:author_location>
+<ghapi:author_affiliation>None</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>220</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Top 5 movies at the box office</title>
+<link>http://www.pramodfanda.info/gadget/top5movies.xml</link>
+<guid>http://www.pramodfanda.info/gadget/top5movies.xml</guid>
+<description>Get a list of top 5 hollywood movies at the box office this week</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/39/81/3981c5aee689de4ce4c931cba2321ef2.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/39/81/3981c5aee689de4ce4c931cba2321ef2-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>pramodfanda(a)gmail.com</author>
+<ghapi:author_name>Pramod Fanda</ghapi:author_name>
+<ghapi:author_location>Dubai</ghapi:author_location>
+<ghapi:author_affiliation>none</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>185</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Bible Verse of the Day</title>
+<link>http://www.believer.com/outreach/versetoday.xml</link>
+<guid>http://www.believer.com/outreach/versetoday.xml</guid>
+<description>Bible Verse of the Day with teachings to inspire and guide.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/fa/84/fa84b748f5ceddb772438b17c30b0fc2.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/fa/84/fa84b748f5ceddb772438b17c30b0fc2-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<author>today(a)Believer.com</author>
+<ghapi:author_name>Believer.com</ghapi:author_name>
+<ghapi:author_location>Sutherlin, OR</ghapi:author_location>
+<ghapi:author_affiliation>Believer.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>120</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Einstein Quote of the Day</title>
+<link>http://charles447.googlepages.com/albert-einstein.xml</link>
+<guid>http://charles447.googlepages.com/albert-einstein.xml</guid>
+<description>Albert Einstein Quote of the Day</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>technology</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_location>Elkton, MD</ghapi:author_location>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/34/0f/340f5600bb95b691b32bab3ff57e7a37-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>140</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Fitness Tip of the Day</title>
+<link>http://phillip132.googlepages.com/fitness.xml</link>
+<guid>http://phillip132.googlepages.com/fitness.xml</guid>
+<description>Daily tips and quotes about fitness and exercise.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/c2/5d/c25dc64c96b128a50c313cb3ddf20be4.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/c2/5d/c25dc64c96b128a50c313cb3ddf20be4-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>communication</ghapi:category2>
+<author>phillip132(a)gmail.com</author>
+<ghapi:author_name>Phillip Olsen</ghapi:author_name>
+<ghapi:author_affiliation>HumanMaze.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>140</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Search YouTube</title>
+<link>http://throttled.org/googlegadgets/youtubesearch.xml</link>
+<guid>http://throttled.org/googlegadgets/youtubesearch.xml</guid>
+<description>A search module, which searches YouTube by tags.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/28/a3/28a39282258f1ba32b6f6468ae6d12bc-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>whistled(a)gmail.com</author>
+<ghapi:author_name>David Olsen</ghapi:author_name>
+<ghapi:author_location>Philadelphia</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>250</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>A Joke A Day</title>
+<link>http://www.happy-gods.com/jokes/joke.xml</link>
+<guid>http://www.happy-gods.com/jokes/joke.xml</guid>
+<description>Every day a new joke. What more could you want? Maybe being able to vote for the jokes you like? You got it! WARNING: NOT ALL JOKES CHILDREN FRIENDLY. We are currently working on implementing content rating</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/64/d7/64d71e73322ca8ce9f614e51a36a8232.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/64/d7/64d71e73322ca8ce9f614e51a36a8232-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>theclyde\(a)happy-gods.com</author>
+<ghapi:author_name>Craig Bennett</ghapi:author_name>
+<ghapi:author_location>Winnipeg, MB Canada</ghapi:author_location>
+<ghapi:author_affiliation>happy-gods.com</ghapi:author_affiliation>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>200</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>National Geographic Photo of the Day</title>
+<link>http://drbeagledotcom.googlepages.com/ngpod.xml</link>
+<guid>http://drbeagledotcom.googlepages.com/ngpod.xml</guid>
+<description>National Geographic Photo of the Day</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<author>drbeagledotcom+modulefeedback(a)gmail.com</author>
+<ghapi:author_name>Cameron Hall</ghapi:author_name>
+<ghapi:author_location>Ithaca, NY, USA</ghapi:author_location>
+<ghapi:author_affiliation>Cornell University Student</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/7f/b6/7fb6ecbe4817327a6018bd3f54c400f6-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>200</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Funny Cat Photos</title>
+<link>http://blog.esaba.com/projects/catphotos/catphotos.xml</link>
+<guid>http://blog.esaba.com/projects/catphotos/catphotos.xml</guid>
+<description>This gadget displays a random funny cat photo everytime it loads. With over 2,300 photos to pick from, it is likely you will see a new photo everytime it loads. Click photos to enlarge.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>elias2+catphotos(a)gmail.com</author>
+<ghapi:author_name>Elias Saba</ghapi:author_name>
+<ghapi:author_location>Los Angeles, CA</ghapi:author_location>
+<ghapi:author_affiliation>http://blog.esaba.com</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/b1/3c/b13ce92b4669143742f693db8efec1ef-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>215</ghapi:height>
+<ghapi:num_userprefs>2</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Hangman (word game)</title>
+<link>http://www.thefreedictionary.com/_/WoD/hangman-module.xml</link>
+<guid>http://www.thefreedictionary.com/_/WoD/hangman-module.xml</guid>
+<description>Hangman - word game provided by TheFreeDictionary.com</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481-thm...</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>info(a)farlex.com</author>
+<ghapi:author_name>Farlex</ghapi:author_name>
+<ghapi:author_affiliation>Farlex, Inc.</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/20/23/202320e879f649d2a79cc8c9ef6cc481-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>110</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Calendar</title>
+<link>http://members.aol.com/markjson/calendar.xml</link>
+<guid>http://members.aol.com/markjson/calendar.xml</guid>
+<description>Simple calendar shows three months and tracks important dates.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_calendar_20060413.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_calendar_20060413-thm.png</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<ghapi:category2></ghapi:category2>
+<author>markjson(a)gmail.com</author>
+<ghapi:author_name>Mark Johnson</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>125</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Horoscope</title>
+<link>http://publish.clearspring.com/current/g/Google/464366710616c822/clearspr...</link>
+<guid>http://publish.clearspring.com/current/g/Google/464366710616c822/clearspr...</guid>
+<description>What is in your love life? Find out with this specialized astrology widget!</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/53/b7/53b795247e2d4750e3007c2cd272fbb4.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/53/b7/53b795247e2d4750e3007c2cd272fbb4-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>nbcu.widgets(a)gmail.com</author>
+<ghapi:author_name>iVillage</ghapi:author_name>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>459</ghapi:width>
+<ghapi:height>277</ghapi:height>
+<ghapi:num_userprefs>2</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Spellcheck - AskAWord.com</title>
+<link>http://www.openinventions.com/spellcheck/openinventions_spellcheck.xml</link>
+<guid>http://www.openinventions.com/spellcheck/openinventions_spellcheck.xml</guid>
+<description>Free English spell checker, thesaurus, dictionary, and encyclopedia for your Google homepage or desktop.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/78/43/7843d6960efca96de3b186a25e0303be.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/78/43/7843d6960efca96de3b186a25e0303be-thm...</ghapi:thumbnail>
+<ghapi:category>tools</ghapi:category>
+<author>ivar(a)openinventions.com</author>
+<ghapi:author_name>Ivar Chan</ghapi:author_name>
+<ghapi:author_location>Arcadia, CA, USA</ghapi:author_location>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>300</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Free Sudoku Puzzles</title>
+<link>http://www.counttonine.com/google-sudoku.xml</link>
+<guid>http://www.counttonine.com/google-sudoku.xml</guid>
+<description>Play Sudoku on your Personalized Google Homepage.</description>
+<ghapi:screenshot>http://www.google.com/ig/modules/ov/module_sudoku2_full.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/modules/ov/module_sudoku2.png</ghapi:thumbnail>
+<ghapi:category>funandgames</ghapi:category>
+<author>wcrosby(a)gmail.com</author>
+<ghapi:author_name>Wayne Crosby</ghapi:author_name>
+<ghapi:author_location>Scottsdale, AZ</ghapi:author_location>
+<ghapi:author_affiliation>Count to Nine</ghapi:author_affiliation>
+<ghapi:author_photo>/ig/cache/4f/d3/4fd39a6bb3c617eef0f1c13eb3f56293-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>370</ghapi:height>
+<ghapi:num_userprefs>1</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item><item>
+<title>Bart Simpson Phrase of the Day</title>
+<link>http://andrewgadget.googlepages.com/bart-simpson.xml</link>
+<guid>http://andrewgadget.googlepages.com/bart-simpson.xml</guid>
+<description>Bart Simpson Quote of the Day.</description>
+<ghapi:screenshot>http://www.google.com/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220.png</ghapi:screenshot>
+<ghapi:thumbnail>http://www.google.com/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220-thm...</ghapi:thumbnail>
+<ghapi:category>lifestyle</ghapi:category>
+<ghapi:category2>funandgames</ghapi:category2>
+<author>andrewgadget(a)gmail.com</author>
+<ghapi:author_name>Andrew Gadget</ghapi:author_name>
+<ghapi:author_photo>/ig/cache/e9/5e/e95e4135e15490bf135a6bff73ee1220-author.png</ghapi:author_photo>
+<ghapi:type>ghapi</ghapi:type>
+<ghapi:hosted>false</ghapi:hosted>
+<ghapi:width>320</ghapi:width>
+<ghapi:height>195</ghapi:height>
+<ghapi:num_userprefs>0</ghapi:num_userprefs>
+<ghapi:weekly_pageviews></ghapi:weekly_pageviews>
+</item></channel></rss>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response1
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response1 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response1 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,16 @@
+{"title":"Digg",
+"icon":{"0":"http:\/\/digg.com\/favicon.ico"},
+"metas":
+ {"author":"Fran\u00e7ois Hodierne",
+ "description":"",
+ "keywords":"digg",
+ "apiVersion":"1.0",
+ "inline":"false",
+ "autoRefresh":"20",
+ "debugMode":"false"},
+"preferences":
+[{"name":"category","type":"hidden","defaultValue":"all"},
+{"name":"minimal","type":"range","label":"Minimum number of diggs","defaultValue":"0","step":"100","min":"0","max":"1000","onchange":"reParse"},
+{"name":"limit","type":"range","label":"Number of items to display","defaultValue":"3","step":"1","min":"1","max":"25","onchange":"rePaint"},
+{"name":"openlinks","type":"hidden","defaultValue":"true"},
+{"name":"offset","type":"hidden","defaultValue":"0"}]}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response2
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response2 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response2 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,18 @@
+{"title":"Multiple Feeds - nyt","icon":"",
+"metas":
+ {"apiVersion":"1.0",
+ "inline":"true",
+ "autoRefresh":"20",
+ "debugMode":"false"},
+"preferences":
+[{"name":"category","type":"hidden","label":"Category"},
+{"name":"nbTitles","type":"range","label":"Number of items to display","defaultValue":"3","step":"1","min":"1","max":"25","onchange":"updateDisplay"},
+{"name":"details","type":"boolean","label":"Show more details","defaultValue":"true","onchange":"updateDisplay"},
+{"name":"showDate","type":"boolean","label":"Show post date","defaultValue":"true","onchange":"updateDisplay"},
+{"name":"openOutside","type":"boolean","label":"Open directly on the site","defaultValue":"false","onchange":"updateDisplay"},
+{"name":"videoAutoPlay","type":"hidden","label":"Show the video at startup","defaultValue":"false"},
+{"name":"numberTabs","type":"hidden","defaultValue":"4"},
+{"name":"selectedTab","type":"hidden","defaultValue":"0"},
+{"name":"title","type":"hidden","defaultValue":"MultipleFeeds"},
+{"name":"lookForHtmlThumbnail","type":"hidden","defaultValue":"true"},
+{"name":"provider","type":"hidden","defaultValue":"google"}]}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response3
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response3 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response3 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,12 @@
+{"title":"Vimeo Hubnut",
+"icon":{"0":"http:\/\/www.vimeo.com\/favicon.ico"},
+"metas":
+ {"author":"Casey Pugh","website":"http:\/\/www.vimeo.com\/widget",
+ "description":"The Hubnut provides a TV-style viewing experience. Use it to publish all of your videos on sites like MySpace at once. You can also use it to watch your Vimeo subscriptions on other sites like Netvibes.",
+ "apiVersion":"1.0",
+ "debugMode":"false"},
+"preferences":
+[{"name":"username","type":"text","label":"Your username","defaultValue":"vimeowidget"},
+{"name":"stream","type":"list","label":"Pick a stream","defaultValue":"videos","onchange":"redraw_flash","options":[{"value":"videos","label":"Videos"},{"value":"subscriptions","label":"Subscriptions"}]},
+{"name":"color","type":"text","label":"Highlight color","defaultValue":"#01AAEA"},
+{"name":"background","type":"text","label":"Background color","defaultValue":"#000000"}]}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response4
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response4 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response4 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,22 @@
+{
+"title":"Alexa",
+"icon":
+{"0":"http:\/\/www.netvibes.com\/modules\/alexa\/img\/favicon.png"},
+"metas":
+ {"author":"Louis-Xavier Vignal (Netvibes)",
+ "description":"Compare multiple domains traffic on a colorful line graph using Alexa traffic rankings.",
+ "keywords":"alexa, alexaholic, traffic, rank",
+ "inline":"true",
+ "apiVersion":"1.0",
+ "debugMode":"false"},
+"preferences":
+[{"name":"alexaTitle","type":"text","label":"Title"},
+{"name":"alexaSite0","type":"text","label":"Domain (1)","defaultValue":"ebay.com"},
+{"name":"alexaSite1","type":"text","label":"vs. (2)","defaultValue":"amazon.com"},
+{"name":"alexaSite2","type":"text","label":"vs. (3)"},
+{"name":"alexaSite3","type":"text","label":"vs. (4)"},
+{"name":"alexaSite4","type":"text","label":"vs. (5)"},
+{"name":"alexaHeight","type":"range","label":"Size","defaultValue":"200","step":"50","min":"150","max":"600"},
+{"name":"alexaRange","type":"hidden","defaultValue":"7d"},
+{"name":"alexaType","type":"hidden","defaultValue":"r"}
+]}
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response5
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response5 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response5 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,19 @@
+{"title":"Multiple Feeds - usatoday",
+"icon":"",
+"metas":{
+ "apiVersion":"1.0",
+ "inline":"true",
+ "autoRefresh":"20",
+ "debugMode":"false"},
+"preferences":
+[{"name":"category","type":"hidden","label":"Category"},
+{"name":"nbTitles","type":"range","label":"Number of items to display","defaultValue":"3","step":"1","min":"1","max":"25","onchange":"updateDisplay"},
+{"name":"details","type":"boolean","label":"Show more details","defaultValue":"true","onchange":"updateDisplay"},
+{"name":"showDate","type":"boolean","label":"Show post date","defaultValue":"true","onchange":"updateDisplay"},
+{"name":"openOutside","type":"boolean","label":"Open directly on the site","defaultValue":"false","onchange":"updateDisplay"},
+{"name":"videoAutoPlay","type":"hidden","label":"Show the video at startup","defaultValue":"false"},
+{"name":"numberTabs","type":"hidden","defaultValue":"4"},
+{"name":"selectedTab","type":"hidden","defaultValue":"0"},
+{"name":"title","type":"hidden","defaultValue":"MultipleFeeds"},
+{"name":"lookForHtmlThumbnail","type":"hidden","defaultValue":"true"},
+{"name":"provider","type":"hidden","defaultValue":"google"}]}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response6
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response6 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response6 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,15 @@
+{"title":"Weather",
+"icon":{"0":"http:\/\/www.netvibes.com\/img\/weather.gif"},
+"metas":{
+ "author":"Netvibes",
+ "description":"Netvibes Weather module",
+ "apiVersion":"1.0",
+ "inline":"true",
+ "autoRefresh":"20",
+ "debugMode":"false"},
+"preferences":
+[{"name":"townName","type":"text","label":"Town","defaultValue":""},
+{"name":"unit","type":"list","label":"Unit","defaultValue":"0","options":[{"value":"0","label":"Fahrenheit"},{"value":"1","label":"Celsius"}]},
+{"name":"showLocalTime","type":"boolean","label":"Show local time","defaultValue":"0"},
+{"name":"town","type":"hidden","defaultValue":""},
+{"name":"townCodeStore","type":"hidden","defaultValue":""}]}
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response7
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response7 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response7 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1,13 @@
+{"title":"RSS Reader",
+"icon":"",
+"metas":{
+ "author":"Fran\u00e7ois Hodierne (Netvibes)",
+ "version":"1.0.2",
+ "apiVersion":"1.0",
+ "inline":"true",
+ "autoRefresh":"20",
+ "debugMode":"true"},
+"preferences":
+[{"name":"feedUrl","type":"text","label":"URL","defaultValue":"http:\/\/feeds.feedburner.com\/NetvibesDevBlog"},
+{"name":"nbTitles","type":"range","label":"Number of items to display","defaultValue":"10","step":"1","min":"1","max":"25"},
+{"name":"search","type":"hidden","defaultValue":""}]}
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response8
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response8 (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/resources/test/netvibes/json.response8 2007-11-09 17:42:36 UTC (rev 8859)
@@ -0,0 +1 @@
+{"title":"Astronomy Picture of the Day","icon":{"0":"http:\/\/antwrp.gsfc.nasa.gov\/apod\/favicon.ico"},"metas":{"author":"Louis-Xavier Vignal (Netvibes)","description":"Each day a different image or photograph of our fascinating universe.","keywords":"astronomy, picture, science, spatial","inline":"true","apiVersion":"1.0","debugMode":"false"},"preferences":[]}
\ No newline at end of file
16 years, 11 months
JBoss Portal SVN: r8858 - in modules/test/trunk/tooling/maven2: src/main/java/org/jboss/unit/tooling/maven2/configuration and 1 other directory.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-09 10:24:46 -0500 (Fri, 09 Nov 2007)
New Revision: 8858
Modified:
modules/test/trunk/tooling/maven2/pom.xml
modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java
Log:
small fix
Modified: modules/test/trunk/tooling/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/maven2/pom.xml 2007-11-09 11:37:10 UTC (rev 8857)
+++ modules/test/trunk/tooling/maven2/pom.xml 2007-11-09 15:24:46 UTC (rev 8858)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-unit-tooling-maven2</artifactId>
<packaging>maven-plugin</packaging>
- <name>JBoss Unit Tooling Maven2</name>
+ <name>JBoss Unit Tooling Maven2</name>
<dependencies>
<dependency>
Modified: modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java
===================================================================
--- modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java 2007-11-09 11:37:10 UTC (rev 8857)
+++ modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java 2007-11-09 15:24:46 UTC (rev 8858)
@@ -39,22 +39,22 @@
/**
* @parameter
*/
- private CasesDescription[] includes;
+ private CasesDescription[] includes = new CasesDescription[0];
/**
* @parameter
*/
- private CasesDescription[] excludes;
+ private CasesDescription[] excludes = new CasesDescription[0];
/**
* @parameter
*/
- private Properties properties;
+ private Properties properties = new Properties();
/**
* @parameter
*/
- private Parameter[] parameters;
+ private Parameter[] parameters = new Parameter[0];
16 years, 11 months
JBoss Portal SVN: r8857 - modules/portlet/trunk/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-09 06:37:10 -0500 (Fri, 09 Nov 2007)
New Revision: 8857
Modified:
modules/portlet/trunk/portlet/build.xml
Log:
- fix the build
Modified: modules/portlet/trunk/portlet/build.xml
===================================================================
--- modules/portlet/trunk/portlet/build.xml 2007-11-09 02:14:14 UTC (rev 8856)
+++ modules/portlet/trunk/portlet/build.xml 2007-11-09 11:37:10 UTC (rev 8857)
@@ -154,11 +154,9 @@
</jar>
<!-- Portlet test lib jar -->
-<!--
<jar jarfile="${build.lib}/portal-portlet-test-lib.jar" manifest="${build.etc}/portal-portlet-lib-jar.mf">
<fileset dir="${build.classes}" includes="org/jboss/portal/test/portlet/**"/>
</jar>
--->
<!-- Portlet test framework lib jar -->
<jar jarfile="${build.lib}/portal-portlet-test-framework-lib.jar" manifest="${build.etc}/portal-portlet-lib-jar.mf">
16 years, 11 months