Author: chris.laprun(a)jboss.com
Date: 2007-09-23 00:56:34 -0400 (Sun, 23 Sep 2007)
New Revision: 8437
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionContextRequestContext.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPActionContext.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRenderContext.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRequestContext.java
Removed:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/invocation/
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/build.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/DestroyClonesPortletManagementBehavior.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- Re-wrote dependency handling of build file to use AS libs wherever possible instead of
using thirparty to avoid conflicts of versions.
- JBPORTAL-1167: Improved exception handling by using SOAPFaultException. Needs more
testing.
- JBPORTAL-1392: Initial commit, works Portal to Portal. Needs more testing.
- Moved invocation package content to producer content as part of work on JBPORTAL-1392.
- NOTE: producer tests fail at this time because of a WS class not being serializable. One
possible solution could be to make sure that the producer tests go through the WS stack.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/build.xml 2007-09-23 04:48:51 UTC (rev 8436)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/build.xml 2007-09-23 04:56:34 UTC (rev 8437)
@@ -103,35 +103,52 @@
<property name="jboss-junit-configuration" value=""/>
<property name="junit.formatter.usefile" value="true"/>
+ <!-- Deploy directory -->
+ <property name="jboss.deploy.dir"
value="${jboss.home}/server/${portal.deploy.dir}"/>
+ <!-- Lib directory for current JBoss configuration -->
+ <property name="jboss.deploy.lib.dir"
value="${jboss.deploy.dir}/../lib"/>
+
<!-- Configure thirdparty libraries -->
&libraries;
+
+ <!-- Libraries required to compile -->
<path id="library.classpath">
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
<path refid="jboss.portal/modules/test.classpath"/>
<path refid="oswego.concurrent.classpath"/>
- <path refid="apache.log4j.classpath"/>
<path refid="junit.junit.classpath"/>
<path refid="sun.servlet.classpath"/>
<path refid="sun.jaf.classpath"/>
- <!-- This lib MUST be in the classpath before jboss.artifacts.classpath
otherwise
- there will be a serialization error due to the fact that JBoss AS
- use the QName class from xerces and jboss.client has a QName version
- from namespace.jar -->
- <path refid="apache.xerces.classpath"/>
- <path refid="jbossas/core.libs.classpath"/>
- <path refid="dom4j.dom4j.classpath"/>
+ <pathelement path="${jboss.home}/lib/jboss-common.jar"/>
+ <pathelement path="${jboss.home}/lib/jboss-jmx.jar"/>
+ <pathelement path="${jboss.home}/lib/jboss-system.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jboss-j2ee.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jboss-jaxrpc.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jboss-saaj.jar"/>
<path refid="ibm.wsdl4j.classpath"/>
<path refid="jboss.jbossxb.classpath"/>
<path refid="apache.httpclient.classpath"/>
- <path refid="apache.logging.classpath"/>
<path refid="hibernate.hibernate.classpath"/>
- <path refid="apache.myfaces.classpath"/>
- <path refid="facelets.facelets.classpath"/>
- <path refid="el.el.classpath"/>
- <pathelement location="${source.etc}/sun-jsf/jsf-example.jar"/>
+ <path refid="apache.fileupload.classpath"/>
+ <path refid="sun.javamail.classpath"/>
</path>
+ <!-- Libraries required for tests -->
+ <path id="tests.classpath">
+ <path refid="library.classpath"/>
+ <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <pathelement path="${jboss.deploy.lib.dir}/log4j.jar"/>
+ <path refid="apache.xerces.classpath"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jnpserver.jar"/>
+ <pathelement
path="${jboss.deploy.lib.dir}/jmx-adaptor-plugin.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jboss.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jbosssx.jar"/>
+ <pathelement
path="${jboss.deploy.lib.dir}/jboss-transaction.jar"/>
+ <path refid="jboss.serialization.classpath"/>
+ <path refid="jboss.remoting.classpath"/>
+ </path>
<!-- Configure modules -->
<call target="configure-modules"/>
@@ -154,21 +171,13 @@
<property name="build.gen.classes"
value="${build.gen}/generated"/>
<property name="jboss.endorsed.dir"
location="${jboss.home}/lib/endorsed"/>
+
- <path id="ws.classpath">
- <path refid="sun.javamail.classpath"/>
- <path refid="jboss.remoting.classpath"/>
- <path refid="jboss.jbossxb.classpath"/>
- <path refid="jboss.jbossws14.classpath"/>
- <path refid="ibm.wsdl4j.classpath"/>
- <path refid="jboss/jbossretro.rt.classpath"/>
- <path refid="jboss/backport.concurrent.classpath"/>
- <path refid="jboss.serialization.classpath"/>
- </path>
-
<path id="aop.classpath">
+ <!-- not directly available in AS -->
<pathelement
path="${jbossas/core.libs.lib}/jboss-aspect-library.jar"/>
- <pathelement path="${jboss.aop.lib}/jboss-aop.jar"/>
+
+ <pathelement path="${jboss.aop.lib}/jboss-aop.jar"/>
<path refid="javassist.javassist.classpath"/>
<path refid="oswego.concurrent.classpath"/>
<path refid="trove.trove.classpath"/>
@@ -186,7 +195,6 @@
<!--+=======================================+-->
<property name="javadoc.private" value="true"/>
<property name="javadoc.protected" value="false"/>
- <property name="jboss.deploy.dir"
value="${jboss.home}/server/${portal.deploy.dir}"/>
<property name="log.dir" value="${module.output}/logs"/>
<property name="reports.dir"
value="${module.output}/reports"/>
@@ -352,23 +360,22 @@
<!-- ================================================================== -->
<!-- Deployment of test agent -->
- <target name="agent-deploy">
+ <target name="agent-deploy" depends="init">
<deploy file="${jboss.portal/modules/test.lib}/portal-test-agent.sar"
config="default"/>
</target>
<!-- Undeployment of test agent -->
- <target name="agent-undeploy">
+ <target name="agent-undeploy" depends="init">
<undeploy
file="${jboss.portal/modules/test.lib}/portal-test-agent.sar"
config="default"/>
</target>
<target name="deploy" description="Deploy WSRP"
depends="output">
- <require file="${jboss.home}/server/${portal.deploy.dir}"/>
- <copy file="./output/lib/portal-wsrp.sar"
todir="${jboss.home}/server/${portal.deploy.dir}"
overwrite="true"/>
- <require file="${jboss.deploy.dir}"/>
+ <require file="${jboss.deploy.dir}"/>
+ <copy file="./output/lib/portal-wsrp.sar"
todir="${jboss.home}/server/${portal.deploy.dir}"
overwrite="true"/>
</target>
<target name="undeploy" description="Undeploy WSRP"
depends="init">
- <require file="${jboss.home}/server/${portal.deploy.dir}"/>
+ <require file="${jboss.deploy.dir}"/>
<delete
file="${jboss.home}/server/${portal.deploy.dir}/portal-wsrp.sar"/>
<delete
file="${jboss.home}/server/${portal.deploy.dir}/test-wsrp-consumer.sar"/>
<delete
file="${jboss.home}/server/${portal.deploy.dir}/test-wsrp-producer.sar"/>
@@ -477,13 +484,16 @@
<mkdir dir="${build.resources.test}/test-wsrp-consumer-sar/lib"/>
<copy todir="${build.resources.test}/test-wsrp-consumer-sar/lib"
overwrite="true">
<fileset dir="${junit.junit.lib}"
includes="junit.jar"/>
+ <fileset dir="${apache.fileupload.lib}"
includes="commons-fileupload.jar"/>
<fileset dir="${build.lib.test}"
includes="test-wsrp-consumer.jar"/>
<fileset dir="${build.lib.test}"
includes="test-wsrp-consumer-client.jar"/>
<fileset dir="${jboss.portal-security.root}/lib"
includes="portal-security-lib.jar"/>
<fileset dir="${build.lib.test}"
includes="test-wsrp-consumer-lib.jar"/>
<fileset dir="${jboss.portal/modules/common.lib}"
includes="portal-common-portal-lib.jar"/>
<fileset dir="${jboss.portal-api.root}/lib"
includes="portal-api-lib.jar"/>
- <fileset dir="${jboss.portal/modules/portlet.lib}"
includes="portal-portlet-lib.jar,portal-portlet-federation-lib.jar,portal-portlet-jsr168api-lib.jar"/>
<!-- , portal-portlet-test-lib.jar -->
+ <fileset dir="${jboss.portal/modules/portlet.lib}"
+
includes="portal-portlet-lib.jar,portal-portlet-federation-lib.jar,portal-portlet-jsr168api-lib.jar"/>
+ <!-- , portal-portlet-test-lib.jar -->
<fileset dir="${jboss.portal/modules/test.lib}"
includes="portal-test-lib.jar"/>
<fileset dir="${jboss.portal/modules/web.lib}"
includes="portal-web-lib.jar"/>
<fileset dir="${jboss.portal-portlet-server.root}/lib"
includes="portal-portlet-server-lib.jar"/>
@@ -513,7 +523,7 @@
<fileset
dir="${build.resources.test}/test-wsrp-producer-client"/>
</jar>
- <!-- microcontainer related -->
+ <!-- producer tests related -->
<jar jarfile="${build.lib.test}/test-wsrp-producer-lib.jar">
<fileset dir="${build.classes}/">
<include name="org/jboss/portal/test/**"/>
@@ -525,13 +535,8 @@
<!-- WS related -->
<jar jarfile="${build.lib.test}/test-wsrp-producer.war">
<fileset dir="${build.resources.test}/test-wsrp-producer-war"/>
- </jar>
+ </jar>
- <!-- -->
- <jar jarfile="${build.lib.test}/test-wsrp-producer.jar">
- <fileset dir="${build.classes}"/>
- </jar>
-
<copy todir="${build.resources.test}/test-wsrp-producer-sar"
overwrite="true">
<fileset dir="${build.lib.test}"
includes="test-wsrp-producer.war"/>
<fileset dir="${jboss.portal-server.root}/lib"
includes="portal-server.sar"/>
@@ -543,13 +548,14 @@
<fileset dir="${build.lib.test}"
includes="test-wsrp-producer-lib.jar"/>
<fileset dir="${jboss.portal/modules/common.lib}"
includes="portal-common-portal-lib.jar"/>
<fileset dir="${jboss.portal-api.root}/lib"
includes="portal-api-lib.jar"/>
- <fileset dir="${jboss.portal/modules/portlet.lib}"
includes="portal-portlet-lib.jar,portal-portlet-federation-lib.jar,portal-portlet-jsr168api-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/portlet.lib}"
+
includes="portal-portlet-lib.jar,portal-portlet-federation-lib.jar,portal-portlet-jsr168api-lib.jar"/>
<fileset dir="${jboss.portal/modules/web.lib}"
includes="portal-web-lib.jar"/>
<fileset dir="${jboss.portal/modules/test.lib}"
includes="portal-test-lib.jar"/>
<fileset dir="${jboss.portal-portlet-server.root}/lib"
includes="portal-portlet-server-lib.jar"/>
<fileset dir="${jboss.portal-registration.root}/lib"
includes="portal-registration-lib.jar"/>
<fileset dir="${junit.junit.lib}"
includes="junit.jar"/>
- <fileset dir="${build.lib.test}"
includes="test-wsrp-producer.jar"/>
+ <fileset dir="${build.lib.test}"
includes="test-wsrp-producer-lib.jar"/>
<fileset dir="${build.lib.test}"
includes="test-wsrp-producer-client.jar"/>
<fileset dir="${jboss.portal-security.root}/lib"
includes="portal-security-lib.jar"/>
<fileset dir="${jboss.portal-server.lib}"
includes="portal-server-test-framework-lib.jar"/>
@@ -607,6 +613,9 @@
<!-- Resourceportlet test portlet -->
<package-test-portlet archiveName="resource"
portletName="Resource"/>
+
+ <!-- Multipart test portlet -->
+ <!--<package-test-portlet archiveName="multipart"
portletName="Multipart"/>-->
</target>
<!-- Packages all the test related artifacts. Note that compilation should have
been already executed -->
@@ -626,7 +635,7 @@
<delete file="output.log"/>
</target>
- <target name="tests-local" depends="clean, output">
+ <target name="tests-local" depends="clean,output">
<server:start name="default"/>
<antcall target="agent-deploy"/>
<antcall target="protocolv1-producer-test"/>
@@ -667,8 +676,8 @@
</zest>
<zest todir="${test.reports}"
name="org.jboss.portal.test.framework.runner.HTTPTestRunner"
-
outfile="TEST-org.jboss.portal.test.wsrp.v1.producer.Producer"
- id="org.jboss.portal.test.wsrp.v1.producer.Producer">
+
outfile="TEST-org.jboss.portal.test.wsrp.v1.producer.Registration"
+ id="org.jboss.portal.test.wsrp.v1.producer.Registration">
<parameter name="archive"
value="test-wsrp-producer-registration.sar"/>
</zest>
<zest todir="${test.reports}"
@@ -688,13 +697,8 @@
<sysproperty key="test.root"
value="${build.lib}/tests"/>
</x-sysproperty>
<x-classpath>
- <fileset dir="${build.lib.test}"
includes="test-wsrp-producer.jar, test-wsrp-producer-lib.jar"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <path refid="apache.codec.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <fileset dir="${build.lib.test}"
includes="test-wsrp-producer-lib.jar"/>
+ <path refid="tests.classpath"/>
</x-classpath>
</execute-tests>
<antcall target="undeploy-producer-test"/>
@@ -734,12 +738,7 @@
</x-sysproperty>
<x-classpath>
<fileset dir="${build.lib.test}"
includes="test-wsrp-consumer.jar, test-wsrp-consumer-lib.jar"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <path refid="apache.codec.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <path refid="tests.classpath"/>
</x-classpath>
</execute-tests>
<antcall target="undeploy-consumer-test"/>
@@ -761,11 +760,10 @@
<x-classpath>
<fileset dir="${build.lib}"
includes="portal-wsrp-lib.jar"/>
<fileset dir="${build.lib.test}"
includes="test-deployment-lib.jar"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <path refid="jboss.portal-api.classpath"/>
+ <path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="tests.classpath"/>
</x-classpath>
</execute-tests>
</target>
@@ -786,11 +784,12 @@
<x-classpath>
<fileset dir="${build.lib}"
includes="portal-wsrp-lib.jar"/>
<fileset dir="${build.lib.test}"
includes="test-producer-configuration-lib.jar"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+
+ <path refid="tests.classpath"/>
+
+ <path refid="jboss.portal-registration.classpath"/>
+ <path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
</x-classpath>
</execute-tests>
</target>
@@ -804,12 +803,8 @@
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg
value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
<sysproperty key="test.root"
value="${build.lib}/tests"/>
- <sysproperty
- key="jboss.aop.path"
- value="${build.resources}/portal-wsrp-sar/wsrp-aop.xml"/>
- <sysproperty
- key="jboss.aop.class.path"
- value="${jbossas/core.libs.lib}/jboss-aspect-library.jar"/>
+ <sysproperty key="jboss.aop.path"
value="${build.resources}/portal-wsrp-sar/wsrp-aop.xml"/>
+ <sysproperty key="jboss.aop.class.path"
value="${jbossas/core.libs.lib}/jboss-aspect-library.jar"/>
</x-sysproperty>
<x-test>
<test todir="${test.reports}"
@@ -833,19 +828,27 @@
<!-- Needed to access datasources.xml -->
<pathelement
location="${jboss.portal/modules/test.resources}"/>
- <path refid="jboss.microcontainer.classpath"/>
+ <path refid="tests.classpath"/>
- <!-- Required for test framework -->
+ <path refid="aop.classpath"/>
+
+ <path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-core.classpath"/>
+ <path refid="jboss.portal-api.classpath"/>
+
+ <path refid="apache.logging.classpath"/>
+ <path refid="dom4j.dom4j.classpath"/>
+ <path refid="cglib.cglib.classpath"/>
<path refid="apache.collections.classpath"/>
- <path refid="cglib.cglib.classpath"/>
- <path refid="aop.classpath"/>
<path refid="asm.asm.classpath"/>
<path refid="antlr.antlr.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <pathelement path="${jboss.deploy.lib.dir}/jboss-jca.jar"/>
+ <pathelement
path="${jboss.deploy.lib.dir}/jboss-common-jdbc-wrapper.jar"/>
+
+ <!-- not directly available in AS -->
+ <pathelement
path="${jbossas/core.libs.lib}/jboss-local-jdbc.jar"/>
</x-classpath>
</execute-tests>
</target>
@@ -870,11 +873,9 @@
<x-classpath>
<fileset dir="${build.lib}"
includes="portal-wsrp-lib.jar"/>
<fileset dir="${build.lib.test}"
includes="test-other-lib.jar"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
- <path refid="ws.classpath"/>
- <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-jboss-lib.jar"/>
+ <path refid="tests.classpath"/>
+ <path refid="apache.logging.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
</x-classpath>
</execute-tests>
</target>
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -315,7 +315,6 @@
}
private Property checkRegistrationData(RegistrationData register)
- throws OperationFailedFault
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(register,
"RegistrationData");
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -65,8 +65,8 @@
{
return (MarkupBehavior)behaviors.get(handle);
}
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("There is no registered MarkupBehavior for
handle '" + handle + "'"));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "There is no registered MarkupBehavior for handle '" + handle +
"'", null);
}
public void registerMarkupBehavior(MarkupBehavior behavior)
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -81,7 +81,8 @@
if (!BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, null);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Can only clone portlet with handle '" +
BasicMarkupBehavior.PORTLET_HANDLE + "'", null);
}
return WSRPTypeFactory.createPortletContext(CLONED_HANDLE);
@@ -137,8 +138,8 @@
}
else
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Unknown handle '" + handle +
"'"));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Unknown handle '" + handle + "'", null);
}
incrementCallCount();
@@ -155,7 +156,8 @@
if (!(CLONED_HANDLE).equals(handle))
{
- throw WSRPExceptionFactory.createOperationFailedFault(new
IllegalArgumentException("Cannot modify portlet '" + handle +
"'"));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Cannot modify portlet '" + handle + "'", null);
}
return setPortletProperties.getPortletContext();
@@ -168,7 +170,8 @@
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(handle,
"portlet handle", "PortletContext");
if (handle.length() == 0)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, null);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Portlet handle is empty", null);
}
return handle;
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/DestroyClonesPortletManagementBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/DestroyClonesPortletManagementBehavior.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/DestroyClonesPortletManagementBehavior.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -67,9 +67,8 @@
}
else
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Invalid portlet handle: "
- + getPortletDescription.getPortletContext().getPortletHandle()));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Invalid portlet handle: " +
getPortletDescription.getPortletContext().getPortletHandle(), null);
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -26,6 +26,7 @@
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPActionURL;
import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPPortletURL;
import org.jboss.portal.wsrp.WSRPRenderURL;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -43,7 +44,6 @@
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.SessionContext;
import org.jboss.portal.wsrp.core.StateChange;
-import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UpdateResponse;
import java.rmi.RemoteException;
@@ -83,9 +83,14 @@
markupService.getMarkup(getMarkup);
ExtendedAssert.fail();
}
- catch (UnsupportedModeFault unsupportedModeFault)
+ catch (RemoteException e)
{
+ checkException(e, WSRPExceptionFactory.UNSUPPORTED_MODE);
}
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (UnsupportedModeFault unsupportedModeFault)
+ {
+ }*/
}
public void testGetMarkupWithSessionID() throws Exception
@@ -99,10 +104,15 @@
markupService.getMarkup(getMarkup);
ExtendedAssert.fail("A sessionID should not be allowed to be passed in
GetMarkup()");
}
- catch (OperationFailedFault operationFailedFault)
+ catch (RemoteException e)
{
+ checkException(e, WSRPExceptionFactory.OPERATION_FAILED);
+ }
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (OperationFailedFault operationFailedFault)
+ {
// expected fault.
- }
+ }*/
}
public void testGetMarkupEditNoSession() throws Exception
@@ -254,9 +264,14 @@
markupService.performBlockingInteraction(performBlockingInteraction);
ExtendedAssert.fail("Should not be able to pass a sessionID in a
PerformBlockingInteraction()");
}
- catch (OperationFailedFault expected)
+ catch (RemoteException e)
{
+ checkException(e, WSRPExceptionFactory.OPERATION_FAILED);
}
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (OperationFailedFault expected)
+ {
+ }*/
}
public void testMarkupCaching() throws Exception
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -25,11 +25,11 @@
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.GetServiceDescription;
-import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PropertyDescription;
@@ -38,6 +38,7 @@
import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
+import java.rmi.RemoteException;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -110,10 +111,16 @@
markupService.getMarkup(getMarkup);
ExtendedAssert.fail("Consumer tried to access info with a de-registered
context. Operations should fail.");
}
- catch (InvalidRegistrationFault invalidRegistrationFault)
+ catch (RemoteException e)
{
+ //expected
+ checkException(e, WSRPExceptionFactory.INVALID_REGISTRATION);
+ }
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
// expected
- }
+ }*/
// Get description with old registration context should fail
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
@@ -124,10 +131,16 @@
serviceDescriptionService.getServiceDescription(gs);
ExtendedAssert.fail("Required registration info has been modified:
operations should fail until registration is modified.");
}
- catch (InvalidRegistrationFault invalidRegistrationFault)
+ catch (RemoteException e)
{
+ //expected
+ checkException(e, WSRPExceptionFactory.INVALID_REGISTRATION);
+ }
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
// expected
- }
+ }*/
// Get description should still work without registration context
gs = getNoRegistrationServiceDescriptionRequest();
@@ -158,12 +171,18 @@
markupService.getMarkup(getMarkup);
ExtendedAssert.fail("Required registration info has been modified:
operations should fail until registration is modified.");
}
- catch (InvalidRegistrationFault expected)
+ catch (RemoteException e)
{
+ //expected
+ checkException(e, WSRPExceptionFactory.INVALID_REGISTRATION);
+ }
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
// expected
// WSRP primer recommends returning OperationFailedFault and NOT
InvalidRegistrationFault
// kinda weird... will be replaced by ModifyRegistrationRequiredFault in WSRP
2.0
- }
+ }*/
// Get description should return information just as if consumer wasn't
registered
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
@@ -174,12 +193,18 @@
serviceDescriptionService.getServiceDescription(gs);
ExtendedAssert.fail("Required registration info has been modified:
operations should fail until registration is modified.");
}
- catch (InvalidRegistrationFault expected)
+ catch (RemoteException e)
{
+ //expected
+ checkException(e, WSRPExceptionFactory.INVALID_REGISTRATION);
+ }
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
// expected
// WSRP primer recommends returning OperationFailedFault and NOT
InvalidRegistrationFault
// kinda weird... will be replaced by ModifyRegistrationRequiredFault in WSRP
2.0
- }
+ }*/
// remove registration context, try again and check that we get new registration
info
gs.setRegistrationContext(null);
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -25,11 +25,13 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ReleaseSessions;
+import java.rmi.RemoteException;
+
/**
* Tests the behavior of the ReleaseSession method.
*
@@ -110,10 +112,15 @@
markupService.releaseSessions(releaseSessions);
ExtendedAssert.fail("ReleaseSessions did not thrown an OperationFailed
Fault." + getSetupString(releaseSessions));
}
- catch (OperationFailedFault operationFailedFault)
+ catch (RemoteException e)
{
- // expected error;
+ checkException(e, WSRPExceptionFactory.OPERATION_FAILED);
}
+ // reactivate check for exception once tests go through WS stack see:
JBPORTAL-1712
+ /*catch (OperationFailedFault operationFailedFault)
+ {
+ // expected fault.
+ }*/
finally
{
tearDown();
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -43,6 +43,8 @@
import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
+import javax.xml.rpc.soap.SOAPFaultException;
+import java.rmi.RemoteException;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -239,4 +241,11 @@
ExtendedAssert.assertEquals(expected.getValue(), tested.getValue());
}
}
+
+ protected void checkException(RemoteException e, String errorCode)
+ {
+ Throwable cause = e.getCause();
+ ExtendedAssert.assertTrue(cause instanceof SOAPFaultException);
+ ExtendedAssert.assertEquals(errorCode,
((SOAPFaultException)cause).getFaultCode().getLocalPart());
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -23,9 +23,6 @@
package org.jboss.portal.wsrp;
-import org.jboss.portal.wsrp.core.Fault;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.servlet.ServletAccess;
import javax.servlet.http.HttpServletRequest;
@@ -60,62 +57,31 @@
public static final String UNSUPPORTED_MODE = "UnsupportedMode";
public static final String UNSUPPORTED_WINDOW_STATE =
"UnsupportedWindowState";
-
- /**
- * Create a new OperationFailedFault based on the specified cause.
- *
- * @param cause the cause why the operation failed
- * @return a new OperationFailedFault based on the specified cause.
- */
- public static OperationFailedFault createOperationFailedFault(Throwable cause)
- {
- return (OperationFailedFault)createFaultFrom(OperationFailedFault.class, cause);
- }
-
- public static Fault createFaultFrom(Class faultClass, Throwable cause)
- {
- Fault fault = null;
- try
- {
- fault = (Fault)faultClass.newInstance();
- fault.initCause(cause);
- }
- catch (Exception e)
- {
- // shouldn't happen
- e.printStackTrace();
- }
- return fault;
- }
-
public static void throwMissingParametersFaultIfValueIsMissing(Object valueToCheck,
String valueName, String context)
- throws MissingParametersFault
+ throws SOAPFaultException
{
if (valueToCheck == null)
{
- throw (MissingParametersFault)
- createFaultFrom(MissingParametersFault.class, new
NullPointerException("Missing required " + valueName
- + (context != null ? " in " + context : "")));
+ throw createSOAPFaultException(MISSING_PARAMETERS, "Missing required "
+ valueName
+ + (context != null ? " in " + context : ""), null);
}
}
public static void throwOperationFailedFaultIfValueIsMissing(Object valueToCheck,
String valueName)
- throws OperationFailedFault
+ throws SOAPFaultException
{
if (valueToCheck == null)
{
- throw (OperationFailedFault)
- createFaultFrom(OperationFailedFault.class, new
NullPointerException("Missing required " + valueName));
+ throw createSOAPFaultException(OPERATION_FAILED, "Missing required " +
valueName, null);
}
}
-
- public static SOAPFaultException throwSOAPFaultException(String errorCode, String
message, Exception cause)
+ public static SOAPFaultException throwSOAPFaultException(String errorCode, String
message, Throwable cause)
{
throw createSOAPFaultException(errorCode, message, cause);
}
- private static SOAPFaultException createSOAPFaultException(String errorCode, String
message, Exception cause)
+ private static SOAPFaultException createSOAPFaultException(String errorCode, String
message, Throwable cause)
{
Detail detail = null;
if (cause != null)
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -72,6 +72,7 @@
import org.jboss.portal.wsrp.core.StateChange;
import org.jboss.portal.wsrp.core.Templates;
import org.jboss.portal.wsrp.core.UpdateResponse;
+import org.jboss.portal.wsrp.core.UploadContext;
import org.jboss.portal.wsrp.core.UserContext;
import javax.xml.namespace.QName;
@@ -916,4 +917,23 @@
return new ModifyRegistration(registrationContext, registrationData);
}
+
+ /**
+ * mimeType(xsd:string), uploadData(xsd:base64Binary), mimeAttributes(NamedString)*,
extensions(Extension)*
+ *
+ * @param mimeType
+ * @param uploadData
+ * @return
+ * @since 2.6.2
+ */
+ public static UploadContext createUploadContext(String mimeType, byte[] uploadData)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mimeType, "MIME
Type", "UploadContext");
+ if (uploadData == null || uploadData.length == 0)
+ {
+ throw new IllegalArgumentException("Must pass non-null, non-empty upload
data");
+ }
+
+ return new UploadContext(mimeType, uploadData, null, null);
+ }
}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionContextRequestContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionContextRequestContext.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionContextRequestContext.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.consumer;
+
+import org.apache.commons.fileupload.RequestContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ActionContextRequestContext implements RequestContext
+{
+ private ActionContext actionContext;
+
+ public ActionContextRequestContext(ActionContext actionContext)
+ {
+ this.actionContext = actionContext;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return actionContext.getCharacterEncoding();
+ }
+
+ public String getContentType()
+ {
+ return actionContext.getContentType();
+ }
+
+ public int getContentLength()
+ {
+ return actionContext.getContentLength();
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return actionContext.getInputStream();
+ }
+}
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionContextRequestContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -23,6 +23,10 @@
package org.jboss.portal.wsrp.consumer;
+import org.apache.commons.fileupload.FileItemIterator;
+import org.apache.commons.fileupload.FileItemStream;
+import org.apache.commons.fileupload.FileUpload;
+import org.apache.commons.fileupload.util.Streams;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletParameters;
@@ -46,8 +50,13 @@
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.UpdateResponse;
+import org.jboss.portal.wsrp.core.UploadContext;
import org.jboss.portal.wsrp.core.UserContext;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -80,8 +89,9 @@
InteractionParams interactionParams =
WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));
+ ActionContext actionContext = (ActionContext)invocation.getPortletContext();
+
// interaction state
- ActionContext actionContext = (ActionContext)invocation.getPortletContext();
StateString interactionState = actionContext.getInteractionState();
if (interactionState != null)
{
@@ -92,23 +102,94 @@
}
}
- // form parameters
- PortletParameters params = actionContext.getForm();
- if (params != null && !params.isEmpty())
+ // check for multi-part
+ ActionContextRequestContext request = new
ActionContextRequestContext(actionContext);
+ try
{
- List formParameters = new ArrayList(params.size());
- for (Iterator paramEntries = params.entrySet().iterator();
paramEntries.hasNext();)
+ if (FileUpload.isMultipartContent(request))
{
- Map.Entry param = (Map.Entry)paramEntries.next();
- String name = (String)param.getKey();
- String[] values = (String[])param.getValue();
- for (int i = 0; i < values.length; i++)
+ // content is multipart, we need to parse it (that includes form parameters)
+ FileUpload upload = new FileUpload();
+ FileItemIterator iter = upload.getItemIterator(request);
+ List uploadContexts = new ArrayList(7);
+ List formParameters = new ArrayList(7);
+ while (iter.hasNext())
{
- formParameters.add(new NamedString(name, values[i]));
+ FileItemStream item = iter.next();
+ InputStream stream = item.openStream();
+ if (!item.isFormField())
+ {
+ String contentType = item.getContentType();
+ log.debug("File field " + item.getFieldName() + " with
file name " + item.getName() + " and content type "
+ + contentType + " detected.");
+ BufferedInputStream bufIn = new BufferedInputStream(stream);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(baos);
+
+ int c = bufIn.read();
+ while (c != -1)
+ {
+ bos.write(c);
+ c = bufIn.read();
+ }
+
+ bos.flush();
+ baos.flush();
+ bufIn.close();
+ bos.close();
+
+ UploadContext uploadContext =
WSRPTypeFactory.createUploadContext(contentType, baos.toByteArray());
+
+ NamedString[] mimeAttributes = new NamedString[2];
+
+ mimeAttributes[0] = new NamedString();
+ mimeAttributes[0].setName(FileUpload.CONTENT_DISPOSITION);
+ mimeAttributes[0].setValue(FileUpload.FORM_DATA + ";"
+ + " name=\"" + item.getFieldName() +
"\";"
+ + " filename=\"" + item.getName() +
"\"");
+ mimeAttributes[1] = new NamedString();
+ mimeAttributes[1].setName(FileUpload.CONTENT_TYPE);
+ mimeAttributes[1].setValue(item.getContentType());
+
+ uploadContext.setMimeAttributes(mimeAttributes);
+
+ uploadContexts.add(uploadContext);
+ }
+ else
+ {
+ formParameters.add(new NamedString(item.getFieldName(),
Streams.asString(stream)));
+ }
}
+
interactionParams.setUploadContexts((UploadContext[])uploadContexts.toArray(new
UploadContext[uploadContexts.size()]));
+ interactionParams.setFormParameters((NamedString[])formParameters.toArray(new
NamedString[formParameters.size()]));
}
- interactionParams.setFormParameters((NamedString[])formParameters.toArray(new
NamedString[0]));
+ else
+ {
+ // if the content is not multipart, then check for form parameters
+ PortletParameters params = actionContext.getForm();
+ if (params != null && !params.isEmpty())
+ {
+ int capacity = params.size();
+ List formParameters = new ArrayList(capacity);
+ for (Iterator paramEntries = params.entrySet().iterator();
paramEntries.hasNext();)
+ {
+ Map.Entry param = (Map.Entry)paramEntries.next();
+ String name = (String)param.getKey();
+ String[] values = (String[])param.getValue();
+ for (int i = 0; i < values.length; i++)
+ {
+ formParameters.add(new NamedString(name, values[i]));
+ }
+ }
+
interactionParams.setFormParameters((NamedString[])formParameters.toArray(new
NamedString[capacity]));
+ }
+ }
}
+ catch (Exception e)
+ {
+ log.debug("Couldn't create UploadContext", e);
+ }
// todo: need to deal with GET method in forms
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -24,7 +24,6 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
@@ -43,7 +42,6 @@
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.MarkupParams;
import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.NamedString;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
import org.jboss.portal.wsrp.core.PortletContext;
@@ -54,11 +52,7 @@
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.core.UpdateResponse;
-import org.jboss.portal.wsrp.invocation.WSRPActionContext;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
@@ -109,7 +103,7 @@
return MarkupHandler.PBI;
}
- AccessMode getAccessMode() throws MissingParametersFault
+ AccessMode getAccessMode()
{
StateChange stateChange = interactionParams.getPortletStateChange();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(stateChange,
"portletStateChange", "InteractionParams");
@@ -119,49 +113,20 @@
void initInvocation(StateString navigationalState, SecurityContext securityContext,
MarkupInfo markupInfo, PortalContext portalContext,
UserContext userContext,
- WindowContext windowContext
- )
+ WindowContext windowContext)
{
- PortletParameters parameters;
- NamedString[] formParams = interactionParams.getFormParameters();
- if (formParams != null && formParams.length > 0)
- {
- int length = formParams.length;
- Map params = new HashMap(length);
- for (int i = 0; i < length; i++)
- {
- NamedString formParam = formParams[i];
- String paramName = formParam.getName();
- String paramValue = formParam.getValue();
- if (params.containsKey(paramName))
- {
- // handle multi-valued parameters...
- String[] oldValues = (String[])params.get(paramName);
- int valuesLength = oldValues.length;
- String[] newValues = new String[valuesLength + 1];
- System.arraycopy(oldValues, 0, newValues, 0, valuesLength);
- newValues[valuesLength] = paramValue;
- params.put(paramName, newValues);
- }
- else
- {
- params.put(paramName, new String[]{paramValue});
- }
- }
- parameters = new PortletParameters(params);
- }
- else
- {
- parameters = new PortletParameters();
- }
+
StateString interactionState =
createNavigationalState(interactionParams.getInteractionState());
- WSRPActionContext actionContext = new WSRPActionContext(navigationalState,
securityContext, markupInfo,
+ /*WSRPActionContext actionContext = new WSRPActionContext(navigationalState,
securityContext, markupInfo,
portalContext, userContext, instanceContext, windowContext,
WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()),
interactionState, parameters,
- markupRequest.getCharacterSet(), markupRequest.getMimeType());
+ markupRequest.getCharacterSet(), markupRequest.getMimeType());*/
+ WSRPActionContext actionContext =
WSRPActionContext.createActionContext(navigationalState, securityContext,
+ markupInfo, portalContext, userContext, instanceContext, windowContext,
markupRequest, interactionState,
+ interactionParams);
setInvocation(new ActionInvocation(actionContext));
actionContext.contextualize(invocation);
invocation.setTarget(portlet.getContext());
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -53,7 +53,6 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
-import org.jboss.portal.wsrp.core.UploadContext;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.servlet.ServletAccess;
@@ -88,16 +87,18 @@
RequestProcessor requestProcessor = new RenderRequestProcessor(producer,
getMarkup);
+ String handle = requestProcessor.getPortletContext().getPortletHandle();
PortletInvocationResponse response;
try
{
- log.debug("RenderInvocation on portlet '" +
requestProcessor.getPortletContext().getPortletHandle() + "'");
+ log.debug("RenderInvocation on portlet '" + handle +
"'");
response = producer.getInvoker().invoke(requestProcessor.getInvocation());
log.debug("RenderInvocation done");
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not render portlet '" + handle + "'", e);
}
checkForError(response);
@@ -115,30 +116,25 @@
final InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(interactionParams,
"InteractionParams", PBI);
- // fix-me: upload contexts are not supported, fail fast!
- UploadContext[] uploadContexts = interactionParams.getUploadContexts();
- if (uploadContexts != null)
- {
- throw WSRPExceptionFactory.createOperationFailedFault(new
UnsupportedOperationException("UploadContexts are not currently supported."));
- }
-
-
RequestProcessor requestProcessor = new ActionRequestProcessor(producer,
performBlockingInteraction, interactionParams);
PortletInvocationResponse response;
+ String handle = requestProcessor.getPortletContext().getPortletHandle();
try
{
- log.debug("ActionInvocation on portlet '" +
requestProcessor.getPortletContext().getPortletHandle() + "'");
+ log.debug("ActionInvocation on portlet '" + handle +
"'");
response = producer.getInvoker().invoke(requestProcessor.getInvocation());
log.debug("ActionInvocation done");
}
catch (PortletStateChangeRequiredException e)
{
- throw
(PortletStateChangeRequiredFault)WSRPExceptionFactory.createFaultFrom(PortletStateChangeRequiredFault.class,
e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.PORTLET_STATE_CHANGE_REQUIRED,
+ e.getLocalizedMessage(), e);
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not perform action on portlet '" + handle +
"'", e);
}
checkForError(response);
@@ -168,10 +164,11 @@
return new ReturnAny();
}
- static void throwOperationFaultOnSessionOperation() throws OperationFailedFault
+ static void throwOperationFaultOnSessionOperation()
{
- throw WSRPExceptionFactory.createOperationFailedFault(new
IllegalArgumentException("JBoss Portal's Producer manages " +
- "sessions completely on the server side, passing or trying to release
sessionIDs is therefore an error."));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"JBoss Portal's Producer" +
+ " manages sessions completely on the server side, passing or trying to
release sessionIDs is therefore an error.",
+ null);
}
private void checkForError(PortletInvocationResponse response)
@@ -180,33 +177,29 @@
if (response instanceof ErrorResponse)
{
ErrorResponse errorResult = (ErrorResponse)response;
- Throwable throwable = errorResult.getCause();
- if (throwable instanceof PortletModeException)
+ Throwable cause = errorResult.getCause();
+ if (cause instanceof PortletModeException)
{
- throw
(UnsupportedModeFault)WSRPExceptionFactory.createFaultFrom(UnsupportedModeFault.class,
- new IllegalArgumentException("Unsupported mode: " +
((PortletModeException)throwable).getMode()));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MODE,
+ "Unsupported mode: " + ((PortletModeException)cause).getMode(),
null);
}
- if (throwable instanceof WindowStateException)
+ if (cause instanceof WindowStateException)
{
- throw
(UnsupportedWindowStateFault)WSRPExceptionFactory.createFaultFrom(UnsupportedWindowStateFault.class,
- new IllegalArgumentException("Unsupported window state: " +
((WindowStateException)throwable).getState()));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_WINDOW_STATE,
+ "Unsupported window state: " +
((WindowStateException)cause).getState(), null);
}
// todo: deal with other exceptions
- if (throwable == null)
- {
- throwable = new Throwable(errorResult.getMessage());
- }
-
// we're not sure what happened so throw an OperationFailedFault
- throw WSRPExceptionFactory.createOperationFailedFault(throwable);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ errorResult.getMessage(), cause);
}
else
if (!(response instanceof HTTPRedirectionResponse || response instanceof
FragmentResponse || response instanceof RenderResponse))
{
- throw WSRPExceptionFactory.createOperationFailedFault(new
IllegalArgumentException("Unsupported result type: "
- + response.getClass().getName()));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Unsupported result type: " + response.getClass().getName(),
null);
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -175,15 +175,18 @@
}
catch (NoSuchPortletException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (InvalidPortletIdException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INCONSISTENT_PARAMETERS,
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
}
@@ -227,7 +230,8 @@
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Failed to destroy clones", e);
}
}
@@ -296,15 +300,18 @@
}
catch (NoSuchPortletException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (InvalidPortletIdException e)
{
- throw
(InconsistentParametersFault)WSRPExceptionFactory.createFaultFrom(InconsistentParametersFault.class,
e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INCONSISTENT_PARAMETERS,
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle(), e);
}
}
@@ -376,7 +383,8 @@
}
catch (PortletInvokerException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Could not retrieve properties for portlet '" + portletContext
+ "'", e);
}
}
@@ -428,7 +436,8 @@
}
catch (PortletInvokerException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class, e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Could not retrieve portlet '" +
portletContext.getPortletHandle() + "'", e);
}
return portlet;
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -91,7 +91,8 @@
catch (Exception e)
{
log.debug(e);
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not register consumer named '" + consumerName +
"'", e);
}
RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext(registration.getId());
@@ -168,7 +169,8 @@
catch (RegistrationException e)
{
log.debug(e);
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not deregister registration with handle '" +
registrationHandle + "'", e);
}
return new ReturnAny();
@@ -211,14 +213,15 @@
catch (RegistrationException e)
{
log.debug(e);
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not modify registration with handle '" +
registrationHandle + "'", e);
}
return null;
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
+ public boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault
{
if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
@@ -239,7 +242,8 @@
}
catch (RegistrationException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Failed to retrieve registration information associated with handle
" + regHandle, e);
}
if (reg == null)
@@ -270,8 +274,8 @@
private boolean throwInvalidRegistrationFault(String message) throws
InvalidRegistrationFault
{
- throw
(InvalidRegistrationFault)WSRPExceptionFactory.createFaultFrom(InvalidRegistrationFault.class,
- new Exception("Invalid registration: " + message));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
+ "Invalid registration: " + message, null);
}
private Map createRegistrationProperties(RegistrationData registrationData)
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -53,7 +53,6 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
-import org.jboss.portal.wsrp.invocation.WSRPRenderContext;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -46,7 +46,6 @@
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.MarkupParams;
import org.jboss.portal.wsrp.core.MarkupType;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescription;
@@ -88,7 +87,8 @@
this.producer = producer;
}
- void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault,
MissingParametersFault, InvalidHandleFault, UnsupportedMimeTypeFault,
UnsupportedWindowStateFault, UnsupportedModeFault
+ void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault,
InvalidHandleFault,
+ UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
producer.checkRegistration(getRegistrationContext());
@@ -114,7 +114,8 @@
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not retrieve portlet '" + portletContext +
"'", e);
}
// get portlet description for the desired portlet...
@@ -122,8 +123,8 @@
portletDescription = producer.getPortletDescription(portlet, desiredLocales);
if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
{
- throw WSRPExceptionFactory.createOperationFailedFault(
- new UnsupportedOperationException("Portlets using GET method in forms
are not currently supported."));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Portlets using GET method in forms are not currently supported.",
null);
}
MarkupType[] markupTypes = portletDescription.getMarkupTypes();
@@ -159,7 +160,7 @@
abstract String getContextName();
- abstract AccessMode getAccessMode() throws MissingParametersFault;
+ abstract AccessMode getAccessMode();
abstract void initInvocation(StateString navigationalState, SecurityContext
securityContext,
MarkupInfo markupInfo, PortalContext portalContext,
UserContext userContext,
@@ -200,8 +201,8 @@
// no MIME type was found: error!
if (markupType == null)
{
- throw
(UnsupportedMimeTypeFault)WSRPExceptionFactory.createFaultFrom(UnsupportedMimeTypeFault.class,
- new IllegalArgumentException("None of the specified MIME types are
supported by this Portlet."));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MIME_TYPE,
+ "None of the specified MIME types are supported by portlet '" +
portlet.getContext().getId() + "'", null);
}
// get the mode
@@ -212,7 +213,8 @@
}
catch (IllegalArgumentException e)
{
- throw
(UnsupportedModeFault)WSRPExceptionFactory.createFaultFrom(UnsupportedModeFault.class,
e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MODE,
+ "Unsupported mode '" + params.getMode() + "'",
e);
}
// get the window state
@@ -223,7 +225,8 @@
}
catch (IllegalArgumentException e)
{
- throw
(UnsupportedWindowStateFault)WSRPExceptionFactory.createFaultFrom(UnsupportedWindowStateFault.class,
e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_WINDOW_STATE,
+ "Unsupported window state '" + params.getMode() +
"'", e);
}
// get the character set
@@ -280,7 +283,7 @@
return defaultValue;
}
- private void checkUserContext(org.jboss.portal.wsrp.core.UserContext wsrpUserContext)
throws MissingParametersFault
+ private void checkUserContext(org.jboss.portal.wsrp.core.UserContext wsrpUserContext)
{
if (wsrpUserContext != null)
{
@@ -289,7 +292,7 @@
}
- private void checkForSessionIDs(RuntimeContext runtimeContext) throws
OperationFailedFault
+ private void checkForSessionIDs(RuntimeContext runtimeContext)
{
if (runtimeContext.getSessionID() != null)
{
@@ -392,7 +395,6 @@
}
private MarkupInfo createStreamInfo(MarkupRequest markupRequest)
- throws UnsupportedMimeTypeFault
{
MarkupInfo markupInfo;
try
@@ -401,7 +403,8 @@
}
catch (MimeTypeParseException e)
{
- throw
(UnsupportedMimeTypeFault)WSRPExceptionFactory.createFaultFrom(UnsupportedMimeTypeFault.class,
e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.UNSUPPORTED_MIME_TYPE,
+ e.getLocalizedMessage(), e);
}
return markupInfo;
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -120,7 +120,8 @@
}
catch (PortletInvokerException e)
{
- throw WSRPExceptionFactory.createOperationFailedFault(e);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Could not retrieve portlet '" + portletContext +
"'", e);
}
return getPortletDescription(portlet, desiredLocales);
}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPActionContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPActionContext.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPActionContext.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -0,0 +1,392 @@
+/******************************************************************************
+ * 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.wsrp.producer;
+
+import org.apache.commons.fileupload.FileUpload;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.core.InteractionParams;
+import org.jboss.portal.wsrp.core.NamedString;
+import org.jboss.portal.wsrp.core.UploadContext;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetHeaders;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4
+ */
+abstract class WSRPActionContext extends WSRPPortletInvocationContext implements
ActionContext
+{
+ protected String characterEncoding;
+ protected StateString interactionState;
+
+ protected WSRPActionContext(StateString navigationalState,
+ SecurityContext securityContext, MarkupInfo markupInfo,
PortalContext portalContext,
+ UserContext userContext, InstanceContext instanceContext,
WindowContext windowContext,
+ Mode mode, WindowState windowState, StateString
interactionState, String characterEncoding)
+ {
+ super(navigationalState, securityContext, markupInfo, portalContext, userContext,
instanceContext,
+ windowContext, mode, windowState);
+ this.interactionState = interactionState;
+ this.characterEncoding = characterEncoding;
+ }
+
+
+ public StateString getInteractionState()
+ {
+ return interactionState;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public int getContentLength()
+ {
+ throw new UnsupportedOperationException("Not currently supported");
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ throw new UnsupportedOperationException("Not currently supported");
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ throw new UnsupportedOperationException("Not currently supported");
+ }
+
+
+ static class WSRPSimpleActionContext extends WSRPActionContext
+ {
+ private PortletParameters formParameters;
+ private String contentType;
+
+ protected WSRPSimpleActionContext(StateString navigationalState,
+ SecurityContext securityContext, MarkupInfo
markupInfo, PortalContext portalContext,
+ UserContext userContext, InstanceContext
instanceContext, WindowContext windowContext,
+ Mode mode, WindowState windowState, StateString
interactionState,
+ String characterEncoding, String contentType,
NamedString[] formParams)
+ {
+ super(navigationalState, securityContext, markupInfo, portalContext,
userContext, instanceContext,
+ windowContext, mode, windowState, interactionState, characterEncoding);
+ this.contentType = contentType;
+
+ if (formParams != null && formParams.length > 0)
+ {
+ int length = formParams.length;
+ Map params = new HashMap(length);
+ for (int i = 0; i < length; i++)
+ {
+ NamedString formParam = formParams[i];
+ String paramName = formParam.getName();
+ String paramValue = formParam.getValue();
+ if (params.containsKey(paramName))
+ {
+ // handle multi-valued parameters...
+ String[] oldValues = (String[])params.get(paramName);
+ int valuesLength = oldValues.length;
+ String[] newValues = new String[valuesLength + 1];
+ System.arraycopy(oldValues, 0, newValues, 0, valuesLength);
+ newValues[valuesLength] = paramValue;
+ params.put(paramName, newValues);
+ }
+ else
+ {
+ params.put(paramName, new String[]{paramValue});
+ }
+ }
+ formParameters = new PortletParameters(params);
+ }
+ else
+ {
+ formParameters = new PortletParameters();
+ }
+
+ }
+
+ public PortletParameters getForm()
+ {
+ return formParameters;
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+ }
+
+ static class WSRPMultiActionContext extends WSRPActionContext
+ {
+
+ private byte[] content;
+ private boolean usingStream;
+ private boolean usingReader;
+ private String contentType;
+
+ protected WSRPMultiActionContext(StateString navigationalState, SecurityContext
securityContext,
+ MarkupInfo markupInfo, PortalContext
portalContext, UserContext userContext,
+ InstanceContext instanceContext, WindowContext
windowContext, Mode mode,
+ WindowState windowState, StateString
interactionState, String characterEncoding,
+ NamedString[] formParams, UploadContext[]
uploadContexts) throws IOException, MessagingException
+ {
+ super(navigationalState, securityContext, markupInfo, portalContext,
userContext, instanceContext,
+ windowContext, mode, windowState, interactionState, characterEncoding);
+
+ MimeMultipart parts = new MimeMultipart();
+ if (uploadContexts != null && uploadContexts.length > 0)
+ {
+ for (int i = 0; i < uploadContexts.length; i++)
+ {
+ UploadContext uploadContext = uploadContexts[i];
+
+ InternetHeaders headers = new InternetHeaders();
+ headers.addHeader(FileUpload.CONTENT_TYPE, uploadContext.getMimeType());
+
+ NamedString[] attributes = uploadContext.getMimeAttributes();
+ if (attributes != null && attributes.length > 0)
+ {
+ for (int j = 0; j < attributes.length; j++)
+ {
+ NamedString attribute = attributes[j];
+ headers.addHeader(attribute.getName(), attribute.getValue());
+ }
+ }
+
+ MimeBodyPart mimeBodyPart = new MimeBodyPart(headers,
uploadContext.getUploadData());
+ parts.addBodyPart(mimeBodyPart);
+ }
+ }
+
+ final String paramContentDispositionHeader = FileUpload.FORM_DATA + ";
name=\"";
+ if (formParams != null)
+ {
+ for (int i = 0; i < formParams.length; i++)
+ {
+ NamedString formParam = formParams[i];
+ InternetHeaders headers = new InternetHeaders();
+
+ StringBuffer paramContentDisposition = new
StringBuffer(paramContentDispositionHeader);
+
paramContentDisposition.append(formParam.getName()).append("\"");
+
+ headers.addHeader(FileUpload.CONTENT_DISPOSITION,
paramContentDisposition.toString());
+
+ MimeBodyPart mimeBodyPart = new MimeBodyPart(headers,
formParam.getValue().getBytes());
+ parts.addBodyPart(mimeBodyPart);
+ }
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ parts.writeTo(baos);
+ content = baos.toByteArray();
+ contentType = parts.getContentType();
+ }
+
+ /**
+ * Un-used for now... had started to write the request content by hand, switched to
use Java Mail to get something
+ * done faster, might switch back to it later when there's more time to work on
it to avoid Java Mail dependency
+ */
+ private void createContent(NamedString[] formParams, UploadContext[]
uploadContexts) throws IOException
+ {
+ /*
+ Content-type: multipart/form-data, boundary=AaB03x
+
+ --AaB03x
+ content-disposition: form-data; name="field1"
+
+ Joe Blow
+ --AaB03x
+ content-disposition: form-data; name="pics"
+ Content-type: multipart/mixed, boundary=BbC04y
+
+ --BbC04y
+ Content-disposition: attachment; filename="file1.txt"
+ Content-Type: text/plain
+
+ ... contents of file1.txt ...
+ --BbC04y
+ Content-disposition: attachment; filename="file2.gif"
+ Content-type: image/gif
+ Content-Transfer-Encoding: binary
+
+ ...contents of file2.gif...
+ --BbC04y--
+ --AaB03x--
+ */
+
+ final String MULTIPART_FORM_DATA_BOUNDARY = FileUpload.MULTIPART_FORM_DATA +
"; boundary=";
+ final String JBOSS_PORTAL_FORM_BOUNDARY = "JBP";
+ final String FORM_BOUNDARY1 = JBOSS_PORTAL_FORM_BOUNDARY + "XXX";
+ final String FORM_BOUNDARY2 = JBOSS_PORTAL_FORM_BOUNDARY + "YYY";
+
+ final byte[] NEWLINE = "\n".getBytes(characterEncoding);
+ final byte[] BOUNDARY1 = ("--" + FORM_BOUNDARY1 +
"\n").getBytes(characterEncoding);
+ final byte[] BOUNDARY2 = ("--" + FORM_BOUNDARY2 +
"\n").getBytes(characterEncoding);
+ final byte[] CONTENT_DISPOSITION = ("Content-disposition: form-data;
name=\"").getBytes(characterEncoding);
+ final byte[] CLOSE_CONTENT_DISPOSITION =
"\"\n\n".getBytes(characterEncoding);
+
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+ String begin = "Content-type: " + MULTIPART_FORM_DATA_BOUNDARY +
FORM_BOUNDARY1 + "\n";
+ baos.write(begin.getBytes(characterEncoding));
+ baos.write(NEWLINE);
+
+ if (uploadContexts != null)
+ {
+ for (int i = 0; i < uploadContexts.length; i++)
+ {
+ UploadContext uploadContext = uploadContexts[i];
+
+ }
+
+ }
+
+ if (formParams != null)
+ {
+ for (int i = 0; i < formParams.length; i++)
+ {
+ NamedString formParam = formParams[i];
+ String paramName = formParam.getName();
+ String paramValue = formParam.getValue();
+
+ /*
+ --AaB03x
+ content-disposition: form-data; name="field1"
+
+ Joe Blow
+ */
+ baos.write(BOUNDARY1);
+ baos.write(CONTENT_DISPOSITION);
+ baos.write(paramName.getBytes(characterEncoding));
+ baos.write(CLOSE_CONTENT_DISPOSITION);
+ baos.write(paramValue.getBytes(characterEncoding));
+ baos.write(NEWLINE);
+ }
+
+ }
+ baos.write(NEWLINE);
+ baos.write(BOUNDARY1);
+ }
+
+ public PortletParameters getForm()
+ {
+ return new PortletParameters();
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public int getContentLength()
+ {
+ return content.length;
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ if (usingStream)
+ {
+ throw new IllegalStateException("getInputStream has already been called
on this ActionContext!");
+ }
+ usingReader = true;
+ return new BufferedReader(new InputStreamReader(getInputStreamFromContent()));
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (usingReader)
+ {
+ throw new IllegalStateException("getReader has already been called on
this ActionContext!");
+ }
+ usingStream = true;
+ return getInputStreamFromContent();
+ }
+
+
+ private InputStream getInputStreamFromContent()
+ {
+ return new ByteArrayInputStream(content);
+ }
+ }
+
+ public static WSRPActionContext createActionContext(StateString navigationalState,
SecurityContext securityContext,
+ MarkupInfo markupInfo,
PortalContext portalContext,
+ UserContext userContext,
InstanceContext instanceContext,
+ WindowContext windowContext,
MarkupRequest markupRequest,
+ StateString interactionState,
InteractionParams interactionParams)
+ {
+ NamedString[] formParams = interactionParams.getFormParameters();
+ UploadContext[] uploadContexts = interactionParams.getUploadContexts();
+
+
+ if (uploadContexts != null && uploadContexts.length > 0)
+ {
+ try
+ {
+ return new WSRPMultiActionContext(navigationalState, securityContext,
markupInfo,
+ portalContext, userContext, instanceContext, windowContext,
+ WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
+
WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()),
interactionState,
+ markupRequest.getCharacterSet(), formParams, uploadContexts);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Invalid upload context", e);
+ }
+ }
+ else
+ {
+ return new WSRPSimpleActionContext(navigationalState, securityContext,
markupInfo,
+ portalContext, userContext, instanceContext, windowContext,
+ WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
+ WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()),
interactionState,
+ markupRequest.getCharacterSet(), markupRequest.getMimeType(), formParams);
+
+ }
+ }
+}
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPActionContext.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * 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.wsrp.producer;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.wsrp.WSRPPortletURL;
+import org.jboss.portal.wsrp.WSRPRewritingConstants;
+import org.jboss.portal.wsrp.servlet.ServletAccess;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 5064 $
+ */
+class WSRPPortletInvocationContext extends AbstractPortletInvocationContext implements
PortletInvocationContext
+{
+
+ protected RequestContext requestContext;
+ private SecurityContext securityContext;
+ private PortalContext portalContext;
+ private UserContext userContext;
+ private InstanceContext instanceContext;
+ private WindowContext windowContext;
+
+ private static final String SCH_END = "://";
+ private static final String PORT_END = ":";
+ private static final String EQ = "=";
+ private static final String AMP = "&";
+ private static final String EQ_TRUE = "=true";
+
+ public WSRPPortletInvocationContext(StateString navigationalState, SecurityContext
securityContext,
+ MarkupInfo markupInfo, PortalContext
portalContext, UserContext userContext,
+ InstanceContext instanceContext, WindowContext
windowContext, Mode mode, WindowState windowState)
+ {
+ super(mode, windowState, navigationalState, markupInfo);
+
+ this.securityContext = securityContext;
+ this.markupInfo = markupInfo;
+ this.portalContext = portalContext;
+ this.userContext = userContext;
+ this.instanceContext = instanceContext;
+ this.windowContext = windowContext;
+ this.requestContext = new WSRPRequestContext();
+
+ //
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new
RequestAttributeResolver(ServletAccess.getRequest()));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return ServletAccess.getRequest();
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return ServletAccess.getResponse();
+ }
+
+ /** Override the default behavior in order to avoid to encode when it is producer
written URL. */
+ public String encodeResourceURL(String url)
+ {
+ if (url != null)
+ {
+ if (url.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
+ {
+ // We don't encode URL through this API when it is a wsrp URL
+ return url;
+ }
+ else
+ {
+ StringBuffer sb;
+ if (!URLTools.isNetworkURL(url))
+ {
+ // URL is not an absolute URL so we need to build one
+ HttpServletRequest req = getClientRequest();
+ String scheme = req.getScheme();
+ String host = req.getServerName();
+ int port = req.getServerPort();
+ sb = new StringBuffer(url.length() * 2);
+
sb.append(scheme).append(SCH_END).append(host).append(PORT_END).append(port).append(url);
+ url = sb.toString();
+ }
+
+ url = URLTools.encodeXWWWFormURL(url);
+
+ // build the WSRP resource URL with rewrite tokens
+ sb = new StringBuffer(url.length() * 2);
+
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
+ .append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
+ .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
+ .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
+ .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
+ return sb.toString();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * <p>URL to be re-written are of the form:
<code>wsrp_rewrite?wsrp-urlType=value&amp;name1=value1&amp;name2=value2
+ * .../wsrp_rewrite</code> </p> <ul>Examples: <li>Load a
resource
http://test.com/images/test.gif: <br/>
+ *
<code>wsrp_rewrite?wsrp-urlType=resource&amp;wsrp-url=http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif&amp;wsrp-requiresRewrite=true/wsrp_rewrite</code></li>
+ * <li>Declare a secure interaction back to the Portlet:<br/>
<code>wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-secureURL=true&amp;wsrp-navigationalState=a8h4K5JD9&amp;wsrp-interactionState=fg4h923mdk/wsrp_rewrite</code></li>
+ * <li>Request the Consumer render the Portlet in a different mode and window
state:
+ *
<code>wsrp_rewrite?wsrp-urlType=render&amp;wsrp-mode=help&amp;wsrp-windowState=maximized/wsrp_rewrite</code></li>
+ * </ul>
+ *
+ * @param portletURL
+ * @param wantSecure
+ * @param wantAuthenticated
+ * @param relative
+ * @return the encoded url
+ */
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ if (portletURL != null)
+ {
+ return WSRPPortletURL.create(portletURL,
Boolean.TRUE.equals(wantSecure)).toString();
+ }
+ return null;
+ }
+
+ public void contextualize(PortletInvocation invocation)
+ {
+ invocation.setRequestContext(requestContext);
+ invocation.setSecurityContext(securityContext);
+ invocation.setInstanceContext(instanceContext);
+ invocation.setWindowContext(windowContext);
+ invocation.setPortalContext(portalContext);
+ invocation.setUserContext(userContext);
+ }
+}
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-23
04:48:51 UTC (rev 8436)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -391,13 +391,13 @@
}
catch (NoSuchPortletException e)
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Couldn't find portlet with handle
'" + portletContext.getId() + "'"));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Couldn't find portlet with handle '" +
portletContext.getId() + "'", null);
}
if (!isRemotable(portlet))
{
- throw
(InvalidHandleFault)WSRPExceptionFactory.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Portlet '" +
portletContext.getId() + "' is not remotely available."));
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Portlet '" + portletContext.getId() + "' is not
remotely available.", null);
}
return portlet;
@@ -447,10 +447,19 @@
{
if (!isRegistrationValid(registrationContext))
{
- IllegalArgumentException cause = new
IllegalArgumentException(registrationContext + " is not a valid
registration.");
- log.debug(cause);
- throw
(InvalidRegistrationFault)WSRPExceptionFactory.createFaultFrom(InvalidRegistrationFault.class,
- cause);
+ String message;
+ if (registrationContext != null)
+ {
+ message = "Registration associated with registration handle '"
+ registrationContext.getRegistrationHandle()
+ + "' is not a valid registration";
+ }
+ else
+ {
+ message = "The given registration context was null";
+ }
+
+ log.debug(message);
+ throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
message, null);
}
}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRenderContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRenderContext.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRenderContext.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.wsrp.producer;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+class WSRPRenderContext extends WSRPPortletInvocationContext implements RenderContext
+{
+
+ public WSRPRenderContext(StateString navigationalState, SecurityContext
securityContext,
+ MarkupInfo markupInfo, PortalContext portalContext,
UserContext userContext,
+ InstanceContext instanceContext, WindowContext windowContext,
Mode mode, WindowState windowState)
+ {
+ super(navigationalState, securityContext, markupInfo, portalContext, userContext,
instanceContext,
+ windowContext, mode, windowState);
+ }
+}
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRenderContext.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRequestContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRequestContext.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRequestContext.java 2007-09-23
04:56:34 UTC (rev 8437)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.wsrp.producer;
+
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.wsrp.servlet.ServletAccess;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+class WSRPRequestContext extends AbstractRequestContext implements RequestContext
+{
+ public WSRPRequestContext()
+ {
+ super(ServletAccess.getRequest(), ServletAccess.getResponse());
+ }
+}
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPRequestContext.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native