JBoss Portal SVN: r9477 - in modules/identity/trunk: build and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-10 15:37:49 -0500 (Thu, 10 Jan 2008)
New Revision: 9477
Modified:
modules/identity/trunk/build/pom.xml
modules/identity/trunk/identity/pom.xml
modules/identity/trunk/pom.xml
modules/identity/trunk/sso/pom.xml
Log:
normalize artifact ids
Modified: modules/identity/trunk/build/pom.xml
===================================================================
--- modules/identity/trunk/build/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
+++ modules/identity/trunk/build/pom.xml 2008-01-10 20:37:49 UTC (rev 9477)
@@ -17,7 +17,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.identity</groupId>
- <artifactId>jboss-portal-modules-identity</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JBoss Portal Identity</name>
@@ -110,7 +110,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
<version>${version.jboss.portal.common}</version>
</dependency>
<dependency>
Modified: modules/identity/trunk/identity/pom.xml
===================================================================
--- modules/identity/trunk/identity/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
+++ modules/identity/trunk/identity/pom.xml 2008-01-10 20:37:49 UTC (rev 9477)
@@ -2,19 +2,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.identity</groupId>
- <artifactId>jboss-portal-modules-identity</artifactId>
+ <artifactId>module-parent</artifactId>
<relativePath>../build/pom.xml</relativePath>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>portal-identity</artifactId>
+ <artifactId>identity-identity</artifactId>
<packaging>jar</packaging>
<name>JBoss Portal Identity Core</name>
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>apache-tomcat</groupId>
Modified: modules/identity/trunk/pom.xml
===================================================================
--- modules/identity/trunk/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
+++ modules/identity/trunk/pom.xml 2008-01-10 20:37:49 UTC (rev 9477)
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.identity</groupId>
- <artifactId>jboss-portal-modules-identity-aggregator</artifactId>
+ <artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Identity Module</name>
<version>1.1.0-SNAPSHOT</version>
Modified: modules/identity/trunk/sso/pom.xml
===================================================================
--- modules/identity/trunk/sso/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
+++ modules/identity/trunk/sso/pom.xml 2008-01-10 20:37:49 UTC (rev 9477)
@@ -2,19 +2,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.identity</groupId>
- <artifactId>jboss-portal-modules-identity</artifactId>
+ <artifactId>module-parent</artifactId>
<relativePath>../build/pom.xml</relativePath>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>portal-identity-sso</artifactId>
+ <artifactId>identity-sso</artifactId>
<packaging>jar</packaging>
<name>JBoss Portal Identity SSO Integration</name>
<dependencies>
<dependency>
<groupId>org.jboss.portal.identity</groupId>
- <artifactId>portal-identity</artifactId>
+ <artifactId>identity-identity</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
18 years, 3 months
JBoss Portal SVN: r9476 - in modules/web/trunk: build and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-10 15:37:38 -0500 (Thu, 10 Jan 2008)
New Revision: 9476
Modified:
modules/web/trunk/build/pom.xml
modules/web/trunk/pom.xml
modules/web/trunk/web/pom.xml
modules/web/trunk/web/src/test/build.xml
Log:
normalize artifact ids
Modified: modules/web/trunk/build/pom.xml
===================================================================
--- modules/web/trunk/build/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
+++ modules/web/trunk/build/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
@@ -17,7 +17,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.web</groupId>
- <artifactId>jboss-portal-modules-web</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JBoss Portal Test Module</name>
@@ -94,7 +94,7 @@
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
<version>${version.jboss.portal.common}</version>
</dependency>
<dependency>
@@ -120,7 +120,7 @@
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-mc</artifactId>
+ <artifactId>common-mc</artifactId>
<version>${version.jboss.portal.common}</version>
</dependency>
<dependency>
Modified: modules/web/trunk/pom.xml
===================================================================
--- modules/web/trunk/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
+++ modules/web/trunk/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.web</groupId>
- <artifactId>jboss-portal-modules-web-aggregator</artifactId>
+ <artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Web Module</name>
<version>1.2.0-SNAPSHOT</version>
Modified: modules/web/trunk/web/pom.xml
===================================================================
--- modules/web/trunk/web/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
+++ modules/web/trunk/web/pom.xml 2008-01-10 20:37:38 UTC (rev 9476)
@@ -2,12 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.web</groupId>
- <artifactId>jboss-portal-modules-web</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>portal-web</artifactId>
+ <artifactId>web-web</artifactId>
<packaging>jar</packaging>
<name>JBoss Unit</name>
@@ -20,7 +20,7 @@
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>sun-servlet</groupId>
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-mc</artifactId>
+ <artifactId>common-mc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -339,8 +339,8 @@
<property name="dependency.xml-apis.jar" value="${maven.dependency.apache-xerces.xml-apis.jar.path}"/>
<property name="dependency.jbossxb.jar" value="${maven.dependency.jboss.jbossxb.jar.path}"/>
<property name="dependency.jboss-remoting.jar" value="${maven.dependency.jboss.jboss-remoting.jar.path}"/>
- <property name="dependency.portal-common.jar" value="${maven.dependency.org.jboss.portal.common.jboss-portal-modules-common.jar.path}"/>
- <property name="dependency.portal-common-mc.jar" value="${maven.dependency.org.jboss.portal.common.jboss-portal-modules-common-mc.jar.path}"/>
+ <property name="dependency.portal-common.jar" value="${maven.dependency.org.jboss.portal.common.common-common.jar.path}"/>
+ <property name="dependency.portal-common-mc.jar" value="${maven.dependency.org.jboss.portal.common.common-mc.jar.path}"/>
<property name="dependency.jboss-unit.jar" value="${maven.dependency.org.jboss.unit.jboss-unit.jar.path}"/>
<property name="dependency.jboss-unit-mc.jar" value="${maven.dependency.org.jboss.unit.jboss-unit-mc.jar.path}"/>
<property name="dependency.jboss-unit-remote.jar" value="${maven.dependency.org.jboss.unit.jboss-unit-remote.jar.path}"/>
Modified: modules/web/trunk/web/src/test/build.xml
===================================================================
--- modules/web/trunk/web/src/test/build.xml 2008-01-10 20:37:26 UTC (rev 9475)
+++ modules/web/trunk/web/src/test/build.xml 2008-01-10 20:37:38 UTC (rev 9476)
@@ -401,7 +401,7 @@
<path location="${dependency.portal-common.jar}"/>
<path location="${dependency.jboss-unit.jar}"/>
<path location="${dependency.jboss-unit-remote.jar}"/>
- <path location="${target}/portal-web-${project.version}.jar"/>
+ <path location="${target}/web-web-${project.version}.jar"/>
</sharedClasspath>
<configuration>
@@ -514,7 +514,7 @@
<path location="${dependency.activation.jar}"/>
<path location="${dependency.junit.jar}"/>
- <path location="${target}/portal-web-${project.version}.jar"/>
+ <path location="${target}/web-web-${project.version}.jar"/>
</sharedClasspath>
<configuration>
18 years, 3 months
JBoss Portal SVN: r9475 - in modules/test/trunk: remote and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-10 15:37:26 -0500 (Thu, 10 Jan 2008)
New Revision: 9475
Modified:
modules/test/trunk/build/pom.xml
modules/test/trunk/remote/pom.xml
modules/test/trunk/test/agent/pom.xml
modules/test/trunk/test/core/pom.xml
modules/test/trunk/test/generic/pom.xml
modules/test/trunk/test/jboss/pom.xml
modules/test/trunk/test/opends/pom.xml
Log:
normalize artifact ids
Modified: modules/test/trunk/build/pom.xml
===================================================================
--- modules/test/trunk/build/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/build/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -130,7 +130,7 @@
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
<version>${version.portal.common}</version>
</dependency>
Modified: modules/test/trunk/remote/pom.xml
===================================================================
--- modules/test/trunk/remote/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/remote/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -23,7 +23,7 @@
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>apache-httpclient</groupId>
Modified: modules/test/trunk/test/agent/pom.xml
===================================================================
--- modules/test/trunk/test/agent/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/test/agent/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>cargo</groupId>
Modified: modules/test/trunk/test/core/pom.xml
===================================================================
--- modules/test/trunk/test/core/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/test/core/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>cargo</groupId>
Modified: modules/test/trunk/test/generic/pom.xml
===================================================================
--- modules/test/trunk/test/generic/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/test/generic/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>cargo</groupId>
Modified: modules/test/trunk/test/jboss/pom.xml
===================================================================
--- modules/test/trunk/test/jboss/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/test/jboss/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
</dependency>
<dependency>
<groupId>cargo</groupId>
Modified: modules/test/trunk/test/opends/pom.xml
===================================================================
--- modules/test/trunk/test/opends/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
+++ modules/test/trunk/test/opends/pom.xml 2008-01-10 20:37:26 UTC (rev 9475)
@@ -51,7 +51,7 @@
<exclude>jboss:jboss-jmx</exclude>
<exclude>jboss:jboss-backport-concurrent</exclude>
<exclude>jboss:jboss-common-logging-spi</exclude>
- <exclude>org.jboss.portal.common:jboss-portal-modules-common</exclude>
+ <exclude>org.jboss.portal.common:common-common</exclude>
<exclude>junit:junit</exclude>
<exclude>jboss:jboss-remoting</exclude>
<exclude>jboss.jbossas.core-libs:jboss-local-jdbc</exclude>
18 years, 3 months
JBoss Portal SVN: r9474 - in modules/common/trunk: build and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-10 15:37:10 -0500 (Thu, 10 Jan 2008)
New Revision: 9474
Modified:
modules/common/trunk/build/pom.xml
modules/common/trunk/common/pom.xml
modules/common/trunk/mc/pom.xml
modules/common/trunk/pom.xml
modules/common/trunk/portal/pom.xml
Log:
normalize artifact ids
Modified: modules/common/trunk/build/pom.xml
===================================================================
--- modules/common/trunk/build/pom.xml 2008-01-10 17:07:49 UTC (rev 9473)
+++ modules/common/trunk/build/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
@@ -7,7 +7,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-parent</artifactId>
+ <artifactId>module-parent</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Modules Common</name>
<version>1.2.0-SNAPSHOT</version>
Modified: modules/common/trunk/common/pom.xml
===================================================================
--- modules/common/trunk/common/pom.xml 2008-01-10 17:07:49 UTC (rev 9473)
+++ modules/common/trunk/common/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
@@ -2,12 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-parent</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-portal-modules-common</artifactId>
+ <artifactId>common-common</artifactId>
<packaging>jar</packaging>
<name>JBoss Portal Modules Common</name>
@@ -145,4 +145,4 @@
</build>
<properties/>
-</project>
\ No newline at end of file
+</project>
Modified: modules/common/trunk/mc/pom.xml
===================================================================
--- modules/common/trunk/mc/pom.xml 2008-01-10 17:07:49 UTC (rev 9473)
+++ modules/common/trunk/mc/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
@@ -2,12 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-parent</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-portal-modules-common-mc</artifactId>
+ <artifactId>common-mc</artifactId>
<packaging>jar</packaging>
<name>JBoss Portal Modules Common MC</name>
@@ -37,4 +37,4 @@
<properties/>
-</project>
\ No newline at end of file
+</project>
Modified: modules/common/trunk/pom.xml
===================================================================
--- modules/common/trunk/pom.xml 2008-01-10 17:07:49 UTC (rev 9473)
+++ modules/common/trunk/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-aggregator</artifactId>
+ <artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Modules Common (aggregator)</name>
<version>1.2.0-SNAPSHOT</version>
Modified: modules/common/trunk/portal/pom.xml
===================================================================
--- modules/common/trunk/portal/pom.xml 2008-01-10 17:07:49 UTC (rev 9473)
+++ modules/common/trunk/portal/pom.xml 2008-01-10 20:37:10 UTC (rev 9474)
@@ -2,12 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jboss.portal.common</groupId>
- <artifactId>jboss-portal-modules-common-parent</artifactId>
+ <artifactId>module-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-portal-modules-common-portal</artifactId>
+ <artifactId>common-portal</artifactId>
<packaging>jar</packaging>
<name>JBoss Portal Modules Common Portal</name>
18 years, 3 months
JBoss Portal SVN: r9473 - modules/portlet/trunk/test/src/test.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-10 12:07:49 -0500 (Thu, 10 Jan 2008)
New Revision: 9473
Modified:
modules/portlet/trunk/test/src/test/build.xml
Log:
Matt patch for possible cargo failures in hudson
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-10 17:01:20 UTC (rev 9472)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-10 17:07:49 UTC (rev 9473)
@@ -436,7 +436,7 @@
<path location="${dependency.portal-web.jar}"/>
<path location="${dependency.jsr168api.jar}"/>
</sharedClasspath>
- <configuration>
+ <configuration home="${test.jboss-4.2.tempdir}">
<property name="cargo.servlet.port" value="8080"/>
<property name="cargo.logging" value="high"/>
<deployable type="war" file="${test.temp.lib}/jboss-4.2/portlet-test.war"/>
@@ -451,7 +451,7 @@
log="${cargo.log.dir}/cargo.${test.id}.startup.log"
action="stop">
<!--<sysproperty key="java.io.tmpdir" value="${target}/cargo-tmp"/>-->
- <configuration>
+ <configuration home="${test.jboss-4.2.tempdir}">
<property name="cargo.rmi.port" value="1099"/>
</configuration>
</cargo>
@@ -491,12 +491,14 @@
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_0"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_0_HOME}"/>
<param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_0_HOME"/>
+ <param name="test.jboss-4.2.tempdir" value="${target}/cargo-tmp/4_2_0"/>
</antcall>
<antcall target="tests.jboss-4.2.container-servlet">
<param name="test.id" value="JBoss-4_2_1-container-servlet"/>
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_1"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_1_HOME}"/>
<param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_1_HOME"/>
+ <param name="test.jboss-4.2.tempdir" value="${target}/cargo-tmp/4_2_1"/>
</antcall>
</target>
18 years, 3 months
JBoss Portal SVN: r9472 - in modules/portlet/trunk/test: src/main and 12 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-10 12:01:20 -0500 (Thu, 10 Jan 2008)
New Revision: 9472
Added:
modules/portlet/trunk/test/src/main/java/
modules/portlet/trunk/test/src/main/java/org/
modules/portlet/trunk/test/src/main/java/org/jboss/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodec.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodecTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestInstanceContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestPortletInvoker.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/impl/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/CodecBuilder.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java
Removed:
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContext.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodec.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodecTestCase.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestActionContext.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestInstanceContext.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestPortletInvoker.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestRenderContext.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory/
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl/
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/CodecBuilder.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java
Modified:
modules/portlet/trunk/test/pom.xml
modules/portlet/trunk/test/src/test/build.xml
Log:
moving some classes....
Modified: modules/portlet/trunk/test/pom.xml
===================================================================
--- modules/portlet/trunk/test/pom.xml 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/pom.xml 2008-01-10 17:01:20 UTC (rev 9472)
@@ -13,100 +13,74 @@
<dependencies>
+ <dependency>
+ <groupId>org.jboss.portal.portlet</groupId>
+ <artifactId>portlet</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
+
<!--TEST SCOPE-->
<dependency>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>portlet</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>concurrent</groupId>
<artifactId>concurrent</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.portal.common</groupId>
<artifactId>jboss-portal-modules-common-mc</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>javassist</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-remote</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-mc</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-ant</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test</artifactId>
- <scope>test</scope>
- <!--<exclusions>-->
- <!--<exclusion>-->
- <!--<groupId>dom4j</groupId>-->
- <!--<artifactId>dom4j</artifactId>-->
- <!--</exclusion>-->
- <!--</exclusions>-->
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test-generic</artifactId>
- <scope>test</scope>
- <!--<exclusions>-->
- <!--<exclusion>-->
- <!--<groupId>dom4j</groupId>-->
- <!--<artifactId>dom4j</artifactId>-->
- <!--</exclusion>-->
- <!--</exclusions>-->
</dependency>
<dependency>
<groupId>trove</groupId>
<artifactId>trove</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>apache-xerces</groupId>
<artifactId>resolver</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossxb</artifactId>
- <scope>test</scope>
- <!--<exclusions>-->
- <!--<exclusion>-->
- <!--<groupId>sun-jaxb</groupId>-->
- <!--<artifactId>jaxb-api</artifactId>-->
- <!--</exclusion>-->
- <!--</exclusions>-->
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-logging-jdk</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
@@ -115,87 +89,70 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-aop-mc-int</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-classloader</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-container</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-dependency</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-client-spi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-client</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-core-spi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-core</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-impl</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-spi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-structure-spi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-vfs-spi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-deployers-vfs</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-kernel</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-managed</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-metatype</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.aop</groupId>
@@ -205,12 +162,10 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>cargo</groupId>
@@ -222,27 +177,13 @@
<groupId>org.jboss.portal.web</groupId>
<artifactId>portal-web</artifactId>
<type>jar</type>
- <scope>test</scope>
- <!--<exclusions>-->
- <!--<exclusion>-->
- <!--<groupId>apache-xerces</groupId>-->
- <!--<artifactId>xml-apis</artifactId>-->
- <!--</exclusion>-->
- <!--</exclusions>-->
</dependency>
<dependency>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>jsr168api</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.portal.portlet</groupId>
- <artifactId>portlet</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
+
</dependencies>
<build>
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.common.invocation.InterceptorStack;
+import org.jboss.portal.common.invocation.Interceptor;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class InterceptorStackFactoryImpl implements InterceptorStackFactory
+{
+
+ /** . */
+ private volatile Interceptor[] interceptors;
+
+ /** . */
+ private final InterceptorStackImpl stack = new InterceptorStackImpl();
+
+ public Interceptor[] getInterceptors()
+ {
+ return interceptors;
+ }
+
+ public void setInterceptors(Interceptor[] interceptors)
+ {
+ this.interceptors = interceptors;
+ }
+
+ public InterceptorStack getInterceptorStack()
+ {
+ return stack;
+ }
+
+ private class InterceptorStackImpl implements InterceptorStack
+ {
+
+ public int getLength()
+ {
+ // Avoid dirty reads
+ Interceptor[] interceptors = InterceptorStackFactoryImpl.this.interceptors;
+
+ //
+ return interceptors != null ? interceptors.length : 0;
+ }
+
+ public Interceptor getInterceptor(int i) throws ArrayIndexOutOfBoundsException
+ {
+ // Avoid dirty reads
+ Interceptor[] interceptors = InterceptorStackFactoryImpl.this.interceptors;
+
+ //
+ if (interceptors == null)
+ {
+ throw new ArrayIndexOutOfBoundsException("No interceptors");
+ }
+
+ //
+ return interceptors[i];
+ }
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalNavigationalState.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalNavigationalState implements Serializable
+{
+
+ /** . */
+ private final Map windows = new HashMap();
+
+ public WindowNavigationalState getWindow(String windowId)
+ {
+ return (WindowNavigationalState)windows.get(windowId);
+ }
+
+ public void setWindow(String windowId, WindowNavigationalState window)
+ {
+ windows.put(windowId, window);
+ }
+
+ public byte[] getBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream zos = new GZIPOutputStream(baos);
+ ObjectOutputStream oos = new ObjectOutputStream(zos);
+ oos.writeObject(this);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static PortalNavigationalState create(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ GZIPInputStream zis = new GZIPInputStream(bais);
+ ObjectInputStream ois = new ObjectInputStream(zis);
+ return (PortalNavigationalState)ois.readObject();
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalServlet.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalServlet extends HttpServlet
+{
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ try
+ {
+ _service(req, resp);
+ }
+ catch (Exception e)
+ {
+ if (e instanceof ServletException)
+ {
+ throw (ServletException)e;
+ }
+ if (e instanceof IOException)
+ {
+ throw (IOException)e;
+ }
+ if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException)e;
+ }
+ throw new ServletException(e);
+ }
+ }
+
+ protected void _service(HttpServletRequest req, HttpServletResponse resp) throws Exception
+ {
+ PortletControllerContext context = new PortletControllerContextImpl(req, PortletControllerContextImpl.SESSION_SCOPE);
+
+ //
+ PortletController controller = new PortletController(context, getServletContext(), req);
+
+ //
+ controller.process(resp);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,327 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.web.WebAppListener;
+import org.jboss.portal.web.WebAppEvent;
+import org.jboss.portal.web.WebAppLifeCycleEvent;
+import org.jboss.portal.web.WebApp;
+import org.jboss.portal.web.ServletContainer;
+import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_168_NS;
+import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_286_NS;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.ValueTrimmingFilter;
+import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
+import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.PortletApplicationRegistry;
+import org.jboss.portal.portlet.container.PortletApplicationRegistrationContext;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.Kernel;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.apache.log4j.Logger;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.net.URL;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletApplicationDeployer implements WebAppListener, KernelControllerContextAware
+{
+
+ /** The schema resolver factory. */
+ private static SingletonSchemaResolverFactory factory;
+
+ /** The schema resolver. */
+ private static DefaultSchemaResolver resolver;
+
+ static
+ {
+ try
+ {
+ factory = SingletonSchemaResolverFactory.getInstance();
+ resolver = (DefaultSchemaResolver) factory.getSchemaBindingResolver();
+
+ /** SchemaResolver */
+ resolver.addSchemaLocation(PORTLET_JSR_168_NS, "portlet-app_1_0.xsd");
+ resolver.addSchemaLocation(PORTLET_JSR_286_NS, "portlet-app_2_0.xsd");
+ resolver.addClassBinding(PORTLET_JSR_286_NS, AnnotationPortletApplication20MetaData.class);
+ resolver.addClassBinding(PORTLET_JSR_168_NS, AnnotationPortletApplication10MetaData.class);
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ /** . */
+ private Logger log = Logger.getLogger(PortletApplicationDeployer.class);
+
+ /** . */
+ private PortletApplicationRegistry registry;
+
+ /** . */
+ private ServletContainer servletContainer;
+
+ /** . */
+ private KernelControllerContext controllerContext;
+
+ /** . */
+ private Map deploymentMap = new HashMap();
+
+ /** . */
+ private ClassLoader classLoader;
+
+ /** . */
+ private final Map registrationContextMap = new HashMap();
+
+ /** . */
+ private Object driver;
+
+ public Object getDriver()
+ {
+ return driver;
+ }
+
+ public void setDriver(Object driver)
+ {
+ this.driver = driver;
+ }
+
+ public PortletApplicationRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(PortletApplicationRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public ServletContainer getServletContainer()
+ {
+ return servletContainer;
+ }
+
+ public void setServletContainer(ServletContainer servletContainer)
+ {
+ this.servletContainer = servletContainer;
+ }
+
+ public void onEvent(WebAppEvent event)
+ {
+ if (event instanceof WebAppLifeCycleEvent)
+ {
+ WebAppLifeCycleEvent lifeCycleEvent = (WebAppLifeCycleEvent)event;
+ String cp = event.getWebApp().getContextPath();
+ switch(lifeCycleEvent.getType())
+ {
+ case WebAppLifeCycleEvent.ADDED:
+ log.debug("Going to install war file" + cp);
+ add(event.getWebApp());
+ log.debug("Installed war file" + cp);
+ break;
+ case WebAppLifeCycleEvent.REMOVED:
+ try
+ {
+ log.debug("Going to uninstall war file" + cp);
+ remove(event.getWebApp());
+ log.debug("Uninstalled war file" + cp);
+ }
+ catch (Throwable e)
+ {
+ log.error("Uninstalled war file " + cp + " with an error", e);
+ }
+ break;
+ }
+ }
+ }
+
+ private void add(WebApp webApp)
+ {
+ // Set the driver for the web app
+ webApp.getServletContext().setAttribute("TestDriverServer", driver);
+
+ //
+ PortletApplication10MetaData metaData = buildPortletApplicationMetaData(webApp);
+ if (metaData != null)
+ {
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Kernel kernel = controllerContext.getKernel();
+ PortletApplicationDeployment deployment = new PortletApplicationDeployment(kernel, webApp, metaData);
+ deploymentMap.put(webApp.getContextPath(), deployment);
+ deployment.start();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+ }
+
+ private void remove(WebApp webApp)
+ {
+ PortletApplicationDeployment deployment = (PortletApplicationDeployment)deploymentMap.remove(webApp.getContextPath());
+ if (deployment != null)
+ {
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ deployment.stop();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+ }
+
+ public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
+ {
+ log.debug("Set controller context " + controllerContext);
+
+ //
+ this.controllerContext = controllerContext;
+ }
+
+ public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
+ {
+ log.debug("Unset controller context " + controllerContext);
+
+ //
+ this.controllerContext = null;
+ }
+
+ public void start()
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+
+ //
+ servletContainer.addWebAppListener(this);
+ }
+
+ public void stop()
+ {
+ servletContainer.removeWebAppListener(this);
+
+ //
+ classLoader = null;
+ }
+
+ private PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
+ {
+ try
+ {
+ URL url = webApp.getServletContext().getResource("/WEB-INF/portlet.xml");
+ if (url != null)
+ {
+ InputStream in = null;
+ try
+ {
+ in = IOTools.safeBufferedWrapper(url.openStream());
+
+ // Validate
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(false);
+ unmarshaller.setValidation(false);
+
+ //
+ PortletApplicationModelFactory factory = new PortletApplicationModelFactory();
+
+ // Unmarshal
+ PortletApplication10MetaData portletApplicationMD = (PortletApplication10MetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory), null);
+ portletApplicationMD.setId(webApp.getContextPath());
+
+ //
+ return portletApplicationMD;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Cannot read portlet.xml", e);
+ }
+ catch (JBossXBException e)
+ {
+ log.error("Cannot parse portlet.xml", e);
+ }
+ return null;
+ }
+
+ /**
+ * Called by MC to install application.
+ */
+ public void installPortletApplication(PortletApplication application)
+ {
+ PortletApplicationRegistrationContext context = registry.registerPortletApplication(application);
+ registrationContextMap.put(application, context);
+ }
+
+ /**
+ * Called by MC to install container.
+ */
+ public void installPortletContainer(PortletContainer container)
+ {
+ PortletApplicationRegistrationContext context = (PortletApplicationRegistrationContext)registrationContextMap.get(container.getApplication());
+ context.registerPortlet(container);
+ }
+
+ /**
+ * Called by MC to uninstall application.
+ */
+ public void uninstallPortletApplication(PortletApplication application)
+ {
+ registry.unregisterPortletApplication(application);
+ }
+
+ /**
+ * Called by MC to uninstall container.
+ */
+ public void uninstallPortletContainer(PortletContainer container)
+ {
+ PortletApplicationRegistrationContext context = (PortletApplicationRegistrationContext)registrationContextMap.get(container.getApplication());
+ context.unregisterPortlet(container);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,288 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.portlet.container.PortletApplicationContext;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
+import org.jboss.portal.portlet.impl.jsr168.SimpleResourceBundleFactory;
+import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfoBuilder;
+import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
+import org.jboss.portal.web.WebApp;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.plugins.ThisValueMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletApplicationDeployment implements PortletApplicationContext
+{
+
+ /** . */
+ private final Logger log;
+
+ /** . */
+ private final Kernel kernel;
+
+ /** . */
+ private final WebApp webApp;
+
+ /** . */
+ private final PortletApplication10MetaData metaData;
+
+ /** . */
+ private final LinkedList<String> installed;
+
+ /** . */
+ private KernelControllerContext portletApplicationControllerContext;
+
+ /** . */
+ private List<KernelControllerContext> portletContainerControllerContexts = new ArrayList<KernelControllerContext>();
+
+ public PortletApplicationDeployment(Kernel kernel, WebApp webApp, PortletApplication10MetaData metaData)
+ {
+ this.kernel = kernel;
+ this.webApp = webApp;
+ this.metaData = metaData;
+ this.log = Logger.getLogger(PortletApplicationDeployment.class + "." + webApp.getContextPath().replace('.', '_'));
+ this.installed = new LinkedList<String>();
+ }
+
+ void start()
+ {
+
+ log.debug("Starting installation");
+
+ //
+ KernelController controller = kernel.getController();
+
+ //
+ String portletApplicationId = "PortletApplication[" + webApp.getContextPath() + "]";
+
+ //
+ for (PortletMetaData portletMetaData : metaData.getPortlets().values())
+ {
+ // Create resource bundle manager
+ String baseName = portletMetaData.getResourceBundle();
+ ResourceBundleFactory rbf = new SimpleResourceBundleFactory(webApp.getClassLoader(), baseName);
+ ResourceBundleManager bundleMgr = new ResourceBundleManager(null, rbf);
+
+ // Build container info
+ ContainerPortletInfo containerInfo = new ContainerPortletInfoBuilder(portletMetaData, bundleMgr).build();
+
+ //
+ String portletContainerId = "PortletContainer[" + webApp.getContextPath() + "," + portletMetaData.getPortletName() + "]";
+
+ //
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletContainerId, PortletContainerImpl.class.getName());
+ AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
+ ctormd.setParameters(Tools.toList((ParameterMetaData)new AbstractParameterMetaData(ContainerPortletInfo.class.getName(), containerInfo), new AbstractParameterMetaData(ResourceBundleManager.class.getName(), bundleMgr)));
+ bmd.setConstructor(ctormd);
+ bmd.setStart(new AbstractLifecycleMetaData("start"));
+ bmd.setStop(new AbstractLifecycleMetaData("stop"));
+ bmd.setProperties(Collections.singleton((PropertyMetaData)new AbstractPropertyMetaData("application", new AbstractDependencyValueMetaData(portletApplicationId))));
+ AbstractInstallMetaData deployerinstallmd = new AbstractInstallMetaData();
+ deployerinstallmd.setBean("PortletApplicationDeployer");
+ deployerinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ deployerinstallmd.setMethodName("installPortletContainer");
+ AbstractInstallMetaData applicationinstallmd = new AbstractInstallMetaData();
+ applicationinstallmd.setBean(portletApplicationId);
+ applicationinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ applicationinstallmd.setMethodName("addContainer");
+ bmd.setInstalls(Tools.toList((InstallMetaData)deployerinstallmd, applicationinstallmd));
+ AbstractInstallMetaData deployeruninstallmd = new AbstractInstallMetaData();
+ deployeruninstallmd.setBean("PortletApplicationDeployer");
+ deployeruninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ deployeruninstallmd.setMethodName("uninstallPortletContainer");
+ AbstractInstallMetaData applicationuninstallmd = new AbstractInstallMetaData();
+ applicationuninstallmd.setBean(portletApplicationId);
+ applicationuninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ applicationuninstallmd.setMethodName("removeContainer");
+ bmd.setUninstalls(Tools.toList((InstallMetaData)deployeruninstallmd, applicationuninstallmd));
+ try
+ {
+ installed.addFirst(portletContainerId);
+ KernelControllerContext portletContainerControllerContext = kernel.getController().install(bmd);
+ portletContainerControllerContexts.add(portletContainerControllerContext);
+ }
+ catch (Throwable t)
+ {
+ log.debug("Cannot install portlet container " + portletMetaData.getPortletName() + " produced an error", t);
+ }
+ }
+
+ //
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletApplicationId, PortletApplicationImpl.class.getName());
+ AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
+ ctormd.setParameters(Tools.toList(
+ (ParameterMetaData)new AbstractParameterMetaData(PortletApplication10MetaData.class.getName(), metaData),
+ new AbstractParameterMetaData(JBossApplicationMetaData.class.getName(), (Object)null),
+ new AbstractParameterMetaData(PortletApplicationContext.class.getName(), this),
+ new AbstractParameterMetaData(PortletAPIFactory.class.getName(), new AbstractDependencyValueMetaData("PortletAPIFactory"))));
+ bmd.setConstructor(ctormd);
+ bmd.setStart(new AbstractLifecycleMetaData("start"));
+ bmd.setStop(new AbstractLifecycleMetaData("stop"));
+ AbstractInstallMetaData installmd = new AbstractInstallMetaData();
+ installmd.setBean("PortletApplicationDeployer");
+ installmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ installmd.setMethodName("installPortletApplication");
+ bmd.setInstalls(Collections.singletonList((InstallMetaData)installmd));
+ AbstractInstallMetaData uninstallmd = new AbstractInstallMetaData();
+ uninstallmd.setBean("PortletApplicationDeployer");
+ uninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
+ uninstallmd.setMethodName("uninstallPortletApplication");
+ bmd.setUninstalls(Collections.singletonList((InstallMetaData)uninstallmd));
+
+ //
+ try
+ {
+ installed.addFirst(portletApplicationId);
+ portletApplicationControllerContext = controller.install(bmd);
+ }
+ catch (Throwable throwable)
+ {
+ log.debug("Installation of portlet application produced an error", throwable);
+ }
+
+ logBeanFailure(portletApplicationControllerContext);
+ for (KernelControllerContext portletContainerControllerContext : portletContainerControllerContexts)
+ {
+ logBeanFailure(portletContainerControllerContext);
+ }
+ }
+
+ private void logBeanFailure(KernelControllerContext context)
+ {
+ Throwable t = context.getError();
+ if (t != null)
+ {
+ log.debug("Installation of bean " + context.getName() + " produced an error", t);
+ }
+ }
+
+ void stop()
+ {
+ log.debug("Stopping installation");
+
+ KernelController controller = kernel.getController();
+
+ for (Iterator<String> i = installed.iterator();i.hasNext();)
+ {
+ String beanName = i.next();
+ i.remove();
+ try
+ {
+ controller.uninstall(beanName);
+ }
+ catch (Throwable t)
+ {
+ // MC throws Error .... need to catch them here
+
+ log.error("Bean " + beanName + " undeployment threw something", t);
+ }
+ }
+
+ //
+ portletApplicationControllerContext = null;
+ portletContainerControllerContexts = null;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return webApp.getServletContext();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return webApp.getClassLoader();
+ }
+
+ public void startPortletApplication() throws Exception
+ {
+ throw new NotYetImplemented();
+// try
+// {
+// kernel.getController().change(portletApplicationControllerContext, ControllerState.INSTALLED);
+// }
+// catch (Throwable throwable)
+// {
+// }
+ }
+
+ public void stopPortletApplication()
+ {
+ throw new NotYetImplemented();
+// try
+// {
+// kernel.getController().change(portletApplicationControllerContext, ControllerState.CREATE);
+// }
+// catch (Throwable throwable)
+// {
+// throwable.printStackTrace();
+// }
+ }
+
+ public void startPortletContainer(String portletName) throws Exception
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void stopPortletContainer(String portletName)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public String getContextPath()
+ {
+ throw new NotYetImplemented();
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletController.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,369 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+import java.io.UnsupportedEncodingException;
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletController
+{
+
+ /** . */
+ private MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
+
+ /** . */
+ private final ServletContext servletContext;
+
+ /** . */
+ private final HttpServletRequest req;
+
+ /** . */
+ private final PortletInvoker invoker;
+
+ /** . */
+ private final PortletControllerContext context;
+
+ /** . */
+ private final boolean redirectAfterAction = true;
+
+ public PortletController(PortletControllerContext context, ServletContext servletContext, HttpServletRequest req) throws IllegalRequestException, UnsupportedEncodingException
+ {
+ this.context = context;
+ this.servletContext = servletContext;
+
+ //
+ this.req = req;
+ this.invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ }
+
+ public void process(HttpServletResponse resp) throws PortletInvokerException, IOException
+ {
+
+ //
+ Request request = context.getRequest();
+
+ //
+ PortalNavigationalState navState = context.getNavigationalState();
+
+ //
+ if (request != null)
+ {
+ PortletContext target = PortletContext.createPortletContext(request.portletId);
+
+ //
+ Portlet portlet = invoker.getPortlet(target);
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
+
+ //
+ WindowNavigationalState windowNS = navState.getWindow(request.portletId);
+
+ //
+ PortletInvocationResponse response = null;
+
+ if (request instanceof Render)
+ {
+ RenderResponse render = new RenderResponse();
+ render.setMode(request.mode);
+ render.setWindowState(request.windowState);
+ render.setNavigationalState(PortletParametersStateString.create(request.queryParameters));
+ response = render;
+ }
+ else
+ {
+ //
+ StateString portletNS = null;
+ if (windowNS != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
+
+ //
+ Mode mode = request.mode;
+ if (mode == null && windowNS != null && windowNS.getMode() != null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ //
+ WindowState windowState = request.windowState;
+ if (windowState == null && windowNS != null && windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ TestActionContext actionContext = new TestActionContext(
+ renderer,
+ mode,
+ windowState,
+ portletNS,
+ MARKUP_INFO,
+ PortletParametersStateString.create(request.queryParameters),
+ request.bodyParameters != null ? new PortletParameters(request.bodyParameters) : null);
+ ActionInvocation action = new ActionInvocation(actionContext);
+
+ //
+ action.setRequestContext(new AbstractRequestContext(req, resp));
+ action.setInstanceContext(instanceContext);
+ action.setUserContext(new AbstractUserContext(req));
+ action.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ action.setPortalContext(new AbstractPortalContext());
+ action.setSecurityContext(new AbstractSecurityContext(req));
+ action.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ response = invoker.invoke(action);
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ if (response instanceof RenderResponse && redirectAfterAction)
+ {
+ final RenderResponse render = (RenderResponse)response;
+ String location = renderer.renderURL(new RenderURL()
+ {
+ public StateString getNavigationalState()
+ {
+ return render.getNavigationalState();
+ }
+ public Mode getMode()
+ {
+ return render.getMode();
+ }
+ public WindowState getWindowState()
+ {
+ return render.getWindowState();
+ }
+ }, null, null, true);
+ response = new HTTPRedirectionResponse(location);
+ }
+ }
+
+ //
+ if (response instanceof RenderResponse)
+ {
+ RenderResponse render = (RenderResponse)response;
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ navState.setWindow(portlet.getContext().getId(), windowNS);
+ }
+
+ //
+ if (render.getMode() != null)
+ {
+ windowNS.setMode(render.getMode());
+ }
+ if (render.getWindowState() != null)
+ {
+ windowNS.setWindowState(render.getWindowState());
+ }
+ if (render.getNavigationalState() != null)
+ {
+ windowNS.setPortletNavigationalState(render.getNavigationalState());
+ }
+ }
+ else if (response instanceof HTTPRedirectionResponse)
+ {
+ HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
+ resp.sendRedirect(redirection.getLocation());
+ return;
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ System.out.println("Error " + error.getMessage());
+ if (error.getCause() != null)
+ {
+ error.getCause().printStackTrace();
+ }
+ resp.sendError(404, error.getMessage());
+ return;
+ }
+ else
+ {
+ System.out.println("Not yet handled " + response);
+ }
+ }
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ writer.print("<html><body>");
+
+ //
+ try
+ {
+ for (Iterator i = invoker.getPortlets().iterator(); i.hasNext();)
+ {
+ Portlet portlet = (Portlet)i.next();
+ writer.print("<div><div>" + portlet.getContext() + "</div>");
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
+
+ //
+ Mode mode = Mode.VIEW;
+ WindowState windowState = WindowState.NORMAL;
+ StateString portletNS = null;
+
+ //
+ WindowNavigationalState windowNS = navState.getWindow(portlet.getContext().getId());
+ if (windowNS != null)
+ {
+ if (windowNS.getMode() != null)
+ {
+ mode= windowNS.getMode();
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ windowState= windowNS.getWindowState();
+ }
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ portletNS= windowNS.getPortletNavigationalState();
+ }
+ }
+
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
+ TestRenderContext renderContext = new TestRenderContext(renderer, mode, windowState, portletNS, MARKUP_INFO);
+
+ //
+ RenderInvocation render = new RenderInvocation(renderContext);
+
+ //
+ render.setRequestContext(new AbstractRequestContext(req, resp));
+ render.setInstanceContext(instanceContext);
+ render.setUserContext(new AbstractUserContext(req));
+ render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ render.setPortalContext(new AbstractPortalContext());
+ render.setSecurityContext(new AbstractSecurityContext(req));
+ render.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ invoker.invoke(render);
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+
+ writer.print("</div>");
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+
+ writer.print("</body></html>");
+ }
+
+ static class Request
+ {
+
+ final String portletId;
+ final ParameterMap queryParameters;
+ final ParameterMap bodyParameters;
+ final Mode mode;
+ final WindowState windowState;
+
+ public Request(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
+ {
+ this.portletId = portletId;
+ this.queryParameters = queryParameters;
+ this.bodyParameters = bodyParameters;
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+ }
+
+ static class Action extends Request
+ {
+ public Action(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
+ {
+ super(portletId, queryParameters, bodyParameters, mode, windowState);
+ }
+ }
+
+ static class Render extends Request
+ {
+ public Render(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
+ {
+ super(portletId, queryParameters, bodyParameters, mode, windowState);
+ }
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContext.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletControllerContext
+{
+
+ PortalNavigationalState getNavigationalState();
+
+ PortletController.Request getRequest();
+
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.Body;
+import org.jboss.portal.portlet.test.url.ParameterDecoder;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletControllerContextImpl implements PortletControllerContext
+{
+
+ /** . */
+ public static final int NAV_SCOPE = 0;
+
+ /** . */
+ public static final int SESSION_SCOPE = 1;
+
+ /** . */
+ private final PortalNavigationalState navState;
+
+ /** . */
+ private final PortletController.Request request;
+
+ public PortletControllerContextImpl(HttpServletRequest req, int navStateScope)
+ throws IllegalRequestException, IOException, ClassNotFoundException
+ {
+
+ if (navStateScope < NAV_SCOPE || navStateScope > SESSION_SCOPE)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String pathInfo = req.getPathInfo();
+ String targetId;
+
+ if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
+ {
+ targetId = StringCodec.decode(pathInfo.substring(1));
+
+ WebRequest ri = new WebRequest(req);
+ ParameterDecoder decoder = PortletURLRenderer.builder.createDecoder();
+ decoder.decode(ri.getQueryParameterMap());
+
+ //
+ ParameterMap metaParameters = decoder.getMetaParameters();
+
+ PortalNavigationalState navState;
+ if (navStateScope == NAV_SCOPE)
+ {
+ String ns = metaParameters.getValue("ns");
+ byte[] bytes = Tools.fromHexString(ns);
+ navState = PortalNavigationalState.create(bytes);
+ }
+ else
+ {
+ navState = (PortalNavigationalState)req.getSession().getAttribute("nav_state");
+ }
+
+ //
+ ParameterMap actualParameters = decoder.getActualParameters();
+
+ //
+ Mode mode = null;
+ if (metaParameters.getValue("mode") != null)
+ {
+ mode = Mode.create(metaParameters.getValue("mode"));
+ }
+
+ //
+ WindowState windowState = null;
+ if (metaParameters.getValue("windowstate") != null)
+ {
+ windowState = WindowState.create(metaParameters.getValue("windowstate"));
+ }
+
+ //
+ PortletController.Request request;
+ String type = metaParameters.getValue("type");
+
+ //
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ if ("action".equals(type))
+ {
+ request = new PortletController.Action(targetId, actualParameters, formParameters, mode, windowState);
+ }
+ else
+ {
+ request = new PortletController.Render(targetId, actualParameters, formParameters, mode, windowState);
+ }
+
+ //
+ this.navState = navState;
+ this.request = request;
+ }
+ else
+ {
+ this.navState = new PortalNavigationalState();
+ this.request = null;
+
+ //
+ if (navStateScope == SESSION_SCOPE)
+ {
+ req.getSession().setAttribute("nav_state", navState);
+ }
+ }
+ }
+
+ public PortletController.Request getRequest()
+ {
+ return request;
+ }
+
+ public PortalNavigationalState getNavigationalState()
+ {
+ return navState;
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletURLRenderer.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.test.url.CodecBuilder;
+import org.jboss.portal.portlet.test.url.ParameterEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Iterator;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletURLRenderer
+{
+
+ /** . */
+ final Portlet portlet;
+
+ /** . */
+ final HttpServletRequest clientReq;
+
+ /** . */
+ final HttpServletResponse clientResp;
+
+ /** . */
+ final PortalNavigationalState navState;
+
+ public PortletURLRenderer(PortalNavigationalState navState, Portlet portlet, HttpServletRequest clientReq, HttpServletResponse clientResp)
+ {
+ this.navState = navState;
+ this.portlet = portlet;
+ this.clientReq = clientReq;
+ this.clientResp = clientResp;
+ }
+
+ static final CodecBuilder builder = new CodecBuilder("action").
+ addMetaParameter("windowstate").
+ addMetaParameter("mode").
+ addMetaParameter("type").
+ addMetaParameter("ns");
+
+ String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ CharBuffer buffer = new CharBuffer();
+ buffer.append(clientReq.getScheme());
+ buffer.append("://");
+ buffer.append(clientReq.getServerName());
+ buffer.append(':');
+ buffer.append(Integer.toString(clientReq.getServerPort()));
+ buffer.append(clientReq.getContextPath());
+ buffer.append('/');
+ buffer.append(StringCodec.encode(portlet.getContext().getId()));
+
+ //
+ ParameterMap metaParameters = new ParameterMap();
+
+ //
+ metaParameters.setValue("type", portletURL instanceof RenderURL ? "render" : "action");
+
+ //
+ try
+ {
+ byte[] bytes = navState.getBytes();
+ String ns = Tools.toHexString(bytes);
+ metaParameters.setValue("ns", ns);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ if (portletURL.getMode() != null)
+ {
+ metaParameters.setValue("mode", portletURL.getMode().toString());
+ }
+ if (portletURL.getWindowState() != null)
+ {
+ metaParameters.setValue("windowstate", portletURL.getWindowState().toString());
+ }
+
+ //
+ ParameterMap actualParameters;
+ if (portletURL instanceof RenderURL)
+ {
+ actualParameters = ((PortletParametersStateString)((RenderURL)portletURL).getNavigationalState()).getParameters();
+ }
+ else
+ {
+ actualParameters = ((PortletParametersStateString)((ActionURL)portletURL).getInteractionState()).getParameters();
+ }
+
+ //
+ ParameterEncoder encoder = builder.createEncoder();
+ encoder.encode(actualParameters, metaParameters);
+ boolean first = true;
+ for (Iterator i = encoder.getParameters().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry parameter = (Map.Entry)i.next();
+ String name = (String)parameter.getKey();
+ String[] values = (String[])parameter.getValue();
+ for (int j = 0; j < values.length; j++)
+ {
+ String value = values[j];
+ buffer.append(first ? '?' : '&');
+ buffer.append(name, FastURLEncoder.getUTF8Instance());
+ buffer.append('=');
+ buffer.append(value, FastURLEncoder.getUTF8Instance());
+ first = false;
+ }
+ }
+
+ //
+ String url = buffer.asString();
+ return clientResp.encodeURL(url);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodec.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodec.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodec.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodec.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import java.io.OutputStreamWriter;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StringCodec
+{
+
+ private static char[] blah = "0123456789ABCDEF".toCharArray();
+
+
+ public static String encode(String decodedValue)
+ {
+ try
+ {
+ StringBuffer buffer = new StringBuffer();
+ char[] tmp = new char[1];
+ for (int i = 0;i < decodedValue.length();i++)
+ {
+ char c = decodedValue.charAt(i);
+ if (Character.isLetterOrDigit(c))
+ {
+ buffer.append(c);
+ }
+ else
+ {
+ tmp[0] = c;
+ byte[] bytes = new String(tmp).getBytes("UTF8");
+ for (int j = 0; j < bytes.length; j++)
+ {
+ byte b = bytes[j];
+ buffer.append('_').append(blah[(b & 0XF0) >> 4]).append(blah[b & 0x0F]);
+ }
+ }
+ }
+ return buffer.toString();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static String decode(String encodedValue)
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedValue.length());
+ for (int i = 0;i < encodedValue.length();i++)
+ {
+ char c = encodedValue.charAt(i);
+ if (Character.isLetterOrDigit(c))
+ {
+ baos.write(c);
+ }
+ else if ('_' == c)
+ {
+ if (i + 3 > encodedValue.length())
+ {
+ throw new IllegalArgumentException("There should be at least 2 chars after an _ char");
+ }
+ String hex = encodedValue.substring(i + 1, i + 3);
+ int x = Integer.parseInt(hex, 16);
+ baos.write(x);
+ i += 2;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid char " + c);
+ }
+ }
+ return baos.toString("UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+
+
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodecTestCase.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodecTestCase.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodecTestCase.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/StringCodecTestCase.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import static org.jboss.unit.api.Assert.*;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StringCodecTestCase
+{
+
+ private static final char EURO_CHAR = '\u20AC';
+
+ @Test
+ public void testA()
+ {
+
+ assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", StringCodec.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
+ assertEquals("abcdefghijklmnopqrstuvwxyz", StringCodec.encode("abcdefghijklmnopqrstuvwxyz"));
+ assertEquals("0123456789", StringCodec.encode("0123456789"));
+ assertEquals("_2F", StringCodec.encode("/"));
+ assertEquals("_40", StringCodec.encode("@"));
+ assertEquals("_E2_82_AC", StringCodec.encode(Character.toString(EURO_CHAR)));
+ assertEquals("A_E2_82_ACB_40C", StringCodec.encode("A" + EURO_CHAR + "B@C"));
+
+ }
+
+ @Test
+ public void testB()
+ {
+ assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", StringCodec.decode(StringCodec.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
+ assertEquals("abcdefghijklmnopqrstuvwxyz", StringCodec.decode(StringCodec.encode("abcdefghijklmnopqrstuvwxyz")));
+ assertEquals("0123456789", StringCodec.decode(StringCodec.encode("0123456789")));
+ assertEquals("/", StringCodec.decode(StringCodec.encode("/")));
+ assertEquals("@", StringCodec.decode(StringCodec.encode("@")));
+ assertEquals(Character.toString(EURO_CHAR), StringCodec.decode(StringCodec.encode(Character.toString(EURO_CHAR))));
+ assertEquals("A" + EURO_CHAR +"B@C", StringCodec.decode(StringCodec.encode("A" + EURO_CHAR + "B@C")));
+ }
+
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestActionContext.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestActionContext extends AbstractActionContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public TestActionContext(PortletURLRenderer urlRenderer, Mode mode, WindowState windowState, StateString navigationalState, MarkupInfo markupInfo, StateString interactionState, PortletParameters form)
+ {
+ super(mode, windowState, navigationalState, markupInfo, interactionState, form);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestInstanceContext.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestInstanceContext.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestInstanceContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestInstanceContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.StateEvent;
+import org.jboss.portal.portlet.spi.InstanceContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestInstanceContext implements InstanceContext
+{
+
+ private HttpServletRequest req;
+
+ private boolean modifiable;
+
+ private PortletContext target;
+
+ private boolean useClone;
+
+ private String id;
+
+ public TestInstanceContext(
+ HttpServletRequest req,
+ PortletContext portletContext,
+ boolean modifiable)
+ {
+ String id = portletContext.getId();
+ PortletContext target = portletContext;
+ boolean useClone = false;
+ HttpSession session = req.getSession(false);
+ if (session != null)
+ {
+ PortletContext clone = (PortletContext)session.getAttribute("clone." + id);
+ if (clone != null)
+ {
+ target = clone;
+ useClone = true;
+ }
+ }
+
+ //
+ this.req = req;
+ this.useClone = useClone;
+ this.target = target;
+ this.id = id;
+ this.modifiable = modifiable;
+ }
+
+ public PortletContext getTarget()
+ {
+ return target;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public AccessMode getAccessMode()
+ {
+ return modifiable ? (useClone ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE) : AccessMode.READ_ONLY;
+ }
+
+ public void onStateEvent(StateEvent event)
+ {
+ target = event.getPortletContext();
+ req.getSession().setAttribute("clone." + id, target);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestPortletInvoker.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestPortletInvoker.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestPortletInvoker.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestPortletInvoker.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+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.state.PropertyMap;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.common.invocation.InvocationHandler;
+import org.jboss.portal.common.invocation.Invocation;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import java.util.Set;
+import java.util.List;
+
+/**
+ * A simple consumer.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6712 $
+ */
+public class TestPortletInvoker implements PortletInvoker
+{
+
+ /** . */
+ private InterceptorStackFactory stackFactory;
+
+ /** . */
+ private PortletInvoker producer;
+
+ /** . */
+ private InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Invocation invocation) throws Exception, InvocationException
+ {
+ PortletInvocation portletInvocation = (PortletInvocation)invocation;
+ try
+ {
+ portletInvocation.setHandler(null);
+ return producer.invoke(portletInvocation);
+ }
+ finally
+ {
+ portletInvocation.setHandler(this);
+ }
+ }
+ };
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ public PortletInvoker getProducer()
+ {
+ return producer;
+ }
+
+ public void setProducer(PortletInvoker producer)
+ {
+ this.producer = producer;
+ }
+
+ public Set<Portlet> getPortlets() throws PortletInvokerException
+ {
+ return producer.getPortlets();
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
+ {
+ return producer.getPortlet(portletContext);
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ InvocationHandler prevHandler = invocation.getHandler();
+ try
+ {
+ invocation.setHandler(handler);
+ return (PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
+ }
+ catch (Exception e)
+ {
+ if (e instanceof PortletInvokerException)
+ {
+ throw(PortletInvokerException)e;
+ }
+ else if (e instanceof RuntimeException)
+ {
+ throw(RuntimeException)e;
+ }
+ else
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ finally
+ {
+ invocation.setHandler(prevHandler);
+ }
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<DestroyCloneFailure> destroyClones(List<PortletContext> 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();
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestRenderContext.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRenderContext extends AbstractRenderContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public TestRenderContext(PortletURLRenderer urlRenderer, Mode mode, WindowState windowState, StateString navigationalState, MarkupInfo markupInfo)
+ {
+ super(mode, windowState, navigationalState, markupInfo);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/WindowNavigationalState.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowNavigationalState implements Serializable
+{
+
+ /** . */
+ private StateString portletNavigationalState;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ public StateString getPortletNavigationalState()
+ {
+ return portletNavigationalState;
+ }
+
+ public void setPortletNavigationalState(StateString portletNavigationalState)
+ {
+ this.portletNavigationalState = portletNavigationalState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public void setMode(Mode mode)
+ {
+ this.mode = mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public void setWindowState(WindowState windowState)
+ {
+ this.windowState = windowState;
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory)
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/impl (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl)
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/CodecBuilder.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/CodecBuilder.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/CodecBuilder.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/CodecBuilder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.url;
+
+import java.util.LinkedHashSet;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CodecBuilder
+{
+
+ /** . */
+ final ArrayList metaParameterNames;
+
+ /** . */
+ final String reservedParameterName;
+
+ public CodecBuilder(CodecBuilder that)
+ {
+ this.metaParameterNames = new ArrayList(that.metaParameterNames);
+ this.reservedParameterName = that.reservedParameterName;
+ }
+
+ public CodecBuilder(String reservedParameter)
+ {
+ this.metaParameterNames = new ArrayList();
+ this.reservedParameterName = reservedParameter;
+ }
+
+ public CodecBuilder addMetaParameter(String name)
+ {
+ if (metaParameterNames.contains(name))
+ {
+ throw new IllegalStateException();
+ }
+ if (reservedParameterName.equals(name))
+ {
+ throw new IllegalStateException();
+ }
+ metaParameterNames.add(name);
+ return this;
+ }
+
+ public ParameterEncoder createEncoder()
+ {
+ return new ParameterEncoder(this);
+ }
+
+ public ParameterDecoder createDecoder()
+ {
+ return new ParameterDecoder(this);
+ }
+
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,161 @@
+/******************************************************************************
+ * 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.portlet.test.url;
+
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterDecoder
+{
+
+ /** . */
+ private final CodecBuilder builder;
+
+ /** . */
+ private final ParameterMap metaParameters;
+
+ /** . */
+ private final ParameterMap actualParameters;
+
+ public ParameterDecoder(CodecBuilder builder)
+ {
+ this.builder = builder;
+ this.actualParameters = new ParameterMap();
+ this.metaParameters = new ParameterMap();
+ }
+
+ public ParameterMap getMetaParameters()
+ {
+ return metaParameters;
+ }
+
+ public ParameterMap getActualParameters()
+ {
+ return actualParameters;
+ }
+
+ public void decode(ParameterMap parameters)
+ {
+ actualParameters.clear();
+ metaParameters.clear();
+
+ // Get the meta parameter
+ long reservedParameter = 0;
+ String[] reservedParameters = parameters.getValues(builder.reservedParameterName);
+ if (reservedParameters != null)
+ {
+ if (reservedParameters.length < 1)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ reservedParameter = Long.parseLong(reservedParameters[0], 2);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (int i = builder.metaParameterNames.size() - 1;reservedParameter > 0;)
+ {
+ if (i < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String parameterName = (String)builder.metaParameterNames.get(i--);
+
+ //
+ if ((reservedParameter & 1) == 1)
+ {
+ String[] parameterValues = parameters.getValues(parameterName);
+
+ //
+ if (parameterValues == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (parameterValues.length == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String metaParameterValue = parameterValues[0];
+ metaParameters.setValue(parameterName, metaParameterValue);
+
+ //
+ if (parameterValues.length > 1)
+ {
+ String[] actualParameterValues = new String[parameterValues.length - 1];
+ System.arraycopy(parameterValues, 1, actualParameterValues, 0, actualParameterValues.length);
+ actualParameters.setValues(parameterName, actualParameterValues);
+ }
+ }
+
+ //
+ reservedParameter = reservedParameter >> 1;
+ }
+
+ //
+ for (Iterator i = parameters.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String parameterName = (String)entry.getKey();
+ if (!metaParameters.containsKey(parameterName))
+ {
+ if (builder.reservedParameterName.equals(parameterName))
+ {
+ String[] reservedParameterValues = (String[])entry.getValue();
+ if (reservedParameterValues.length > 1)
+ {
+ String[] parameterValues = new String[reservedParameterValues.length - 1];
+ System.arraycopy(reservedParameterValues, 1, parameterValues, 0, parameterValues.length);
+ actualParameters.setValues(parameterName, parameterValues);
+ }
+ }
+ else
+ {
+ String[] parameterValues = (String[])entry.getValue();
+ actualParameters.setValues(parameterName, parameterValues);
+ }
+ }
+ }
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java (from rev 9471, modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * 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.portlet.test.url;
+
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterEncoder
+{
+
+ /** . */
+ private final CodecBuilder builder;
+
+ /** . */
+ private final ParameterMap parameters;
+
+ public ParameterEncoder(CodecBuilder builder)
+ {
+ this.builder = new CodecBuilder(builder);
+ this.parameters = new ParameterMap();
+ }
+
+ public ParameterMap getParameters()
+ {
+ return parameters;
+ }
+
+ public void encode(ParameterMap actualParameters, ParameterMap metaParameters)
+ {
+ parameters.clear();
+
+ //
+ long meta = 0;
+
+ //
+ for (Iterator i = builder.metaParameterNames.iterator();i.hasNext();)
+ {
+ String mv = (String)i.next();
+ String pv = metaParameters.getValue(mv);
+
+ //
+ meta *= 2;
+
+ //
+ if (pv != null)
+ {
+ String[] pvs = actualParameters.getValues(mv);
+ if (pvs != null)
+ {
+ String[] blah = new String[1 + pvs.length];
+ blah[0] = pv;
+ System.arraycopy(pvs, 0, blah, 1, pvs.length);
+ parameters.setValues(mv, blah);
+ }
+ else
+ {
+ parameters.setValue(mv, pv);
+ }
+ meta |= 1;
+ }
+ }
+
+ //
+ String def = Long.toBinaryString(meta);
+ String[] pvs = actualParameters.getValues(builder.reservedParameterName);
+ if (pvs != null)
+ {
+ String[] blah = new String[1 + pvs.length];
+ blah[0] = def;
+ System.arraycopy(pvs, 0, blah, 1, pvs.length);
+ parameters.setValues(builder.reservedParameterName, blah);
+ }
+ else
+ {
+ parameters.setValue(builder.reservedParameterName, def);
+ }
+
+ //
+ for (Iterator i = actualParameters.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ if (!parameters.containsKey(name))
+ {
+ String[] values = (String[])entry.getValue();
+ parameters.setValues(name, values);
+ }
+ }
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-10 17:01:20 UTC (rev 9472)
@@ -236,6 +236,7 @@
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
+ <fileset dir="${target}/classes"/>
</jar>
<path id="mc.concurrent">
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/InterceptorStackFactoryImpl.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,84 +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.portlet.test;
-
-import org.jboss.portal.common.invocation.InterceptorStack;
-import org.jboss.portal.common.invocation.Interceptor;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class InterceptorStackFactoryImpl implements InterceptorStackFactory
-{
-
- /** . */
- private volatile Interceptor[] interceptors;
-
- /** . */
- private final InterceptorStackImpl stack = new InterceptorStackImpl();
-
- public Interceptor[] getInterceptors()
- {
- return interceptors;
- }
-
- public void setInterceptors(Interceptor[] interceptors)
- {
- this.interceptors = interceptors;
- }
-
- public InterceptorStack getInterceptorStack()
- {
- return stack;
- }
-
- private class InterceptorStackImpl implements InterceptorStack
- {
-
- public int getLength()
- {
- // Avoid dirty reads
- Interceptor[] interceptors = InterceptorStackFactoryImpl.this.interceptors;
-
- //
- return interceptors != null ? interceptors.length : 0;
- }
-
- public Interceptor getInterceptor(int i) throws ArrayIndexOutOfBoundsException
- {
- // Avoid dirty reads
- Interceptor[] interceptors = InterceptorStackFactoryImpl.this.interceptors;
-
- //
- if (interceptors == null)
- {
- throw new ArrayIndexOutOfBoundsException("No interceptors");
- }
-
- //
- return interceptors[i];
- }
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,73 +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.portlet.test;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.zip.GZIPOutputStream;
-import java.util.zip.GZIPInputStream;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortalNavigationalState implements Serializable
-{
-
- /** . */
- private final Map windows = new HashMap();
-
- public WindowNavigationalState getWindow(String windowId)
- {
- return (WindowNavigationalState)windows.get(windowId);
- }
-
- public void setWindow(String windowId, WindowNavigationalState window)
- {
- windows.put(windowId, window);
- }
-
- public byte[] getBytes() throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
- ObjectOutputStream oos = new ObjectOutputStream(zos);
- oos.writeObject(this);
- oos.close();
- return baos.toByteArray();
- }
-
- public static PortalNavigationalState create(byte[] bytes) throws IOException, ClassNotFoundException
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- GZIPInputStream zis = new GZIPInputStream(bais);
- ObjectInputStream ois = new ObjectInputStream(zis);
- return (PortalNavigationalState)ois.readObject();
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,72 +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.portlet.test;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortalServlet extends HttpServlet
-{
-
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- try
- {
- _service(req, resp);
- }
- catch (Exception e)
- {
- if (e instanceof ServletException)
- {
- throw (ServletException)e;
- }
- if (e instanceof IOException)
- {
- throw (IOException)e;
- }
- if (e instanceof RuntimeException)
- {
- throw (RuntimeException)e;
- }
- throw new ServletException(e);
- }
- }
-
- protected void _service(HttpServletRequest req, HttpServletResponse resp) throws Exception
- {
- PortletControllerContext context = new PortletControllerContextImpl(req, PortletControllerContextImpl.SESSION_SCOPE);
-
- //
- PortletController controller = new PortletController(context, getServletContext(), req);
-
- //
- controller.process(resp);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,327 +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.portlet.test;
-
-import org.jboss.portal.web.WebAppListener;
-import org.jboss.portal.web.WebAppEvent;
-import org.jboss.portal.web.WebAppLifeCycleEvent;
-import org.jboss.portal.web.WebApp;
-import org.jboss.portal.web.ServletContainer;
-import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_168_NS;
-import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_286_NS;
-import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
-import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
-import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
-import org.jboss.portal.portlet.test.metadata.impl.ValueTrimmingFilter;
-import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
-import org.jboss.portal.portlet.container.PortletApplication;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.PortletApplicationRegistry;
-import org.jboss.portal.portlet.container.PortletApplicationRegistrationContext;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.Kernel;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
-import org.apache.log4j.Logger;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.net.URL;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletApplicationDeployer implements WebAppListener, KernelControllerContextAware
-{
-
- /** The schema resolver factory. */
- private static SingletonSchemaResolverFactory factory;
-
- /** The schema resolver. */
- private static DefaultSchemaResolver resolver;
-
- static
- {
- try
- {
- factory = SingletonSchemaResolverFactory.getInstance();
- resolver = (DefaultSchemaResolver) factory.getSchemaBindingResolver();
-
- /** SchemaResolver */
- resolver.addSchemaLocation(PORTLET_JSR_168_NS, "portlet-app_1_0.xsd");
- resolver.addSchemaLocation(PORTLET_JSR_286_NS, "portlet-app_2_0.xsd");
- resolver.addClassBinding(PORTLET_JSR_286_NS, AnnotationPortletApplication20MetaData.class);
- resolver.addClassBinding(PORTLET_JSR_168_NS, AnnotationPortletApplication10MetaData.class);
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
-
- /** . */
- private Logger log = Logger.getLogger(PortletApplicationDeployer.class);
-
- /** . */
- private PortletApplicationRegistry registry;
-
- /** . */
- private ServletContainer servletContainer;
-
- /** . */
- private KernelControllerContext controllerContext;
-
- /** . */
- private Map deploymentMap = new HashMap();
-
- /** . */
- private ClassLoader classLoader;
-
- /** . */
- private final Map registrationContextMap = new HashMap();
-
- /** . */
- private Object driver;
-
- public Object getDriver()
- {
- return driver;
- }
-
- public void setDriver(Object driver)
- {
- this.driver = driver;
- }
-
- public PortletApplicationRegistry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry(PortletApplicationRegistry registry)
- {
- this.registry = registry;
- }
-
- public ServletContainer getServletContainer()
- {
- return servletContainer;
- }
-
- public void setServletContainer(ServletContainer servletContainer)
- {
- this.servletContainer = servletContainer;
- }
-
- public void onEvent(WebAppEvent event)
- {
- if (event instanceof WebAppLifeCycleEvent)
- {
- WebAppLifeCycleEvent lifeCycleEvent = (WebAppLifeCycleEvent)event;
- String cp = event.getWebApp().getContextPath();
- switch(lifeCycleEvent.getType())
- {
- case WebAppLifeCycleEvent.ADDED:
- log.debug("Going to install war file" + cp);
- add(event.getWebApp());
- log.debug("Installed war file" + cp);
- break;
- case WebAppLifeCycleEvent.REMOVED:
- try
- {
- log.debug("Going to uninstall war file" + cp);
- remove(event.getWebApp());
- log.debug("Uninstalled war file" + cp);
- }
- catch (Throwable e)
- {
- log.error("Uninstalled war file " + cp + " with an error", e);
- }
- break;
- }
- }
- }
-
- private void add(WebApp webApp)
- {
- // Set the driver for the web app
- webApp.getServletContext().setAttribute("TestDriverServer", driver);
-
- //
- PortletApplication10MetaData metaData = buildPortletApplicationMetaData(webApp);
- if (metaData != null)
- {
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(classLoader);
- Kernel kernel = controllerContext.getKernel();
- PortletApplicationDeployment deployment = new PortletApplicationDeployment(kernel, webApp, metaData);
- deploymentMap.put(webApp.getContextPath(), deployment);
- deployment.start();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
- }
- }
-
- private void remove(WebApp webApp)
- {
- PortletApplicationDeployment deployment = (PortletApplicationDeployment)deploymentMap.remove(webApp.getContextPath());
- if (deployment != null)
- {
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(classLoader);
- deployment.stop();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
- }
- }
-
- public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- log.debug("Set controller context " + controllerContext);
-
- //
- this.controllerContext = controllerContext;
- }
-
- public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
- {
- log.debug("Unset controller context " + controllerContext);
-
- //
- this.controllerContext = null;
- }
-
- public void start()
- {
- classLoader = Thread.currentThread().getContextClassLoader();
-
- //
- servletContainer.addWebAppListener(this);
- }
-
- public void stop()
- {
- servletContainer.removeWebAppListener(this);
-
- //
- classLoader = null;
- }
-
- private PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
- {
- try
- {
- URL url = webApp.getServletContext().getResource("/WEB-INF/portlet.xml");
- if (url != null)
- {
- InputStream in = null;
- try
- {
- in = IOTools.safeBufferedWrapper(url.openStream());
-
- // Validate
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- unmarshaller.setNamespaceAware(true);
- unmarshaller.setSchemaValidation(false);
- unmarshaller.setValidation(false);
-
- //
- PortletApplicationModelFactory factory = new PortletApplicationModelFactory();
-
- // Unmarshal
- PortletApplication10MetaData portletApplicationMD = (PortletApplication10MetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory), null);
- portletApplicationMD.setId(webApp.getContextPath());
-
- //
- return portletApplicationMD;
- }
- finally
- {
- IOTools.safeClose(in);
- }
- }
- }
- catch (IOException e)
- {
- log.error("Cannot read portlet.xml", e);
- }
- catch (JBossXBException e)
- {
- log.error("Cannot parse portlet.xml", e);
- }
- return null;
- }
-
- /**
- * Called by MC to install application.
- */
- public void installPortletApplication(PortletApplication application)
- {
- PortletApplicationRegistrationContext context = registry.registerPortletApplication(application);
- registrationContextMap.put(application, context);
- }
-
- /**
- * Called by MC to install container.
- */
- public void installPortletContainer(PortletContainer container)
- {
- PortletApplicationRegistrationContext context = (PortletApplicationRegistrationContext)registrationContextMap.get(container.getApplication());
- context.registerPortlet(container);
- }
-
- /**
- * Called by MC to uninstall application.
- */
- public void uninstallPortletApplication(PortletApplication application)
- {
- registry.unregisterPortletApplication(application);
- }
-
- /**
- * Called by MC to uninstall container.
- */
- public void uninstallPortletContainer(PortletContainer container)
- {
- PortletApplicationRegistrationContext context = (PortletApplicationRegistrationContext)registrationContextMap.get(container.getApplication());
- context.unregisterPortlet(container);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,288 +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.portlet.test;
-
-import org.jboss.portal.portlet.container.PortletApplicationContext;
-import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
-import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
-import org.jboss.portal.portlet.impl.jsr168.SimpleResourceBundleFactory;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
-import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
-import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
-import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.impl.info.ContainerPortletInfoBuilder;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
-import org.jboss.portal.web.WebApp;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.i18n.ResourceBundleFactory;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
-import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
-import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
-import org.jboss.beans.metadata.plugins.ThisValueMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
-import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.beans.metadata.spi.InstallMetaData;
-import org.apache.log4j.Logger;
-
-import javax.servlet.ServletContext;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletApplicationDeployment implements PortletApplicationContext
-{
-
- /** . */
- private final Logger log;
-
- /** . */
- private final Kernel kernel;
-
- /** . */
- private final WebApp webApp;
-
- /** . */
- private final PortletApplication10MetaData metaData;
-
- /** . */
- private final LinkedList<String> installed;
-
- /** . */
- private KernelControllerContext portletApplicationControllerContext;
-
- /** . */
- private List<KernelControllerContext> portletContainerControllerContexts = new ArrayList<KernelControllerContext>();
-
- public PortletApplicationDeployment(Kernel kernel, WebApp webApp, PortletApplication10MetaData metaData)
- {
- this.kernel = kernel;
- this.webApp = webApp;
- this.metaData = metaData;
- this.log = Logger.getLogger(PortletApplicationDeployment.class + "." + webApp.getContextPath().replace('.', '_'));
- this.installed = new LinkedList<String>();
- }
-
- void start()
- {
-
- log.debug("Starting installation");
-
- //
- KernelController controller = kernel.getController();
-
- //
- String portletApplicationId = "PortletApplication[" + webApp.getContextPath() + "]";
-
- //
- for (PortletMetaData portletMetaData : metaData.getPortlets().values())
- {
- // Create resource bundle manager
- String baseName = portletMetaData.getResourceBundle();
- ResourceBundleFactory rbf = new SimpleResourceBundleFactory(webApp.getClassLoader(), baseName);
- ResourceBundleManager bundleMgr = new ResourceBundleManager(null, rbf);
-
- // Build container info
- ContainerPortletInfo containerInfo = new ContainerPortletInfoBuilder(portletMetaData, bundleMgr).build();
-
- //
- String portletContainerId = "PortletContainer[" + webApp.getContextPath() + "," + portletMetaData.getPortletName() + "]";
-
- //
- AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletContainerId, PortletContainerImpl.class.getName());
- AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
- ctormd.setParameters(Tools.toList((ParameterMetaData)new AbstractParameterMetaData(ContainerPortletInfo.class.getName(), containerInfo), new AbstractParameterMetaData(ResourceBundleManager.class.getName(), bundleMgr)));
- bmd.setConstructor(ctormd);
- bmd.setStart(new AbstractLifecycleMetaData("start"));
- bmd.setStop(new AbstractLifecycleMetaData("stop"));
- bmd.setProperties(Collections.singleton((PropertyMetaData)new AbstractPropertyMetaData("application", new AbstractDependencyValueMetaData(portletApplicationId))));
- AbstractInstallMetaData deployerinstallmd = new AbstractInstallMetaData();
- deployerinstallmd.setBean("PortletApplicationDeployer");
- deployerinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- deployerinstallmd.setMethodName("installPortletContainer");
- AbstractInstallMetaData applicationinstallmd = new AbstractInstallMetaData();
- applicationinstallmd.setBean(portletApplicationId);
- applicationinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- applicationinstallmd.setMethodName("addContainer");
- bmd.setInstalls(Tools.toList((InstallMetaData)deployerinstallmd, applicationinstallmd));
- AbstractInstallMetaData deployeruninstallmd = new AbstractInstallMetaData();
- deployeruninstallmd.setBean("PortletApplicationDeployer");
- deployeruninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- deployeruninstallmd.setMethodName("uninstallPortletContainer");
- AbstractInstallMetaData applicationuninstallmd = new AbstractInstallMetaData();
- applicationuninstallmd.setBean(portletApplicationId);
- applicationuninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- applicationuninstallmd.setMethodName("removeContainer");
- bmd.setUninstalls(Tools.toList((InstallMetaData)deployeruninstallmd, applicationuninstallmd));
- try
- {
- installed.addFirst(portletContainerId);
- KernelControllerContext portletContainerControllerContext = kernel.getController().install(bmd);
- portletContainerControllerContexts.add(portletContainerControllerContext);
- }
- catch (Throwable t)
- {
- log.debug("Cannot install portlet container " + portletMetaData.getPortletName() + " produced an error", t);
- }
- }
-
- //
- AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletApplicationId, PortletApplicationImpl.class.getName());
- AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
- ctormd.setParameters(Tools.toList(
- (ParameterMetaData)new AbstractParameterMetaData(PortletApplication10MetaData.class.getName(), metaData),
- new AbstractParameterMetaData(JBossApplicationMetaData.class.getName(), (Object)null),
- new AbstractParameterMetaData(PortletApplicationContext.class.getName(), this),
- new AbstractParameterMetaData(PortletAPIFactory.class.getName(), new AbstractDependencyValueMetaData("PortletAPIFactory"))));
- bmd.setConstructor(ctormd);
- bmd.setStart(new AbstractLifecycleMetaData("start"));
- bmd.setStop(new AbstractLifecycleMetaData("stop"));
- AbstractInstallMetaData installmd = new AbstractInstallMetaData();
- installmd.setBean("PortletApplicationDeployer");
- installmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- installmd.setMethodName("installPortletApplication");
- bmd.setInstalls(Collections.singletonList((InstallMetaData)installmd));
- AbstractInstallMetaData uninstallmd = new AbstractInstallMetaData();
- uninstallmd.setBean("PortletApplicationDeployer");
- uninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
- uninstallmd.setMethodName("uninstallPortletApplication");
- bmd.setUninstalls(Collections.singletonList((InstallMetaData)uninstallmd));
-
- //
- try
- {
- installed.addFirst(portletApplicationId);
- portletApplicationControllerContext = controller.install(bmd);
- }
- catch (Throwable throwable)
- {
- log.debug("Installation of portlet application produced an error", throwable);
- }
-
- logBeanFailure(portletApplicationControllerContext);
- for (KernelControllerContext portletContainerControllerContext : portletContainerControllerContexts)
- {
- logBeanFailure(portletContainerControllerContext);
- }
- }
-
- private void logBeanFailure(KernelControllerContext context)
- {
- Throwable t = context.getError();
- if (t != null)
- {
- log.debug("Installation of bean " + context.getName() + " produced an error", t);
- }
- }
-
- void stop()
- {
- log.debug("Stopping installation");
-
- KernelController controller = kernel.getController();
-
- for (Iterator<String> i = installed.iterator();i.hasNext();)
- {
- String beanName = i.next();
- i.remove();
- try
- {
- controller.uninstall(beanName);
- }
- catch (Throwable t)
- {
- // MC throws Error .... need to catch them here
-
- log.error("Bean " + beanName + " undeployment threw something", t);
- }
- }
-
- //
- portletApplicationControllerContext = null;
- portletContainerControllerContexts = null;
- }
-
- public ServletContext getServletContext()
- {
- return webApp.getServletContext();
- }
-
- public ClassLoader getClassLoader()
- {
- return webApp.getClassLoader();
- }
-
- public void startPortletApplication() throws Exception
- {
- throw new NotYetImplemented();
-// try
-// {
-// kernel.getController().change(portletApplicationControllerContext, ControllerState.INSTALLED);
-// }
-// catch (Throwable throwable)
-// {
-// }
- }
-
- public void stopPortletApplication()
- {
- throw new NotYetImplemented();
-// try
-// {
-// kernel.getController().change(portletApplicationControllerContext, ControllerState.CREATE);
-// }
-// catch (Throwable throwable)
-// {
-// throwable.printStackTrace();
-// }
- }
-
- public void startPortletContainer(String portletName) throws Exception
- {
- throw new NotYetImplemented();
- }
-
- public void stopPortletContainer(String portletName)
- {
- throw new NotYetImplemented();
- }
-
- public String getContextPath()
- {
- throw new NotYetImplemented();
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,369 +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.portlet.test;
-
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-import java.io.UnsupportedEncodingException;
-import java.io.PrintWriter;
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletController
-{
-
- /** . */
- private MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
-
- /** . */
- private final ServletContext servletContext;
-
- /** . */
- private final HttpServletRequest req;
-
- /** . */
- private final PortletInvoker invoker;
-
- /** . */
- private final PortletControllerContext context;
-
- /** . */
- private final boolean redirectAfterAction = true;
-
- public PortletController(PortletControllerContext context, ServletContext servletContext, HttpServletRequest req) throws IllegalRequestException, UnsupportedEncodingException
- {
- this.context = context;
- this.servletContext = servletContext;
-
- //
- this.req = req;
- this.invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
- }
-
- public void process(HttpServletResponse resp) throws PortletInvokerException, IOException
- {
-
- //
- Request request = context.getRequest();
-
- //
- PortalNavigationalState navState = context.getNavigationalState();
-
- //
- if (request != null)
- {
- PortletContext target = PortletContext.createPortletContext(request.portletId);
-
- //
- Portlet portlet = invoker.getPortlet(target);
-
- //
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
-
- //
- WindowNavigationalState windowNS = navState.getWindow(request.portletId);
-
- //
- PortletInvocationResponse response = null;
-
- if (request instanceof Render)
- {
- RenderResponse render = new RenderResponse();
- render.setMode(request.mode);
- render.setWindowState(request.windowState);
- render.setNavigationalState(PortletParametersStateString.create(request.queryParameters));
- response = render;
- }
- else
- {
- //
- StateString portletNS = null;
- if (windowNS != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
-
- //
- Mode mode = request.mode;
- if (mode == null && windowNS != null && windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (mode == null)
- {
- mode = Mode.VIEW;
- }
-
- //
- WindowState windowState = request.windowState;
- if (windowState == null && windowNS != null && windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowState == null)
- {
- windowState = WindowState.NORMAL;
- }
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
- TestActionContext actionContext = new TestActionContext(
- renderer,
- mode,
- windowState,
- portletNS,
- MARKUP_INFO,
- PortletParametersStateString.create(request.queryParameters),
- request.bodyParameters != null ? new PortletParameters(request.bodyParameters) : null);
- ActionInvocation action = new ActionInvocation(actionContext);
-
- //
- action.setRequestContext(new AbstractRequestContext(req, resp));
- action.setInstanceContext(instanceContext);
- action.setUserContext(new AbstractUserContext(req));
- action.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- action.setPortalContext(new AbstractPortalContext());
- action.setSecurityContext(new AbstractSecurityContext(req));
- action.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- response = invoker.invoke(action);
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
-
- //
- if (response instanceof RenderResponse && redirectAfterAction)
- {
- final RenderResponse render = (RenderResponse)response;
- String location = renderer.renderURL(new RenderURL()
- {
- public StateString getNavigationalState()
- {
- return render.getNavigationalState();
- }
- public Mode getMode()
- {
- return render.getMode();
- }
- public WindowState getWindowState()
- {
- return render.getWindowState();
- }
- }, null, null, true);
- response = new HTTPRedirectionResponse(location);
- }
- }
-
- //
- if (response instanceof RenderResponse)
- {
- RenderResponse render = (RenderResponse)response;
-
- //
- if (windowNS == null)
- {
- windowNS = new WindowNavigationalState();
- navState.setWindow(portlet.getContext().getId(), windowNS);
- }
-
- //
- if (render.getMode() != null)
- {
- windowNS.setMode(render.getMode());
- }
- if (render.getWindowState() != null)
- {
- windowNS.setWindowState(render.getWindowState());
- }
- if (render.getNavigationalState() != null)
- {
- windowNS.setPortletNavigationalState(render.getNavigationalState());
- }
- }
- else if (response instanceof HTTPRedirectionResponse)
- {
- HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
- resp.sendRedirect(redirection.getLocation());
- return;
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- System.out.println("Error " + error.getMessage());
- if (error.getCause() != null)
- {
- error.getCause().printStackTrace();
- }
- resp.sendError(404, error.getMessage());
- return;
- }
- else
- {
- System.out.println("Not yet handled " + response);
- }
- }
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.print("<html><body>");
-
- //
- try
- {
- for (Iterator i = invoker.getPortlets().iterator(); i.hasNext();)
- {
- Portlet portlet = (Portlet)i.next();
- writer.print("<div><div>" + portlet.getContext() + "</div>");
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- WindowNavigationalState windowNS = navState.getWindow(portlet.getContext().getId());
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode= windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState= windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS= windowNS.getPortletNavigationalState();
- }
- }
-
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
- TestRenderContext renderContext = new TestRenderContext(renderer, mode, windowState, portletNS, MARKUP_INFO);
-
- //
- RenderInvocation render = new RenderInvocation(renderContext);
-
- //
- render.setRequestContext(new AbstractRequestContext(req, resp));
- render.setInstanceContext(instanceContext);
- render.setUserContext(new AbstractUserContext(req));
- render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(new AbstractPortalContext());
- render.setSecurityContext(new AbstractSecurityContext(req));
- render.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- invoker.invoke(render);
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
-
- writer.print("</div>");
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
-
- writer.print("</body></html>");
- }
-
- static class Request
- {
-
- final String portletId;
- final ParameterMap queryParameters;
- final ParameterMap bodyParameters;
- final Mode mode;
- final WindowState windowState;
-
- public Request(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
- {
- this.portletId = portletId;
- this.queryParameters = queryParameters;
- this.bodyParameters = bodyParameters;
- this.mode = mode;
- this.windowState = windowState;
- }
- }
-
- static class Action extends Request
- {
- public Action(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
- {
- super(portletId, queryParameters, bodyParameters, mode, windowState);
- }
- }
-
- static class Render extends Request
- {
- public Render(String portletId, ParameterMap queryParameters, ParameterMap bodyParameters, Mode mode, WindowState windowState)
- {
- super(portletId, queryParameters, bodyParameters, mode, windowState);
- }
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,36 +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.portlet.test;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortletControllerContext
-{
-
- PortalNavigationalState getNavigationalState();
-
- PortletController.Request getRequest();
-
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,155 +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.portlet.test;
-
-import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.web.WebRequest;
-import org.jboss.portal.web.Body;
-import org.jboss.portal.portlet.test.url.ParameterDecoder;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletControllerContextImpl implements PortletControllerContext
-{
-
- /** . */
- public static final int NAV_SCOPE = 0;
-
- /** . */
- public static final int SESSION_SCOPE = 1;
-
- /** . */
- private final PortalNavigationalState navState;
-
- /** . */
- private final PortletController.Request request;
-
- public PortletControllerContextImpl(HttpServletRequest req, int navStateScope)
- throws IllegalRequestException, IOException, ClassNotFoundException
- {
-
- if (navStateScope < NAV_SCOPE || navStateScope > SESSION_SCOPE)
- {
- throw new IllegalArgumentException();
- }
-
- //
- String pathInfo = req.getPathInfo();
- String targetId;
-
- if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
- {
- targetId = StringCodec.decode(pathInfo.substring(1));
-
- WebRequest ri = new WebRequest(req);
- ParameterDecoder decoder = PortletURLRenderer.builder.createDecoder();
- decoder.decode(ri.getQueryParameterMap());
-
- //
- ParameterMap metaParameters = decoder.getMetaParameters();
-
- PortalNavigationalState navState;
- if (navStateScope == NAV_SCOPE)
- {
- String ns = metaParameters.getValue("ns");
- byte[] bytes = Tools.fromHexString(ns);
- navState = PortalNavigationalState.create(bytes);
- }
- else
- {
- navState = (PortalNavigationalState)req.getSession().getAttribute("nav_state");
- }
-
- //
- ParameterMap actualParameters = decoder.getActualParameters();
-
- //
- Mode mode = null;
- if (metaParameters.getValue("mode") != null)
- {
- mode = Mode.create(metaParameters.getValue("mode"));
- }
-
- //
- WindowState windowState = null;
- if (metaParameters.getValue("windowstate") != null)
- {
- windowState = WindowState.create(metaParameters.getValue("windowstate"));
- }
-
- //
- PortletController.Request request;
- String type = metaParameters.getValue("type");
-
- //
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
- if ("action".equals(type))
- {
- request = new PortletController.Action(targetId, actualParameters, formParameters, mode, windowState);
- }
- else
- {
- request = new PortletController.Render(targetId, actualParameters, formParameters, mode, windowState);
- }
-
- //
- this.navState = navState;
- this.request = request;
- }
- else
- {
- this.navState = new PortalNavigationalState();
- this.request = null;
-
- //
- if (navStateScope == SESSION_SCOPE)
- {
- req.getSession().setAttribute("nav_state", navState);
- }
- }
- }
-
- public PortletController.Request getRequest()
- {
- return request;
- }
-
- public PortalNavigationalState getNavigationalState()
- {
- return navState;
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,151 +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.portlet.test;
-
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.test.url.CodecBuilder;
-import org.jboss.portal.portlet.test.url.ParameterEncoder;
-import org.jboss.portal.common.text.CharBuffer;
-import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.Tools;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Iterator;
-import java.util.Map;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletURLRenderer
-{
-
- /** . */
- final Portlet portlet;
-
- /** . */
- final HttpServletRequest clientReq;
-
- /** . */
- final HttpServletResponse clientResp;
-
- /** . */
- final PortalNavigationalState navState;
-
- public PortletURLRenderer(PortalNavigationalState navState, Portlet portlet, HttpServletRequest clientReq, HttpServletResponse clientResp)
- {
- this.navState = navState;
- this.portlet = portlet;
- this.clientReq = clientReq;
- this.clientResp = clientResp;
- }
-
- static final CodecBuilder builder = new CodecBuilder("action").
- addMetaParameter("windowstate").
- addMetaParameter("mode").
- addMetaParameter("type").
- addMetaParameter("ns");
-
- String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- CharBuffer buffer = new CharBuffer();
- buffer.append(clientReq.getScheme());
- buffer.append("://");
- buffer.append(clientReq.getServerName());
- buffer.append(':');
- buffer.append(Integer.toString(clientReq.getServerPort()));
- buffer.append(clientReq.getContextPath());
- buffer.append('/');
- buffer.append(StringCodec.encode(portlet.getContext().getId()));
-
- //
- ParameterMap metaParameters = new ParameterMap();
-
- //
- metaParameters.setValue("type", portletURL instanceof RenderURL ? "render" : "action");
-
- //
- try
- {
- byte[] bytes = navState.getBytes();
- String ns = Tools.toHexString(bytes);
- metaParameters.setValue("ns", ns);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
-
- //
- if (portletURL.getMode() != null)
- {
- metaParameters.setValue("mode", portletURL.getMode().toString());
- }
- if (portletURL.getWindowState() != null)
- {
- metaParameters.setValue("windowstate", portletURL.getWindowState().toString());
- }
-
- //
- ParameterMap actualParameters;
- if (portletURL instanceof RenderURL)
- {
- actualParameters = ((PortletParametersStateString)((RenderURL)portletURL).getNavigationalState()).getParameters();
- }
- else
- {
- actualParameters = ((PortletParametersStateString)((ActionURL)portletURL).getInteractionState()).getParameters();
- }
-
- //
- ParameterEncoder encoder = builder.createEncoder();
- encoder.encode(actualParameters, metaParameters);
- boolean first = true;
- for (Iterator i = encoder.getParameters().entrySet().iterator(); i.hasNext();)
- {
- Map.Entry parameter = (Map.Entry)i.next();
- String name = (String)parameter.getKey();
- String[] values = (String[])parameter.getValue();
- for (int j = 0; j < values.length; j++)
- {
- String value = values[j];
- buffer.append(first ? '?' : '&');
- buffer.append(name, FastURLEncoder.getUTF8Instance());
- buffer.append('=');
- buffer.append(value, FastURLEncoder.getUTF8Instance());
- first = false;
- }
- }
-
- //
- String url = buffer.asString();
- return clientResp.encodeURL(url);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodec.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodec.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodec.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,114 +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.portlet.test;
-
-import java.io.OutputStreamWriter;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.io.ByteArrayOutputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class StringCodec
-{
-
- private static char[] blah = "0123456789ABCDEF".toCharArray();
-
-
- public static String encode(String decodedValue)
- {
- try
- {
- StringBuffer buffer = new StringBuffer();
- char[] tmp = new char[1];
- for (int i = 0;i < decodedValue.length();i++)
- {
- char c = decodedValue.charAt(i);
- if (Character.isLetterOrDigit(c))
- {
- buffer.append(c);
- }
- else
- {
- tmp[0] = c;
- byte[] bytes = new String(tmp).getBytes("UTF8");
- for (int j = 0; j < bytes.length; j++)
- {
- byte b = bytes[j];
- buffer.append('_').append(blah[(b & 0XF0) >> 4]).append(blah[b & 0x0F]);
- }
- }
- }
- return buffer.toString();
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException();
- }
- }
-
- public static String decode(String encodedValue)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(encodedValue.length());
- for (int i = 0;i < encodedValue.length();i++)
- {
- char c = encodedValue.charAt(i);
- if (Character.isLetterOrDigit(c))
- {
- baos.write(c);
- }
- else if ('_' == c)
- {
- if (i + 3 > encodedValue.length())
- {
- throw new IllegalArgumentException("There should be at least 2 chars after an _ char");
- }
- String hex = encodedValue.substring(i + 1, i + 3);
- int x = Integer.parseInt(hex, 16);
- baos.write(x);
- i += 2;
- }
- else
- {
- throw new IllegalArgumentException("Invalid char " + c);
- }
- }
- return baos.toString("UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException();
- }
- }
-
-
-
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodecTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodecTestCase.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/StringCodecTestCase.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,64 +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.portlet.test;
-
-import org.jboss.unit.api.pojo.annotations.Test;
-
-import static org.jboss.unit.api.Assert.*;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class StringCodecTestCase
-{
-
- private static final char EURO_CHAR = '\u20AC';
-
- @Test
- public void testA()
- {
-
- assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", StringCodec.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
- assertEquals("abcdefghijklmnopqrstuvwxyz", StringCodec.encode("abcdefghijklmnopqrstuvwxyz"));
- assertEquals("0123456789", StringCodec.encode("0123456789"));
- assertEquals("_2F", StringCodec.encode("/"));
- assertEquals("_40", StringCodec.encode("@"));
- assertEquals("_E2_82_AC", StringCodec.encode(Character.toString(EURO_CHAR)));
- assertEquals("A_E2_82_ACB_40C", StringCodec.encode("A" + EURO_CHAR + "B@C"));
-
- }
-
- @Test
- public void testB()
- {
- assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", StringCodec.decode(StringCodec.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
- assertEquals("abcdefghijklmnopqrstuvwxyz", StringCodec.decode(StringCodec.encode("abcdefghijklmnopqrstuvwxyz")));
- assertEquals("0123456789", StringCodec.decode(StringCodec.encode("0123456789")));
- assertEquals("/", StringCodec.decode(StringCodec.encode("/")));
- assertEquals("@", StringCodec.decode(StringCodec.encode("@")));
- assertEquals(Character.toString(EURO_CHAR), StringCodec.decode(StringCodec.encode(Character.toString(EURO_CHAR))));
- assertEquals("A" + EURO_CHAR +"B@C", StringCodec.decode(StringCodec.encode("A" + EURO_CHAR + "B@C")));
- }
-
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestActionContext.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,78 +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.portlet.test;
-
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestActionContext extends AbstractActionContext
-{
-
- /** . */
- private final PortletURLRenderer urlRenderer;
-
- public TestActionContext(PortletURLRenderer urlRenderer, Mode mode, WindowState windowState, StateString navigationalState, MarkupInfo markupInfo, StateString interactionState, PortletParameters form)
- {
- super(mode, windowState, navigationalState, markupInfo, interactionState, form);
-
- //
- this.urlRenderer = urlRenderer;
-
- //
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return urlRenderer.clientReq;
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return urlRenderer.clientResp;
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestInstanceContext.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestInstanceContext.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestInstanceContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,97 +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.portlet.test;
-
-import org.jboss.portal.portlet.state.AccessMode;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.StateEvent;
-import org.jboss.portal.portlet.spi.InstanceContext;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestInstanceContext implements InstanceContext
-{
-
- private HttpServletRequest req;
-
- private boolean modifiable;
-
- private PortletContext target;
-
- private boolean useClone;
-
- private String id;
-
- public TestInstanceContext(
- HttpServletRequest req,
- PortletContext portletContext,
- boolean modifiable)
- {
- String id = portletContext.getId();
- PortletContext target = portletContext;
- boolean useClone = false;
- HttpSession session = req.getSession(false);
- if (session != null)
- {
- PortletContext clone = (PortletContext)session.getAttribute("clone." + id);
- if (clone != null)
- {
- target = clone;
- useClone = true;
- }
- }
-
- //
- this.req = req;
- this.useClone = useClone;
- this.target = target;
- this.id = id;
- this.modifiable = modifiable;
- }
-
- public PortletContext getTarget()
- {
- return target;
- }
-
- public String getId()
- {
- return id;
- }
-
- public AccessMode getAccessMode()
- {
- return modifiable ? (useClone ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE) : AccessMode.READ_ONLY;
- }
-
- public void onStateEvent(StateEvent event)
- {
- target = event.getPortletContext();
- req.getSession().setAttribute("clone." + id, target);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestPortletInvoker.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestPortletInvoker.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestPortletInvoker.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,158 +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.portlet.test;
-
-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.state.PropertyMap;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.common.invocation.InvocationHandler;
-import org.jboss.portal.common.invocation.Invocation;
-import org.jboss.portal.common.invocation.InvocationException;
-
-import java.util.Set;
-import java.util.List;
-
-/**
- * A simple consumer.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 6712 $
- */
-public class TestPortletInvoker implements PortletInvoker
-{
-
- /** . */
- private InterceptorStackFactory stackFactory;
-
- /** . */
- private PortletInvoker producer;
-
- /** . */
- private InvocationHandler handler = new InvocationHandler()
- {
- public Object invoke(Invocation invocation) throws Exception, InvocationException
- {
- PortletInvocation portletInvocation = (PortletInvocation)invocation;
- try
- {
- portletInvocation.setHandler(null);
- return producer.invoke(portletInvocation);
- }
- finally
- {
- portletInvocation.setHandler(this);
- }
- }
- };
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public PortletInvoker getProducer()
- {
- return producer;
- }
-
- public void setProducer(PortletInvoker producer)
- {
- this.producer = producer;
- }
-
- public Set<Portlet> getPortlets() throws PortletInvokerException
- {
- return producer.getPortlets();
- }
-
- public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
- {
- return producer.getPortlet(portletContext);
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
- {
- InvocationHandler prevHandler = invocation.getHandler();
- try
- {
- invocation.setHandler(handler);
- return (PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
- }
- catch (Exception e)
- {
- if (e instanceof PortletInvokerException)
- {
- throw(PortletInvokerException)e;
- }
- else if (e instanceof RuntimeException)
- {
- throw(RuntimeException)e;
- }
- else
- {
- throw new PortletInvokerException(e);
- }
- }
- finally
- {
- invocation.setHandler(prevHandler);
- }
- }
-
- public PortletContext createClone(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
- public List<DestroyCloneFailure> destroyClones(List<PortletContext> 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();
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestRenderContext.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,77 +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.portlet.test;
-
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestRenderContext extends AbstractRenderContext
-{
-
- /** . */
- private final PortletURLRenderer urlRenderer;
-
- public TestRenderContext(PortletURLRenderer urlRenderer, Mode mode, WindowState windowState, StateString navigationalState, MarkupInfo markupInfo)
- {
- super(mode, windowState, navigationalState, markupInfo);
-
- //
- this.urlRenderer = urlRenderer;
-
- //
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return urlRenderer.clientReq;
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return urlRenderer.clientResp;
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,76 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test;
-
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class WindowNavigationalState implements Serializable
-{
-
- /** . */
- private StateString portletNavigationalState;
-
- /** . */
- private Mode mode;
-
- /** . */
- private WindowState windowState;
-
- public StateString getPortletNavigationalState()
- {
- return portletNavigationalState;
- }
-
- public void setPortletNavigationalState(StateString portletNavigationalState)
- {
- this.portletNavigationalState = portletNavigationalState;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public void setMode(Mode mode)
- {
- this.mode = mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public void setWindowState(WindowState windowState)
- {
- this.windowState = windowState;
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/CodecBuilder.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/CodecBuilder.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/CodecBuilder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,77 +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.portlet.test.url;
-
-import java.util.LinkedHashSet;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CodecBuilder
-{
-
- /** . */
- final ArrayList metaParameterNames;
-
- /** . */
- final String reservedParameterName;
-
- public CodecBuilder(CodecBuilder that)
- {
- this.metaParameterNames = new ArrayList(that.metaParameterNames);
- this.reservedParameterName = that.reservedParameterName;
- }
-
- public CodecBuilder(String reservedParameter)
- {
- this.metaParameterNames = new ArrayList();
- this.reservedParameterName = reservedParameter;
- }
-
- public CodecBuilder addMetaParameter(String name)
- {
- if (metaParameterNames.contains(name))
- {
- throw new IllegalStateException();
- }
- if (reservedParameterName.equals(name))
- {
- throw new IllegalStateException();
- }
- metaParameterNames.add(name);
- return this;
- }
-
- public ParameterEncoder createEncoder()
- {
- return new ParameterEncoder(this);
- }
-
- public ParameterDecoder createDecoder()
- {
- return new ParameterDecoder(this);
- }
-
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterDecoder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,161 +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.portlet.test.url;
-
-import org.jboss.portal.common.util.ParameterMap;
-
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ParameterDecoder
-{
-
- /** . */
- private final CodecBuilder builder;
-
- /** . */
- private final ParameterMap metaParameters;
-
- /** . */
- private final ParameterMap actualParameters;
-
- public ParameterDecoder(CodecBuilder builder)
- {
- this.builder = builder;
- this.actualParameters = new ParameterMap();
- this.metaParameters = new ParameterMap();
- }
-
- public ParameterMap getMetaParameters()
- {
- return metaParameters;
- }
-
- public ParameterMap getActualParameters()
- {
- return actualParameters;
- }
-
- public void decode(ParameterMap parameters)
- {
- actualParameters.clear();
- metaParameters.clear();
-
- // Get the meta parameter
- long reservedParameter = 0;
- String[] reservedParameters = parameters.getValues(builder.reservedParameterName);
- if (reservedParameters != null)
- {
- if (reservedParameters.length < 1)
- {
- throw new IllegalArgumentException();
- }
- try
- {
- reservedParameter = Long.parseLong(reservedParameters[0], 2);
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException();
- }
- }
- else
- {
- throw new IllegalArgumentException();
- }
-
- //
- for (int i = builder.metaParameterNames.size() - 1;reservedParameter > 0;)
- {
- if (i < 0)
- {
- throw new IllegalArgumentException();
- }
-
- //
- String parameterName = (String)builder.metaParameterNames.get(i--);
-
- //
- if ((reservedParameter & 1) == 1)
- {
- String[] parameterValues = parameters.getValues(parameterName);
-
- //
- if (parameterValues == null)
- {
- throw new IllegalArgumentException();
- }
- if (parameterValues.length == 0)
- {
- throw new IllegalArgumentException();
- }
-
- //
- String metaParameterValue = parameterValues[0];
- metaParameters.setValue(parameterName, metaParameterValue);
-
- //
- if (parameterValues.length > 1)
- {
- String[] actualParameterValues = new String[parameterValues.length - 1];
- System.arraycopy(parameterValues, 1, actualParameterValues, 0, actualParameterValues.length);
- actualParameters.setValues(parameterName, actualParameterValues);
- }
- }
-
- //
- reservedParameter = reservedParameter >> 1;
- }
-
- //
- for (Iterator i = parameters.entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String parameterName = (String)entry.getKey();
- if (!metaParameters.containsKey(parameterName))
- {
- if (builder.reservedParameterName.equals(parameterName))
- {
- String[] reservedParameterValues = (String[])entry.getValue();
- if (reservedParameterValues.length > 1)
- {
- String[] parameterValues = new String[reservedParameterValues.length - 1];
- System.arraycopy(reservedParameterValues, 1, parameterValues, 0, parameterValues.length);
- actualParameters.setValues(parameterName, parameterValues);
- }
- }
- else
- {
- String[] parameterValues = (String[])entry.getValue();
- actualParameters.setValues(parameterName, parameterValues);
- }
- }
- }
- }
-}
Deleted: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java 2008-01-10 00:25:47 UTC (rev 9471)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/url/ParameterEncoder.java 2008-01-10 17:01:20 UTC (rev 9472)
@@ -1,116 +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.portlet.test.url;
-
-import org.jboss.portal.common.util.ParameterMap;
-
-import java.util.Map;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ParameterEncoder
-{
-
- /** . */
- private final CodecBuilder builder;
-
- /** . */
- private final ParameterMap parameters;
-
- public ParameterEncoder(CodecBuilder builder)
- {
- this.builder = new CodecBuilder(builder);
- this.parameters = new ParameterMap();
- }
-
- public ParameterMap getParameters()
- {
- return parameters;
- }
-
- public void encode(ParameterMap actualParameters, ParameterMap metaParameters)
- {
- parameters.clear();
-
- //
- long meta = 0;
-
- //
- for (Iterator i = builder.metaParameterNames.iterator();i.hasNext();)
- {
- String mv = (String)i.next();
- String pv = metaParameters.getValue(mv);
-
- //
- meta *= 2;
-
- //
- if (pv != null)
- {
- String[] pvs = actualParameters.getValues(mv);
- if (pvs != null)
- {
- String[] blah = new String[1 + pvs.length];
- blah[0] = pv;
- System.arraycopy(pvs, 0, blah, 1, pvs.length);
- parameters.setValues(mv, blah);
- }
- else
- {
- parameters.setValue(mv, pv);
- }
- meta |= 1;
- }
- }
-
- //
- String def = Long.toBinaryString(meta);
- String[] pvs = actualParameters.getValues(builder.reservedParameterName);
- if (pvs != null)
- {
- String[] blah = new String[1 + pvs.length];
- blah[0] = def;
- System.arraycopy(pvs, 0, blah, 1, pvs.length);
- parameters.setValues(builder.reservedParameterName, blah);
- }
- else
- {
- parameters.setValue(builder.reservedParameterName, def);
- }
-
- //
- for (Iterator i = actualParameters.entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- if (!parameters.containsKey(name))
- {
- String[] values = (String[])entry.getValue();
- parameters.setValues(name, values);
- }
- }
- }
-}
18 years, 3 months
JBoss Portal SVN: r9471 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-09 19:25:47 -0500 (Wed, 09 Jan 2008)
New Revision: 9471
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
Log:
- setValue should not return anything.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2008-01-10 00:22:06 UTC (rev 9470)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2008-01-10 00:25:47 UTC (rev 9471)
@@ -126,8 +126,8 @@
}
}
- public Object setValue(ProducerRegistrationRequirementsImpl regReq, UnmarshallingContext nav, String nsURI,
- String localName, String value)
+ public void setValue(ProducerRegistrationRequirementsImpl regReq, UnmarshallingContext nav, String nsURI,
+ String localName, String value)
{
if ("registration-policy".equals(localName))
{
@@ -139,8 +139,6 @@
value = StringPropertyReplacer.replaceProperties(value);
regReq.setValidatorClassName(value);
}
-
- return null;
}
public void setValue(RegistrationPropertyDescription desc, UnmarshallingContext nav, String nsURI,
18 years, 3 months
JBoss Portal SVN: r9470 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/i18n and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 19:22:06 -0500 (Wed, 09 Jan 2008)
New Revision: 9470
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java
Log:
improvements of i18n stuff
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -25,10 +25,10 @@
import org.jboss.portal.common.io.UndeclaredIOException;
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.common.util.NullConversionException;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.CharWriter;
import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
import java.util.Locale;
/**
@@ -56,7 +56,7 @@
return internalToString(locale);
}
- public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ public void write(Locale locale, CharWriter writer) throws IOException, ConversionException
{
if (locale == null)
{
@@ -75,9 +75,9 @@
{
try
{
- StringWriter writer = new StringWriter();
- internalWrite(locale, writer);
- return writer.toString();
+ CharBuffer buffer = new CharBuffer();
+ internalWrite(locale, buffer);
+ return buffer.asString();
}
catch (IOException e)
{
@@ -85,6 +85,6 @@
}
}
- protected abstract void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException;
+ protected abstract void internalWrite(Locale locale, CharWriter writer) throws IOException, ConversionException;
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -22,8 +22,12 @@
******************************************************************************/
package org.jboss.portal.common.i18n;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.util.ConversionException;
+
import java.util.Locale;
import java.util.NoSuchElementException;
+import java.io.IOException;
/**
* The immutable name of a bundle.
@@ -68,92 +72,113 @@
throw new IllegalArgumentException();
}
this.baseName = baseName;
- this.language = language;
- this.country = country;
- this.variant = variant;
+ this.locale = new Locale(language, country, variant);
}
/** . */
private final String baseName;
- /** Lower-case two-letter codes as defined by ISO-639. */
- private final String language;
-
- /** Upper-case two-letter codes as defined by ISO-3166. */
- private final String country;
-
/** . */
- private final String variant;
+ private final Locale locale;
public String getBaseName()
{
return baseName;
}
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
public String getLanguage()
{
- return language;
+ return locale.getLanguage();
}
public String getCountry()
{
- return country;
+ return locale.getCountry();
}
public String getVariant()
{
- return variant;
+ return locale.getVariant();
}
- public static class Iterator implements java.util.Iterator
+ public String toString()
{
+ if (locale.getLanguage().length() == 0 && locale.getCountry().length() == 0)
+ {
+ return baseName;
+ }
+ else
+ {
+ CharBuffer buffer = new CharBuffer(baseName.length() + 15);
+ buffer.append(baseName);
- /** . */
- private final String language;
+ //
+ buffer.append('_');
- /** . */
- private final String country;
+ //
+ try
+ {
+ LocaleFormat.DEFAULT.write(locale, buffer);
+ }
+ catch (IOException e)
+ {
+ throw new AssertionError(e);
+ }
+ catch (ConversionException e)
+ {
+ throw new AssertionError(e);
+ }
- /** . */
- private final String variant;
+ //
+ return buffer.asString();
+ }
+ }
+ public static class Iterator implements java.util.Iterator<BundleName>
+ {
+
/** . */
- private String name;
+ private BundleName name;
/** . */
private int status;
public Iterator(String baseName, Locale locale)
{
- language = locale.getLanguage();
- country = locale.getCountry();
- variant = locale.getVariant();
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
status = 8 + (language.length() > 0 ? 4 : 0) + (country.length() > 0 ? 2 : 0) + (variant.length() > 0 ? 1 : 0);
switch (status & 0x7)
{
case 0:
- name = baseName;
+ name = new BundleName(baseName);
break;
case 1:
- name = baseName + "___" + variant;
+ name = new BundleName(baseName, "", "", variant);
break;
case 2:
- name = baseName + "__" + country;
+ name = new BundleName(baseName, "", variant, "");
break;
case 3:
- name = baseName + "__" + country + "_" + variant;
+ name = new BundleName(baseName, "", country, variant);
break;
case 4:
- name = baseName + "_" + language;
+ name = new BundleName(baseName, language, "", "");
break;
case 5:
- name = baseName + "_" + language + "__" + variant;
+ name = new BundleName(baseName, language, "", variant);
break;
case 6:
- name = baseName + "_" + language + "_" + country;
+ name = new BundleName(baseName, language, country, "");
break;
case 7:
- name = baseName + "_" + language + "_" + country + "_" + variant;
+ name = new BundleName(baseName, language, country, variant);
break;
default:
throw new AssertionError("Should not be here");
@@ -165,7 +190,7 @@
return status != 0;
}
- public Object next()
+ public BundleName next()
{
if (status >= 8)
{
@@ -178,31 +203,31 @@
case 0:
throw new NoSuchElementException();
case 1:
- name = name.substring(0, name.length() - 3 - variant.length());
+ name = new BundleName(name.getBaseName());
status = 0;
break;
case 2:
- name = name.substring(0, name.length() - 2 - country.length());
+ name = new BundleName(name.getBaseName());
status = 0;
break;
case 3:
- name = name.substring(0, name.length() - 1 - variant.length());
+ name = new BundleName(name.getBaseName(), "", name.getCountry());
status = 2;
break;
case 4:
- name = name.substring(0, name.length() - 1 - language.length());
+ name = new BundleName(name.getBaseName());
status = 0;
break;
case 5:
- name = name.substring(0, name.length() - 2 - variant.length());
+ name = new BundleName(name.getBaseName(), name.getLanguage());
status = 4;
break;
case 6:
- name = name.substring(0, name.length() - 1 - country.length());
+ name = new BundleName(name.getBaseName(), name.getLanguage());
status = 4;
break;
case 7:
- name = name.substring(0, name.length() - 1 - variant.length());
+ name = new BundleName(name.getBaseName(), name.getLanguage(), name.getCountry());
status = 6;
break;
default:
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -24,9 +24,9 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.common.text.CharWriter;
import java.io.IOException;
-import java.io.Writer;
import java.util.Locale;
/**
@@ -98,7 +98,7 @@
return string;
}
- public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ public void write(Locale locale, CharWriter writer) throws IOException, ConversionException
{
delegate.write(locale, writer);
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -59,7 +59,7 @@
//
for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, locale); iterator.hasNext();)
{
- String name = (String)iterator.next();
+ BundleName name = iterator.next();
// We don't want to process the base name only with the specified locale
// in order to respect the sequence of candidate bundle names
@@ -69,7 +69,7 @@
}
//
- ResourceBundle bundle = lookup(name);
+ ResourceBundle bundle = lookup(name.toString());
if (bundle != null)
{
return bundle;
@@ -79,10 +79,10 @@
// Try default locale
for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, Locale.getDefault()); iterator.hasNext();)
{
- String name = (String)iterator.next();
+ BundleName name = iterator.next();
//
- ResourceBundle bundle = lookup(name);
+ ResourceBundle bundle = lookup(name.toString());
if (bundle != null)
{
return bundle;
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -23,9 +23,9 @@
package org.jboss.portal.common.i18n;
import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.text.CharWriter;
import java.io.IOException;
-import java.io.Writer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
@@ -113,8 +113,8 @@
return factory.createLocale(value.substring(0, p2), b, a);
}
- protected void internalWrite(Locale locale, Writer writer) throws IOException
+ protected void internalWrite(Locale locale, CharWriter writer) throws IOException
{
- writer.write(locale.toString());
+ writer.append(locale.toString());
}
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -23,9 +23,9 @@
package org.jboss.portal.common.i18n;
import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.common.text.CharWriter;
import java.io.IOException;
-import java.io.Writer;
import java.util.Locale;
/**
@@ -51,6 +51,6 @@
String toString(Locale locale) throws ConversionException;
- void write(Locale locale, Writer writer) throws IOException, ConversionException;
+ void write(Locale locale, CharWriter writer) throws IOException, ConversionException;
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -37,11 +37,11 @@
public class MapResourceBundle extends ResourceBundle
{
- protected Map content;
+ protected Map<String, Object> content;
- public MapResourceBundle(Map content)
+ public MapResourceBundle(Map<String, Object> content)
{
- this.content = new HashMap(content);
+ this.content = new HashMap<String, Object>(content);
}
protected Object handleGetObject(String key)
@@ -53,7 +53,7 @@
return content.get(key);
}
- public Enumeration getKeys()
+ public Enumeration<String> getKeys()
{
return Collections.enumeration(content.keySet());
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -23,9 +23,9 @@
package org.jboss.portal.common.i18n;
import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.text.CharWriter;
import java.io.IOException;
-import java.io.Writer;
import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
@@ -83,22 +83,23 @@
* English, "en-GB" for British English, etc.
*
* @param locale the locale which language tag is wanted
+ * @param writer
* @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
* @throws IllegalArgumentException if the given locale is not valid
* @since 2.4
*/
- protected void internalWrite(Locale locale, Writer writer) throws IOException
+ protected void internalWrite(Locale locale, CharWriter writer) throws IOException
{
String country = locale.getCountry(); // country will be empty if no country was specified in the locale
- writer.write(locale.getLanguage());
+ writer.append(locale.getLanguage());
if (country.length() == 2)
{
- writer.write(RFC3066_SEPARATOR);
- writer.write(country);
+ writer.append(RFC3066_SEPARATOR);
+ writer.append(country);
}
else
{
- writer.write(country);
+ writer.append(country);
}
}
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -25,15 +25,16 @@
import org.apache.log4j.Logger;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
/**
- * <p>Manage a set of resource bundles. Obtaining bundles is done using a ResourceBundleFactory object. A bundle
- * obtained successfully is cached in order to avoid the potential expensive cost of bundle retrieval.</p>
+ * <p>Manage a set of resource bundles. Obtention of bundles is delegated to a ResourceBundleFactory. A bundle
+ * obtained successfully is cached in order to avoid the potential expensive cost of the bundle retrieval.</p>
* <p/>
* <p>The manager can also be used to build LocalizedString object from the loaded bundles.</p>
*
@@ -45,16 +46,16 @@
{
/** . */
- private Logger log = Logger.getLogger(getClass());
+ private final Logger log = Logger.getLogger(getClass());
/** . */
- private volatile Map localeBundles;
+ private final ConcurrentMap<Locale, BundleRef> localeBundles;
/** . */
- private ResourceBundle defaultBundle;
+ private final ResourceBundle defaultBundle;
/** . */
- private ResourceBundleFactory resourceBundleFactory;
+ private final ResourceBundleFactory resourceBundleFactory;
/**
* @param defaultBundle the default bundle returned when no bundle has been obtained for the locale
@@ -67,7 +68,7 @@
{
throw new IllegalArgumentException("Need a resource bundle factory");
}
- this.localeBundles = new HashMap();
+ this.localeBundles = new ConcurrentHashMap<Locale, BundleRef>();
this.defaultBundle = defaultBundle;
this.resourceBundleFactory = resourceBundleFactory;
}
@@ -93,28 +94,40 @@
{
throw new IllegalArgumentException("No null default value accepted");
}
- Map m = new HashMap();
- for (Iterator j = localeBundles.entrySet().iterator(); j.hasNext();)
+
+ //
+ Map<Locale, String> m = new HashMap<Locale, String>();
+ for (Map.Entry<Locale, BundleRef> entry : localeBundles.entrySet())
{
- Map.Entry entry = (Map.Entry)j.next();
try
{
- Locale locale = (Locale)entry.getKey();
- ResourceBundle bundle = (ResourceBundle)entry.getValue();
- String localizedDisplayName = bundle.getString(key);
- m.put(locale, localizedDisplayName);
+ Locale locale = entry.getKey();
+ ResourceBundle container = entry.getValue().bundle;
+
+ //
+ if (container != null)
+ {
+ String localizedDisplayName = container.getString(key);
+ m.put(locale, localizedDisplayName);
+ }
}
catch (MissingResourceException ignore)
{
}
}
+
+ // Always need default value
if (!m.containsKey(Locale.ENGLISH))
{
m.put(Locale.ENGLISH, defaultValue);
}
+
+ //
return new LocalizedString(m, Locale.ENGLISH);
}
+
+
/**
* Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it
* falls back to (language + country) or (language) or the default file.
@@ -122,6 +135,8 @@
* When the resource bundle object is found and was not in the global map, it put it in that map with a copy on
* write.
*
+ * @param locale the locale we want a bundle for
+ * @return a bundle for the locale or null if not suitable bundle is found.
* @throws IllegalArgumentException if the locale is null
*/
public ResourceBundle getResourceBundle(Locale locale) throws IllegalArgumentException
@@ -133,20 +148,20 @@
}
// Try to get the bundle if the map
- ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
- if (bundle != null)
+ BundleRef ref = localeBundles.get(locale);
+ if (ref != null)
{
- return bundle;
+ return ref.bundle;
}
//
log.debug("Want to load bundle for locale " + locale);
- bundle = resourceBundleFactory.getBundle(locale);
+ ResourceBundle bundle = resourceBundleFactory.getBundle(locale);
//
if (bundle != null)
{
- log.debug("Obtained bundle " + bundle + " for locale " + locale);
+ log.debug("Obtained bundle " + bundle + " with locale " + bundle.getLocale() + " for locale " + locale);
}
else
{
@@ -154,11 +169,24 @@
}
// Cache the bundle
- Map copy = new HashMap(localeBundles);
- copy.put(locale, bundle);
- localeBundles = copy;
+ localeBundles.put(locale, new BundleRef(bundle));
//
return bundle;
}
+
+ /**
+ * Keeps track of what we loaded, even null.
+ */
+ private static class BundleRef
+ {
+
+ /** . */
+ final ResourceBundle bundle;
+
+ private BundleRef(ResourceBundle bundle)
+ {
+ this.bundle = bundle;
+ }
+ }
}
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -45,13 +45,13 @@
Locale l = new Locale("a", "b", "c");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
+ assertEquals("base_" + A + "_" + B + "_" + C, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
+ assertEquals("base_" + A + "_" + B, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -68,11 +68,11 @@
Locale l = new Locale("a", "b");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
+ assertEquals("base_" + A + "_" + B, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -89,11 +89,11 @@
Locale l = new Locale("a", "b", "");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
+ assertEquals("base_" + A + "_" + B, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -110,9 +110,9 @@
Locale l = new Locale("a");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -129,9 +129,9 @@
Locale l = new Locale("a", "", "");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -148,11 +148,11 @@
Locale l = new Locale("a", "", "c");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "__" + C, iterator.next());
+ assertEquals("base_" + A + "__" + C, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
+ assertEquals("base_" + A, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -169,11 +169,11 @@
Locale l = new Locale("", "b", "c");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base__" + B + "_" + C, iterator.next());
+ assertEquals("base__" + B + "_" + C, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base__" + B, iterator.next());
+ assertEquals("base__" + B, iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
@@ -190,9 +190,9 @@
Locale l = new Locale("", "", "c");
BundleName.Iterator iterator = new BundleName.Iterator("base", l);
assertTrue(iterator.hasNext());
- assertEquals("base___" + C, iterator.next());
+ assertEquals("base", iterator.next().toString());
assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
+ assertEquals("base", iterator.next().toString());
assertFalse(iterator.hasNext());
try
{
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java 2008-01-09 23:25:22 UTC (rev 9469)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java 2008-01-10 00:22:06 UTC (rev 9470)
@@ -27,7 +27,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
-import java.io.Writer;
import java.io.IOException;
import org.jboss.portal.common.i18n.LocaleFormat;
@@ -35,6 +34,7 @@
import org.jboss.portal.common.i18n.AbstractLocaleFormat;
import org.jboss.portal.common.util.FormatConversionException;
import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.common.text.CharWriter;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -203,14 +203,14 @@
return locale;
}
- protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
+ protected void internalWrite(Locale locale, CharWriter writer) throws IOException, ConversionException
{
String string = (String)localeToString.get(locale);
if (string == null)
{
throw new ConversionException();
}
- writer.write(string);
+ writer.append(string);
}
}
18 years, 3 months
JBoss Portal SVN: r9469 - in modules/portlet/trunk/test: src/test and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 18:25:22 -0500 (Wed, 09 Jan 2008)
New Revision: 9469
Modified:
modules/portlet/trunk/test/pom.xml
modules/portlet/trunk/test/src/test/build.xml
Log:
- update the life cycle dependencies between portlet and test modules (thanks Bolek) to create jars
- make test work with jboss now
Modified: modules/portlet/trunk/test/pom.xml
===================================================================
--- modules/portlet/trunk/test/pom.xml 2008-01-09 21:30:33 UTC (rev 9468)
+++ modules/portlet/trunk/test/pom.xml 2008-01-09 23:25:22 UTC (rev 9469)
@@ -276,7 +276,7 @@
<executions>
<execution>
<id>test</id>
- <phase>test</phase>
+ <phase>integration-test</phase>
<configuration>
<tasks>
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-09 21:30:33 UTC (rev 9468)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-09 23:25:22 UTC (rev 9469)
@@ -352,6 +352,7 @@
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
+ <path refid="mc.jaxb-api"/>
</copy>
<mkdir dir="${test.temp.lib}/jboss-4.2"/>
@@ -369,7 +370,7 @@
<path refid="mc.portal-common"/>
<path refid="mc.portal-portlet"/>
- <!-- Remote plugin -->
+ <!-- Remote plugin -->
<path refid="mc.jboss-remoting"/>
<path refid="mc.portal-test-generic"/>
@@ -393,10 +394,7 @@
<fileset dir="${target}/test-classes/portlet-test-war"/>
</jar>
-
-
-
- <!--Strip cargo manager war filename-->
+ <!-- Strip cargo manager war filename-->
<copy file="${dependency.cargo-manager.war}" tofile="${test.temp.lib}/manager.war"/>
</target>
@@ -436,7 +434,6 @@
<path location="${dependency.portal-test.jar}"/>
<path location="${dependency.portal-web.jar}"/>
<path location="${dependency.jsr168api.jar}"/>
- <path location="${dependency.portal-portlet.jar}"/>
</sharedClasspath>
<configuration>
<property name="cargo.servlet.port" value="8080"/>
@@ -530,7 +527,6 @@
<path location="${dependency.portal-test.jar}"/>
<path location="${dependency.portal-web.jar}"/>
<path location="${dependency.jsr168api.jar}"/>
- <path location="${dependency.portal-portlet.jar}"/>
<path location="${dependency.log4j.jar}"/>
<path location="${dependency.concurrent.jar}"/>
18 years, 3 months
JBoss Portal SVN: r9468 - branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-09 16:30:33 -0500 (Wed, 09 Jan 2008)
New Revision: 9468
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/portlet-instances_2_6.dtd
Log:
- JBPORTAL-1868: Removed duplicated display-name element definition.
Modified: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/portlet-instances_2_6.dtd
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/portlet-instances_2_6.dtd 2008-01-09 17:17:49 UTC (rev 9467)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/portlet-instances_2_6.dtd 2008-01-09 21:30:33 UTC (rev 9468)
@@ -77,10 +77,6 @@
<!ELEMENT instance (instance-id,portlet-ref,display-name*,preferences?,
security-constraint?, (display-name* | (resource-bundle, supported-locale+)))>
-<!ELEMENT display-name (#PCDATA)>
-<!ATTLIST display-name
- xml:lang NMTOKEN #IMPLIED
->
<!ELEMENT resource-bundle (#PCDATA)>
18 years, 3 months