Author: bdaw
Date: 2007-07-31 15:05:35 -0400 (Tue, 31 Jul 2007)
New Revision: 7850
Added:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/
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/info/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferenceInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferencesInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetCategoryInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/metadata/
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/metadata/GGWidgetMetaData.java
Removed:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferenceInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferencesInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetCategoryInfo.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetInfo.java
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/widget/Widget.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/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/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/widget-war/WEB-INF/jsp/edit.jsp
Log:
- improve internationalizations in google gadgets
- rewrite gadgets directory rss parse to JBossXB
- small refactoring
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/google/PreferencesTestCase.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
import org.jboss.portal.widget.google.provider.GGWidgetInfoBuilder;
-import org.jboss.portal.widget.google.GGPreferencesInfo;
-import org.jboss.portal.widget.google.GGPreferenceInfo;
-import org.jboss.portal.widget.google.GGWidgetInfo;
+import org.jboss.portal.widget.google.info.GGPreferencesInfo;
+import org.jboss.portal.widget.google.info.GGPreferenceInfo;
+import org.jboss.portal.widget.google.info.GGWidgetInfo;
import org.jboss.portal.widget.google.type.DataType;
import org.jboss.portal.widget.google.type.EnumType;
import org.jboss.portal.common.io.IOTools;
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/Widget.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/Widget.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/Widget.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Map;
+import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,4 +42,6 @@
String render(Map parameters);
+ String render(Map parameters, Locale locale);
+
}
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -120,7 +120,7 @@
Widget widget = provider.getWidget(uri);
if (widget != null)
{
- writer.print(widget.render(req.getParameterMap()));
+ writer.print(widget.render(req.getParameterMap(), req.getLocale()));
}
else
{
Deleted:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferenceInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferenceInfo.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferenceInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -1,82 +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;
-
-import org.jboss.portal.widget.google.type.DataType;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public final class GGPreferenceInfo
-{
-
- /** . */
- private final String name;
-
- /** . */
- private final DataType type;
-
- /** . */
- private final String displayName;
-
- /** . */
- private final boolean required;
-
- /** . */
- private final String defaultValue;
-
- public GGPreferenceInfo(String name, DataType type, String displayName, boolean
required, String defaultValue)
- {
- this.name = name;
- this.type = type;
- this.displayName = displayName;
- this.required = required;
- this.defaultValue = defaultValue;
- }
-
- public String getName()
- {
- return name;
- }
-
- public DataType getType()
- {
- return type;
- }
-
- public String getDefaultValue()
- {
- return defaultValue;
- }
-
- public String getDisplayName()
- {
- return displayName;
- }
-
- public boolean isRequired()
- {
- return required;
- }
-}
Deleted:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferencesInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferencesInfo.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferencesInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -1,76 +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;
-
-import java.util.Map;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public final class GGPreferencesInfo
-{
-
- /** . */
- public static final GGPreferencesInfo EMPTY_PREFS = new GGPreferencesInfo();
-
- /** . */
- private final Map content;
-
- public GGPreferencesInfo(Collection prefInfos)
- {
- if (prefInfos == null)
- {
- throw new IllegalArgumentException();
- }
- content = new HashMap(prefInfos.size());
- for (Iterator i = prefInfos.iterator();i.hasNext();)
- {
- GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
- content.put(prefInfo.getName(), prefInfo);
- }
- }
-
- private GGPreferencesInfo()
- {
- content = null;
- }
-
- public Collection getPreferences()
- {
- return content == null ? Collections.EMPTY_SET : content.values();
- }
-
- public GGPreferenceInfo getPreference(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- return content == null ? null : (GGPreferenceInfo)content.get(name);
- }
-}
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -26,9 +26,13 @@
import org.jboss.portal.common.util.UUIDGenerator;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.google.info.GGWidgetInfo;
+import org.jboss.portal.widget.google.info.GGPreferenceInfo;
+import org.jboss.portal.widget.google.info.GGPreferencesInfo;
import java.util.Iterator;
import java.util.Map;
+import java.util.Locale;
import java.net.URL;
/**
@@ -90,6 +94,11 @@
public String render(Map parameters)
{
+ return render(parameters, null);
+ }
+
+ public String render(Map parameters, Locale locale)
+ {
String id = generator.generateKey();
StringBuffer tmp = new
StringBuffer("http://gmodules.com/ig/ifr?url=").append(url);
@@ -107,6 +116,12 @@
//tmp.append("&title=").append(FastURLEncoder.DEFAULT_ENCODER.encode(info.getTitle().getDefaultString()));
tmp.append("&border=%23ffffff%7C3px%2C1px+none+%23999999"); //
"&border=%23ffffff%7C3px%2C1px+solid+%23999999"
tmp.append("&output=js");
+ //pass locale information
+ if (locale != null)
+ {
+ tmp.append("&lang=").append(locale.getLanguage());
+ tmp.append("&country=").append(locale.getCountry());
+ }
//
GGPreferencesInfo prefsInfo = info.getPreferences();
Deleted:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetCategoryInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetCategoryInfo.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetCategoryInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -1,62 +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;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GGWidgetCategoryInfo
-{
-
- /** . */
- private final String name;
-
- /** . */
- private final String displayName;
-
-
- public GGWidgetCategoryInfo(String name, String displayName)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- if (displayName == null)
- {
- throw new IllegalArgumentException();
- }
- this.name = name;
- this.displayName = displayName;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDisplayName()
- {
- return displayName;
- }
-}
Deleted:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetInfo.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -1,100 +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;
-
-import org.jboss.portal.common.i18n.LocalizedString;
-
-/**
- * Meta data retrieved from the XML file.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GGWidgetInfo
-{
-
- /** . */
- private final LocalizedString title;
-
- /** . */
- private final LocalizedString directoryTitle;
-
- /** . */
- private final LocalizedString description;
-
- /** . */
- private final int width;
-
- /** . */
- private final int height;
-
- /** . */
- private final GGPreferencesInfo preferences;
-
- public GGWidgetInfo(
- LocalizedString title,
- LocalizedString directoryTitle,
- LocalizedString description,
- int width,
- int height,
- GGPreferencesInfo preferences)
- {
- this.title = title;
- this.directoryTitle = directoryTitle;
- this.description = description;
- this.width = width;
- this.height = height;
- this.preferences = preferences;
- }
-
- public GGPreferencesInfo getPreferences()
- {
- return preferences;
- }
-
- public LocalizedString getTitle()
- {
- return title;
- }
-
- public LocalizedString getDescription()
- {
- return description;
- }
-
- public int getWidth()
- {
- return width;
- }
-
- public int getHeight()
- {
- return height;
- }
-
-
- public LocalizedString getDirectoryTitle()
- {
- return directoryTitle;
- }
-}
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/directory/GGWidgetDirecotoryFactory.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -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 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/info/GGPreferenceInfo.java
(from rev 7840,
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferenceInfo.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferenceInfo.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferenceInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * 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.info;
+
+import org.jboss.portal.widget.google.type.DataType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class GGPreferenceInfo
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final DataType type;
+
+ /** . */
+ private final String displayName;
+
+ /** . */
+ private final boolean required;
+
+ /** . */
+ private final String defaultValue;
+
+ public GGPreferenceInfo(String name, DataType type, String displayName, boolean
required, String defaultValue)
+ {
+ this.name = name;
+ this.type = type;
+ this.displayName = displayName;
+ this.required = required;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public DataType getType()
+ {
+ return type;
+ }
+
+ public String getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public boolean isRequired()
+ {
+ return required;
+ }
+}
Copied:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferencesInfo.java
(from rev 7840,
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGPreferencesInfo.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferencesInfo.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGPreferencesInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * 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.info;
+
+import org.jboss.portal.widget.google.info.GGPreferenceInfo;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class GGPreferencesInfo
+{
+
+ /** . */
+ public static final GGPreferencesInfo EMPTY_PREFS = new GGPreferencesInfo();
+
+ /** . */
+ private final Map content;
+
+ public GGPreferencesInfo(Collection prefInfos)
+ {
+ if (prefInfos == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ content = new HashMap(prefInfos.size());
+ for (Iterator i = prefInfos.iterator();i.hasNext();)
+ {
+ GGPreferenceInfo prefInfo = (GGPreferenceInfo)i.next();
+ content.put(prefInfo.getName(), prefInfo);
+ }
+ }
+
+ private GGPreferencesInfo()
+ {
+ content = null;
+ }
+
+ public Collection getPreferences()
+ {
+ return content == null ? Collections.EMPTY_SET : content.values();
+ }
+
+ public GGPreferenceInfo getPreference(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return content == null ? null : (GGPreferenceInfo)content.get(name);
+ }
+}
Copied:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetCategoryInfo.java
(from rev 7840,
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetCategoryInfo.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetCategoryInfo.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetCategoryInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.info;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GGWidgetCategoryInfo
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String displayName;
+
+
+ public GGWidgetCategoryInfo(String name, String displayName)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (displayName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.displayName = displayName;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+}
Copied:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetInfo.java
(from rev 7840,
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetInfo.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetInfo.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/info/GGWidgetInfo.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * 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.info;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.widget.google.info.GGPreferencesInfo;
+
+/**
+ * Meta data retrieved from the XML file.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GGWidgetInfo
+{
+
+ /** . */
+ private final LocalizedString title;
+
+ /** . */
+ private final LocalizedString directoryTitle;
+
+ /** . */
+ private final LocalizedString description;
+
+ /** . */
+ private final int width;
+
+ /** . */
+ private final int height;
+
+ /** . */
+ private final GGPreferencesInfo preferences;
+
+ public GGWidgetInfo(
+ LocalizedString title,
+ LocalizedString directoryTitle,
+ LocalizedString description,
+ int width,
+ int height,
+ GGPreferencesInfo preferences)
+ {
+ this.title = title;
+ this.directoryTitle = directoryTitle;
+ this.description = description;
+ this.width = width;
+ this.height = height;
+ this.preferences = preferences;
+ }
+
+ public GGPreferencesInfo getPreferences()
+ {
+ return preferences;
+ }
+
+ public LocalizedString getTitle()
+ {
+ return title;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+
+ public LocalizedString getDirectoryTitle()
+ {
+ return directoryTitle;
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/metadata/GGWidgetMetaData.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/metadata/GGWidgetMetaData.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/metadata/GGWidgetMetaData.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -0,0 +1,261 @@
+/*
+* 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.metadata;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class GGWidgetMetaData
+{
+ private String title;
+
+ private String link;
+
+ private String guid;
+
+ private String description;
+
+ private String author;
+
+ private String authorEmail;
+
+ private String screenshot;
+
+ private String thumbnail;
+
+ private String authorLocaltion;
+
+ private String authorAffiliation;
+
+ private String titleURL;
+
+ private String directoryTitle;
+
+ private String authorPhoto;
+
+ private String authorAboutme;
+
+ private String authorLink;
+
+ private String authorQuote;
+
+ private String width;
+
+ private String height;
+
+
+ public GGWidgetMetaData()
+ {
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public String getLink()
+ {
+ return link;
+ }
+
+ public void setLink(String link)
+ {
+ this.link = link;
+ }
+
+ public String getGuid()
+ {
+ return guid;
+ }
+
+ public void setGuid(String guid)
+ {
+ this.guid = guid;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getAuthor()
+ {
+ return author;
+ }
+
+ public void setAuthor(String author)
+ {
+ this.author = author;
+ }
+
+ public String getAuthorEmail()
+ {
+ return authorEmail;
+ }
+
+ public void setAuthorEmail(String authorEmail)
+ {
+ this.authorEmail = authorEmail;
+ }
+
+ public String getScreenshot()
+ {
+ return screenshot;
+ }
+
+ public void setScreenshot(String screenshot)
+ {
+ this.screenshot = screenshot;
+ }
+
+ public String getThumbnail()
+ {
+ return thumbnail;
+ }
+
+ public void setThumbnail(String thumbnail)
+ {
+ this.thumbnail = thumbnail;
+ }
+
+ public String getAuthorLocaltion()
+ {
+ return authorLocaltion;
+ }
+
+ public void setAuthorLocaltion(String authorLocaltion)
+ {
+ this.authorLocaltion = authorLocaltion;
+ }
+
+ public String getAuthorAffiliation()
+ {
+ return authorAffiliation;
+ }
+
+ public void setAuthorAffiliation(String authorAffiliation)
+ {
+ this.authorAffiliation = authorAffiliation;
+ }
+
+ public String getTitleURL()
+ {
+ return titleURL;
+ }
+
+ public void setTitleURL(String titleURL)
+ {
+ this.titleURL = titleURL;
+ }
+
+ public String getDirectoryTitle()
+ {
+ return directoryTitle;
+ }
+
+ public void setDirectoryTitle(String directoryTitle)
+ {
+ this.directoryTitle = directoryTitle;
+ }
+
+ public String getAuthorPhoto()
+ {
+ return authorPhoto;
+ }
+
+ public void setAuthorPhoto(String authorPhoto)
+ {
+ this.authorPhoto = authorPhoto;
+ }
+
+ public String getAuthorAboutme()
+ {
+ return authorAboutme;
+ }
+
+ public void setAuthorAboutme(String authorAboutme)
+ {
+ this.authorAboutme = authorAboutme;
+ }
+
+ public String getAuthorLink()
+ {
+ return authorLink;
+ }
+
+ public void setAuthorLink(String authorLink)
+ {
+ this.authorLink = authorLink;
+ }
+
+ public String getAuthorQuote()
+ {
+ return authorQuote;
+ }
+
+ public void setAuthorQuote(String authorQuote)
+ {
+ this.authorQuote = authorQuote;
+ }
+
+ public String getWidth()
+ {
+ return width;
+ }
+
+ public void setWidth(String width)
+ {
+ this.width = width;
+ }
+
+ public String getHeight()
+ {
+ return height;
+ }
+
+ public void setHeight(String height)
+ {
+ this.height = height;
+ }
+
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Title: ").append(getTitle());
+ buffer.append("Link: ").append(getLink());
+
+ return buffer.toString();
+ }
+}
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -39,8 +39,8 @@
import java.util.ArrayList;
import org.jboss.portal.widget.google.GGWidget;
-import org.jboss.portal.widget.google.GGWidgetCategoryInfo;
-import org.jboss.portal.widget.google.GGWidgetInfo;
+import org.jboss.portal.widget.google.info.GGWidgetCategoryInfo;
+import org.jboss.portal.widget.google.info.GGWidgetInfo;
import org.jboss.portal.common.util.CollectionBuilder;
/**
@@ -51,7 +51,7 @@
{
/** . */
- public static final GGQuery INITIAL_QUERY = new GGQuery(0, null, null);
+ public static final GGQuery INITIAL_QUERY = new GGQuery(0, null, null, null);
/** The different descriptors. */
private final ConcurrentMap entries = new ConcurrentHashMap();
@@ -91,6 +91,8 @@
return CATEGORIES;
}
+
+
/**
* Returns a specified widget.
*/
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQuery.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -24,6 +24,7 @@
import java.net.URL;
import java.net.MalformedURLException;
+import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -32,6 +33,8 @@
public final class GGQuery
{
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(GGQuery.class);
+
/** . */
private int start;
@@ -47,7 +50,10 @@
/** . */
private int hashCode;
- public GGQuery(int start, String cat, String q)
+ /** . */
+ private Locale locale;
+
+ public GGQuery(int start, String cat, String q, Locale locale)
{
if (start < 0)
{
@@ -67,7 +73,8 @@
this.num = 10;
this.cat = cat;
this.q = q;
- this.hashCode = start + (cat == null ? 0 : 1 + cat.hashCode()) + (q == null ? 0 : 1
+ q.hashCode());
+ this.locale = locale;
+ this.hashCode = start + (cat == null ? 0 : 1 + cat.hashCode()) + (q == null ? 0 : 1
+ q.hashCode()) + (locale == null ? 0 : 1 + locale.hashCode());
}
@@ -132,6 +139,24 @@
{
buffer.append("&q=").append(q);
}
+ if (locale != null && locale.getLanguage().length() > 0)
+ {
+ buffer.append("&lang=").append(locale.getLanguage());
+ }
+ // if country info is not provided use the lang code
+ // its because Google assumes that country is US
+ if (locale != null && locale.getCountry().length() > 0)
+ {
+ buffer.append("&country=").append(locale.getCountry());
+ }
+ else if(locale != null && locale.getLanguage().length() > 0 )
+ {
+ 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/GGQueryResultBuilder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -25,16 +25,26 @@
import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.widget.google.directory.GGWidgetDirecotoryFactory;
+import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -47,6 +57,8 @@
public class GGQueryResultBuilder
{
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(GGQueryResultBuilder.class);
+
/** . */
public static final String GHAPI_URI =
"http://www.google.com/apis/homepage";
@@ -84,6 +96,7 @@
}
else
{
+
InputStream in = url.openStream();
try
{
@@ -101,45 +114,25 @@
throw new Exception("Cannot retrieve " + url);
}
- //
- DocumentBuilderFactory factory = XMLTools.getDocumentBuilderFactory();
- factory.setNamespaceAware(true);
+ List data = null;
- //
- Document doc = factory.newDocumentBuilder().parse(new
ByteArrayInputStream(bytes));
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
- //
- Element rssElt = doc.getDocumentElement();
- Element channelElt = XMLTools.getUniqueChild(rssElt, "channel",
true);
+ // create an instance of ObjectModelFactory
+ ObjectModelFactory factory = new GGWidgetDirecotoryFactory();
- //
+ // let the object model factory to create an instance of List and populate it
with data from XML
+ data = (List)unmarshaller.unmarshal(new ByteArrayInputStream(bytes), factory,
null);
+
List entries = new ArrayList();
- for (Iterator i = XMLTools.getChildrenIterator(channelElt,
"item");i.hasNext();)
+
+ for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
- Element itemElt = (Element)i.next();
+ GGWidgetMetaData md = (GGWidgetMetaData)iterator.next();
- //
- Element titleElt = XMLTools.getUniqueChild(itemElt, "title",
true);
- Element linkElt = XMLTools.getUniqueChild(itemElt, "link", true);
- Element descriptionElt = XMLTools.getUniqueChild(itemElt,
"description", true);
- Element authorElt = XMLTools.getUniqueChild(itemElt, "author",
false);
- Element screenshotElt = XMLTools.getUniqueChild(itemElt, GHAPI_URI,
"screenshot", true);
- Element thumbnailElt = XMLTools.getUniqueChild(itemElt, GHAPI_URI,
"thumbnail", true);
- Element widthElt = XMLTools.getUniqueChild(itemElt, GHAPI_URI,
"width", true);
- Element heightElt = XMLTools.getUniqueChild(itemElt, GHAPI_URI,
"height", true);
-
- //
- String title = XMLTools.asString(titleElt);
- URL link = new URL(XMLTools.asString(linkElt));
- String description = XMLTools.asString(descriptionElt);
- String screenshot = XMLTools.asString(screenshotElt);
- String thumbnail = XMLTools.asString(thumbnailElt);
- String author = authorElt != null ? XMLTools.asString(authorElt) :
"";
- int width = Integer.parseInt(XMLTools.asString(widthElt));
- int height = Integer.parseInt(XMLTools.asString(heightElt));
-
- //
- GGQueryResultEntry entry = new GGQueryResultEntry(link, title, description,
screenshot, thumbnail, author, width, height);
+ log.debug("Adding gadget: " + md);
+
+ GGQueryResultEntry entry = new GGQueryResultEntry(md);
entries.add(entry);
}
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultEntry.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
+import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
+
import java.net.URL;
/**
@@ -77,6 +79,34 @@
this.height = height;
}
+ public GGQueryResultEntry(GGWidgetMetaData metadata) throws Exception
+ {
+ this.url = new URL(metadata.getLink());
+ this.title = metadata.getTitle();
+ this.description = metadata.getDescription();
+ this.screenshot = metadata.getScreenshot();
+ this.thumbnail = metadata.getThumbnail();
+ this.author = metadata.getAuthor();
+ if (metadata.getWidth() != null)
+ {
+ this.width = Integer.parseInt(metadata.getWidth());
+ }
+ else
+ {
+ this.width = 0;
+ }
+ if (metadata.getHeight() != null)
+ {
+ this.height = Integer.parseInt(metadata.getHeight());
+ }
+ else
+ {
+ this.height = 0;
+ }
+
+
+ }
+
public URL getURL()
{
return url;
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-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetInfoBuilder.java 2007-07-31
19:05:35 UTC (rev 7850)
@@ -32,9 +32,9 @@
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.GGPreferenceInfo;
-import org.jboss.portal.widget.google.GGPreferencesInfo;
-import org.jboss.portal.widget.google.GGWidgetInfo;
+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.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-07-31
14:16:32 UTC (rev 7849)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-07-31
19:05:35 UTC (rev 7850)
@@ -2,9 +2,9 @@
<%@ page import="org.jboss.portal.widget.google.provider.GGProvider" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="org.jboss.portal.widget.google.GGWidget" %>
-<%@ page import="org.jboss.portal.widget.google.GGPreferenceInfo" %>
+<%@ page import="org.jboss.portal.widget.google.info.GGPreferenceInfo"
%>
<%@ page import="org.jboss.portal.widget.google.type.DataType" %>
-<%@ page import="org.jboss.portal.widget.google.GGWidgetCategoryInfo" %>
+<%@ page import="org.jboss.portal.widget.google.info.GGWidgetCategoryInfo"
%>
<%@ page import="org.jboss.portal.widget.google.provider.GGQuery" %>
<%@ page import="org.jboss.portal.widget.google.type.EnumType" %>
<%@ page import="javax.portlet.PortletURL" %>
@@ -44,7 +44,7 @@
}
// Compute query
- GGQuery query = new GGQuery(0, catTerm, queryTerm);
+ GGQuery query = new GGQuery(0, catTerm, queryTerm, request.getLocale());
Collection widgets = provider.search(query);
String ggPickMethod = request.getParameter("gg_pick_method");