JBoss Portal SVN: r6575 - in trunk/widget/src/main/org/jboss/portal/widget/google: type and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 10:40:11 -0500 (Wed, 07 Mar 2007)
New Revision: 6575
Added:
trunk/widget/src/main/org/jboss/portal/widget/google/type/
trunk/widget/src/main/org/jboss/portal/widget/google/type/DataType.java
Removed:
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java
Modified:
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java
Log:
moving type stuff to a type package
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java 2007-03-07 15:28:28 UTC (rev 6574)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java 2007-03-07 15:40:11 UTC (rev 6575)
@@ -1,111 +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 GWidgetDataType
-{
-
- /** . */
- public static final int STRING = 0;
-
- /** . */
- public static final int BOOL = 1;
-
- /** . */
- public static final int ENUM = 2;
-
- /** . */
- public static final int HIDDEN = 3;
-
- /** . */
- public static final int LIST = 4;
-
- /** . */
- public static final int LOCATION = 5;
-
- /** . */
- public static final GWidgetDataType STRING_TYPE = new GWidgetDataType(STRING);
-
- /** . */
- private final int value;
-
- /** . */
- private final Object object;
-
- public GWidgetDataType(int ordinal)
- {
- this(ordinal, null);
- }
-
- public GWidgetDataType(int dataType, Object dataObject)
- {
- this.value = dataType;
- this.object = dataObject;
- }
-
- public int getValue()
- {
- return value;
- }
-
- public Object getObject()
- {
- return object;
- }
-
- public static int parseDataTypeLiteral(String literal)
- {
- if ("string".equals(literal))
- {
- return STRING;
- }
- else if ("bool".equals(literal))
- {
- return BOOL;
- }
- else if ("enum".equals(literal))
- {
- return ENUM;
- }
- else if ("hidden".equals(literal))
- {
- return HIDDEN;
- }
- else if ("list".equals(literal))
- {
- return LIST;
- }
- else if ("location".equals(literal))
- {
- return LOCATION;
- }
- else
- {
- throw new IllegalArgumentException("Cannot parse " + literal);
- }
- }
-}
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java 2007-03-07 15:28:28 UTC (rev 6574)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java 2007-03-07 15:40:11 UTC (rev 6575)
@@ -24,6 +24,7 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.widget.google.type.DataType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -86,11 +87,11 @@
}
// String is default type when not specified
- GWidgetDataType dataType = GWidgetDataType.STRING_TYPE;
+ DataType dataType = DataType.STRING_TYPE;
if (dataTypeAttr.length() > 0)
{
- int dataTypeValue = GWidgetDataType.parseDataTypeLiteral(dataTypeAttr);
- dataType = new GWidgetDataType(dataTypeValue);
+ int dataTypeValue = DataType.parseDataTypeLiteral(dataTypeAttr);
+ dataType = new DataType(dataTypeValue);
}
//
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java 2007-03-07 15:28:28 UTC (rev 6574)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java 2007-03-07 15:40:11 UTC (rev 6575)
@@ -22,6 +22,8 @@
******************************************************************************/
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 $
@@ -33,7 +35,7 @@
private final String name;
/** . */
- private final GWidgetDataType type;
+ private final DataType type;
/** . */
private final String displayName;
@@ -44,7 +46,7 @@
/** . */
private final String defaultValue;
- protected GWidgetPreferenceInfo(String name, GWidgetDataType type, String displayName, boolean required, String defaultValue)
+ protected GWidgetPreferenceInfo(String name, DataType type, String displayName, boolean required, String defaultValue)
{
this.name = name;
this.type = type;
@@ -58,7 +60,7 @@
return name;
}
- public GWidgetDataType getType()
+ public DataType getType()
{
return type;
}
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/type/DataType.java (from rev 6574, trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/type/DataType.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/type/DataType.java 2007-03-07 15:40:11 UTC (rev 6575)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.type;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DataType
+{
+
+ /** . */
+ public static final int STRING = 0;
+
+ /** . */
+ public static final int BOOL = 1;
+
+ /** . */
+ public static final int ENUM = 2;
+
+ /** . */
+ public static final int HIDDEN = 3;
+
+ /** . */
+ public static final int LIST = 4;
+
+ /** . */
+ public static final int LOCATION = 5;
+
+ /** . */
+ public static final DataType STRING_TYPE = new DataType(STRING);
+
+ /** . */
+ private final int value;
+
+ /** . */
+ private final Object object;
+
+ public DataType(int ordinal)
+ {
+ this(ordinal, null);
+ }
+
+ public DataType(int dataType, Object dataObject)
+ {
+ this.value = dataType;
+ this.object = dataObject;
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public static int parseDataTypeLiteral(String literal)
+ {
+ if ("string".equals(literal))
+ {
+ return STRING;
+ }
+ else if ("bool".equals(literal))
+ {
+ return BOOL;
+ }
+ else if ("enum".equals(literal))
+ {
+ return ENUM;
+ }
+ else if ("hidden".equals(literal))
+ {
+ return HIDDEN;
+ }
+ else if ("list".equals(literal))
+ {
+ return LIST;
+ }
+ else if ("location".equals(literal))
+ {
+ return LOCATION;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot parse " + literal);
+ }
+ }
+}
17 years, 4 months
JBoss Portal SVN: r6574 - in trunk/widget/src/main/org/jboss/portal/widget: google and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 10:28:28 -0500 (Wed, 07 Mar 2007)
New Revision: 6574
Added:
trunk/widget/src/main/org/jboss/portal/widget/google/GWidget.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferencesInfo.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetProvider.java
trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetRetrieval.java
Removed:
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java
Modified:
trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
Log:
early support for widget preferences, for now configure default preferences
Modified: trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-03-07 14:18:05 UTC (rev 6573)
+++ trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget;
-import org.jboss.portal.widget.google.GoogleWidgetProvider;
+import org.jboss.portal.widget.google.GWidgetProvider;
import javax.portlet.GenericPortlet;
import javax.portlet.RenderRequest;
@@ -52,7 +52,7 @@
private static final PortletMode EDIT_CONTENT_MODE = new PortletMode("edit_content");
/** . */
- private GoogleWidgetProvider provider = new GoogleWidgetProvider();
+ private GWidgetProvider provider = new GWidgetProvider();
public void init() throws PortletException
{
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/GWidget.java (from rev 6573, trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidget.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidget.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * 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.util.LocalizedString;
+import org.jboss.portal.common.util.UUIDGenerator;
+import org.jboss.portal.widget.Widget;
+
+import java.util.Iterator;
+
+/**
+ * Getting list :
+ * http://www.google.com/ig/directory?synd=open
+ *
+ * synd=open -> mandatory to get the embedable widgets
+ * &source=gghp ????
+ *
+ * &start= default=0 [->sa=N ??? ]
+ * &num= default=24
+ * &cat= default=all (popular|news|tools|communication|funandgames|finance|sports|lifestyle|technology|new)
+ *
+ * <Module>
+ * <ModulePrefs
+ * title=""
+ * author=""
+ * author_email=""
+ * author_affiliation=""
+ * author_location=""
+ * screenshot=""
+ * thumbnail=""
+ * category=""
+ * description=""
+ * render_inline="optional"
+ * height=""
+ * scaling="true|false"
+ * scrolling="true|false">
+ * <UserPref
+ * name=""
+ * display_name=""
+ * default_value=""/>
+ *
+ * Getting javascript :
+ *
+ * http://gmodules.com/ig/ifr?url=
+ * up_color=blue
+ * synd=open
+ * w=554
+ * h=205
+ * title=Date+%26+Time
+ * border=%23ffffff%7C3px%2C1px+solid+%23999999
+ * output=js
+ * +
+ * up_ + user pref name = value
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GWidget implements Widget
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** . */
+ private final String url;
+
+ /** . */
+ private final GWidgetPreferencesInfo prefsInfo;
+
+ /** . */
+ private final LocalizedString title;
+
+ /** . */
+ private final LocalizedString description;
+
+ /** . */
+ private final int width;
+
+ /** . */
+ private final int height;
+
+ public GWidget(String url,
+ GWidgetPreferencesInfo prefsInfo,
+ LocalizedString title,
+ LocalizedString description,
+ int width,
+ int height)
+ {
+ this.url = url;
+ this.prefsInfo = prefsInfo;
+ this.title = title;
+ this.description = description;
+ this.width = width;
+ this.height = height;
+ }
+
+ public String getId()
+ {
+ return url;
+ }
+
+ public GWidgetPreferencesInfo getPreferencesInfo()
+ {
+ return prefsInfo;
+ }
+
+ public LocalizedString getTitle()
+ {
+ return title;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public String render()
+ {
+ String id = generator.generateKey();
+ StringBuffer tmp = new StringBuffer("http://gmodules.com/ig/ifr?url=").append(url);
+
+ // Generate base params
+ tmp.append("&synd=open");
+ tmp.append("&w=").append(width);
+ tmp.append("&h=").append(height);
+ tmp.append("&title=").append(title.getDefaultString());
+ tmp.append("&border=%23ffffff%7C3px%2C1px+none+%23999999"); // "&border=%23ffffff%7C3px%2C1px+solid+%23999999"
+ tmp.append("&output=js");
+
+ // Append default values
+ for (Iterator i = prefsInfo.getPreferencesInfo().iterator();i.hasNext();)
+ {
+ GWidgetPreferenceInfo prefInfo = (GWidgetPreferenceInfo)i.next();
+ if (prefInfo.getDefaultValue() != null)
+ {
+ tmp.append("&_up").append(prefInfo.getName()).append("=").append(prefInfo.getDefaultValue());
+ }
+ }
+
+ //
+ String clipper = "" +
+ "(function(){\n" +
+ "var a = document.getElementById('" + id + "');\n" +
+ "var b = a.childNodes.item(2);\n" + // table
+ "var c = b.childNodes.item(0);\n" + // tbody
+ "var d = c.childNodes.item(0);\n" + // tr
+ "var e = c.childNodes.item(1);\n" + // tr
+ "var f = c.childNodes.item(3);\n" + // tr
+ "c.removeChild(d);\n" +
+ "c.removeChild(e);\n" +
+ "c.removeChild(f);\n" +
+ "})();";
+
+ return "<div id=\"" + id + "\">\n" +
+ "<script src=\"" + tmp + "\"></script>\n" +
+ "<script>" + clipper + "</script>\n" +
+ "</div>\n";
+ }
+
+
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetDataType.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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 GWidgetDataType
+{
+
+ /** . */
+ public static final int STRING = 0;
+
+ /** . */
+ public static final int BOOL = 1;
+
+ /** . */
+ public static final int ENUM = 2;
+
+ /** . */
+ public static final int HIDDEN = 3;
+
+ /** . */
+ public static final int LIST = 4;
+
+ /** . */
+ public static final int LOCATION = 5;
+
+ /** . */
+ public static final GWidgetDataType STRING_TYPE = new GWidgetDataType(STRING);
+
+ /** . */
+ private final int value;
+
+ /** . */
+ private final Object object;
+
+ public GWidgetDataType(int ordinal)
+ {
+ this(ordinal, null);
+ }
+
+ public GWidgetDataType(int dataType, Object dataObject)
+ {
+ this.value = dataType;
+ this.object = dataObject;
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public static int parseDataTypeLiteral(String literal)
+ {
+ if ("string".equals(literal))
+ {
+ return STRING;
+ }
+ else if ("bool".equals(literal))
+ {
+ return BOOL;
+ }
+ else if ("enum".equals(literal))
+ {
+ return ENUM;
+ }
+ else if ("hidden".equals(literal))
+ {
+ return HIDDEN;
+ }
+ else if ("list".equals(literal))
+ {
+ return LIST;
+ }
+ else if ("location".equals(literal))
+ {
+ return LOCATION;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot parse " + literal);
+ }
+ }
+}
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java (from rev 6573, trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetFactory.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -0,0 +1,140 @@
+/******************************************************************************
+ * 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.util.XML;
+import org.jboss.portal.common.util.LocalizedString;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GWidgetFactory
+{
+
+ /** . */
+ private final URL url;
+
+ public GWidgetFactory(URL url)
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("No null URL");
+ }
+ this.url = url;
+ }
+
+ public URL getURL()
+ {
+ return url;
+ }
+
+ public GWidget create() throws Exception
+ {
+ DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(url.toString());
+ Element moduleElt = doc.getDocumentElement();
+
+ //
+ Collection tmp = null;
+ Iterator userPrefsEltIterator = XML.getChildrenIterator(moduleElt, "UserPref");
+ while (userPrefsEltIterator.hasNext())
+ {
+ Element userPrefs = (Element)userPrefsEltIterator.next();
+ String nameAttr = userPrefs.getAttribute("name");
+ String displayNameAttr = userPrefs.getAttribute("displayName");
+ String urlParamAttr = userPrefs.getAttribute("urlparam");
+ String dataTypeAttr = userPrefs.getAttribute("datatype");
+ String requiredAttr = userPrefs.getAttribute("required");
+ String defaultValueAttr = userPrefs.getAttribute("default_value");
+
+ // We don't support that for now
+ if (urlParamAttr.length() > 0)
+ {
+ throw new Exception();
+ }
+
+ // String is default type when not specified
+ GWidgetDataType dataType = GWidgetDataType.STRING_TYPE;
+ if (dataTypeAttr.length() > 0)
+ {
+ int dataTypeValue = GWidgetDataType.parseDataTypeLiteral(dataTypeAttr);
+ dataType = new GWidgetDataType(dataTypeValue);
+ }
+
+ //
+ GWidgetPreferenceInfo prefInfo = new GWidgetPreferenceInfo(
+ nameAttr,
+ dataType,
+ displayNameAttr.length() > 0 ? displayNameAttr : null,
+ requiredAttr.length() > 0 ? Boolean.valueOf(requiredAttr).booleanValue() : false,
+ defaultValueAttr.length() > 0 ? defaultValueAttr : null
+ );
+
+ //
+ if (tmp == null)
+ {
+ tmp = new ArrayList();
+ }
+ tmp.add(prefInfo);
+ }
+ GWidgetPreferencesInfo prefsInfo = GWidgetPreferencesInfo.EMPTY_PREFS;
+ if (tmp != null)
+ {
+ prefsInfo = new GWidgetPreferencesInfo(tmp);
+ }
+
+ //
+ Iterator modulePrefsEltIterator = XML.getChildrenIterator(moduleElt, "ModulePrefs");
+ if (modulePrefsEltIterator.hasNext())
+ {
+ Element modulePrefsElt = (Element)modulePrefsEltIterator.next();
+ String titleAttr = modulePrefsElt.getAttribute("title");
+ String descriptionAttr = modulePrefsElt.getAttribute("description");
+ String widthAttr = modulePrefsElt.getAttribute("width");
+ String heightAttr = modulePrefsElt.getAttribute("height");
+
+ //
+ LocalizedString title = titleAttr != null ? new LocalizedString(titleAttr, Locale.ENGLISH) : null;
+ LocalizedString description = descriptionAttr != null ? new LocalizedString(descriptionAttr, Locale.ENGLISH) : null;
+ int width = (widthAttr != null && widthAttr.length() > 0) ? Integer.parseInt(widthAttr) : 320;
+ int height = (heightAttr != null && heightAttr.length() > 0) ? Integer.parseInt(heightAttr) : 200;
+ return new GWidget(url.toString(), prefsInfo, title, description, width, height);
+ }
+ else
+ {
+ throw new Exception(); // Basic for now
+ }
+ }
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferenceInfo.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -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.google;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GWidgetPreferenceInfo
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final GWidgetDataType type;
+
+ /** . */
+ private final String displayName;
+
+ /** . */
+ private final boolean required;
+
+ /** . */
+ private final String defaultValue;
+
+ protected GWidgetPreferenceInfo(String name, GWidgetDataType 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 GWidgetDataType getType()
+ {
+ return type;
+ }
+
+ public String getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public boolean isRequired()
+ {
+ return required;
+ }
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferencesInfo.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferencesInfo.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetPreferencesInfo.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * 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 class GWidgetPreferencesInfo
+{
+
+ public static final GWidgetPreferencesInfo EMPTY_PREFS = new GWidgetPreferencesInfo();
+
+ /** . */
+ private final Map content;
+
+ public GWidgetPreferencesInfo(Collection prefInfos)
+ {
+ if (prefInfos == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ content = new HashMap(prefInfos.size());
+ for (Iterator i = prefInfos.iterator();i.hasNext();)
+ {
+ GWidgetPreferenceInfo prefInfo = (GWidgetPreferenceInfo)i.next();
+ content.put(prefInfo.getName(), prefInfo);
+ }
+ }
+
+ private GWidgetPreferencesInfo()
+ {
+ content = null;
+ }
+
+ public Collection getPreferencesInfo()
+ {
+ return content == null ? Collections.EMPTY_SET : content.values();
+ }
+
+ public GWidgetPreferenceInfo getPreferenceInfo(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return content == null ? null : (GWidgetPreferenceInfo)content.get(name);
+ }
+}
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetProvider.java (from rev 6573, trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetProvider.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetProvider.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -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.google;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.util.StringTokenizer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedHashMap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.ArrayList;
+
+import org.jboss.portal.widget.WidgetProvider;
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
+
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.MutableAttributeSet;
+
+import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
+import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingDeque;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GWidgetProvider implements WidgetProvider
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(GWidgetProvider.class);
+
+ /** . */
+ private volatile FutureTask future;
+
+ /** . */
+ private final Lock lock = new ReentrantLock();
+
+ /** . */
+ private final ExecutorService executor = new ThreadPoolExecutor(3, 3, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ executor.shutdownNow();
+ }
+
+ private Map getMap()
+ {
+ try
+ {
+ lock.lock();
+ try
+ {
+ if (future == null)
+ {
+ future = new FutureTask(new Callable()
+ {
+ public Object call() throws Exception
+ {
+ WidgetBuilder map = new WidgetBuilder();
+ map.start();
+ return map;
+ }
+ });
+ executor.execute(future);
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ WidgetBuilder wmap = (WidgetBuilder)future.get();
+ return wmap.map;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return Collections.EMPTY_MAP;
+ }
+ }
+
+ public Collection getKeys()
+ {
+ return getMap().keySet();
+ }
+
+ public Widget getWidget(String key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Map tmp = getMap();
+ GWidgetRetrieval.List retrievals = (GWidgetRetrieval.List)tmp.get(key);
+ if (retrievals != null)
+ {
+ GWidgetRetrieval retrieval = retrievals.getRetrieval(key);
+ if (retrieval.getStatus() == GWidgetRetrieval.AVAILABLE)
+ {
+ return retrieval.getWidget();
+ }
+ }
+
+ //
+ return null;
+ }
+
+ private class WidgetBuilder
+ {
+
+ /** . */
+ private Map map;
+
+ public void start()
+ {
+ try
+ {
+ // Find widget URLs
+ URL url = new URL("http://www.google.com/ig/directory?synd=open");
+
+ // Read fully the URL content first
+ byte[] bytes = null;
+ InputStream in = null;
+ try
+ {
+ log.info("Retrieving " + url);
+ in = url.openStream();
+ bytes = Tools.getBytes(in);
+ log.info("Document " + url + " has been retrieved");
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ }
+
+ //
+ final LinkedHashSet urls = new LinkedHashSet();
+ HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
+ {
+ public void handleStartTag(HTML.Tag t, MutableAttributeSet attrSet, int pos)
+ {
+ if (t == HTML.Tag.A)
+ {
+ try
+ {
+ String href = (String)attrSet.getAttribute(HTML.Attribute.HREF);
+ URL url = new URL(href);
+ String query = url.getQuery();
+ if (query != null)
+ {
+ Map params = new HashMap();
+ StringTokenizer st = new StringTokenizer(query, "&");
+ while (st.hasMoreTokens())
+ {
+ String pair = st.nextToken();
+ int separator = pair.indexOf('=');
+ if (separator != -1)
+ {
+ String left = pair.substring(0, separator);
+ String right = pair.substring(separator + 1);
+ params.put(left, right);
+ }
+ }
+
+ //
+ if (params.containsKey("url"))
+ {
+ String tmp = (String)params.get("url");
+ if (tmp.endsWith(".xml"))
+ {
+ url = new URL(tmp);
+ urls.add(url);
+ }
+ }
+ }
+ }
+ catch (MalformedURLException ignore)
+ {
+ }
+ }
+ }
+ };
+ HTMLEditorKit.Parser parser = new ParserAccessor().getParser();
+ parser.parse(new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8"), callback, true);
+
+ //
+ Map map = new LinkedHashMap();
+
+ // Now parse each
+ Collection tmp = new ArrayList(BATCH_SIZE);
+ for (Iterator i = urls.iterator();i.hasNext();)
+ {
+ URL widgetURL = (URL)i.next();
+ GWidgetFactory widgetFactory = new GWidgetFactory(widgetURL);
+
+ //
+ if (tmp.size() < BATCH_SIZE)
+ {
+ tmp.add(widgetFactory);
+ }
+ else
+ {
+ GWidgetRetrieval.List retrievals = new GWidgetRetrieval.List(executor, tmp);
+ for (int j = 0;j < retrievals.getSize();j++)
+ {
+ GWidgetFactory t = retrievals.getFactory(j);
+ map.put(t.getURL().toString(), retrievals);
+ log.info("Added widget for later retrieval" + t.getURL());
+ }
+
+ //
+ tmp.clear();
+ tmp.add(widgetFactory);
+ }
+ }
+
+ //
+ this.map = Collections.unmodifiableMap(map);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static final int BATCH_SIZE = 6;
+
+ private static class ParserAccessor extends HTMLEditorKit
+ {
+ public Parser getParser()
+ {
+ return super.getParser();
+ }
+ }
+}
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetRetrieval.java (from rev 6573, trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetRetrieval.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GWidgetRetrieval.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * 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 edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
+import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import edu.emory.mathcs.backport.java.util.concurrent.CompletionService;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
+import edu.emory.mathcs.backport.java.util.concurrent.Future;
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GWidgetRetrieval
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(GWidgetRetrieval.class);
+
+ /** . */
+ public static int UNAVAILABLE = 0;
+
+ /** . */
+ public static int AVAILABLE = 1;
+
+ /** . */
+ private GWidget widget;
+
+ public GWidgetRetrieval(GWidget widget)
+ {
+ this.widget = widget;
+ }
+
+ public GWidget getWidget() throws IllegalStateException
+ {
+ if (widget == null)
+ {
+ throw new IllegalStateException("Widget not available");
+ }
+ return widget;
+ }
+
+ public int getStatus()
+ {
+ return widget != null ? AVAILABLE : UNAVAILABLE;
+ }
+
+ public static class List
+ {
+
+ /** . */
+ private final GWidgetFactory[] factories;
+
+ /** . */
+ private final Executor executor;
+
+ /** . */
+ private final Lock lock = new ReentrantLock();
+
+ /** . */
+ private FutureTask future;
+
+ public List(Executor executor, Collection c)
+ {
+ this.executor = executor;
+ this.factories = (GWidgetFactory[])c.toArray(new GWidgetFactory[c.size()]);
+ }
+
+ public int getSize()
+ {
+ return factories.length;
+ }
+
+ public GWidgetFactory getFactory(int index)
+ {
+ return factories[index];
+ }
+
+ public GWidgetRetrieval getRetrieval(String key)
+ {
+ for (int i = 0;i < factories.length;i++)
+ {
+ GWidgetFactory factory = factories[i];
+ if (key.equals(factory.getURL().toString()))
+ {
+ return getRetrieval(i);
+ }
+ }
+ return null;
+ }
+
+ private class Fetcher implements Callable
+ {
+
+ /** . */
+ private final int index;
+
+ /** . */
+ private GWidgetRetrieval retrieval;
+
+ public Fetcher(int index)
+ {
+ this.index = index;
+ }
+
+ public Object call() throws Exception
+ {
+ GWidgetFactory factory = factories[index];
+ try
+ {
+ log.info("Creating widget " + factory.getURL());
+ GWidget widget = factory.create();
+ retrieval = new GWidgetRetrieval(widget);
+ }
+ catch (Exception e)
+ {
+ log.error("Widget " + factory.getURL() + " was not retrievable", e);
+ retrieval = new GWidgetRetrieval(null);
+ }
+ return this;
+ }
+ }
+
+ public GWidgetRetrieval getRetrieval(int index)
+ {
+ //
+ lock.lock();
+ try
+ {
+ if (future == null)
+ {
+ future = new FutureTask(new Callable()
+ {
+ public Object call() throws Exception
+ {
+ log.info("Creating widget batch");
+ CompletionService completionService = new ExecutorCompletionService(executor);
+ for (int i = 0; i < factories.length; i++)
+ {
+ completionService.submit(new Fetcher(i));
+ }
+ GWidgetRetrieval[] retrievals = new GWidgetRetrieval[factories.length];
+ for (int i = 0; i < factories.length; i++)
+ {
+ Future future = completionService.take();
+ Fetcher fetcher = (Fetcher)future.get();
+ retrievals[fetcher.index] = fetcher.retrieval;
+ }
+ return retrievals;
+ }
+ });
+ executor.execute(future);
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+
+ try
+ {
+ //
+ GWidgetRetrieval[] retrievals = (GWidgetRetrieval[])future.get();
+
+ //
+ return retrievals[index];
+ }
+ catch (Exception e)
+ {
+ return new GWidgetRetrieval(null);
+ }
+ }
+ }
+}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java 2007-03-07 14:18:05 UTC (rev 6573)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -1,157 +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.util.LocalizedString;
-import org.jboss.portal.common.util.UUIDGenerator;
-import org.jboss.portal.widget.Widget;
-
-/**
- * Getting list :
- * http://www.google.com/ig/directory?synd=open
- *
- * synd=open -> mandatory to get the embedable widgets
- * &source=gghp ????
- *
- * &start= default=0 [->sa=N ??? ]
- * &num= default=24
- * &cat= default=all (popular|news|tools|communication|funandgames|finance|sports|lifestyle|technology|new)
- *
- * <Module>
- * <ModulePrefs
- * title=""
- * author=""
- * author_email=""
- * author_affiliation=""
- * author_location=""
- * screenshot=""
- * thumbnail=""
- * category=""
- * description=""
- * render_inline="optional"
- * height=""
- * scaling="true|false"
- * scrolling="true|false">
- * <UserPref
- * name=""
- * display_name=""
- * default_value=""/>
- *
- * Getting javascript :
- *
- * http://gmodules.com/ig/ifr?url=
- * up_color=blue
- * synd=open
- * w=554
- * h=205
- * title=Date+%26+Time
- * border=%23ffffff%7C3px%2C1px+solid+%23999999
- * output=js
- * +
- * up_ + user pref name = value
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidget implements Widget
-{
-
- /** . */
- private static final UUIDGenerator generator = new UUIDGenerator();
-
- /** . */
- private final String url;
-
- /** . */
- private final LocalizedString title;
-
- /** . */
- private final LocalizedString description;
-
- /** . */
- private final int width;
-
- /** . */
- private final int height;
-
- public GoogleWidget(String url,
- LocalizedString title,
- LocalizedString description,
- int width,
- int height)
- {
- this.url = url;
- this.title = title;
- this.description = description;
- this.width = width;
- this.height = height;
- }
-
- public String getId()
- {
- return url;
- }
-
- public LocalizedString getTitle()
- {
- return title;
- }
-
- public LocalizedString getDescription()
- {
- return description;
- }
-
- public String render()
- {
- String id = generator.generateKey();
- String tmp = "http://gmodules.com/ig/ifr?url=" + url +
- "&synd=open" +
- "&w=" + width +
- "&h=" + height +
- "&title=" + title.getDefaultString() +
-// "&border=%23ffffff%7C3px%2C1px+solid+%23999999" +
- "&border=%23ffffff%7C3px%2C1px+none+%23999999" +
- "&output=js";
-
- String clipper = "" +
- "(function(){\n" +
- "var a = document.getElementById('" + id + "');\n" +
- "var b = a.childNodes.item(2);\n" + // table
- "var c = b.childNodes.item(0);\n" + // tbody
- "var d = c.childNodes.item(0);\n" + // tr
- "var e = c.childNodes.item(1);\n" + // tr
- "var f = c.childNodes.item(3);\n" + // tr
- "c.removeChild(d);\n" +
- "c.removeChild(e);\n" +
- "c.removeChild(f);\n" +
- "})();";
-
- return "<div id=\"" + id + "\">\n" +
- "<script src=\"" + tmp + "\"></script>\n" +
- "<script>" + clipper + "</script>\n" +
- "</div>\n";
- }
-
-
-}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java 2007-03-07 14:18:05 UTC (rev 6573)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -1,80 +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.util.XML;
-import org.jboss.portal.common.util.LocalizedString;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidgetFactory
-{
-
- /** . */
- private final URL url;
-
- public GoogleWidgetFactory(URL url)
- {
- if (url == null)
- {
- throw new IllegalArgumentException("No null URL");
- }
- this.url = url;
- }
-
- public URL getURL()
- {
- return url;
- }
-
- public GoogleWidget create() throws Exception
- {
- DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(url.toString());
- Element moduleElt = doc.getDocumentElement();
- Iterator modulePrefsEltIterator = XML.getChildrenIterator(moduleElt, "ModulePrefs");
- Element modulePrefsElt = (Element)modulePrefsEltIterator.next();
- String titleAttr = modulePrefsElt.getAttribute("title");
- String descriptionAttr = modulePrefsElt.getAttribute("description");
- String widthAttr = modulePrefsElt.getAttribute("width");
- String heightAttr = modulePrefsElt.getAttribute("height");
-
-
- LocalizedString title = titleAttr != null ? new LocalizedString(titleAttr, Locale.ENGLISH) : null;
- LocalizedString description = descriptionAttr != null ? new LocalizedString(descriptionAttr, Locale.ENGLISH) : null;
- int width = (widthAttr != null && widthAttr.length() > 0) ? Integer.parseInt(widthAttr) : 320;
- int height = (heightAttr != null && heightAttr.length() > 0) ? Integer.parseInt(heightAttr) : 200;
- return new GoogleWidget(url.toString(), title, description, width, height);
- }
-}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java 2007-03-07 14:18:05 UTC (rev 6573)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -1,276 +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.net.URL;
-import java.net.MalformedURLException;
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.util.StringTokenizer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedHashMap;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.ArrayList;
-
-import org.jboss.portal.widget.WidgetProvider;
-import org.jboss.portal.widget.Widget;
-import org.jboss.portal.common.util.Tools;
-import org.apache.log4j.Logger;
-
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.MutableAttributeSet;
-
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingDeque;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidgetProvider implements WidgetProvider
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(GoogleWidgetProvider.class);
-
- /** . */
- private volatile FutureTask future;
-
- /** . */
- private final Lock lock = new ReentrantLock();
-
- /** . */
- private final ExecutorService executor = new ThreadPoolExecutor(3, 3, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
-
- public void start()
- {
- }
-
- public void stop()
- {
- executor.shutdownNow();
- }
-
- private Map getMap()
- {
- try
- {
- lock.lock();
- try
- {
- if (future == null)
- {
- future = new FutureTask(new Callable()
- {
- public Object call() throws Exception
- {
- WidgetBuilder map = new WidgetBuilder();
- map.start();
- return map;
- }
- });
- executor.execute(future);
- }
- }
- finally
- {
- lock.unlock();
- }
- WidgetBuilder wmap = (WidgetBuilder)future.get();
- return wmap.map;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return Collections.EMPTY_MAP;
- }
- }
-
- public Collection getKeys()
- {
- return getMap().keySet();
- }
-
- public Widget getWidget(String key)
- {
- if (key == null)
- {
- throw new IllegalArgumentException();
- }
- Map tmp = getMap();
- GoogleWidgetRetrieval.List retrievals = (GoogleWidgetRetrieval.List)tmp.get(key);
- if (retrievals != null)
- {
- GoogleWidgetRetrieval retrieval = retrievals.getRetrieval(key);
- if (retrieval.getStatus() == GoogleWidgetRetrieval.AVAILABLE)
- {
- return retrieval.getWidget();
- }
- }
-
- //
- return null;
- }
-
- private class WidgetBuilder
- {
-
- /** . */
- private Map map;
-
- public void start()
- {
- try
- {
- // Find widget URLs
- URL url = new URL("http://www.google.com/ig/directory?synd=open");
-
- // Read fully the URL content first
- byte[] bytes = null;
- InputStream in = null;
- try
- {
- log.info("Retrieving " + url);
- in = url.openStream();
- bytes = Tools.getBytes(in);
- log.info("Document " + url + " has been retrieved");
- }
- finally
- {
- Tools.safeClose(in);
- }
-
- //
- final LinkedHashSet urls = new LinkedHashSet();
- HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
- {
- public void handleStartTag(HTML.Tag t, MutableAttributeSet attrSet, int pos)
- {
- if (t == HTML.Tag.A)
- {
- try
- {
- String href = (String)attrSet.getAttribute(HTML.Attribute.HREF);
- URL url = new URL(href);
- String query = url.getQuery();
- if (query != null)
- {
- Map params = new HashMap();
- StringTokenizer st = new StringTokenizer(query, "&");
- while (st.hasMoreTokens())
- {
- String pair = st.nextToken();
- int separator = pair.indexOf('=');
- if (separator != -1)
- {
- String left = pair.substring(0, separator);
- String right = pair.substring(separator + 1);
- params.put(left, right);
- }
- }
-
- //
- if (params.containsKey("url"))
- {
- String tmp = (String)params.get("url");
- if (tmp.endsWith(".xml"))
- {
- url = new URL(tmp);
- urls.add(url);
- }
- }
- }
- }
- catch (MalformedURLException ignore)
- {
- }
- }
- }
- };
- HTMLEditorKit.Parser parser = new ParserAccessor().getParser();
- parser.parse(new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8"), callback, true);
-
- //
- Map map = new LinkedHashMap();
-
- // Now parse each
- Collection tmp = new ArrayList(BATCH_SIZE);
- for (Iterator i = urls.iterator();i.hasNext();)
- {
- URL widgetURL = (URL)i.next();
- GoogleWidgetFactory widgetFactory = new GoogleWidgetFactory(widgetURL);
-
- //
- if (tmp.size() < BATCH_SIZE)
- {
- tmp.add(widgetFactory);
- }
- else
- {
- GoogleWidgetRetrieval.List retrievals = new GoogleWidgetRetrieval.List(executor, tmp);
- for (int j = 0;j < retrievals.getSize();j++)
- {
- GoogleWidgetFactory t = retrievals.getFactory(j);
- map.put(t.getURL().toString(), retrievals);
- log.info("Added widget for later retrieval" + t.getURL());
- }
-
- //
- tmp.clear();
- tmp.add(widgetFactory);
- }
- }
-
- //
- this.map = Collections.unmodifiableMap(map);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private static final int BATCH_SIZE = 6;
-
- private static class ParserAccessor extends HTMLEditorKit
- {
- public Parser getParser()
- {
- return super.getParser();
- }
- }
-}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java 2007-03-07 14:18:05 UTC (rev 6573)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java 2007-03-07 15:28:28 UTC (rev 6574)
@@ -1,202 +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 edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
-import edu.emory.mathcs.backport.java.util.concurrent.CompletionService;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
-import edu.emory.mathcs.backport.java.util.concurrent.Future;
-import edu.emory.mathcs.backport.java.util.concurrent.Executor;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
-
-import java.util.Collection;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidgetRetrieval
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(GoogleWidgetRetrieval.class);
-
- /** . */
- public static int UNAVAILABLE = 0;
-
- /** . */
- public static int AVAILABLE = 1;
-
- /** . */
- private GoogleWidget widget;
-
- public GoogleWidgetRetrieval(GoogleWidget widget)
- {
- this.widget = widget;
- }
-
- public GoogleWidget getWidget() throws IllegalStateException
- {
- if (widget == null)
- {
- throw new IllegalStateException("Widget not available");
- }
- return widget;
- }
-
- public int getStatus()
- {
- return widget != null ? AVAILABLE : UNAVAILABLE;
- }
-
- public static class List
- {
-
- /** . */
- private final GoogleWidgetFactory[] factories;
-
- /** . */
- private final Executor executor;
-
- /** . */
- private final Lock lock = new ReentrantLock();
-
- /** . */
- private FutureTask future;
-
- public List(Executor executor, Collection c)
- {
- this.executor = executor;
- this.factories = (GoogleWidgetFactory[])c.toArray(new GoogleWidgetFactory[c.size()]);
- }
-
- public int getSize()
- {
- return factories.length;
- }
-
- public GoogleWidgetFactory getFactory(int index)
- {
- return factories[index];
- }
-
- public GoogleWidgetRetrieval getRetrieval(String key)
- {
- for (int i = 0;i < factories.length;i++)
- {
- GoogleWidgetFactory factory = factories[i];
- if (key.equals(factory.getURL().toString()))
- {
- return getRetrieval(i);
- }
- }
- return null;
- }
-
- private class Fetcher implements Callable
- {
-
- /** . */
- private final int index;
-
- /** . */
- private GoogleWidgetRetrieval retrieval;
-
- public Fetcher(int index)
- {
- this.index = index;
- }
-
- public Object call() throws Exception
- {
- GoogleWidgetFactory factory = factories[index];
- try
- {
- log.info("Creating widget " + factory.getURL());
- GoogleWidget widget = factory.create();
- retrieval = new GoogleWidgetRetrieval(widget);
- }
- catch (Exception e)
- {
- log.error("Widget " + factory.getURL() + " was not retrievable", e);
- retrieval = new GoogleWidgetRetrieval(null);
- }
- return this;
- }
- }
-
- public GoogleWidgetRetrieval getRetrieval(int index)
- {
- //
- lock.lock();
- try
- {
- if (future == null)
- {
- future = new FutureTask(new Callable()
- {
- public Object call() throws Exception
- {
- log.info("Creating widget batch");
- CompletionService completionService = new ExecutorCompletionService(executor);
- for (int i = 0; i < factories.length; i++)
- {
- completionService.submit(new Fetcher(i));
- }
- GoogleWidgetRetrieval[] retrievals = new GoogleWidgetRetrieval[factories.length];
- for (int i = 0; i < factories.length; i++)
- {
- Future future = completionService.take();
- Fetcher fetcher = (Fetcher)future.get();
- retrievals[fetcher.index] = fetcher.retrieval;
- }
- return retrievals;
- }
- });
- executor.execute(future);
- }
- }
- finally
- {
- lock.unlock();
- }
-
- try
- {
- //
- GoogleWidgetRetrieval[] retrievals = (GoogleWidgetRetrieval[])future.get();
-
- //
- return retrievals[index];
- }
- catch (Exception e)
- {
- return new GoogleWidgetRetrieval(null);
- }
- }
- }
-}
17 years, 4 months
JBoss Portal SVN: r6573 - in trunk: core/src/main/org/jboss/portal/core/impl/model/content and 13 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 09:18:05 -0500 (Wed, 07 Mar 2007)
New Revision: 6573
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java
trunk/widget/src/main/org/jboss/portal/widget/Widget.java
trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
trunk/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java
trunk/widget/src/resources/widget-war/
trunk/widget/src/resources/widget-war/WEB-INF/
trunk/widget/src/resources/widget-war/WEB-INF/portlet-instances.xml
trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml
trunk/widget/src/resources/widget-war/WEB-INF/web.xml
Removed:
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortlet.java
trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortletInvoker.java
trunk/widget/src/resources/widget-invoker-sar/
Modified:
trunk/common/src/main/org/jboss/portal/common/util/Tools.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/AbstractContentRenderer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/GenericPortletContentRenderer.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/widget/build.xml
Log:
- added generic support for content portlet
- redone the google widget thing to integrate with new content contracts
Modified: trunk/common/src/main/org/jboss/portal/common/util/Tools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -178,8 +178,35 @@
}
/**
- * Pipe an input stream in an output stream.
+ * @see #getBytes(java.io.InputStream, int)
+ * @param in the input stream
+ * @return the bytes read from the stream
+ * @throws IOException
+ * @throws IllegalArgumentException if the input stream is null
+ */
+ public static byte[] getBytes(InputStream in) throws IOException, IllegalArgumentException
+ {
+ return getBytes(in, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Get the bytes from the provided input stream. No attempt will be made to close the stream.
*
+ * @param in the input stream
+ * @param bufferSize the buffer size used to copy the bytes
+ * @return the bytes read from the stream
+ * @throws IOException
+ * @throws IllegalArgumentException if the input stream is null or the buffer size < 1
+ */
+ public static byte[] getBytes(InputStream in, int bufferSize) throws IOException, IllegalArgumentException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(in, out, bufferSize);
+ return out.toByteArray();
+ }
+
+ /**
+ * @see #copy(java.io.InputStream, java.io.OutputStream, int)
* @param in the incoming stream
* @param out the outcoming stream
* @throws IllegalArgumentException if an argument is null
@@ -190,7 +217,8 @@
}
/**
- * Pipe an incoming stream in an outcoming stream.
+ * Pipe an incoming stream in an outcoming stream until no bytes is available from the input stream.
+ * No attempts will be made to close the streams.
*
* @param in the incoming stream
* @param out the outcoming stream
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.core.impl.model.content.generic;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.impl.model.content.portlet.PortletContentHandler;
+import org.jboss.portal.common.util.LocalizedString;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericContent implements Content
+{
+
+ /** . */
+ private final ContentState state;
+
+ /** . */
+ private final GenericContentHandler handler;
+
+ /** . */
+ private final String contextId;
+
+ public GenericContent(GenericContentHandler handler, String contextId, ContentState state)
+ {
+ this.handler = handler;
+ this.contextId = contextId;
+ this.state = state;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return new LocalizedString(state.getURI() + " portlet", Locale.ENGLISH);
+ }
+
+ public boolean isMutable()
+ {
+ return true;
+ }
+
+ public String getURI()
+ {
+ return state.getURI();
+ }
+
+ public void setURI(String uri)
+ {
+ state.setURI(uri);
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.core.impl.model.content.generic;
+
+import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.Content;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericContentHandler extends AbstractContentHandler implements ContentHandler
+{
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new GenericContent(this, contextId, state);
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -230,7 +230,16 @@
ContentType contentType = getContentType();
//
- return context.getContentHandler(contentType);
+ ContentHandler handler = context.getContentHandler(contentType);
+
+ //
+ if (handler == null)
+ {
+ handler = context.getContentHandler(ContentType.GENERIC);
+ }
+
+ //
+ return handler;
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/AbstractContentRenderer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/AbstractContentRenderer.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/AbstractContentRenderer.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -63,6 +63,11 @@
this.registry = registry;
}
+ public ContentType getRegisteredContentType()
+ {
+ return registeredContentType;
+ }
+
protected void startService() throws Exception
{
registeredContentType = ContentType.create(contentType);
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/GenericPortletContentRenderer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/GenericPortletContentRenderer.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/GenericPortletContentRenderer.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -28,7 +28,9 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.Mode;
import org.jboss.portal.theme.page.WindowResult;
@@ -75,9 +77,27 @@
protected Instance findInstance(RenderWindowCommand cmd)
{
- ControllerContext context = cmd.getControllerContext();
- InstanceContainer container = context.getController().getInstanceContainer();
- return container.getDefinition(instanceName);
+ String id = instanceName;
+
+ //
+ if (id == null)
+ {
+ Window window = cmd.getWindow();
+ ContentType contentType = window.getContentType();
+ id = ContentEditorRegistry.getInstance().getEditor(contentType);
+ }
+
+ //
+ if (id != null)
+ {
+ ControllerContext context = cmd.getControllerContext();
+ InstanceContainer container = context.getController().getInstanceContainer();
+ return container.getDefinition(id);
+ }
+ else
+ {
+ return null;
+ }
}
public Object renderWindow(RenderWindowCommand cmd) throws Exception
@@ -86,11 +106,17 @@
Window window = cmd.getWindow();
PortalObjectId windowId = window.getId();
+ // No content
+ Content content = window.getContent();
+ if (content == null)
+ {
+ return null;
+ }
+
// Initialize the navigational state with the URI when needed
PortletParametersStateString navigationalState = (PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId);
if (navigationalState == null)
{
- Content content = window.getContent();
String uri = content.getURI();
navigationalState = new PortletParametersStateString();
navigationalState.setValue("uri", uri);
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -43,6 +43,9 @@
public static final ContentType PORTLET = new ContentType("portlet");
/** . */
+ public static final ContentType GENERIC = new ContentType("generic");
+
+ /** . */
private final String value;
private ContentType(String value)
@@ -91,6 +94,10 @@
{
return PORTLET;
}
+ else if ("generic".equals(value))
+ {
+ return GENERIC;
+ }
else if ("cms".equals(value))
{
return CMS;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -75,13 +75,18 @@
public Object execute() throws ControllerException
{
ContentRendererRegistry registry = context.getController().getContentRendererRegistry();
-
ContentType contentType = window.getContentType();
-
ContentRenderer renderer = registry.getRenderer(contentType);
+ // Try generic renderer
if (renderer == null)
{
+ renderer = registry.getRenderer(ContentType.GENERIC);
+ }
+
+ //
+ if (renderer == null)
+ {
return null;
}
else
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -563,6 +563,17 @@
proxy-type="attribute">portal:container=Instance</depends>
<attribute name="ContentType">portlet</attribute>
</mbean>
+ <mbean
+ code="org.jboss.portal.core.impl.model.content.generic.GenericContentHandler"
+ name="portal:service=ContentHandler,type=generic"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Registry"
+ proxy-type="attribute">portal:container=PortalObject</depends>
+ <attribute name="ContentType">generic</attribute>
+ </mbean>
<!-- Customization manager -->
<mbean
@@ -943,6 +954,21 @@
optional-attribute-name="CustomizationManager"
proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
+ <mbean
+ code="org.jboss.portal.core.impl.model.portal.content.GenericPortletContentRenderer"
+ name="portal:service=ContentRenderer,type=generic"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="ContentType">generic</attribute>
+ <attribute name="DecorateContent">true</attribute>
+ <depends
+ optional-attribute-name="Registry"
+ proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+ proxy-type="attribute">portal:service=CustomizationManager</depends>
+ </mbean>
<!-- The core controller -->
<mbean
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -687,7 +687,6 @@
<xmbean/>
<attribute name="ContentType">cms</attribute>
<attribute name="DecorateContent">false</attribute>
- <attribute name="InstanceName">CMSPortletInstance</attribute>
<depends
optional-attribute-name="Registry"
proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
Modified: trunk/widget/build.xml
===================================================================
--- trunk/widget/build.xml 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/widget/build.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -89,12 +89,14 @@
&libraries;
<path id="library.classpath">
<path refid="jbossas/core.libs.classpath"/>
+ <path refid="jboss/backport.concurrent.classpath"/>
<path refid="apache.log4j.classpath"/>
</path>
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
+ <path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-server.classpath"/>
@@ -145,13 +147,23 @@
description="Generate all target output."
depends="compile">
- <!-- widget-invoker-lib.jar -->
+ <!-- widget-lib.jar -->
<mkdir dir="${build.lib}"/>
- <jar jarfile="${build.lib}/widget-invoker-lib.jar">
+ <jar jarfile="${build.lib}/widget-lib.jar">
<fileset dir="${build.classes}"/>
</jar>
+ <!-- widget.war -->
+ <mkdir dir="${build.resources}/widget-war/WEB-INF/lib"/>
+ <copy todir="${build.resources}/widget-war/WEB-INF/lib">
+ <fileset dir="${build.lib}" includes="widget-lib.jar"/>
+ </copy>
+ <jar jarfile="${build.lib}/widget.war">
+ <fileset dir="${build.resources}/widget-war"/>
+ </jar>
+
<!-- widget-invoker.sar -->
+<!--
<mkdir dir="${build.resources}/widget-invoker-sar/lib"/>
<copy todir="${build.resources}/widget-invoker-sar/lib">
<fileset dir="${build.lib}" includes="widget-invoker-lib.jar"/>
@@ -159,6 +171,7 @@
<jar jarfile="${build.lib}/widget-invoker.sar">
<fileset dir="${build.resources}/widget-invoker-sar"/>
</jar>
+-->
</target>
<!-- ================================================================== -->
@@ -197,14 +210,14 @@
description="Deploy."
depends="output">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
- <copy file="${build.lib}/widget-invoker.sar" todir="${jboss.home}/server/${portal.deploy.dir}"/>
+ <copy file="${build.lib}/widget.war" todir="${jboss.home}/server/${portal.deploy.dir}"/>
</target>
<target name="undeploy"
description="Undeploy."
depends="init">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
- <delete file="${jboss.home}/server/${portal.deploy.dir}/widget-invoker.sar"/>
+ <delete file="${jboss.home}/server/${portal.deploy.dir}/widget.war"/>
</target>
</project>
Added: trunk/widget/src/main/org/jboss/portal/widget/Widget.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/Widget.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/Widget.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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 org.jboss.portal.common.util.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Widget
+{
+
+ String getId();
+
+ LocalizedString getTitle();
+
+ LocalizedString getDescription();
+
+ String render();
+
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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 org.jboss.portal.widget.google.GoogleWidgetProvider;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletMode;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WidgetPortlet extends GenericPortlet
+{
+
+ /** . */
+ private static final PortletMode VIEW_CONTENT_MODE = new PortletMode("view_content");
+
+ /** . */
+ private static final PortletMode EDIT_CONTENT_MODE = new PortletMode("edit_content");
+
+ /** . */
+ private GoogleWidgetProvider provider = new GoogleWidgetProvider();
+
+ public void init() throws PortletException
+ {
+ provider.start();
+ }
+
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (VIEW_CONTENT_MODE.equals(req.getPortletMode()))
+ {
+ 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());
+ }
+ else
+ {
+ writer.print("Widget is not available");
+ }
+ writer.close();
+ }
+ else if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ Collection widgets = provider.getKeys();
+ writer.print("<ul>");
+ int size = 0;
+ for (Iterator i = widgets.iterator();i.hasNext() && size < 9;size++)
+ {
+ String key = (String)i.next();
+ Widget widget = provider.getWidget(key);
+ if (widget != null)
+ {
+ PortletURL url = resp.createActionURL();
+ url.setParameter("meta_action", "select");
+ url.setParameter("uri", widget.getId());
+ writer.print("<li><a href=\"" + url + "\">" + widget.getTitle().getDefaultString() + "</a></li>");
+ }
+ }
+ writer.print("/<ul>");
+ writer.close();
+ }
+ }
+
+ public void destroy()
+ {
+ provider.stop();
+ }
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/WidgetProvider.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/WidgetProvider.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * 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.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface WidgetProvider
+{
+
+ Collection getKeys();
+
+ Widget getWidget(String key);
+
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidget.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * 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.util.LocalizedString;
+import org.jboss.portal.common.util.UUIDGenerator;
+import org.jboss.portal.widget.Widget;
+
+/**
+ * Getting list :
+ * http://www.google.com/ig/directory?synd=open
+ *
+ * synd=open -> mandatory to get the embedable widgets
+ * &source=gghp ????
+ *
+ * &start= default=0 [->sa=N ??? ]
+ * &num= default=24
+ * &cat= default=all (popular|news|tools|communication|funandgames|finance|sports|lifestyle|technology|new)
+ *
+ * <Module>
+ * <ModulePrefs
+ * title=""
+ * author=""
+ * author_email=""
+ * author_affiliation=""
+ * author_location=""
+ * screenshot=""
+ * thumbnail=""
+ * category=""
+ * description=""
+ * render_inline="optional"
+ * height=""
+ * scaling="true|false"
+ * scrolling="true|false">
+ * <UserPref
+ * name=""
+ * display_name=""
+ * default_value=""/>
+ *
+ * Getting javascript :
+ *
+ * http://gmodules.com/ig/ifr?url=
+ * up_color=blue
+ * synd=open
+ * w=554
+ * h=205
+ * title=Date+%26+Time
+ * border=%23ffffff%7C3px%2C1px+solid+%23999999
+ * output=js
+ * +
+ * up_ + user pref name = value
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GoogleWidget implements Widget
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** . */
+ private final String url;
+
+ /** . */
+ private final LocalizedString title;
+
+ /** . */
+ private final LocalizedString description;
+
+ /** . */
+ private final int width;
+
+ /** . */
+ private final int height;
+
+ public GoogleWidget(String url,
+ LocalizedString title,
+ LocalizedString description,
+ int width,
+ int height)
+ {
+ this.url = url;
+ this.title = title;
+ this.description = description;
+ this.width = width;
+ this.height = height;
+ }
+
+ public String getId()
+ {
+ return url;
+ }
+
+ public LocalizedString getTitle()
+ {
+ return title;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public String render()
+ {
+ String id = generator.generateKey();
+ String tmp = "http://gmodules.com/ig/ifr?url=" + url +
+ "&synd=open" +
+ "&w=" + width +
+ "&h=" + height +
+ "&title=" + title.getDefaultString() +
+// "&border=%23ffffff%7C3px%2C1px+solid+%23999999" +
+ "&border=%23ffffff%7C3px%2C1px+none+%23999999" +
+ "&output=js";
+
+ String clipper = "" +
+ "(function(){\n" +
+ "var a = document.getElementById('" + id + "');\n" +
+ "var b = a.childNodes.item(2);\n" + // table
+ "var c = b.childNodes.item(0);\n" + // tbody
+ "var d = c.childNodes.item(0);\n" + // tr
+ "var e = c.childNodes.item(1);\n" + // tr
+ "var f = c.childNodes.item(3);\n" + // tr
+ "c.removeChild(d);\n" +
+ "c.removeChild(e);\n" +
+ "c.removeChild(f);\n" +
+ "})();";
+
+ return "<div id=\"" + id + "\">\n" +
+ "<script src=\"" + tmp + "\"></script>\n" +
+ "<script>" + clipper + "</script>\n" +
+ "</div>\n";
+ }
+
+
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetFactory.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -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.google;
+
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.util.LocalizedString;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GoogleWidgetFactory
+{
+
+ /** . */
+ private final URL url;
+
+ public GoogleWidgetFactory(URL url)
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("No null URL");
+ }
+ this.url = url;
+ }
+
+ public URL getURL()
+ {
+ return url;
+ }
+
+ public GoogleWidget create() throws Exception
+ {
+ DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(url.toString());
+ Element moduleElt = doc.getDocumentElement();
+ Iterator modulePrefsEltIterator = XML.getChildrenIterator(moduleElt, "ModulePrefs");
+ Element modulePrefsElt = (Element)modulePrefsEltIterator.next();
+ String titleAttr = modulePrefsElt.getAttribute("title");
+ String descriptionAttr = modulePrefsElt.getAttribute("description");
+ String widthAttr = modulePrefsElt.getAttribute("width");
+ String heightAttr = modulePrefsElt.getAttribute("height");
+
+
+ LocalizedString title = titleAttr != null ? new LocalizedString(titleAttr, Locale.ENGLISH) : null;
+ LocalizedString description = descriptionAttr != null ? new LocalizedString(descriptionAttr, Locale.ENGLISH) : null;
+ int width = (widthAttr != null && widthAttr.length() > 0) ? Integer.parseInt(widthAttr) : 320;
+ int height = (heightAttr != null && heightAttr.length() > 0) ? Integer.parseInt(heightAttr) : 200;
+ return new GoogleWidget(url.toString(), title, description, width, height);
+ }
+}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortlet.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortlet.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortlet.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -1,153 +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.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.support.info.MetaInfoSupport;
-import org.jboss.portal.portlet.support.info.SessionInfoSupport;
-import org.jboss.portal.portlet.support.info.CacheInfoSupport;
-import org.jboss.portal.portlet.support.info.SecurityInfoSupport;
-import org.jboss.portal.portlet.support.info.PreferencesInfoSupport;
-import org.jboss.portal.portlet.support.info.CapabilitiesInfoSupport;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.CapabilitiesInfo;
-import org.jboss.portal.portlet.info.PreferencesInfo;
-import org.jboss.portal.portlet.info.MetaInfo;
-import org.jboss.portal.portlet.info.SecurityInfo;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.info.SessionInfo;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidgetPortlet implements Portlet
-{
-
- /** . */
- private final String id;
-
- /** . */
- private final String title;
-
- /** . */
- private final String description;
-
- /** . */
- private final Info info;
-
- /** . */
- private final String content;
-
- public GoogleWidgetPortlet(String id, Document widgetDoc)
- {
- this.id = id;
- this.info = new Info();
-
- Element moduleElt = widgetDoc.getDocumentElement();
- Iterator modulePrefsEltIterator = XML.getChildrenIterator(moduleElt, "ModulePrefs");
- Element modulePrefsElt = (Element)modulePrefsEltIterator.next();
-
- this.title = modulePrefsElt.getAttribute("title");
- this.description = modulePrefsElt.getAttribute("description");
-
- Iterator contentEltIterator = XML.getChildrenIterator(moduleElt, "Content");
- Element contentElt = (Element)contentEltIterator.next();
-
- this.content = XML.asString(contentElt);
- }
-
-
- public PortletContext getContext()
- {
- return PortletContext.createPortletContext(id);
- }
-
- public PortletInfo getInfo()
- {
- return info;
- }
-
- public boolean isRemote()
- {
- return false;
- }
-
- public String getContent()
- {
- return content;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- private class Info implements PortletInfo
- {
- public CapabilitiesInfo getCapabilities()
- {
- return new CapabilitiesInfoSupport();
- }
-
- public PreferencesInfo getPreferences()
- {
- return new PreferencesInfoSupport();
- }
-
- public MetaInfo getMeta()
- {
- MetaInfoSupport support = new MetaInfoSupport();
- support.setDisplayName(title);
- support.setDescription(description);
- return support;
- }
-
- public SecurityInfo getSecurity()
- {
- return new SecurityInfoSupport();
- }
-
- public CacheInfo getCache()
- {
- return new CacheInfoSupport();
- }
-
- public SessionInfo getSession()
- {
- return new SessionInfoSupport();
- }
-
- public Boolean isRemotable()
- {
- return Boolean.FALSE;
- }
- }
-
-}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortletInvoker.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortletInvoker.java 2007-03-07 03:44:28 UTC (rev 6572)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetPortletInvoker.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -1,234 +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.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.InvokerUnavailableException;
-import org.jboss.portal.portlet.NoSuchPortletException;
-import org.jboss.portal.portlet.state.PropertyMap;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.w3c.dom.Document;
-
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.HTML;
-import javax.swing.text.MutableAttributeSet;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import java.util.Set;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-import java.util.LinkedHashSet;
-import java.util.Iterator;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.HashSet;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GoogleWidgetPortletInvoker extends AbstractJBossService implements PortletInvoker
-{
-
- private volatile Map portletMap;
-
- private static class ParserAccessor extends HTMLEditorKit
- {
- public Parser getParser()
- {
- return super.getParser();
- }
- }
-
- public Map getPortletMap() throws PortletInvokerException
- {
- // Lazy create the map
- if (portletMap == null)
- {
- try
- {
- LinkedHashMap portletMap = new LinkedHashMap();
-
- // Find widget URLs
- URL url = new URL("http://www.google.com/ig/directory");
- InputStream in = url.openStream();
- final LinkedHashSet urls = new LinkedHashSet();
- HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
- {
- public void handleStartTag(HTML.Tag t, MutableAttributeSet attrSet, int pos)
- {
- if (t == HTML.Tag.A)
- {
- try
- {
- String href = (String)attrSet.getAttribute(HTML.Attribute.HREF);
- URL url = new URL(href);
- String query = url.getQuery();
- if (query != null)
- {
- Map params = new HashMap();
- StringTokenizer st = new StringTokenizer(query, "&");
- while (st.hasMoreTokens())
- {
- String pair = st.nextToken();
- int separator = pair.indexOf('=');
- if (separator != -1)
- {
- String left = pair.substring(0, separator);
- String right = pair.substring(separator + 1);
- params.put(left, right);
- }
- }
-
- //
- if (params.containsKey("url"))
- {
- url = new URL((String)params.get("url"));
- if (url.toString().endsWith(".xml"))
- {
- urls.add(url);
- }
- }
- }
- }
- catch (MalformedURLException ignore)
- {
- }
- }
- }
- };
- HTMLEditorKit.Parser parser = new ParserAccessor().getParser();
- parser.parse(new InputStreamReader(in, "UTF-8"), callback, true);
-
- // Now parse each
- for (Iterator i = urls.iterator();i.hasNext();)
- {
- URL widgetURL = (URL)i.next();
- DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(widgetURL.toString());
- try
- {
- GoogleWidgetPortlet portlet = new GoogleWidgetPortlet(widgetURL.toString(), doc);
- portletMap.put(portlet.getContext().getId(), portlet);
- }
- catch (Exception e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- this.portletMap = portletMap;
- }
- catch (Exception e)
- {
- throw new InvokerUnavailableException(e);
- }
- }
-
- //
- Map portletMap = this.portletMap;
- if (portletMap == null)
- {
- portletMap = Collections.EMPTY_MAP;
- }
-
- //
- return portletMap;
- }
-
-
- public Set getPortlets() throws PortletInvokerException
- {
- return new HashSet(getPortletMap().values());
- }
-
- public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
- {
- String targetId = portletContext.getId();
- GoogleWidgetPortlet portlet = (GoogleWidgetPortlet)getPortletMap().get(targetId);
- if (portlet == null)
- {
- throw new NoSuchPortletException(targetId);
- }
- return portlet;
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
- {
- if (invocation instanceof RenderInvocation)
- {
- PortletContext target = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
- GoogleWidgetPortlet portlet = (GoogleWidgetPortlet)getPortlet(target);
- FragmentResponse resp = new FragmentResponse();
- resp.setContentType("text/html");
- resp.getWriter().print(portlet.getContent());
- resp.setTitle(portlet.getTitle());
- return resp;
- }
- else
- {
- throw new UnsupportedOperationException();
- }
- }
-
- public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetProvider.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,276 @@
+/******************************************************************************
+ * 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.net.URL;
+import java.net.MalformedURLException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.util.StringTokenizer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedHashMap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.ArrayList;
+
+import org.jboss.portal.widget.WidgetProvider;
+import org.jboss.portal.widget.Widget;
+import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
+
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.MutableAttributeSet;
+
+import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
+import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingDeque;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GoogleWidgetProvider implements WidgetProvider
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(GoogleWidgetProvider.class);
+
+ /** . */
+ private volatile FutureTask future;
+
+ /** . */
+ private final Lock lock = new ReentrantLock();
+
+ /** . */
+ private final ExecutorService executor = new ThreadPoolExecutor(3, 3, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ executor.shutdownNow();
+ }
+
+ private Map getMap()
+ {
+ try
+ {
+ lock.lock();
+ try
+ {
+ if (future == null)
+ {
+ future = new FutureTask(new Callable()
+ {
+ public Object call() throws Exception
+ {
+ WidgetBuilder map = new WidgetBuilder();
+ map.start();
+ return map;
+ }
+ });
+ executor.execute(future);
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ WidgetBuilder wmap = (WidgetBuilder)future.get();
+ return wmap.map;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return Collections.EMPTY_MAP;
+ }
+ }
+
+ public Collection getKeys()
+ {
+ return getMap().keySet();
+ }
+
+ public Widget getWidget(String key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Map tmp = getMap();
+ GoogleWidgetRetrieval.List retrievals = (GoogleWidgetRetrieval.List)tmp.get(key);
+ if (retrievals != null)
+ {
+ GoogleWidgetRetrieval retrieval = retrievals.getRetrieval(key);
+ if (retrieval.getStatus() == GoogleWidgetRetrieval.AVAILABLE)
+ {
+ return retrieval.getWidget();
+ }
+ }
+
+ //
+ return null;
+ }
+
+ private class WidgetBuilder
+ {
+
+ /** . */
+ private Map map;
+
+ public void start()
+ {
+ try
+ {
+ // Find widget URLs
+ URL url = new URL("http://www.google.com/ig/directory?synd=open");
+
+ // Read fully the URL content first
+ byte[] bytes = null;
+ InputStream in = null;
+ try
+ {
+ log.info("Retrieving " + url);
+ in = url.openStream();
+ bytes = Tools.getBytes(in);
+ log.info("Document " + url + " has been retrieved");
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ }
+
+ //
+ final LinkedHashSet urls = new LinkedHashSet();
+ HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback()
+ {
+ public void handleStartTag(HTML.Tag t, MutableAttributeSet attrSet, int pos)
+ {
+ if (t == HTML.Tag.A)
+ {
+ try
+ {
+ String href = (String)attrSet.getAttribute(HTML.Attribute.HREF);
+ URL url = new URL(href);
+ String query = url.getQuery();
+ if (query != null)
+ {
+ Map params = new HashMap();
+ StringTokenizer st = new StringTokenizer(query, "&");
+ while (st.hasMoreTokens())
+ {
+ String pair = st.nextToken();
+ int separator = pair.indexOf('=');
+ if (separator != -1)
+ {
+ String left = pair.substring(0, separator);
+ String right = pair.substring(separator + 1);
+ params.put(left, right);
+ }
+ }
+
+ //
+ if (params.containsKey("url"))
+ {
+ String tmp = (String)params.get("url");
+ if (tmp.endsWith(".xml"))
+ {
+ url = new URL(tmp);
+ urls.add(url);
+ }
+ }
+ }
+ }
+ catch (MalformedURLException ignore)
+ {
+ }
+ }
+ }
+ };
+ HTMLEditorKit.Parser parser = new ParserAccessor().getParser();
+ parser.parse(new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8"), callback, true);
+
+ //
+ Map map = new LinkedHashMap();
+
+ // Now parse each
+ Collection tmp = new ArrayList(BATCH_SIZE);
+ for (Iterator i = urls.iterator();i.hasNext();)
+ {
+ URL widgetURL = (URL)i.next();
+ GoogleWidgetFactory widgetFactory = new GoogleWidgetFactory(widgetURL);
+
+ //
+ if (tmp.size() < BATCH_SIZE)
+ {
+ tmp.add(widgetFactory);
+ }
+ else
+ {
+ GoogleWidgetRetrieval.List retrievals = new GoogleWidgetRetrieval.List(executor, tmp);
+ for (int j = 0;j < retrievals.getSize();j++)
+ {
+ GoogleWidgetFactory t = retrievals.getFactory(j);
+ map.put(t.getURL().toString(), retrievals);
+ log.info("Added widget for later retrieval" + t.getURL());
+ }
+
+ //
+ tmp.clear();
+ tmp.add(widgetFactory);
+ }
+ }
+
+ //
+ this.map = Collections.unmodifiableMap(map);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static final int BATCH_SIZE = 6;
+
+ private static class ParserAccessor extends HTMLEditorKit
+ {
+ public Parser getParser()
+ {
+ return super.getParser();
+ }
+ }
+}
Added: trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GoogleWidgetRetrieval.java 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * 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 edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
+import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import edu.emory.mathcs.backport.java.util.concurrent.CompletionService;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
+import edu.emory.mathcs.backport.java.util.concurrent.Future;
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GoogleWidgetRetrieval
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(GoogleWidgetRetrieval.class);
+
+ /** . */
+ public static int UNAVAILABLE = 0;
+
+ /** . */
+ public static int AVAILABLE = 1;
+
+ /** . */
+ private GoogleWidget widget;
+
+ public GoogleWidgetRetrieval(GoogleWidget widget)
+ {
+ this.widget = widget;
+ }
+
+ public GoogleWidget getWidget() throws IllegalStateException
+ {
+ if (widget == null)
+ {
+ throw new IllegalStateException("Widget not available");
+ }
+ return widget;
+ }
+
+ public int getStatus()
+ {
+ return widget != null ? AVAILABLE : UNAVAILABLE;
+ }
+
+ public static class List
+ {
+
+ /** . */
+ private final GoogleWidgetFactory[] factories;
+
+ /** . */
+ private final Executor executor;
+
+ /** . */
+ private final Lock lock = new ReentrantLock();
+
+ /** . */
+ private FutureTask future;
+
+ public List(Executor executor, Collection c)
+ {
+ this.executor = executor;
+ this.factories = (GoogleWidgetFactory[])c.toArray(new GoogleWidgetFactory[c.size()]);
+ }
+
+ public int getSize()
+ {
+ return factories.length;
+ }
+
+ public GoogleWidgetFactory getFactory(int index)
+ {
+ return factories[index];
+ }
+
+ public GoogleWidgetRetrieval getRetrieval(String key)
+ {
+ for (int i = 0;i < factories.length;i++)
+ {
+ GoogleWidgetFactory factory = factories[i];
+ if (key.equals(factory.getURL().toString()))
+ {
+ return getRetrieval(i);
+ }
+ }
+ return null;
+ }
+
+ private class Fetcher implements Callable
+ {
+
+ /** . */
+ private final int index;
+
+ /** . */
+ private GoogleWidgetRetrieval retrieval;
+
+ public Fetcher(int index)
+ {
+ this.index = index;
+ }
+
+ public Object call() throws Exception
+ {
+ GoogleWidgetFactory factory = factories[index];
+ try
+ {
+ log.info("Creating widget " + factory.getURL());
+ GoogleWidget widget = factory.create();
+ retrieval = new GoogleWidgetRetrieval(widget);
+ }
+ catch (Exception e)
+ {
+ log.error("Widget " + factory.getURL() + " was not retrievable", e);
+ retrieval = new GoogleWidgetRetrieval(null);
+ }
+ return this;
+ }
+ }
+
+ public GoogleWidgetRetrieval getRetrieval(int index)
+ {
+ //
+ lock.lock();
+ try
+ {
+ if (future == null)
+ {
+ future = new FutureTask(new Callable()
+ {
+ public Object call() throws Exception
+ {
+ log.info("Creating widget batch");
+ CompletionService completionService = new ExecutorCompletionService(executor);
+ for (int i = 0; i < factories.length; i++)
+ {
+ completionService.submit(new Fetcher(i));
+ }
+ GoogleWidgetRetrieval[] retrievals = new GoogleWidgetRetrieval[factories.length];
+ for (int i = 0; i < factories.length; i++)
+ {
+ Future future = completionService.take();
+ Fetcher fetcher = (Fetcher)future.get();
+ retrievals[fetcher.index] = fetcher.retrieval;
+ }
+ return retrievals;
+ }
+ });
+ executor.execute(future);
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+
+ try
+ {
+ //
+ GoogleWidgetRetrieval[] retrievals = (GoogleWidgetRetrieval[])future.get();
+
+ //
+ return retrievals[index];
+ }
+ catch (Exception e)
+ {
+ return new GoogleWidgetRetrieval(null);
+ }
+ }
+ }
+}
Added: trunk/widget/src/resources/widget-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/widget/src/resources/widget-war/WEB-INF/portlet-instances.xml (rev 0)
+++ trunk/widget/src/resources/widget-war/WEB-INF/portlet-instances.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -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>GoogleWidgetPortletInstance</instance-id>
+ <portlet-ref>GoogleWidgetPortlet</portlet-ref>
+ </instance>
+ </deployment>
+</deployments>
\ No newline at end of file
Added: trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml
===================================================================
--- trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml (rev 0)
+++ trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -0,0 +1,44 @@
+<?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>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>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Google Widget</title>
+ <keywords>widget</keywords>
+ </portlet-info>
+ </portlet>
+</portlet-app>
Added: trunk/widget/src/resources/widget-war/WEB-INF/web.xml
===================================================================
--- trunk/widget/src/resources/widget-war/WEB-INF/web.xml (rev 0)
+++ trunk/widget/src/resources/widget-war/WEB-INF/web.xml 2007-03-07 14:18:05 UTC (rev 6573)
@@ -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/google</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.jboss.portal.portlet_instance</param-name>
+ <param-value>GoogleWidgetPortletInstance</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.core.servlet.jsp.ContentTypeRegistration</listener-class>
+ </listener>
+</web-app>
17 years, 4 months
JBoss Portal SVN: r6572 - in trunk/wsrp: src/main/org/jboss/portal/test/wsrp/deployment and 4 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-06 22:44:28 -0500 (Tue, 06 Mar 2007)
New Revision: 6572
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- RegistrationInfo is invalid at construction time.
- Better transactional handling in ConsumerRegistryService.startService.
- Re-added WSRPConsumer.setServiceFactory since it's required for wiring of tests.
- Moved MockConsumerRegistry to framework/support.
- Properly set the registry on ProducerInfo in V1ConsumerBaseTest.
- Re-added no-arg constructor on WSRPConsumerImpl since it's required for wiring of tests.
- Tests should now all properly pass.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/build.xml 2007-03-07 03:44:28 UTC (rev 6572)
@@ -736,6 +736,7 @@
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.EndpointConfigurationInfoTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
</x-test>
<x-sysproperty>
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.wsrp.deployment;
import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -1,99 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.wsrp.deployment;
-
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
-import org.jboss.portal.test.wsrp.framework.support.MockWSRPConsumer;
-import org.jboss.portal.wsrp.WSRPConsumer;
-import org.jboss.portal.wsrp.consumer.ConsumerException;
-import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
-import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.consumer.RegistrationInfo;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class MockConsumerRegistry implements ConsumerRegistry
-{
- private Map consumers = new HashMap(3);
-
-
- public MockConsumerRegistry()
- {
- consumers.put("inDB", new MockWSRPConsumer("inDB"));
- MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
- consumer.getProducerInfo().setActive(true);
- consumers.put("inDB2", consumer);
- }
-
- public Collection getConfiguredConsumers()
- {
- return consumers.values();
- }
-
- public WSRPConsumer getConsumer(String id)
- {
- return (WSRPConsumer)consumers.get(id);
- }
-
- public FederatingPortletInvoker getFederatingPortletInvoker()
- {
- return null;
- }
-
- public WSRPConsumer createConsumer(String id)
- {
- MockWSRPConsumer consumer = new MockWSRPConsumer(id);
- consumers.put(id, consumer);
- return consumer;
- }
-
- public void persistConsumer(WSRPConsumer consumer)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "WSRPConsumer");
- consumers.put(consumer.getProducerId(), consumer);
- }
-
- public void activateConsumerWith(String id) throws ConsumerException
- {
- // do nothing
- }
-
- public void updateProducerInfo(ProducerInfo producerInfo)
- {
- // do nothing
- }
-
- public RegistrationInfo getDefaultRegistrationInfo()
- {
- return new RegistrationInfo();
- }
-}
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java (from rev 6571, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.framework.support;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerException;
+import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class MockConsumerRegistry implements ConsumerRegistry
+{
+ private Map consumers = new HashMap(3);
+ private final static RegistrationInfo NULL_REGISTRATION_INFO = new RegistrationInfo();
+
+
+ public MockConsumerRegistry()
+ {
+ consumers.put("inDB", new MockWSRPConsumer("inDB"));
+ MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
+ consumer.getProducerInfo().setActive(true);
+ consumers.put("inDB2", consumer);
+ }
+
+ public Collection getConfiguredConsumers()
+ {
+ return consumers.values();
+ }
+
+ public WSRPConsumer getConsumer(String id)
+ {
+ return (WSRPConsumer)consumers.get(id);
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return null;
+ }
+
+ public WSRPConsumer createConsumer(String id)
+ {
+ MockWSRPConsumer consumer = new MockWSRPConsumer(id);
+ consumers.put(id, consumer);
+ return consumer;
+ }
+
+ public void persistConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "WSRPConsumer");
+ consumers.put(consumer.getProducerId(), consumer);
+ }
+
+ public void activateConsumerWith(String id) throws ConsumerException
+ {
+ // do nothing
+ }
+
+ public void updateProducerInfo(ProducerInfo producerInfo)
+ {
+ // do nothing
+ }
+
+ public RegistrationInfo getDefaultRegistrationInfo()
+ {
+ return NULL_REGISTRATION_INFO;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -59,6 +59,10 @@
return producerInfo.getId();
}
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ }
+
public ServiceFactory getServiceFactory()
{
return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -28,6 +28,7 @@
import org.jboss.portal.test.wsrp.WSRPConsumerBaseTest;
import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
@@ -61,7 +62,10 @@
public void setUp() throws Exception
{
super.setUp();
+
+ // reset producer state
producer.reset();
+
// reset the behaviors
BehaviorRegistry registry = producer.getBehaviorRegistry();
registry.setPortletManagementBehavior(new BasicPortletManagementBehavior(registry));
@@ -71,7 +75,14 @@
registry.registerMarkupBehavior(new InitCookieMarkupBehavior(registry));
registry.registerMarkupBehavior(new NullMarkupBehavior(registry));
registry.registerMarkupBehavior(new SessionMarkupBehavior(registry));
+
+ // use a fresh ConsumerRegistry
+ consumer.getProducerInfo().setRegistry(new MockConsumerRegistry());
+
// make sure we use clean producer info for each test
consumer.refreshProducerInfo();
+
+ // use cache to avoid un-necessary calls
+ consumer.getProducerInfo().setExpirationCacheSeconds(new Integer(120));
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -48,6 +48,14 @@
String getProducerId();
/**
+ * Sets the ServiceFactory this Consumer will use to access the associated Producer's services. Required for wiring
+ * of services.
+ *
+ * @param serviceFactory the ServiceFactory this Consumer will use to access the associated Producer's services.
+ */
+ void setServiceFactory(ServiceFactory serviceFactory);
+
+ /**
* Retrieves the ServiceFactory this Consumer will use to access the associated Producer's services.
*
* @return the ServiceFactory this Consumer will use to access the associated Producer's services.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -124,8 +124,13 @@
// load the configured consumers
consumers = new TreeMap();
+
Session session = sessionFactory.getCurrentSession();
+
+ session.beginTransaction();
Iterator producerInfos = session.createQuery("from ProducerInfo pi order by pi.id").iterate();
+
+ // load the configured producers
ProducerInfo producerInfo;
while (producerInfos.hasNext())
{
@@ -135,20 +140,30 @@
producerInfo.setRegistry(this);
createConsumerFrom(producerInfo);
- activateConsumerWith(producerInfo.getId());
+
+ // if the producer is marked as active, activate it fo' real! :)
+ if (producerInfo.isActive())
+ {
+ activateConsumerWith(producerInfo.getId());
+ }
}
+ session.getTransaction().commit();
+ session.beginTransaction();
nullRegistration = (RegistrationInfo)session.createQuery("from RegistrationInfo where key = (select min(key) from RegistrationInfo)").uniqueResult();
if (nullRegistration == null)
{
nullRegistration = new RegistrationInfo();
session.persist(nullRegistration);
}
+ session.getTransaction().commit();
+
+ session.close();
}
private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
- WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo, this);
+ WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo);
consumers.put(producerInfo.getId(), consumer);
return consumer;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -558,7 +558,7 @@
private RegistrationContext getRegistrationContext()
{
- return persistentRegistrationInfo.getRegistrationContext();
+ return persistentRegistrationInfo == null ? null : persistentRegistrationInfo.getRegistrationContext();
}
public void resetRegistration() throws PortletInvokerException
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -75,7 +75,7 @@
public RegistrationInfo()
{
consumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
- isRegistrationValid = true;
+ isRegistrationValid = false;
requiresRegistration = false;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07 03:44:28 UTC (rev 6572)
@@ -117,10 +117,14 @@
/** The set of supported user scopes */
private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE; // todo: make it possible to support different user scopes
- WSRPConsumerImpl(ProducerInfo info, ConsumerRegistry registry)
+ public WSRPConsumerImpl()
{
+ this(new ProducerInfo());
+ }
+
+ WSRPConsumerImpl(ProducerInfo info)
+ {
ParameterValidation.throwIllegalArgExceptionIfNull(info, "ProducerInfo");
- ParameterValidation.throwIllegalArgExceptionIfNull(registry, "ConsumerRegistry");
producerInfo = info;
actionHandler = new ActionHandler(this);
@@ -476,6 +480,11 @@
return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
}
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ producerInfo.getEndpointConfigurationInfo().setServiceFactory(serviceFactory);
+ }
+
public WSRP_v1_ServiceDescription_PortType getServiceDescriptionService() throws PortletInvokerException
{
producerInfo.refresh(false);
17 years, 4 months
JBoss Portal SVN: r6571 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/framework/support and 3 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-06 21:39:54 -0500 (Tue, 06 Mar 2007)
New Revision: 6571
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
- Fixed DeploymentTestCase by having smarter mocks and adpating expectations.
- MockConsumerRegistry now implements createConsumer.
- Removed unused setServiceFactory method on WSRPConsumer.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -106,10 +106,10 @@
assertEquals("inDB2", consumer.getProducerId());
assertNull(consumer.getProducerInfo().getExpirationCacheSeconds());
// since inDB2 is loaded from MockConsumerRegistry, it shouldn't be processed by WSRPDeploymentFactory and should
- // therefore return null for most values (as it's how MockWSRPConsumer is implemented)
+ // therefore return the default value for the mandatory URLs
EndpointConfigurationInfo endpoint = consumer.getProducerInfo().getEndpointConfigurationInfo();
- assertNull(endpoint.getServiceDescriptionURL());
- assertNull(endpoint.getMarkupURL());
+ assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getServiceDescriptionURL());
+ assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
//
service = services.get(2);
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -71,7 +71,9 @@
public WSRPConsumer createConsumer(String id)
{
- throw new UnsupportedOperationException("createConsumer is not supported on MockConsumerRegistry");
+ MockWSRPConsumer consumer = new MockWSRPConsumer(id);
+ consumers.put(id, consumer);
+ return consumer;
}
public void persistConsumer(WSRPConsumer consumer)
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -59,13 +59,9 @@
return producerInfo.getId();
}
- public void setServiceFactory(ServiceFactory serviceFactory)
- {
- }
-
public ServiceFactory getServiceFactory()
{
- return null;
+ return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
}
public ProducerSessionInformation getProducerSessionInformationFrom(PortletInvocation invocation)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -48,13 +48,6 @@
String getProducerId();
/**
- * Sets the ServiceFactory this Consumer will use to access the associated Producer's services.
- *
- * @param serviceFactory the ServiceFactory this Consumer will use to access the associated Producer's services.
- */
- void setServiceFactory(ServiceFactory serviceFactory);
-
- /**
* Retrieves the ServiceFactory this Consumer will use to access the associated Producer's services.
*
* @return the ServiceFactory this Consumer will use to access the associated Producer's services.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -476,11 +476,6 @@
return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
}
- public void setServiceFactory(ServiceFactory serviceFactory)
- {
- producerInfo.getEndpointConfigurationInfo().setServiceFactory(serviceFactory);
- }
-
public WSRP_v1_ServiceDescription_PortType getServiceDescriptionService() throws PortletInvokerException
{
producerInfo.refresh(false);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-07 01:14:28 UTC (rev 6570)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-07 02:39:54 UTC (rev 6571)
@@ -207,7 +207,7 @@
thread.start();
// Wait for the thread to finish but don't wait longer than the specified time
- long delayMillis = 1000;
+ long delayMillis = 2500;
try
{
thread.join(delayMillis);
17 years, 4 months
JBoss Portal SVN: r6570 - in trunk/core-admin/src: resources/portal-admin-war/WEB-INF/jsf and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 20:14:28 -0500 (Tue, 06 Mar 2007)
New Revision: 6570
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
Log:
when editing a window, if a portlet is selected then it becomes the portlet of the window
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-07 00:46:57 UTC (rev 6569)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-07 01:14:28 UTC (rev 6570)
@@ -627,8 +627,24 @@
Map actionParams = actionEvent.getParameterMap();
if (actionParams.get("meta_action") != null)
{
- String[] uris = (String[])actionParams.get("uri");
- selectedContentURI = uris[0];
+ String[] uris = (String[])actionParams.get("uri");
+ if (uris != null && uris.length > 0)
+ {
+ String uri = uris[0];
+
+ PortalObject po = getSelectedObject();
+ switch(po.getType())
+ {
+ case PortalObject.TYPE_WINDOW:
+ Window window = (Window)po;
+ window.getContent().setURI(uri);
+ break;
+ case PortalObject.TYPE_PAGE:
+ selectedContentURI = uri;
+ break;
+ }
+
+ }
}
}
}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-07 00:46:57 UTC (rev 6569)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-07 01:14:28 UTC (rev 6570)
@@ -12,6 +12,7 @@
<!-- -->
<div>
<jbp:portlet
+ actionListener="#{portalobjectmgr.processEvent}"
instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
renderParameters="#{portalobjectmgr.renderParameters}"
supportedModes="edit_content"
17 years, 4 months
JBoss Portal SVN: r6569 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 19:46:57 -0500 (Tue, 06 Mar 2007)
New Revision: 6569
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
Log:
run the PortletContentEditorPortlet in a new transaction so it does not break when it dies
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-06 23:08:36 UTC (rev 6568)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-07 00:46:57 UTC (rev 6569)
@@ -35,6 +35,15 @@
<link rel="stylesheet" type="text/css" href="/style.css" title="" media="screen"/>
</header-content>
</portlet>
+ <portlet>
+ <portlet-name>PortletContentEditorPortlet</portlet-name>
+ <transaction>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </transaction>
+ <header-content>
+ <link rel="stylesheet" type="text/css" href="/style.css" title="" media="screen"/>
+ </header-content>
+ </portlet>
<!-- Service injected in the portlet context. -->
<service>
17 years, 4 months
JBoss Portal SVN: r6568 - in trunk: core/src/main/org/jboss/portal/core/servlet/jsp and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 18:08:36 -0500 (Tue, 06 Mar 2007)
New Revision: 6568
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
Log:
- hack to merge cms content viewer and content editor
- moved ContentTypeRegistry into core
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java (from rev 6566, trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -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.core.impl.model.content;
+
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+import org.jboss.portal.core.model.content.ContentType;
+
+import java.util.Collection;
+
+/**
+ * A simple registry to track the instance that provides content facilities.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentEditorRegistry
+{
+
+ /** The singleton instance. */
+ private static final ContentEditorRegistry instance = new ContentEditorRegistry();
+
+ /** . */
+ private final CopyOnWriteRegistry editors = new CopyOnWriteRegistry();
+
+ public static ContentEditorRegistry getInstance()
+ {
+ return instance;
+ }
+
+ public void registerEditor(ContentType contentType, String instanceName)
+ {
+ editors.register(contentType, instanceName);
+ }
+
+ public void unregisterEditor(ContentType contentType)
+ {
+ editors.unregister(contentType);
+ }
+
+ public String getEditor(ContentType contentType)
+ {
+ return (String)editors.getRegistration(contentType);
+ }
+
+ public Collection getContentTypes()
+ {
+ return editors.getKeys();
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -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.core.servlet.jsp;
+
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.model.content.ContentType;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContext;
+
+/**
+ * Provide registration of a content type with a portlet instance. This listener can be used
+ * in war files to register content driven portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentTypeRegistration implements ServletContextListener
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ContentTypeRegistration.class);
+
+ /** . */
+ private ContentType contentType;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ ServletContext ctx = event.getServletContext();
+
+ //
+ String tmp = ctx.getInitParameter("org.jboss.portal.content_type");
+ if (tmp == null)
+ {
+ log.warn("The content type of the content registration is not defined, please define the init parameter org.jboss.portal.content_type in web.xml");
+ return;
+ }
+ contentType = ContentType.create(tmp);
+
+ //
+ String portletInstance = event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
+ if (portletInstance == null)
+ {
+ log.warn("The portlet instance of the content registration is not defined, please define the init parameter org.jboss.portal.portlet_instance in web.xml");
+ return;
+ }
+
+ //
+ log.debug("About to register content type "+ contentType + " with portlet instance " + portletInstance);
+ ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
+ registry.registerEditor(contentType, portletInstance);
+ log.debug("Registered content type "+ contentType + " with portlet instance " + portletInstance);
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ if (contentType != null)
+ {
+ log.debug("About to unregister content type "+ contentType);
+ ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
+ registry.unregisterEditor(contentType);
+ log.debug("Content type "+ contentType + " has been unregistered");
+ }
+ }
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -38,7 +38,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import javax.faces.context.FacesContext;
import java.util.Set;
@@ -223,12 +223,12 @@
DelegatingPropertyResolver.registerDecorator(PortalObject.class, portalObjectDecorator);
//
- DelegatingPropertyResolver.registerDecorator(ContentEditors.class, new AbstractBeanDecorator()
+ DelegatingPropertyResolver.registerDecorator(ContentEditorRegistry.class, new AbstractBeanDecorator()
{
protected PropertyDecorator getProperty(Object propertyName)
{
ContentType contentType = ContentType.create((String)propertyName);
- final String instanceName = ContentEditors.getInstance().getEditor(contentType);
+ final String instanceName = ContentEditorRegistry.getInstance().getEditor(contentType);
return instanceName == null ? null : new AbstractPropertyDecorator(String.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -52,7 +52,7 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.admin.ui.actions.WindowComparator;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import org.jboss.portal.core.faces.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.AuthorizationDomainRegistry;
@@ -145,7 +145,7 @@
public List getAvailableContentTypes()
{
LinkedList types = new LinkedList();
- for (Iterator i = ContentEditors.getInstance().getContentTypes().iterator();i.hasNext();)
+ for (Iterator i = ContentEditorRegistry.getInstance().getContentTypes().iterator();i.hasNext();)
{
ContentType contentType = (ContentType)i.next();
SelectItem item = new SelectItem();
@@ -163,16 +163,16 @@
return types;
}
- public ContentEditors getContentEditors()
+ public ContentEditorRegistry getContentEditors()
{
- return ContentEditors.getInstance();
+ return ContentEditorRegistry.getInstance();
}
public String getSelectedContentEditorInstance()
{
if (selectedContentType != null)
{
- return ContentEditors.getInstance().getEditor(selectedContentType);
+ return ContentEditorRegistry.getInstance().getEditor(selectedContentType);
}
return null;
}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -1,67 +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.core.admin.ui.content;
-
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
-import org.jboss.portal.core.model.content.ContentType;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditors
-{
-
- /** . */
- private static final ContentEditors instance = new ContentEditors();
-
- /** . */
- private final CopyOnWriteRegistry editors = new CopyOnWriteRegistry();
-
- public static ContentEditors getInstance()
- {
- return instance;
- }
-
- public void registerEditor(ContentType contentType, String instanceName)
- {
- editors.register(contentType, instanceName);
- }
-
- public void unregisterEditor(ContentType contentType)
- {
- editors.unregister(contentType);
- }
-
- public String getEditor(ContentType contentType)
- {
- return (String)editors.getRegistration(contentType);
- }
-
- public Collection getContentTypes()
- {
- return editors.getKeys();
- }
-}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -25,7 +25,7 @@
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.MetaInfo;
@@ -59,7 +59,7 @@
public void init() throws PortletException
{
instanceContainer = (InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
- ContentEditors.getInstance().registerEditor(ContentType.PORTLET, "PortletContentEditorInstance");
+ ContentEditorRegistry.getInstance().registerEditor(ContentType.PORTLET, "PortletContentEditorInstance");
}
public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -38,6 +38,9 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletMode;
+import javax.portlet.PortletConfig;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
import org.apache.log4j.Logger;
import org.jboss.portal.cms.CMS;
@@ -47,8 +50,11 @@
import org.jboss.portal.cms.search.CMSFederatedSearch;
import org.jboss.portal.cms.util.FileUtil;
import org.jboss.portal.core.cms.CMSConstants;
+import org.jboss.portal.core.cms.ui.admin.CMSContentEditorPortlet;
import org.jboss.portal.core.cms.command.StreamContentCommand;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.search.federation.SearchFederation;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -132,15 +138,41 @@
/** . */
private CMS CMSService;
+ /** . */
+ private CMSContentEditorPortlet hack = new CMSContentEditorPortlet();
+
+
+ public void init(PortletConfig config) throws PortletException
+ {
+ super.init(config);
+
+ //
+ hack.init(config);
+ }
+
+
+ public void destroy()
+ {
+ super.destroy();
+
+ //
+ ContentEditorRegistry.getInstance().unregisterEditor(ContentType.CMS);
+
+ //
+ hack.destroy();
+ }
+
public void init() throws PortletException
{
CMSService = (CMS)getPortletContext().getAttribute("CMS");
-
if (CMSService == null)
{
throw new PortletException("Cannot start CMS portlet due to service unavailability");
}
-
+
+ //
+ ContentEditorRegistry.getInstance().registerEditor(ContentType.CMS, "CMSPortletInstance");
+
try
{
SearchFederation searchFederationService = (SearchFederation)getPortletContext().getAttribute("SearchFederationService");
@@ -158,6 +190,12 @@
}
+ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ // Only the editor uses it for now, so just forward
+ hack.processAction(request, response);
+ }
+
protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
PortletMode portletMode = req.getPortletMode();
@@ -165,6 +203,10 @@
{
doViewContent(req, resp);
}
+ else if ("edit_content".equals(portletMode.toString()))
+ {
+ hack.render(req, resp);
+ }
else
{
super.doDispatch(req, resp);
@@ -184,6 +226,11 @@
}
}
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ hack.render(req, resp);
+ }
+
protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
PortletPreferences prefs = req.getPreferences();
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06 23:08:36 UTC (rev 6568)
@@ -37,8 +37,6 @@
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
-import org.jboss.portal.core.model.content.ContentType;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -54,7 +52,6 @@
public void init() throws PortletException
{
cmsService = (CMS)getPortletContext().getAttribute("CMS");
- ContentEditors.getInstance().registerEditor(ContentType.CMS, "CMSContentEditorInstance");
}
public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06 22:53:50 UTC (rev 6567)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06 23:08:36 UTC (rev 6568)
@@ -47,10 +47,4 @@
</instance>
</deployment>
- <deployment>
- <instance>
- <instance-id>CMSContentEditorInstance</instance-id>
- <portlet-ref>CMSContentEditorPortlet</portlet-ref>
- </instance>
- </deployment>
</deployments>
\ No newline at end of file
17 years, 4 months
JBoss Portal SVN: r6567 - in trunk/core-cms/src: resources/portal-cms-war/WEB-INF/jsp/cms/editor and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-06 17:53:50 -0500 (Tue, 06 Mar 2007)
New Revision: 6567
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
Log:
CMSContentEditorPortlet working
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06 22:21:42 UTC (rev 6566)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06 22:53:50 UTC (rev 6567)
@@ -29,6 +29,7 @@
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
@@ -45,9 +46,10 @@
*/
public class CMSContentEditorPortlet extends GenericPortlet
{
+ /** . */
+ private static final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
private CMS cmsService;
-
public void init() throws PortletException
{
@@ -57,42 +59,48 @@
public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
{
- String uri = req.getParameter("uri");
- String path = req.getParameter("path");
- if (uri != null)
+ if (req.getPortletMode().equals(EDIT_CONTENT))
{
- resp.setRenderParameter("uri", uri);
+ String uri = req.getParameter("uri");
+ String path = req.getParameter("path");
+ if (uri != null)
+ {
+ resp.setRenderParameter("uri", uri);
+ }
+ if (path != null)
+ {
+ resp.setRenderParameter("path", path);
+ }
+ resp.setRenderParameter("meta_action", "blah");
}
- if (path != null)
- {
- resp.setRenderParameter("path", path);
- }
}
public void render(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
- resp.setContentType("text/html");
-
- String sPath = req.getParameter("path");
- if (sPath == null)
+ if (req.getPortletMode().equals(EDIT_CONTENT))
{
- sPath = "/";
- }
+ resp.setContentType("text/html");
- Command listCMD = cmsService.getCommandFactory().createFolderGetListCommand(sPath);
- Folder mainFolder = (Folder)cmsService.execute(listCMD);
- List folders = mainFolder.getFolders();
- List files = mainFolder.getFiles();
+ String sPath = req.getParameter("path");
+ if (sPath == null)
+ {
+ sPath = "/";
+ }
- resp.setContentType("text/html");
- req.setAttribute("folders", folders);
- req.setAttribute("files", files);
- req.setAttribute("currpath", sPath);
-
-
- javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSEditorConstants.CMS_EDITOR_JSP_PATH + "/main.jsp");
- prd.include(req, resp);
+ Command listCMD = cmsService.getCommandFactory().createFolderGetListCommand(sPath);
+ Folder mainFolder = (Folder)cmsService.execute(listCMD);
+ List folders = mainFolder.getFolders();
+ List files = mainFolder.getFiles();
+ resp.setContentType("text/html");
+ req.setAttribute("folders", folders);
+ req.setAttribute("files", files);
+ req.setAttribute("currpath", sPath);
+
+
+ javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSEditorConstants.CMS_EDITOR_JSP_PATH + "/main.jsp");
+ prd.include(req, resp);
+ }
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-03-06 22:21:42 UTC (rev 6566)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-03-06 22:53:50 UTC (rev 6567)
@@ -110,6 +110,7 @@
border="0"> <a href="<portlet:actionURL>
<portlet:param name="uri" value="<%= file.getBasePath() %>"/>
<portlet:param name="path" value="<%= sCurrPath %>"/>
+ <portlet:param name="meta_action" value="select"/>
</portlet:actionURL>"><%=
file.getBasePath().substring(file.getBasePath().lastIndexOf("/") + 1, file.getBasePath().length()) %>
</a>
17 years, 4 months
JBoss Portal SVN: r6566 - in trunk: core-admin/src/main/org/jboss/portal/core/admin/ui/content and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 17:21:42 -0500 (Tue, 06 Mar 2007)
New Revision: 6566
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractContentEditor.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractFaceletContentEditor.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditor.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistry.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryService.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorTagHandler.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/FaceletContentEditor.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/PortletContentEditor.java
trunk/core-admin/src/resources/portal-admin-sar/content/
trunk/core-admin/src/resources/portal-admin-war/META-INF/
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java
trunk/core-cms/src/resources/portal-cms-sar/content/
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
trunk/core-admin/src/resources/portal-admin-sar/META-INF/jboss-service.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
remove previous content editor based on facelet
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.LinkedList;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
@@ -141,6 +142,27 @@
// Wired services
+ public List getAvailableContentTypes()
+ {
+ LinkedList types = new LinkedList();
+ for (Iterator i = ContentEditors.getInstance().getContentTypes().iterator();i.hasNext();)
+ {
+ ContentType contentType = (ContentType)i.next();
+ SelectItem item = new SelectItem();
+ item.setValue(contentType);
+ item.setLabel(contentType.toString());
+ if (contentType.equals(ContentType.PORTLET))
+ {
+ types.addFirst(item);
+ }
+ else
+ {
+ types.addLast(item);
+ }
+ }
+ return types;
+ }
+
public ContentEditors getContentEditors()
{
return ContentEditors.getInstance();
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractContentEditor.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,74 +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.core.admin.ui.content;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.core.model.content.ContentType;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class AbstractContentEditor extends AbstractJBossService implements ContentEditor
-{
-
- /** . */
- private String contentType;
-
- /** . */
- private ContentEditorRegistry registry;
-
- /** . */
- private ContentType registeredContentType;
-
- public ContentEditorRegistry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry(ContentEditorRegistry registry)
- {
- this.registry = registry;
- }
-
- public String getContentType()
- {
- return contentType;
- }
-
- public void setContentType(String contentType)
- {
- this.contentType = contentType;
- }
-
- protected void startService() throws Exception
- {
- registeredContentType = ContentType.create(contentType);
- registry.registerEditor(registeredContentType, this);
- }
-
- protected void stopService() throws Exception
- {
- registry.unregisterEditor(registeredContentType);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractFaceletContentEditor.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractFaceletContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/AbstractFaceletContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,70 +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.core.admin.ui.content;
-
-import java.net.URL;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class AbstractFaceletContentEditor extends AbstractContentEditor implements FaceletContentEditor
-{
-
- /** . */
- private String faceletPath;
-
- /** . */
- private URL faceletURL;
-
- public String getFaceletPath()
- {
- return faceletPath;
- }
-
- public void setFaceletPath(String faceletPath)
- {
- this.faceletPath = faceletPath;
- }
-
- protected void startService() throws Exception
- {
- faceletURL = Thread.currentThread().getContextClassLoader().getResource(faceletPath);
-
- //
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
- super.stopService();
-
- //
- faceletURL = null;
- }
-
- public URL getFaceletURL()
- {
- return faceletURL;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditor.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,31 +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.core.admin.ui.content;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentEditor
-{
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistry.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistry.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistry.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,39 +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.core.admin.ui.content;
-
-import org.jboss.portal.core.model.content.ContentType;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentEditorRegistry
-{
- Set getContentTypes();
- void registerEditor(ContentType contentType, ContentEditor editor);
- void unregisterEditor(ContentType contentType);
- ContentEditor getEditor(ContentType contentType);
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryBean.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryBean.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,122 +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.core.admin.ui.content;
-
-import org.jboss.portal.faces.el.dynamic.AbstractDynamicBean;
-import org.jboss.portal.faces.el.PropertyValue;
-import org.jboss.portal.core.model.content.ContentType;
-
-import javax.faces.model.SelectItem;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditorRegistryBean
-{
-
- /** . */
- private ContentEditorRegistry registry;
-
- /** . */
- private AbstractDynamicBean editors;
-
- /** . */
- private String selectedType;
-
- public ContentEditorRegistryBean()
- {
- selectedType = "portlet";
- editors = new AbstractDynamicBean()
- {
- public Class getType(Object propertyName)
- {
- ContentEditor editor = getEditor(propertyName);
- if (editor != null)
- {
- return editor.getClass();
- }
- return null;
- }
- public PropertyValue getValue(Object propertyName)
- {
- ContentEditor editor = getEditor(propertyName);
- return editor != null ? new PropertyValue(editor) : null;
- }
- };
- }
-
- private ContentEditor getEditor(Object propertyName)
- {
- if (propertyName instanceof String)
- {
- ContentType ct = ContentType.create((String)propertyName);
- return registry.getEditor(ct);
- }
- return null;
- }
-
- public List getAvailableTypes()
- {
- Set types = registry.getContentTypes();
- List items = new ArrayList(types.size());
- for (Iterator i = types.iterator();i.hasNext();)
- {
- ContentType def = (ContentType)i.next();
- SelectItem item = new SelectItem();
- item.setValue(def.toString());
- item.setLabel(def.toString());
- items.add(item);
- }
- return items;
- }
-
- public String getSelectedType()
- {
- return selectedType;
- }
-
- public void setSelectedType(String selectedType)
- {
- this.selectedType = selectedType;
- }
-
- public ContentEditorRegistry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry(ContentEditorRegistry registry)
- {
- this.registry = registry;
- }
-
- public AbstractDynamicBean getEditors()
- {
- return editors;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryService.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryService.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorRegistryService.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,65 +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.core.admin.ui.content;
-
-import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditorRegistryService extends AbstractJBossService implements ContentEditorRegistry
-{
-
- /** . */
- private final CopyOnWriteRegistry registry;
-
- public ContentEditorRegistryService()
- {
- registry = new CopyOnWriteRegistry();
- }
-
- public Set getContentTypes()
- {
- return registry.getKeys();
- }
-
- public void registerEditor(ContentType contentType, ContentEditor editor)
- {
- registry.register(contentType, editor);
- }
-
- public void unregisterEditor(ContentType contentType)
- {
- registry.unregister(contentType);
- }
-
- public ContentEditor getEditor(ContentType contentType)
- {
- return (ContentEditor)registry.getRegistration(contentType);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorTagHandler.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorTagHandler.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditorTagHandler.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,136 +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.core.admin.ui.content;
-
-import com.sun.facelets.tag.TagHandler;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.FacesException;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.el.ExpressionFactory;
-import javax.el.VariableMapper;
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.portal.core.model.content.ContentType;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditorTagHandler extends TagHandler
-{
-
- /** . */
- private ContentEditorRegistry registry;
-
- /** . */
- private final TagAttribute contentType;
-
- /** . */
- private final TagAttribute contentURI;
-
- /** . */
- private final TagAttribute submitFunction;
-
- public ContentEditorTagHandler(TagConfig tagConfig)
- {
- super(tagConfig);
-
- //
- this.contentURI = this.getRequiredAttribute("contentURI");
- this.contentType = this.getRequiredAttribute("contentType");
- this.submitFunction = this.getRequiredAttribute("submitFunction");
- }
-
- public static String getContentURI()
- {
- return null;
- }
-
- public ContentEditorRegistry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry(ContentEditorRegistry registry)
- {
- this.registry = registry;
- }
-
- public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException
- {
- ExpressionFactory f = ctx.getExpressionFactory();
-
- ValueExpression ve = f.createValueExpression(ctx, "#{applicationScope.ContentEditorRegistry}", ContentEditorRegistry.class);
- ContentEditorRegistry registry = (ContentEditorRegistry)ve.getValue(ctx);
-
- // Get content type value
- ValueExpression contentTypeValue = contentType.getValueExpression(ctx, Object.class);
- ContentType contentType = (ContentType)contentTypeValue.getValue(ctx);
-
- // Get editor
- FaceletContentEditor editor = null;
- if (contentType != null)
- {
- editor = (FaceletContentEditor)registry.getEditor(contentType);
- }
-
- // Only perform inclusion if content type is not null
- if (editor != null)
- {
- // Get editor URL
- URL url = editor.getFaceletURL();
-
- //
- VariableMapper variableMapper = ctx.getVariableMapper();
- ValueExpression previousContentURIVE = variableMapper.resolveVariable(contentURI.getLocalName());
-
- // Do the include stuff
- try
- {
- nextHandler.apply(ctx, null);
-
- //
- ValueExpression contentURIVE = contentURI.getValueExpression(ctx, Object.class);
- variableMapper.setVariable(contentURI.getLocalName(), contentURIVE);
-
- //
- ValueExpression submitFunctionVE = submitFunction.getValueExpression(ctx, Object.class);
- variableMapper.setVariable(submitFunction.getLocalName(), submitFunctionVE);
-
- //
- ctx.includeFacelet(parent, url);
- }
- finally
- {
- variableMapper.setVariable(contentURI.getLocalName(), previousContentURIVE);
- }
- }
- }
-}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -25,6 +25,8 @@
import org.jboss.portal.common.util.CopyOnWriteRegistry;
import org.jboss.portal.core.model.content.ContentType;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -57,4 +59,9 @@
{
return (String)editors.getRegistration(contentType);
}
+
+ public Collection getContentTypes()
+ {
+ return editors.getKeys();
+ }
}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/FaceletContentEditor.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/FaceletContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/FaceletContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,34 +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.core.admin.ui.content;
-
-import java.net.URL;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface FaceletContentEditor extends ContentEditor
-{
- URL getFaceletURL();
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/PortletContentEditor.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/PortletContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/PortletContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,138 +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.core.admin.ui.content;
-
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.core.model.instance.Instance;
-
-import javax.faces.model.SelectItem;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletContentEditor extends AbstractFaceletContentEditor
-{
-
- /** . */
- private InstanceContainer instanceContainer;
-
- public InstanceContainer getInstanceContainer()
- {
- return instanceContainer;
- }
-
- public void setInstanceContainer(InstanceContainer instanceContainer)
- {
- this.instanceContainer = instanceContainer;
- }
-
- public List getInstanceItems()
- {
- Collection definitions = instanceContainer.getDefinitions();
- List items = new ArrayList(definitions.size());
- for (Iterator i = definitions.iterator();i.hasNext();)
- {
- InstanceDefinition def = (InstanceDefinition)i.next();
- SelectItem item = new SelectItem();
- item.setValue(def.getId());
- item.setDescription("blah");
- item.setLabel(def.getId());
- items.add(item);
- }
- return items;
- }
-
- public Map getInstanceMap()
- {
- Collection definitions = instanceContainer.getDefinitions();
- Map map = new HashMap(definitions.size());
- for (Iterator i = definitions.iterator();i.hasNext();)
- {
- InstanceDefinition def = (InstanceDefinition)i.next();
- map.put(def.getId(), def);
- }
- return map;
- }
-
- public Instance getSelectedInstance()
- {
- try
- {
-// Class clazz = Thread.currentThread().getContextClassLoader().loadClass("com.sun.el.ExpressionFactoryImpl");
-// ExpressionFactory factory = (ExpressionFactory)clazz.newInstance();
-// ELContext ctx = ELAdaptor.getELContext(FacesContext.getCurrentInstance());
-//
-// ValueExpression ve = ctx.getVariableMapper().resolveVariable("contentURI");
-// System.out.println("ve = " + ve);
-// Object o = ve.getValue(ctx);
-// System.out.println("o = " + o);
-// System.out.println("o = " + o);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
-// FacesContext ctx = FacesContext.getCurrentInstance();
-// Application app = ctx.getApplication();
-// ValueBinding vb = app.createValueBinding("#{contentURI}");
-// String contentURI = (String)vb.getValue(ctx);
-//// System.out.println("vb.getExpressionString() = " + vb.getExpressionString());
-//// System.out.println("vb.getExpressionString() = " + vb.getExpressionString());
-//// System.out.println("vb.getExpressionString() = " + vb.getExpressionString());
-// System.out.println("contentURI = " + contentURI);
-// System.out.println("contentURI = " + contentURI);
-// System.out.println("contentURI = " + contentURI);
-
-
- return null;
- }
-
-// public List getKeywords()
-// {
-// Collection definitions = instanceContainer.getDefinitions();
-// List items = new ArrayList(definitions.size());
-// for (Iterator i = definitions.iterator();i.hasNext();)
-// {
-// InstanceDefinition def = (InstanceDefinition)i.next();
-// Portlet portlet = def.getPortlet();
-// PortletInfo info = portlet.getInfo();
-// MetaInfo meta = info.getMeta();
-// meta.getMetaValue(MetaInfo.KEYWORDS);
-// SelectItem item = new SelectItem();
-// item.setValue(def.getId());
-// item.setDescription("blah");
-// item.setLabel(def.getId());
-// items.add(item);
-// }
-// return items;
-// }
-}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -28,7 +28,6 @@
import org.jboss.portal.core.admin.ui.content.ContentEditors;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.MetaInfo;
import javax.portlet.GenericPortlet;
@@ -83,6 +82,7 @@
//
PortletURL actionURL = resp.createActionURL();
+ actionURL.setParameter("meta_action", "select");
//
resp.setContentType("text/html");
Modified: trunk/core-admin/src/resources/portal-admin-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-sar/META-INF/jboss-service.xml 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/resources/portal-admin-sar/META-INF/jboss-service.xml 2007-03-06 22:21:42 UTC (rev 6566)
@@ -22,31 +22,4 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<server>
-
- <!-- -->
- <mbean
- code="org.jboss.portal.core.admin.ui.content.ContentEditorRegistryService"
- name="portal:service=ContentEditorRegistry2"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean>
-
- <!-- -->
- <mbean
- code="org.jboss.portal.core.admin.ui.content.PortletContentEditor"
- name="portal:service=ContentEditor,type=portlet2"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- <attribute name="ContentType">portlet</attribute>
- <attribute name="FaceletPath">content/editor.xhtml</attribute>
- <depends
- optional-attribute-name="Registry"
- proxy-type="attribute">portal:service=ContentEditorRegistry2</depends>
- <depends
- optional-attribute-name="InstanceContainer"
- proxy-type="attribute">portal:container=Instance</depends>
- </mbean>
-
</server>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-06 22:21:42 UTC (rev 6566)
@@ -190,17 +190,6 @@
</managed-property>
</managed-bean>
- <!-- The content editor registry bean -->
- <managed-bean>
- <managed-bean-name>registry</managed-bean-name>
- <managed-bean-class>org.jboss.portal.core.admin.ui.content.ContentEditorRegistryBean</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- <managed-property>
- <property-name>registry</property-name>
- <value>#{applicationScope.ContentEditorRegistry}</value>
- </managed-property>
- </managed-bean>
-
<navigation-rule>
<navigation-case>
<from-outcome>objects</from-outcome>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-06 22:21:42 UTC (rev 6566)
@@ -97,9 +97,4 @@
<service-class>org.jboss.portal.portlet.federation.FederatingPortletInvoker</service-class>
<service-ref>:service=PortletInvoker,type=Federating</service-ref>
</service>
- <service>
- <service-name>ContentEditorRegistry</service-name>
- <service-class>org.jboss.portal.core.admin.ui.content.ContentEditorRegistry</service-class>
- <service-ref>:service=ContentEditorRegistry2</service-ref>
- </service>
</portlet-app>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 22:21:42 UTC (rev 6566)
@@ -82,7 +82,7 @@
id="instanceId"
value="#{portalobjectmgr.selectedContentType}"
styleClass="portlet-form-field contentType">
- <f:selectItems value="#{registry.availableTypes}"/>
+ <f:selectItems value="#{portalobjectmgr.availableContentTypes}"/>
</h:selectOneMenu>
<h:commandButton value="Update" styleClass="portlet-form-button"/>
<h:message for="instanceId" errorClass="portlet-msg-error"/>
Deleted: trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSFaceletContentEditor.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1,72 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.core.cms.content;
-
-import org.jboss.portal.cms.CMS;
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.model.File;
-import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.core.admin.ui.content.AbstractFaceletContentEditor;
-
-import javax.faces.model.SelectItem;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CMSFaceletContentEditor extends AbstractFaceletContentEditor
-{
-
- /** . */
- private CMS cms;
-
- public CMS getCMS()
- {
- return cms;
- }
-
- public void setCMS(CMS cms)
- {
- this.cms = cms;
- }
-
- public List getFiles()
- {
- Command listCMD = cms.getCommandFactory().createFolderGetListCommand("/default");
- Folder folder = (Folder)cms.execute(listCMD);
- List files = folder.getFiles();
- List items = new ArrayList(files.size());
- for (int i = 0; i < files.size(); i++)
- {
- File file = (File)files.get(i);
- SelectItem item = new SelectItem();
- item.setValue(file.getBasePath());
- item.setDescription("blah");
- item.setLabel(file.getName());
- items.add(item);
- }
- return items;
- }
-}
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-03-06 22:21:42 UTC (rev 6566)
@@ -1280,13 +1280,6 @@
this.storePermission("manage", path, manageRoles, manageUsers);
}
- /**
- * @param permission
- * @param action
- * @param criteria
- * @param roles
- * @param users
- */
private void storePermission(String action, String path, String[] roles, String[] users) throws Exception
{
Permission permission = new Permission("cms", action);
@@ -1378,10 +1371,6 @@
return userPermissions;
}
- /**
- * @param aReq
- * @return
- */
private boolean isPortletAccessible(PortletRequest portletRequest)
{
try
@@ -1416,10 +1405,6 @@
}
}
- /**
- * @param aReq
- * @return
- */
private boolean isSecurityConsoleAccessible(PortletRequest portletRequest)
{
try
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-06 21:58:35 UTC (rev 6565)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-06 22:21:42 UTC (rev 6566)
@@ -678,22 +678,6 @@
<attribute name="ContentType">cms</attribute>
</mbean>
- <mbean
- code="org.jboss.portal.core.cms.content.CMSFaceletContentEditor"
- name="portal:service=ContentEditor,type=cms2"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- <attribute name="ContentType">cms</attribute>
- <attribute name="FaceletPath">content/editor.xhtml</attribute>
- <depends
- optional-attribute-name="Registry"
- proxy-type="attribute">portal:service=ContentEditorRegistry2</depends>
- <depends
- optional-attribute-name="CMS"
- proxy-type="attribute">portal:service=CMS</depends>
- </mbean>
-
<!-- Content renderer integration -->
<mbean
code="org.jboss.portal.core.cms.content.CMSContentRenderer"
17 years, 4 months