JBoss Portal SVN: r7428 - trunk/faces/src/main/org/jboss/portal/faces/el.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 19:20:26 -0400 (Thu, 14 Jun 2007)
New Revision: 7428
Modified:
trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
Log:
minor javadoc update
Modified: trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2007-06-14 23:17:48 UTC (rev 7427)
+++ trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2007-06-14 23:20:26 UTC (rev 7428)
@@ -31,17 +31,17 @@
/**
* An implementation of <code>DynamicBean</code> which exposes all the fields on a class which are
- * public and static. The properties are read only and cannot be modified.
+ * public and static. The properties are read only and cannot be modified. It allows to use
+ * constant names from expression language rather than the constant values directly.
*
+ * The semantics to obtain values from a class are the same defined by the Java Language Specification.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class ClassConstantPublisherBean implements DynamicBean
{
- /** . */
- private static final int PUBLIC_STATIC_MODS = Modifier.STATIC | Modifier.PUBLIC;
-
/** The class name. */
private String className;
18 years, 10 months
JBoss Portal SVN: r7427 - in trunk/faces: src/main/org/jboss/portal/faces/el and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 19:17:48 -0400 (Thu, 14 Jun 2007)
New Revision: 7427
Added:
trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant1.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant2.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant3.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java
Modified:
trunk/faces/build.xml
trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
Log:
class constant bean test cases
Modified: trunk/faces/build.xml
===================================================================
--- trunk/faces/build.xml 2007-06-14 22:06:47 UTC (rev 7426)
+++ trunk/faces/build.xml 2007-06-14 23:17:48 UTC (rev 7427)
@@ -232,6 +232,7 @@
<test todir="${test.reports}" name="org.jboss.portal.test.faces.el.AbstractDynamicBeanTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.faces.el.SimpleDynamicBeanTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.faces.el.DelegatingPropertyResolverTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.faces.el.ClassConstantPublisherBeanTestCase"/>
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
Modified: trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2007-06-14 22:06:47 UTC (rev 7426)
+++ trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2007-06-14 23:17:48 UTC (rev 7427)
@@ -30,6 +30,9 @@
import java.lang.reflect.Modifier;
/**
+ * An implementation of <code>DynamicBean</code> which exposes all the fields on a class which are
+ * public and static. The properties are read only and cannot be modified.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -37,40 +40,56 @@
{
/** . */
+ private static final int PUBLIC_STATIC_MODS = Modifier.STATIC | Modifier.PUBLIC;
+
+ /** The class name. */
private String className;
- /** . */
+ /** The cached entries. */
private volatile Map entries;
+ private static Map getEntries(Class clazz)
+ {
+ Class superClazz = clazz.getSuperclass();
+ Map entries = clazz.getSuperclass() == null ? new HashMap() : getEntries(superClazz);
+
+ //
+ try
+ {
+ Field[] fields = clazz.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ Field field = fields[i];
+ final int modifiers = field.getModifiers();
+ if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
+ {
+ Object value = field.get(null);
+ entries.put(field.getName(), value);
+ }
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ return entries;
+ }
+
private Map getEntries()
{
if (entries == null)
{
try
{
- Map entries = new HashMap();
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
- Field[] fields = clazz.getFields();
- for (int i = 0; i < fields.length; i++)
- {
- Field field = fields[i];
- int modifiers = field.getModifiers();
- if ((modifiers & Modifier.STATIC | modifiers & Modifier.PUBLIC) != 0)
- {
- Object value = field.get(null);
- entries.put(field.getName(), value);
- }
- }
- this.entries = entries;
+ this.entries = getEntries(clazz);
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
- catch (IllegalAccessException e)
- {
- e.printStackTrace();
- }
}
return entries;
}
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant1.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant1.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant1.java 2007-06-14 23:17:48 UTC (rev 7427)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassConstant1
+{
+
+ private String PRIVATE_1;
+ private final String PRIVATE_FINAL_1 = "";
+ protected String PROTECTED_1;
+ protected final String PROTECTED_FINAL_1 = "";
+ String PACKAGE_PROTECTED_1;
+ final String PACKAGE_PROTECTED_FINAL_1 = "";
+ public String PUBLIC_1;
+ public final String PUBLIC_FINAL_1 = "";
+
+ static private String STATIC_PRIVATE_1;
+ static private final String STATIC_PRIVATE_FINAL_1 = "";
+ static protected String STATIC_PROTECTED_1;
+ static protected final String STATIC_PROTECTED_FINAL_1 = "";
+ static String STATIC_PACKAGE_PROTECTED_1;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_1 = "";
+ static public String STATIC_PUBLIC_1 = "CT1_STATIC_PUBLIC_1_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_1 = "CT1_STATIC_PUBLIC_FINAL_1_VALUE";
+
+ private String PRIVATE_2;
+ private final String PRIVATE_FINAL_2 = "";
+ protected String PROTECTED_2;
+ protected final String PROTECTED_FINAL_2 = "";
+ String PACKAGE_PROTECTED_2;
+ final String PACKAGE_PROTECTED_FINAL_2 = "";
+ public String PUBLIC_2;
+ public final String PUBLIC_FINAL_2 = "";
+
+ static private String STATIC_PRIVATE_2;
+ static private final String STATIC_PRIVATE_FINAL_2 = "";
+ static protected String STATIC_PROTECTED_2;
+ static protected final String STATIC_PROTECTED_FINAL_2 = "";
+ static String STATIC_PACKAGE_PROTECTED_2;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_2 = "";
+ static public String STATIC_PUBLIC_2 = "CT1_STATIC_PUBLIC_2_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_2 = "CT1_STATIC_PUBLIC_FINAL_2_VALUE";
+}
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant2.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant2.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant2.java 2007-06-14 23:17:48 UTC (rev 7427)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassConstant2 extends ClassConstant1
+{
+
+ private String PRIVATE_2;
+ private final String PRIVATE_FINAL_2 = "";
+ protected String PROTECTED_2;
+ protected final String PROTECTED_FINAL_2 = "";
+ String PACKAGE_PROTECTED_2;
+ final String PACKAGE_PROTECTED_FINAL_2 = "";
+ public String PUBLIC_2;
+ public final String PUBLIC_FINAL_2 = "";
+
+ static private String STATIC_PRIVATE_2;
+ static private final String STATIC_PRIVATE_FINAL_2 = "";
+ static protected String STATIC_PROTECTED_2;
+ static protected final String STATIC_PROTECTED_FINAL_2 = "";
+ static String STATIC_PACKAGE_PROTECTED_2;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_2 = "";
+ static public String STATIC_PUBLIC_2 = "CT2_STATIC_PUBLIC_2_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_2 = "CT2_STATIC_PUBLIC_FINAL_2_VALUE";
+
+ private String PRIVATE_3;
+ private final String PRIVATE_FINAL_3 = "";
+ protected String PROTECTED_3;
+ protected final String PROTECTED_FINAL_3 = "";
+ String PACKAGE_PROTECTED_3;
+ final String PACKAGE_PROTECTED_FINAL_3 = "";
+ public String PUBLIC_3;
+ public final String PUBLIC_FINAL_3 = "";
+
+ static private String STATIC_PRIVATE_3;
+ static private final String STATIC_PRIVATE_FINAL_3 = "";
+ static protected String STATIC_PROTECTED_3;
+ static protected final String STATIC_PROTECTED_FINAL_3 = "";
+ static String STATIC_PACKAGE_PROTECTED_3;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_3 = "";
+ static public String STATIC_PUBLIC_3 = "CT2_STATIC_PUBLIC_3_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_3 = "CT2_STATIC_PUBLIC_FINAL_3_VALUE";
+
+}
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant3.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant3.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstant3.java 2007-06-14 23:17:48 UTC (rev 7427)
@@ -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.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassConstant3
+{
+ public static final int INT_0 = 0;
+ public static final int INT_1 = 1;
+ public static final int INT_2 = 2;
+ public static final boolean BOOLEAN_TRUE = true;
+ public static final boolean BOOLEAN_FALSE = false;
+ public static final Integer INTEGER_0 = new Integer(0);
+ public static final Integer INTEGER_1 = new Integer(1);
+ public static final Integer INTEGER_2 = new Integer(2);
+ public static final Boolean BOOLEAN_OBJECT_TRUE = Boolean.TRUE;
+ public static final Boolean BOOLEAN_OBJECT_FALSE = Boolean.FALSE;
+ public static final Object OBJECT = new Object();
+}
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java 2007-06-14 23:17:48 UTC (rev 7427)
@@ -0,0 +1,380 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+import org.jboss.portal.faces.el.ClassConstantPublisherBean;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassConstantPublisherBeanTestCase extends TestCase
+{
+
+ private DynamicBean bean1;
+ private DynamicBean bean2;
+ private DynamicBean bean3;
+
+ protected void setUp() throws Exception
+ {
+ bean1 = new ClassConstantPublisherBean();
+ bean1.setValue("className", ClassConstant1.class.getName());
+ bean2 = new ClassConstantPublisherBean();
+ bean2.setValue("className", ClassConstant2.class.getName());
+ bean3 = new ClassConstantPublisherBean();
+ bean3.setValue("className", ClassConstant3.class.getName());
+ }
+
+ public void testExtendsObject()
+ {
+ assertNull(bean1.getType("PRIVATE_1"));
+ assertNull(bean1.getType("PRIVATE_FINAL_1"));
+ assertNull(bean1.getType("PROTECTED_1"));
+ assertNull(bean1.getType("PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_1"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("PUBLIC_1"));
+ assertNull(bean1.getType("PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean1.getType("STATIC_PRIVATE_1"));
+ assertNull(bean1.getType("STATIC_PRIVATE_FINAL_1"));
+ assertNull(bean1.getType("STATIC_PROTECTED_1"));
+ assertNull(bean1.getType("STATIC_PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_1"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_1"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean1.getValue("PRIVATE_1"));
+ assertNotNull(bean1.getValue("PRIVATE_FINAL_1"));
+ assertNotNull(bean1.getValue("PROTECTED_1"));
+ assertNotNull(bean1.getValue("PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_1"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("PUBLIC_1"));
+ assertNotNull(bean1.getValue("PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_1"));
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_1"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_1"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_1"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean1.getValue("PRIVATE_1").getObject());
+ assertNull(bean1.getValue("PRIVATE_FINAL_1").getObject());
+ assertNull(bean1.getValue("PROTECTED_1").getObject());
+ assertNull(bean1.getValue("PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("PUBLIC_1").getObject());
+ assertNull(bean1.getValue("PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean1.getValue("STATIC_PRIVATE_1").getObject());
+ assertNull(bean1.getValue("STATIC_PRIVATE_FINAL_1").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_1").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_1_VALUE", bean1.getValue("STATIC_PUBLIC_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_1_VALUE", bean1.getValue("STATIC_PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean1.getType("PRIVATE_2"));
+ assertNull(bean1.getType("PRIVATE_FINAL_2"));
+ assertNull(bean1.getType("PROTECTED_2"));
+ assertNull(bean1.getType("PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_2"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("PUBLIC_2"));
+ assertNull(bean1.getType("PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean1.getType("STATIC_PRIVATE_2"));
+ assertNull(bean1.getType("STATIC_PRIVATE_FINAL_2"));
+ assertNull(bean1.getType("STATIC_PROTECTED_2"));
+ assertNull(bean1.getType("STATIC_PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_2"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_2"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean1.getValue("PRIVATE_2"));
+ assertNotNull(bean1.getValue("PRIVATE_FINAL_2"));
+ assertNotNull(bean1.getValue("PROTECTED_2"));
+ assertNotNull(bean1.getValue("PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_2"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("PUBLIC_2"));
+ assertNotNull(bean1.getValue("PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_2"));
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_2"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_2"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_2"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean1.getValue("PRIVATE_2").getObject());
+ assertNull(bean1.getValue("PRIVATE_FINAL_2").getObject());
+ assertNull(bean1.getValue("PROTECTED_2").getObject());
+ assertNull(bean1.getValue("PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("PUBLIC_2").getObject());
+ assertNull(bean1.getValue("PUBLIC_FINAL_2").getObject());
+
+ //
+ assertNull(bean1.getValue("STATIC_PRIVATE_2").getObject());
+ assertNull(bean1.getValue("STATIC_PRIVATE_FINAL_2").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_2").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_2_VALUE", bean1.getValue("STATIC_PUBLIC_2").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_2_VALUE", bean1.getValue("STATIC_PUBLIC_FINAL_2").getObject());
+ }
+
+ public void testExtendsObjectAnotherClass()
+ {
+ assertNull(bean2.getType("PRIVATE_1"));
+ assertNull(bean2.getType("PRIVATE_FINAL_1"));
+ assertNull(bean2.getType("PROTECTED_1"));
+ assertNull(bean2.getType("PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_1"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("PUBLIC_1"));
+ assertNull(bean2.getType("PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_1"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_1"));
+ assertNull(bean2.getType("STATIC_PROTECTED_1"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_1"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_1"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_1"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_1"));
+ assertNotNull(bean2.getValue("PROTECTED_1"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_1"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("PUBLIC_1"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_1"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_1"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_1"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_1"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_1").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_1").getObject());
+ assertNull(bean2.getValue("PROTECTED_1").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("PUBLIC_1").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_1").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_1").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_1").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_1_VALUE", bean2.getValue("STATIC_PUBLIC_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_1_VALUE", bean2.getValue("STATIC_PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean2.getType("PRIVATE_2"));
+ assertNull(bean2.getType("PRIVATE_FINAL_2"));
+ assertNull(bean2.getType("PROTECTED_2"));
+ assertNull(bean2.getType("PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_2"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("PUBLIC_2"));
+ assertNull(bean2.getType("PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_2"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_2"));
+ assertNull(bean2.getType("STATIC_PROTECTED_2"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_2"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_2"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_2"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_2"));
+ assertNotNull(bean2.getValue("PROTECTED_2"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_2"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("PUBLIC_2"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_2"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_2"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_2"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_2"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_2").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_2").getObject());
+ assertNull(bean2.getValue("PROTECTED_2").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("PUBLIC_2").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_2").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_2").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_2").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_2").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_2_VALUE", bean2.getValue("STATIC_PUBLIC_2").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_FINAL_2_VALUE", bean2.getValue("STATIC_PUBLIC_FINAL_2").getObject());
+
+ assertNull(bean2.getType("PRIVATE_3"));
+ assertNull(bean2.getType("PRIVATE_FINAL_3"));
+ assertNull(bean2.getType("PROTECTED_3"));
+ assertNull(bean2.getType("PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_3"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("PUBLIC_3"));
+ assertNull(bean2.getType("PUBLIC_FINAL_3"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_3"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_3"));
+ assertNull(bean2.getType("STATIC_PROTECTED_3"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_3"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_3"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_3"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_3"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_3"));
+ assertNotNull(bean2.getValue("PROTECTED_3"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_3"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("PUBLIC_3"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_3"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_3"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_3"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_3"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_3"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_3"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_3").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_3").getObject());
+ assertNull(bean2.getValue("PROTECTED_3").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_3").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("PUBLIC_3").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_3").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_3").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_3").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_3").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_3").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_3").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_3_VALUE", bean2.getValue("STATIC_PUBLIC_3").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_FINAL_3_VALUE", bean2.getValue("STATIC_PUBLIC_FINAL_3").getObject());
+ }
+
+ public void testValues()
+ {
+ assertNotNull(bean3.getValue("INT_0"));
+ assertNotNull(bean3.getValue("INT_1"));
+ assertNotNull(bean3.getValue("INT_2"));
+ assertNotNull(bean3.getValue("BOOLEAN_TRUE"));
+ assertNotNull(bean3.getValue("BOOLEAN_FALSE"));
+ assertNotNull(bean3.getValue("INTEGER_0"));
+ assertNotNull(bean3.getValue("INTEGER_1"));
+ assertNotNull(bean3.getValue("INTEGER_2"));
+ assertNotNull(bean3.getValue("BOOLEAN_OBJECT_TRUE"));
+ assertNotNull(bean3.getValue("BOOLEAN_OBJECT_FALSE"));
+ assertNotNull(bean3.getValue("OBJECT"));
+
+ //
+ assertEquals(new Integer(0), bean3.getValue("INT_0").getObject());
+ assertEquals(new Integer(1), bean3.getValue("INT_1").getObject());
+ assertEquals(new Integer(2), bean3.getValue("INT_2").getObject());
+ assertEquals(Boolean.TRUE, bean3.getValue("BOOLEAN_TRUE").getObject());
+ assertEquals(Boolean.FALSE, bean3.getValue("BOOLEAN_FALSE").getObject());
+ assertEquals(new Integer(0), bean3.getValue("INTEGER_0").getObject());
+ assertEquals(new Integer(1), bean3.getValue("INTEGER_1").getObject());
+ assertEquals(new Integer(2), bean3.getValue("INTEGER_2").getObject());
+ assertEquals(Boolean.TRUE, bean3.getValue("BOOLEAN_OBJECT_TRUE").getObject());
+ assertEquals(Boolean.FALSE, bean3.getValue("BOOLEAN_OBJECT_FALSE").getObject());
+ assertEquals(ClassConstant3.OBJECT, bean3.getValue("OBJECT").getObject());
+ }
+}
18 years, 10 months
JBoss Portal SVN: r7426 - trunk/faces/src/main/org/jboss/portal/faces/el.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 18:06:47 -0400 (Thu, 14 Jun 2007)
New Revision: 7426
Added:
trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
Log:
implemented a dynamic bean which allow to access class constant fields in EL
Added: trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java (rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2007-06-14 22:06:47 UTC (rev 7426)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * 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.faces.el;
+
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassConstantPublisherBean implements DynamicBean
+{
+
+ /** . */
+ private String className;
+
+ /** . */
+ private volatile Map entries;
+
+ private Map getEntries()
+ {
+ if (entries == null)
+ {
+ try
+ {
+ Map entries = new HashMap();
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ Field[] fields = clazz.getFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ Field field = fields[i];
+ int modifiers = field.getModifiers();
+ if ((modifiers & Modifier.STATIC | modifiers & Modifier.PUBLIC) != 0)
+ {
+ Object value = field.get(null);
+ entries.put(field.getName(), value);
+ }
+ }
+ this.entries = entries;
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return entries;
+ }
+
+ public Class getType(Object propertyName) throws IllegalArgumentException
+ {
+ Map entries = getEntries();
+ Object value = entries.get(propertyName);
+ return value != null ? value.getClass() : null;
+ }
+
+ public PropertyValue getValue(Object propertyName) throws IllegalArgumentException
+ {
+ if ("className".equals(propertyName))
+ {
+ return new PropertyValue(className);
+ }
+
+ //
+ Map entries = getEntries();
+ Object value = entries.get(propertyName);
+ return new PropertyValue(value);
+ }
+
+ public boolean setValue(Object propertyName, Object value) throws IllegalArgumentException
+ {
+ if ("className".equals(propertyName))
+ {
+ this.className = (String)value;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
18 years, 10 months
JBoss Portal SVN: r7425 - in trunk/common/src/main/org/jboss/portal: common/net/file and 3 other directories.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2007-06-14 18:05:20 -0400 (Thu, 14 Jun 2007)
New Revision: 7425
Modified:
trunk/common/src/main/org/jboss/portal/common/jar/JarEntryInfo.java
trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
trunk/common/src/main/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
Log:
- Add and modify tests for URLNavigationTestCase.
- Implement file name based filtering.
- Add option to allow visiting jar root.
Modified: trunk/common/src/main/org/jboss/portal/common/jar/JarEntryInfo.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/jar/JarEntryInfo.java 2007-06-14 21:41:59 UTC (rev 7424)
+++ trunk/common/src/main/org/jboss/portal/common/jar/JarEntryInfo.java 2007-06-14 22:05:20 UTC (rev 7425)
@@ -52,9 +52,12 @@
throw new IllegalArgumentException();
}
- //
String entryName = entry.getName();
ArrayList atoms = new ArrayList();
+
+ //add the root element since this is not actually included in the jar as a entry
+ atoms.add("/");
+
int previous = -1;
while (true)
{
Modified: trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2007-06-14 21:41:59 UTC (rev 7424)
+++ trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2007-06-14 22:05:20 UTC (rev 7425)
@@ -29,6 +29,7 @@
import java.util.Arrays;
import java.net.URL;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.File;
@@ -53,48 +54,55 @@
private void visit(File file, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
{
- String name = file.getName();
- if (file.isDirectory())
+ if (!file.exists())
{
- if (trace)
+ throw new FileNotFoundException();
+ }
+ else
+ {
+ String name = file.getName();
+ if (file.isDirectory())
{
- log.debug("entering directory" + file.getAbsolutePath());
+ if (trace)
+ {
+ log.debug("entering directory" + file.getAbsolutePath());
+ }
+ URL url = file.toURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ File[] childrenFiles = file.listFiles();
+ Arrays.sort(childrenFiles);
+ for (int i = 0; i < childrenFiles.length; i++)
+ {
+ File childFile = childrenFiles[i];
+ visit(childFile, visitor, filter);
+ }
+ visitor.endDir(file.toURL(), name);
+ if (trace)
+ {
+ log.debug("leaving directory" + file.getAbsolutePath());
+ }
+ }
}
- URL url = file.toURL();
- boolean visit = filter == null || filter.acceptDir(url);
- if (visit)
+ else
{
- visitor.startDir(url, name);
- File[] childrenFiles = file.listFiles();
- Arrays.sort(childrenFiles);
- for (int i = 0; i < childrenFiles.length; i++)
+ if (trace)
{
- File childFile = childrenFiles[i];
- visit(childFile, visitor, filter);
+ log.debug("visiting file " + file.getAbsolutePath());
}
- visitor.endDir(file.toURL(), name);
- if (trace)
+ URL url = file.toURL();
+ File file2 = new File(url.getFile());
+ if (file.equals(file2) && filter.acceptFile(url))
{
- log.debug("leaving directory" + file.getAbsolutePath());
+ visitor.file(url, name);
}
+ else if (trace)
+ {
+ log.debug("The file does not respect url format");
+ }
}
}
- else
- {
- if (trace)
- {
- log.debug("visiting file " + file.getAbsolutePath());
- }
- URL url = file.toURL();
- File file2 = new File(url.getFile());
- if (file.equals(file2))
- {
- visitor.file(url, name);
- }
- else if (trace)
- {
- log.debug("The file does not respect url format");
- }
- }
}
}
Modified: trunk/common/src/main/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java 2007-06-14 21:41:59 UTC (rev 7424)
+++ trunk/common/src/main/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java 2007-06-14 22:05:20 UTC (rev 7425)
@@ -65,13 +65,27 @@
JarFile jarFile = conn.getJarFile();
URL jarURL = conn.getJarFileURL();
JarEntry rootEntry = conn.getJarEntry();
-
- //
- if (rootEntry == null)
+
+ // if the URL specifies a directory without a "/" at the end
+ // the entry will be found, except it won't actually exist.
+ // To get around this issue, we need to check if an entry exists
+ // with a "/" at the end.
+ if (rootEntry != null)
{
- throw new NotYetImplemented("The code for exact jar url has not been implemented");
+ JarEntry testDirEntry = conn.getJarFile().getJarEntry(rootEntry + "/");
+ if (testDirEntry != null)
+ {
+ rootEntry = testDirEntry;
+ }
}
-
+ else
+ {
+ // if rootEntry == null then the url points to the root of the jar. The problem
+ // is that the root of the jar doesn't actually exist in the jar.
+ // We need to create a fake jar entry to mimic this behavior
+ rootEntry = new JarEntry("/");
+ }
+
// Get the root entry
JarEntryInfo rootEntryInfo = new JarEntryInfo(rootEntry);
@@ -89,8 +103,15 @@
// Only consider descendant of the root or root itself
if (entryInfo.equals(rootEntryInfo) || entryInfo.isDescendantOf(rootEntryInfo))
{
+ List relPath;
// The relative path from the root
- List relPath = entryInfo.getNames().subList(rootEntryInfo.size() - 1, entryInfo.size());
+ if (rootEntryInfo.size() > 1){
+ relPath = entryInfo.getNames().subList(rootEntryInfo.size() - 1, entryInfo.size());
+ }
+ else
+ {
+ relPath = entryInfo.getNames();
+ }
// Enter intermediate dirs
while (stack.size() < relPath.size() - 1 && enabled)
@@ -145,7 +166,10 @@
String name = (String)relPath.get(relPath.size() - 1);
stack.push(name, false);
URL url = stack.getURL();
- visitor.file(url, name);
+ if (filter.acceptFile(url))
+ {
+ visitor.file(url, name);
+ }
stack.pop();
}
}
Modified: trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java 2007-06-14 21:41:59 UTC (rev 7424)
+++ trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java 2007-06-14 22:05:20 UTC (rev 7425)
@@ -54,31 +54,31 @@
public void testJarEntryInfo()
{
JarEntryInfo info1 = new JarEntryInfo(new JarEntry("a"));
- assertEquals(Arrays.asList(new String[]{"a"}), info1.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info1.getNames());
JarEntryInfo info2 = new JarEntryInfo(new JarEntry("a/"));
- assertEquals(Arrays.asList(new String[]{"a"}), info2.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info2.getNames());
JarEntryInfo info3 = new JarEntryInfo(new JarEntry("/"));
- assertEquals(Arrays.asList(new String[]{}), info3.getNames());
+ assertEquals(Arrays.asList(new String[]{"/"}), info3.getNames());
JarEntryInfo info4 = new JarEntryInfo(new JarEntry("a/b"));
- assertEquals(Arrays.asList(new String[]{"a","b"}), info4.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info4.getNames());
JarEntryInfo info5 = new JarEntryInfo(new JarEntry("a/b/"));
- assertEquals(Arrays.asList(new String[]{"a","b"}), info5.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info5.getNames());
JarEntryInfo info6 = new JarEntryInfo(new JarEntry("/a"));
- assertEquals(Arrays.asList(new String[]{"a"}), info6.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info6.getNames());
JarEntryInfo info7 = new JarEntryInfo(new JarEntry("/a/"));
- assertEquals(Arrays.asList(new String[]{"a"}), info7.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info7.getNames());
JarEntryInfo info8 = new JarEntryInfo(new JarEntry("/a/b"));
- assertEquals(Arrays.asList(new String[]{"a","b"}), info8.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info8.getNames());
JarEntryInfo info9 = new JarEntryInfo(new JarEntry("/a/b/"));
- assertEquals(Arrays.asList(new String[]{"a","b"}), info9.getNames());
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info9.getNames());
}
public void testEntryComparator() throws IOException
Modified: trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2007-06-14 21:41:59 UTC (rev 7424)
+++ trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2007-06-14 22:05:20 UTC (rev 7425)
@@ -25,14 +25,16 @@
import junit.framework.TestCase;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.net.URLNavigator;
import org.jboss.portal.common.net.URLVisitor;
-import org.jboss.portal.common.net.URLNavigator;
-import org.jboss.portal.common.net.URLFilter;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,224 +48,431 @@
super(name);
}
- private List expectedAtoms1;
- private List expectedAtoms2;
- private List expectedAtoms3;
- private List expectedAtoms4;
- private List expectedAtoms5;
- private List expectedAtoms6;
- private List expectedAtoms7;
+ // the name of the jar that contains the tests
+ private final String TEST_JAR_NAME="test.jar";
- private List expectedURLs1;
- private List expectedURLs2;
- private List expectedURLs3;
- private List expectedURLs4;
- private List expectedURLs5;
- private List expectedURLs6;
- private List expectedURLs7;
-
- private List filterValues1;
- private List filterValues2;
- private List filterValues3;
- private List filterValues4;
- private List filterValues5;
- private List filterValues6;
- private List filterValues7;
-
+
+ ArrayList expectedAtomsC1 = new ArrayList();
+ ArrayList expectedAtomsB1 = new ArrayList();
+ ArrayList expectedAtomsA1 = new ArrayList();
+ ArrayList expectedAtomsB1Dash = new ArrayList();
+ ArrayList expectedAtomsD1txt = new ArrayList();
+ ArrayList expectedAtomsC1txt = new ArrayList();
+ ArrayList expectedAtomsB1txt = new ArrayList();
+ ArrayList expectedAtomsB2txt = new ArrayList();
+ ArrayList expectedAtomsA3txt = new ArrayList();
+
+ ArrayList expectedURLsC1 = new ArrayList();
+ ArrayList expectedURLsB1 = new ArrayList();
+ ArrayList expectedURLsA1 = new ArrayList();
+ ArrayList expectedURLsB1Dash = new ArrayList();
+ ArrayList expectedURLsD1txt = new ArrayList();
+ ArrayList expectedURLsC1txt = new ArrayList();
+ ArrayList expectedURLsB1txt = new ArrayList();
+ ArrayList expectedURLsB2txt = new ArrayList();
+ ArrayList expectedURLsA3txt = new ArrayList();
+
+ Filter noFilter;
+ Filter fullFilter;
+ Filter noDirFilter;
+ Filter noFileFilter;
+
protected void setUp() throws Exception
{
- expectedAtoms1 = new ArrayList();
- expectedAtoms1.add("<b1>");
- expectedAtoms1.add("<c1>");
- expectedAtoms1.add("d1.txt");
- expectedAtoms1.add("</c1>");
- expectedAtoms1.add("c1.txt");
- expectedAtoms1.add("</b1>");
- expectedURLs1 = new ArrayList();
- expectedURLs1.add("/a1/b1/");
- expectedURLs1.add("/a1/b1/c1/");
- expectedURLs1.add("/a1/b1/c1/d1.txt");
- expectedURLs1.add("/a1/b1/c1/");
- expectedURLs1.add("/a1/b1/c1.txt");
- expectedURLs1.add("/a1/b1/");
- filterValues1 = new ArrayList();
- filterValues1.add(Boolean.TRUE);
- filterValues1.add(Boolean.TRUE);
+
+ expectedURLsD1txt = new ArrayList();
+ expectedURLsD1txt.add("/a1/b1/c1/d1.txt");
+
+ expectedURLsC1 = new ArrayList();
+ expectedURLsC1.add("/a1/b1/c1/");
+ expectedURLsC1.addAll(expectedURLsD1txt);
+ expectedURLsC1.add("/a1/b1/c1/");
+
+ expectedURLsC1txt = new ArrayList();
+ expectedURLsC1txt.add("/a1/b1/c1.txt");
+
+ expectedURLsB1 = new ArrayList();
+ expectedURLsB1.add("/a1/b1/");
+ expectedURLsB1.addAll(expectedURLsC1);
+ expectedURLsB1.addAll(expectedURLsC1txt);
+ expectedURLsB1.add("/a1/b1/");
+
+ expectedURLsB1Dash = new ArrayList();
+ expectedURLsB1Dash.add("/a1/b1-/");
+ expectedURLsB1Dash.add("/a1/b1-/");
+
+ expectedURLsB1txt = new ArrayList();
+ expectedURLsB1txt.add("/a1/b1.txt");
+
+ expectedURLsB2txt = new ArrayList();
+ expectedURLsB2txt.add("/a1/b2.txt");
+
+ expectedURLsA1 = new ArrayList();
+ expectedURLsA1.add("/a1/");
+ expectedURLsA1.addAll(expectedURLsB1);
+ expectedURLsA1.addAll(expectedURLsB1Dash);
+ expectedURLsA1.addAll(expectedURLsB1txt);
+ expectedURLsA1.addAll(expectedURLsB2txt);
+ expectedURLsA1.add("/a1/");
+
+ expectedURLsA3txt = new ArrayList();
+ expectedURLsA3txt.add("a3.txt");
+
+ expectedAtomsD1txt = new ArrayList();
+ expectedAtomsD1txt.add("d1.txt");
+
+ expectedAtomsC1 = new ArrayList();
+ expectedAtomsC1.add("<c1>");
+ expectedAtomsC1.addAll(expectedAtomsD1txt);
+ expectedAtomsC1.add("</c1>");
+
+ expectedAtomsC1txt = new ArrayList();
+ expectedAtomsC1txt.add("c1.txt");
+
+ expectedAtomsB1 = new ArrayList();
+ expectedAtomsB1.add("<b1>");
+ expectedAtomsB1.addAll(expectedAtomsC1);
+ expectedAtomsB1.addAll(expectedAtomsC1txt);
+ expectedAtomsB1.add("</b1>");
+
+ expectedAtomsB1Dash = new ArrayList();
+ expectedAtomsB1Dash.add("<b1->");
+ expectedAtomsB1Dash.add("</b1->");
+
+ expectedAtomsB1txt = new ArrayList();
+ expectedAtomsB1txt.add("b1.txt");
+
+ expectedAtomsB2txt = new ArrayList();
+ expectedAtomsB2txt.add("b2.txt");
+
+ expectedAtomsA1 = new ArrayList();
+ expectedAtomsA1.add("<a1>");
+ expectedAtomsA1.addAll(expectedAtomsB1);
+ expectedAtomsA1.addAll(expectedAtomsB1Dash);
+ expectedAtomsA1.addAll(expectedAtomsB1txt);
+ expectedAtomsA1.addAll(expectedAtomsB2txt);
+ expectedAtomsA1.add("</a1>");
+
+ expectedAtomsA3txt = new ArrayList();
+ expectedAtomsA3txt.add("a3.txt");
+
+ noFilter = new Filter(true, true);
+ fullFilter = new Filter(false, false);
+ noDirFilter = new Filter(true, false);
+ noFileFilter = new Filter(false, true);
+ }
- //
- expectedAtoms2 = new ArrayList();
- expectedAtoms2.add("<a1>");
- expectedAtoms2.add("<b1>");
- expectedAtoms2.add("<c1>");
- expectedAtoms2.add("d1.txt");
- expectedAtoms2.add("</c1>");
- expectedAtoms2.add("c1.txt");
- expectedAtoms2.add("</b1>");
- expectedAtoms2.add("<b1->");
- expectedAtoms2.add("</b1->");
- expectedAtoms2.add("b1.txt");
- expectedAtoms2.add("b2.txt");
- expectedAtoms2.add("</a1>");
- expectedURLs2 = new ArrayList();
- expectedURLs2.add("/a1/");
- expectedURLs2.add("/a1/b1/");
- expectedURLs2.add("/a1/b1/c1/");
- expectedURLs2.add("/a1/b1/c1/d1.txt");
- expectedURLs2.add("/a1/b1/c1/");
- expectedURLs2.add("/a1/b1/c1.txt");
- expectedURLs2.add("/a1/b1/");
- expectedURLs2.add("/a1/b1-/");
- expectedURLs2.add("/a1/b1-/");
- expectedURLs2.add("/a1/b1.txt");
- expectedURLs2.add("/a1/b2.txt");
- expectedURLs2.add("/a1/");
- filterValues2 = new ArrayList();
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
+ protected void tearDown() throws Exception
+ {
+ }
- //
- expectedAtoms3 = new ArrayList();
- expectedAtoms3.add("d1.txt");
- expectedURLs3 = new ArrayList();
- expectedURLs3.add("/a1/b1/c1/d1.txt");
- filterValues3 = new ArrayList();
+
+//// Root tests
+
+ public void testRootWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test/test-jar/");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("<test-jar>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ expectedAtoms.add("</test-jar>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("/test-jar/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ //expectedURLs.add("a3.txt");
+ expectedURLs.add("/test-jar/");
+
+ doTest (fileURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (fileURL, expectedAtoms, expectedURLs, null);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ //since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ }
- //
- expectedAtoms4 = new ArrayList();
- expectedAtoms4.add("<b1>");
- expectedAtoms4.add("c1.txt");
- expectedAtoms4.add("</b1>");
- expectedURLs4 = new ArrayList();
- expectedURLs4.add("/a1/b1/");
- expectedURLs4.add("/a1/b1/c1.txt");
- expectedURLs4.add("/a1/b1/");
- filterValues4 = new ArrayList();
- filterValues4.add(Boolean.TRUE);
- filterValues4.add(Boolean.FALSE);
+ public void testRootWithJar() throws Exception
+ {
+ URL jarURL = getJarURL ("/");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("</>");
+ expectedAtoms.add("<META-INF>");
+ expectedAtoms.add("MANIFEST.MF");
+ expectedAtoms.add("</META-INF>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ expectedAtoms.add("<//>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("/");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.add("/META-INF/MANIFEST.MF");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("/");
+
+ doTest (jarURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), noDirFilter);
+
+ }
+
+//// Directory Test
+
+ public void testDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test/test-jar/a1/");
+ doDirectoryTest(fileURL);
+ }
+
+ public void testDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/");
+ doDirectoryTest(jarURL);
+ }
- //
- expectedAtoms5 = new ArrayList();
- expectedURLs5 = new ArrayList();
- filterValues5 = new ArrayList();
- filterValues5.add(Boolean.FALSE);
-
- //
- expectedAtoms6 = new ArrayList();
- expectedAtoms6.add("<a1>");
- expectedAtoms6.add("<b1>");
- expectedAtoms6.add("c1.txt");
- expectedAtoms6.add("</b1>");
- expectedAtoms6.add("<b1->");
- expectedAtoms6.add("</b1->");
- expectedAtoms6.add("b1.txt");
- expectedAtoms6.add("b2.txt");
- expectedAtoms6.add("</a1>");
- expectedURLs6 = new ArrayList();
- expectedURLs6.add("/a1/");
- expectedURLs6.add("/a1/b1/");
- expectedURLs6.add("/a1/b1/c1.txt");
- expectedURLs6.add("/a1/b1/");
- expectedURLs6.add("/a1/b1-/");
- expectedURLs6.add("/a1/b1-/");
- expectedURLs6.add("/a1/b1.txt");
- expectedURLs6.add("/a1/b2.txt");
- expectedURLs6.add("/a1/");
- filterValues6 = new ArrayList();
- filterValues6.add(Boolean.TRUE);
- filterValues6.add(Boolean.TRUE);
- filterValues6.add(Boolean.FALSE);
- filterValues6.add(Boolean.TRUE);
-
- //
- expectedAtoms7 = new ArrayList();
- expectedAtoms7.add("<a1>");
- expectedAtoms7.add("<b1->");
- expectedAtoms7.add("</b1->");
- expectedAtoms7.add("b1.txt");
- expectedAtoms7.add("b2.txt");
- expectedAtoms7.add("</a1>");
- expectedURLs7 = new ArrayList();
- expectedURLs7.add("/a1/");
- expectedURLs7.add("/a1/b1-/");
- expectedURLs7.add("/a1/b1-/");
- expectedURLs7.add("/a1/b1.txt");
- expectedURLs7.add("/a1/b2.txt");
- expectedURLs7.add("/a1/");
- filterValues7 = new ArrayList();
- filterValues7.add(Boolean.TRUE);
- filterValues7.add(Boolean.FALSE);
- filterValues7.add(Boolean.TRUE);
+ private void doDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (url, expectedAtomsA1, expectedURLsA1, new Filter());
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //a1
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.TRUE); //c1
+ dirSeq.add(Boolean.FALSE); //b1-
+
+ List fileSeq = new ArrayList();
+ fileSeq.add(Boolean.TRUE); //d1.txt
+ fileSeq.add(Boolean.FALSE); //c1.txt
+ fileSeq.add(Boolean.FALSE); //b1.txt
+ fileSeq.add(Boolean.FALSE); //b2.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<a1>");
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.add("<c1>");
+ expectedMixAtoms.add("d1.txt");
+ expectedMixAtoms.add("</c1>");
+ expectedMixAtoms.add("</b1>");
+ expectedMixAtoms.add("</a1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/c1/d1.txt");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
}
+
+//// SubDirectory Test
- protected void tearDown() throws Exception
+ public void testSubDirectoryWithFile() throws Exception
{
+ URL fileURL = getFileURL ("test/test-jar/a1/b1");
+ doSubDirectoryTest(fileURL);
}
+
+ public void testSubDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/");
+ doSubDirectoryTest(jarURL);
+ }
+
+ private void doSubDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1, expectedURLsB1, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsB1), removeFiles(expectedURLsB1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.FALSE); //c1
+
+ List fileSeq = new ArrayList();
+ fileSeq.add (Boolean.TRUE); //c1.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.addAll(expectedAtomsC1txt);
+ expectedMixAtoms.add("</b1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1.txt");
+ expectedMixURLs.add("/a1/b1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+/// SingleFileTest
+
+ public void testSingleFileWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test/test-jar/a1/b1/c1/d1.txt");
+ doSingleFileTest(fileURL);
+ }
+
+ public void testSingleFileWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/c1/d1.txt");
+ doSingleFileTest(jarURL);
+ }
- public void testJar() throws Exception
+ private void doSingleFileTest(URL url) throws Exception
{
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsD1txt), removeFiles(expectedAtomsD1txt), noFileFilter);
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noDirFilter);
+ }
+
+//// Empty Directory Test
+
+ public void testEmptyDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test/test-jar/a1/b1-");
+ doEmptyDirectoryTest(fileURL);
+ }
+
+ public void testEmptyDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1-/");
+ doEmptyDirectoryTest(jarURL);
+ }
+
+ private void doEmptyDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFileFilter);
+ doTest (url, new ArrayList(), new ArrayList(), noDirFilter);
+ }
+
+////
+
+ public void testJarURLs() throws Exception
+ {
+ //Note no / at the end
+ URL jarURL = getJarURL("/a1");
+
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ jarURL = getJarURL("/foobar/");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid jar url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+ public void testFileURLs() throws Exception
+ {
+ //Note no / at the end
+ URL fileURL = getFileURL("test/test-jar/a1");
+
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ fileURL = new URL("file:foobar");
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid file url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+
+/*----------Utility Metods and Classes ---------------*/
+
+ private URL getFileURL (String name) throws MalformedURLException
+ {
+ String resourcePath = System.getProperty("build.resources");
+ File resourcesDir = new File(resourcePath);
+ assertTrue(resourcesDir.exists());
+ assertTrue(resourcesDir.isDirectory());
+
+ File file = new File (resourcesDir, name);
+ assertTrue (file.exists());
+ return file.toURL();
+ }
+
+ private URL getJarURL (String name) throws MalformedURLException
+ {
String libPath = System.getProperty("build.lib");
assertNotNull(libPath);
File libDir = new File(libPath);
assertTrue(libDir.exists());
assertTrue(libDir.isDirectory());
- File jarFile = new File(libDir, "test.jar");
+ File jarFile = new File(libDir, TEST_JAR_NAME);
assertTrue(jarFile.exists());
jarFile.deleteOnExit();
assertFalse(jarFile.isDirectory());
-
- //
- URL jarURL1 = new URL("jar", "", jarFile.toURL() + "!" + "/a1/b1/");
- doTest(jarURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
- doTest(jarURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
- doTest(jarURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
-
- //
- URL jarURL2 = new URL("jar", "", jarFile.toURL() + "!" + "/a1/");
- doTest(jarURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
- doTest(jarURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
- doTest(jarURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
-
- //
- URL jarURL3 = new URL("jar", "", jarFile.toURL() + "!" + "/a1/b1/c1/d1.txt");
- doTest(jarURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
+ URL jarURL = new URL("jar", "", jarFile.toURL() + "!" + name);
+ return jarURL;
}
+
+ public List removeFiles(ArrayList list){
+ ArrayList newList = (ArrayList)list.clone();
+ ArrayList fileList = new ArrayList();
+
+ Iterator iterator = newList.iterator();
+ while (iterator.hasNext())
+ {
+ String element = (String)(iterator.next());
+ if (element.endsWith(".txt") || element.endsWith(".MF"))
+ {
+ fileList.add(element);
+ }
+ }
- public void testFile() throws Exception
- {
- String resourcePath = System.getProperty("build.resources");
- File resourcesDir = new File(resourcePath);
- assertTrue(resourcesDir.exists());
- assertTrue(resourcesDir.isDirectory());
-
- //
- File f1 = new File(resourcesDir, "test/test-jar/a1/b1/");
- assertTrue(f1.exists());
- assertTrue(f1.isDirectory());
- URL dirURL1 = f1.toURL();
- doTest(dirURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
- doTest(dirURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
- doTest(dirURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
-
- //
- File f2 = new File(resourcesDir, "test/test-jar/a1/");
- assertTrue(f2.exists());
- assertTrue(f2.isDirectory());
- URL dirURL2 = f2.toURL();
- doTest(dirURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
- doTest(dirURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
- doTest(dirURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
-
- //
- File f3 = new File(resourcesDir, "test/test-jar/a1/b1/c1/d1.txt");
- assertTrue(f3.exists());
- assertFalse(f3.isDirectory());
- URL dirURL3 = f3.toURL();
- doTest(dirURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
+ newList.removeAll(fileList);
+
+ return newList;
}
-
- private void doTest(URL url, List expectedAtoms, List expectedURLs, final Iterator filterBehavior) throws Exception
+
+ private void doTest(URL url, List expectedAtoms, List expectedURLs, Filter filter) throws Exception
{
final List atoms = new ArrayList();
final List urls = new ArrayList();
@@ -284,21 +493,12 @@
atoms.add(name);
urls.add(url);
}
- }, new URLFilter()
- {
- public boolean acceptFile(URL url)
- {
- throw new UnsupportedOperationException();
- }
- public boolean acceptDir(URL url)
- {
- return Boolean.TRUE.equals(filterBehavior.next());
- }
- });
+ }, filter);
//
if (urls.size() != expectedURLs.size())
{
+ assertEquals(expectedURLs, urls);
fail("URLs size does not match " + urls.size() + "!=" + expectedURLs.size());
}
@@ -315,8 +515,105 @@
fail("URL " + entryURL + " does not end with the suffix " + suffix + " at index " + i);
}
}
+
+ if (filter != null)
+ {
+ assertTrue("The Sequence never completed", filter.SequenceComplete());
+ }
+ }
- //
- assertFalse(filterBehavior.hasNext());
+ /**
+ * Class used to setup URLFilter behavior for tests
+ * @author Matt Wringe
+ */
+ private static class Filter implements URLFilter
+ {
+ private boolean acceptFile;
+ private boolean acceptDir;
+
+ private List acceptFileSequence = null;
+ private Iterator fileIterator = null;
+
+ private List acceptDirSequence = null;
+ private Iterator dirIterator = null;
+
+ /**
+ * Method used to setup URLFilter behavior
+ * @param acceptFile Always accept files
+ * @param acceptDir Always accept files
+ */
+ public Filter (boolean acceptFile, boolean acceptDir)
+ {
+ this.acceptFile = acceptFile;
+ this.acceptDir = acceptDir;
+ }
+
+ /**
+ * Method to setup URLFilter behavior which by default always accepts
+ * files and directories
+ */
+ public Filter()
+ {
+ this.acceptDir = true;
+ this.acceptFile = true;
+ }
+
+ /**
+ * Set the sequence to accept or reject files
+ * @param acceptFileSequence Sequence for accepting files
+ */
+ public void setAcceptFile (List acceptFileSequence)
+ {
+ this.acceptFileSequence = acceptFileSequence;
+ this.fileIterator = acceptFileSequence.iterator();
+ }
+
+ /**
+ * Set the sequence to accept or reject directories
+ * @param acceptDirSequence Sequence for accepting directories
+ */
+ public void setAcceptDir (List acceptDirSequence)
+ {
+ this.acceptDirSequence = acceptDirSequence;
+ this.dirIterator = acceptDirSequence.iterator();
+ }
+
+ /**
+ * Returns true if the sequence is complete or if no sequence has been setup
+ * @return True if the sequence is complete
+ */
+ public boolean SequenceComplete()
+ {
+ if ((dirIterator == null || !dirIterator.hasNext()) && (fileIterator == null || !fileIterator.hasNext()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean acceptFile(URL url)
+ {
+ if (fileIterator != null)
+ {
+ return ((Boolean)fileIterator.next()).booleanValue();
+ }
+ else
+ {
+ return acceptFile;
+ }
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ if (dirIterator != null)
+ {
+ return ((Boolean)dirIterator.next()).booleanValue();
+ }
+ return acceptDir;
+ }
}
}
+
18 years, 10 months
JBoss Portal SVN: r7424 - in trunk/core-samples/src: resources/portal-samples-war/WEB-INF and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 17:41:59 -0400 (Thu, 14 Jun 2007)
New Revision: 7424
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
Log:
added a sample portlet which perform programmatic form submit triggered by browser events
Added: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java (rev 0)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java 2007-06-14 21:41:59 UTC (rev 7424)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class FormAutoSubmitPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+
+ //
+ PrintWriter writer = resp.getWriter();
+ PortletURL actionURL = resp.createActionURL();
+ String formId = resp.getNamespace() + "_the_form";
+
+ //
+ writer.write("<form id=\"" + formId + "\" action=\"" + actionURL + "\">");
+ writer.write("<select onclick=\"document.getElementById('" + formId + "').submit()\" multiple=\"multiple\">");
+ writer.write("<option>A</option>");
+ writer.write("<option>B</option>");
+ writer.write("<option>C</option>");
+ writer.write("</select>");
+ writer.write("</form>");
+ writer.write("<a href=\"javascript:document.getElementById('" + formId + "').submit()\">submit</a>");
+ }
+}
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-06-14 21:35:25 UTC (rev 7423)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-06-14 21:41:59 UTC (rev 7424)
@@ -305,6 +305,21 @@
<height>0</height>
</window>
</page>
+ <page>
+ <page-name>javascript test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>FormAutoSubmitPortletWindow</window-name>
+ <instance-ref>FormAutoSubmitPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
</page>
</deployment>
<deployment>
@@ -558,6 +573,21 @@
<height>0</height>
</window>
</page>
+ <page>
+ <page-name>javascript test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>FormAutoSubmitPortletWindow</window-name>
+ <instance-ref>FormAutoSubmitPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
</page>
</deployment>
</deployments>
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-06-14 21:35:25 UTC (rev 7423)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-06-14 21:41:59 UTC (rev 7424)
@@ -164,4 +164,10 @@
<portlet-ref>FileUploadPortlet</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>FormAutoSubmitPortletInstance</instance-id>
+ <portlet-ref>FormAutoSubmitPortlet</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-14 21:35:25 UTC (rev 7423)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-14 21:41:59 UTC (rev 7424)
@@ -42,7 +42,7 @@
</portlet-info>
</portlet>
<portlet>
- <description>Simple Portlet</description>
+ <description>Event Portlet</description>
<portlet-name>EventPortlet</portlet-name>
<display-name>Event Portlet</display-name>
<portlet-class>org.jboss.samples.portlet.event.EventPortlet</portlet-class>
@@ -388,6 +388,20 @@
<keywords>sample,test</keywords>
</portlet-info>
</portlet>
+ <portlet>
+ <description>Portlet which performs a programmatic submit of a form</description>
+ <portlet-name>FormAutoSubmitPortlet</portlet-name>
+ <display-name>Form auto submit Portlet</display-name>
+ <portlet-class>org.jboss.portal.core.portlet.test.FormAutoSubmitPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Auto submit</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ </portlet>
<user-attribute>
<name>user.name.nickName</name>
</user-attribute>
18 years, 10 months
JBoss Portal SVN: r7423 - in docs/trunk/referenceGuide/en: modules and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-06-14 17:35:25 -0400 (Thu, 14 Jun 2007)
New Revision: 7423
Added:
docs/trunk/referenceGuide/en/images/wsrp/config_create.png
docs/trunk/referenceGuide/en/images/wsrp/config_created.png
docs/trunk/referenceGuide/en/images/wsrp/config_end.png
docs/trunk/referenceGuide/en/images/wsrp/config_init.png
docs/trunk/referenceGuide/en/images/wsrp/config_refresh.png
docs/trunk/referenceGuide/en/images/wsrp/config_usewsdl.png
Modified:
docs/trunk/referenceGuide/en/modules/wsrp.xml
Log:
- Added documentation on how to use the WSRP configuration portlet to create a Consumer.
Added: docs/trunk/referenceGuide/en/images/wsrp/config_create.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_create.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: docs/trunk/referenceGuide/en/images/wsrp/config_created.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_created.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: docs/trunk/referenceGuide/en/images/wsrp/config_end.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_end.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: docs/trunk/referenceGuide/en/images/wsrp/config_init.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_init.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: docs/trunk/referenceGuide/en/images/wsrp/config_refresh.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_refresh.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: docs/trunk/referenceGuide/en/images/wsrp/config_usewsdl.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/wsrp/config_usewsdl.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: docs/trunk/referenceGuide/en/modules/wsrp.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/wsrp.xml 2007-06-14 21:09:08 UTC (rev 7422)
+++ docs/trunk/referenceGuide/en/modules/wsrp.xml 2007-06-14 21:35:25 UTC (rev 7423)
@@ -264,15 +264,77 @@
<sect3>
<title>Using the configuration portlet</title>
- <para>TODO</para>
+ <para>
+ As of Portal 2.6, a configuration portlet is provided to configure access to remote WSRP Producers
+ grahically. You can access it at <literal>http://{hostname}:{port}/portal/auth/portal/admin/WSRP</literal>
+ or by logging in as a Portal administrator and clicking on the WSRP tab in the Admin portal. If all went
+ well, you should see something similar to this:
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_init.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ This screen presents all the configured producers associated with their status and possible actions on
+ them. A Consumer can be active or inactive. Activating a Consumer means that it is ready to act as a
+ portlet provider. Deactivating it will remove it from the list of available portlet providers. Note also
+ that a Consumer can be marked as requiring refresh meaning that the information held about it might not
+ be up to date and refreshing it from the remote Producer might be a good idea. This can happen for
+ several reasons: the service description for that remote Producer has not been fetched yet, the cached
+ version has expired or modifications have been made to the configuration that could potentially invalidate
+ it, thus requiring re-validation of the information.
+ </para>
+
+ <para>
+ Next, we create a new Consumer which we will call "bea". Type "bea" in the "Create a consumer named:"
+ field then click on "Create consumer":
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_create.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ You should now see a form allowing you to enter/modify the information about the Consumer:
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_created.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ Set the cache expiration value to 120 seconds and check the "Use WSDL?" checkbox. The form should now
+ morph to:
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_usewsdl.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ Enter the WSDL URL for the producer in the text field and press the "Refresh" button. This will retrieve
+ the service description associated with the Producer which WSRP is described by the WSDL file found at
+ the URL you just entered. In our case, querying the service description will allow us to learn that the
+ Producer requires registration and that it expects a value for the registration property named
+ "registration/consumerRole":
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_refresh.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ <note>At this point, there is no automated way to learn about which possible values (if any) are
+ expected by the remote Producer. Please refer to the specific Producer's documentation.</note>
+ Enter "public" as the value for the registration property and press "Refresh" once more. You should now
+ see something similar to:
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/wsrp/config_end.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ The Consumer for the "bea" Producer should now be available as a portlet provider and is ready to be used.
+ </para>
+
</sect3>
<sect3>
<title>Configuring access to a remote portlet</title>
<para>
- Let's now look at the Admin page and the Management portlet. Click on the "Portlets" link at the top to
- manage the portlets. Once this is done, look at the list of available portlet providers. If all went well,
- you should see something similar to this:
+ Let's now look at the Admin page and the Management portlet. Click on the "Portlet definitions" tab at the
+ top. Once this is done, look at the list of available portlet providers. If all went well,
+ you should see something similar to this:
<mediaobject>
<imageobject>
<imagedata fileref="images/wsrp/portlets.png" format="png" align="center" valign="middle"/>
@@ -284,7 +346,7 @@
"local" portlet provider exposes all the portlets deployed in this particular instance of Portal. As
explained above, the "self" provider refers to the default WSRP consumer bundled with Portal that consumes
the portlets exposed by the default WSRP producer. The "bea" provider corresponds to BEA's public producer
- we just configured. Select it and click on "Change portlet provider". You should now see something similar to:
+ we just configured. Select it and click on "Change". You should now see something similar to:
<mediaobject>
<imageobject>
<imagedata fileref="images/wsrp/bea.png" format="png" align="center" valign="middle"/>
18 years, 10 months
JBoss Portal SVN: r7422 - trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-06-14 17:09:08 -0400 (Thu, 14 Jun 2007)
New Revision: 7422
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
Log:
- Made activate call refresh to make sure that the consumer information is valid.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-06-14 21:02:41 UTC (rev 7421)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-06-14 21:09:08 UTC (rev 7422)
@@ -87,7 +87,19 @@
{
if (activate)
{
- registry.activateConsumerWith(selectedId);
+ WSRPConsumer consumer = getSelectedConsumer();
+ if (consumer.isRefreshNeeded())
+ {
+ RefreshResult result = internalRefresh(consumer);
+ if (result != null && !result.hasIssues())
+ {
+ registry.activateConsumerWith(selectedId);
+ }
+ }
+ else
+ {
+ registry.activateConsumerWith(selectedId);
+ }
}
else
{
@@ -197,22 +209,7 @@
{
if (refreshConsumerId() != null)
{
- try
- {
- RefreshResult result = getSelectedConsumer().refresh(true);
- if (result.hasIssues())
- {
- createErrorMessage(result.getStatus());
- }
- else
- {
- createInfoMessage(null, result.getStatus());
- }
- }
- catch (PortletInvokerException e)
- {
- createErrorMessageFrom(e);
- }
+ internalRefresh(getSelectedConsumer());
return configureConsumer();
}
@@ -223,6 +220,28 @@
}
}
+ private RefreshResult internalRefresh(WSRPConsumer consumer)
+ {
+ try
+ {
+ RefreshResult result = consumer.refresh(true);
+ if (result.hasIssues())
+ {
+ createErrorMessage(result.getStatus());
+ }
+ else
+ {
+ createInfoMessage(null, result.getStatus());
+ }
+ return result;
+ }
+ catch (PortletInvokerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
+ }
+
public String listConsumers()
{
setConsumerIdInSession(true);
18 years, 10 months
JBoss Portal SVN: r7421 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 17:02:41 -0400 (Thu, 14 Jun 2007)
New Revision: 7421
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml
Log:
hide unknown region when it is empty in the page layout editor
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml 2007-06-14 20:38:15 UTC (rev 7420)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml 2007-06-14 21:02:41 UTC (rev 7421)
@@ -118,31 +118,33 @@
</tr>
</tbody>
</c:forEach>
- <tbody>
- <tr>
- <td colspan="2" class="portlet-form-field-label"
- style="border-width:0px;border-top:1px dashed #d5d5d5">Unassigned
- windows
- </td>
- </tr>
- <tr>
- <td>
- <div style="margin-top: 1em">
- <h:commandButton value="Delete"
- id="l_unknown" actionListener="#{pageManager.assignWindows}"
- styleClass="portlet-form-button"/>
- </div>
- </td>
- <td>
- <h:selectManyListbox
- value="#{pageManager.assignedWindows['unknown']}"
- size="7" styleClass="windowList portlet-form-field">
- <f:selectItems
- value="#{pageManager.windowItemsMap['unknown']}"/>
- </h:selectManyListbox>
- </td>
- </tr>
- </tbody>
+ <c:if test="#{!(empty pageManager.assignedWindows['unknown'])}">
+ <tbody>
+ <tr>
+ <td colspan="2" class="portlet-form-field-label"
+ style="border-width:0px;border-top:1px dashed #d5d5d5">Unassigned
+ windows
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div style="margin-top: 1em">
+ <h:commandButton value="Delete"
+ id="l_unknown" actionListener="#{pageManager.assignWindows}"
+ styleClass="portlet-form-button"/>
+ </div>
+ </td>
+ <td>
+ <h:selectManyListbox
+ value="#{pageManager.assignedWindows['unknown']}"
+ size="7" styleClass="windowList portlet-form-field">
+ <f:selectItems
+ value="#{pageManager.windowItemsMap['unknown']}"/>
+ </h:selectManyListbox>
+ </td>
+ </tr>
+ </tbody>
+ </c:if>
</table>
</h:form>
</td>
18 years, 10 months
JBoss Portal SVN: r7420 - trunk/core/src/resources/portal-core-war/WEB-INF.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 16:38:15 -0400 (Thu, 14 Jun 2007)
New Revision: 7420
Modified:
trunk/core/src/resources/portal-core-war/WEB-INF/portal-layouts.xml
Log:
remove navigation region from layout metadata so it does not appear in the visual editor and ppl cannot add regions to it by accident.
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/portal-layouts.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/portal-layouts.xml 2007-06-14 20:24:29 UTC (rev 7419)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/portal-layouts.xml 2007-06-14 20:38:15 UTC (rev 7420)
@@ -48,7 +48,6 @@
<regions>
<region name="left"/>
<region name="center"/>
- <region name="navigation"/>
</regions>
</layout>
<layout>
@@ -59,7 +58,6 @@
<region name="left"/>
<region name="center"/>
<region name="right"/>
- <region name="navigation"/>
</regions>
</layout>
</layouts>
18 years, 10 months
JBoss Portal SVN: r7419 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/dashboard.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-06-14 16:24:29 -0400 (Thu, 14 Jun 2007)
New Revision: 7419
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/dashboard/dashboard.xhtml
Log:
auto submit of page selection in the dashboard editor
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/dashboard/dashboard.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/dashboard/dashboard.xhtml 2007-06-14 20:16:25 UTC (rev 7418)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/dashboard/dashboard.xhtml 2007-06-14 20:24:29 UTC (rev 7419)
@@ -48,14 +48,14 @@
</tr>
<tr>
<td class="portlet-section-body" align="center">
- <h:form style="padding:0;margin:0">
+ <h:form id="page_selector_form" style="padding:0;margin:0">
Select: <h:selectOneMenu
id="pageNameSelector"
value="#{dashboard.selectedPageName}"
- styleClass="portlet-form-field">
+ styleClass="portlet-form-field"
+ onclick="document.getElementById('page_selector_form').submit()">
<f:selectItems value="#{dashboard.pageItems}"/>
</h:selectOneMenu>
- <h:commandButton value="Go" styleClass="portlet-form-button"/>
</h:form>
<br/>
</td>
18 years, 10 months