JBoss Portal SVN: r5994 - docs/tags.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-11 08:16:32 -0500 (Thu, 11 Jan 2007)
New Revision: 5994
Added:
docs/tags/JBoss_Portal_2_6_0_ALPHA1/
Log:
tagging 2.6 alpha
Copied: docs/tags/JBoss_Portal_2_6_0_ALPHA1 (from rev 5993, docs/trunk)
19 years, 3 months
JBoss Portal SVN: r5993 - tags.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-11 08:16:13 -0500 (Thu, 11 Jan 2007)
New Revision: 5993
Added:
tags/JBoss_Portal_2_6_0_ALPHA1/
Log:
tagging 2.6 alpha
Copied: tags/JBoss_Portal_2_6_0_ALPHA1 (from rev 5992, trunk)
19 years, 3 months
JBoss Portal SVN: r5992 - trunk/core/src/resources/portal-core-sar.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-11 07:36:34 -0500 (Thu, 11 Jan 2007)
New Revision: 5992
Modified:
trunk/core/src/resources/portal-core-sar/portal-aop.xml
Log:
update tx aspect weaving such as an invalid portlet id during the runtime invocation of a portlet does not set the tx as rollback only
Modified: trunk/core/src/resources/portal-core-sar/portal-aop.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-01-11 11:01:02 UTC (rev 5991)
+++ trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-01-11 12:36:34 UTC (rev 5992)
@@ -109,6 +109,7 @@
</method>
<method name="invoke">
<trans-attribute>Required</trans-attribute>
+ <application-exceptions>org.jboss.portal.portlet.InvalidPortletIdException</application-exceptions>
</method>
</metadata>
<metadata
@@ -122,6 +123,7 @@
</method>
<method name="invoke">
<trans-attribute>Required</trans-attribute>
+ <application-exceptions>org.jboss.portal.portlet.InvalidPortletIdException</application-exceptions>
</method>
</metadata>
</aop>
\ No newline at end of file
19 years, 3 months
JBoss Portal SVN: r5991 - in trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default: private and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-11 06:01:02 -0500 (Thu, 11 Jan 2007)
New Revision: 5991
Modified:
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/index.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/support.html
Log:
removed commented html in cms content
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/index.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/index.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/index.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -62,41 +62,3 @@
developing it!</p>
<p>Baci e abbracci,<br/>
The JBoss Portal Team.</p>
-
-<!--
-<table width="100%" border="0" cellpadding="2">
-<tr>
-<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Portal provides an open source platform for hosting and serving a portal's Web interface, publishing and managing its content, and customizing its experience. While most packaged Portal frameworks help enterprises launch Portals more quickly, only JBoss Portal delivers the benefits of a zero-cost open source license combined with a flexible and scalable underlying platform.</font></td>
-<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
-<tr>
-<td colspan="2"><table width="100%" border="0">
-<tr>
-<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="default/support.html"><img src="default/images/support.gif" border="0"></a></td>
-<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>Support Services</b><br/>
-JBoss Inc. offers various support services tailored to fit your needs. <a href="default/support.html">Click here</a> to explore support and service options related to JBoss Portal.
-</font></td>
-</tr>
-<tr>
-<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="http://www.portletswap.com" target="_blank"><img src="default/images/plugin.gif" border="0"></a></td>
-<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>PortletSwap</b><br/>
-<a href="http://www.portletswap.com" target="_blank">PortletSwap.com</a> is a open community sponsored by JBoss, Inc. to facilitate the exchange of portlets and layouts for use in JBoss Portal. <a href="http://www.portletswap.com" target="_blank">Click here</a> to visit PortletSwap.com.
-</font></td>
-</tr>
-<tr>
-<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="default/project.html"><img src="default/images/project.gif" border="0"></a></td>
-<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>Project Information</b><br/>
-<a href="default/project.html">Click here</a> to learn more about the JBoss Portal project, on-going development, open issues, and our vibrant user and developer communities.
-</font></td>
-</tr>
-</table>
-</tr>
-<tr>
-<td colspan="2" align="left" class="portlet-section-body"><font class="portlet-font">
-Thank you for downloading and deploying JBoss Portal. We hope you enjoy working with it as much as we enjoy developing it!
-<br/><br/>
-Bacci e Abracci,<br/>
-The JBoss Portal Team.
-</font></td>
-</tr>
-</table>
--->
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -1,4 +1,3 @@
-<!-- begin: portlet content -->
<table width="100%" border="0" cellpadding="2">
<tr>
<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document2: This is a protected document. This is used to test the fine grained access control</b></font></td>
@@ -35,4 +34,3 @@
</table>
<br/>
<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
-<!-- end: portlet content -->
\ No newline at end of file
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -1,4 +1,3 @@
-<!-- begin: portlet content -->
<table width="100%" border="0" cellpadding="2">
<tr>
<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document3: This is a protected document. This is used to test the fine grained access control</b></font></td>
@@ -35,4 +34,3 @@
</table>
<br/>
<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
-<!-- end: portlet content -->
\ No newline at end of file
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -1,4 +1,3 @@
-<!-- begin: portlet content -->
<table width="100%" border="0" cellpadding="2">
<tr>
<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document1: This is a protected document. This is used to test the fine grained access control</b></font></td>
@@ -35,4 +34,3 @@
</table>
<br/>
<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
-<!-- end: portlet content -->
\ No newline at end of file
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -1,4 +1,3 @@
-<!-- begin: portlet content -->
<table width="100%" border="0" cellpadding="2">
<tr>
<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the
@@ -66,4 +65,4 @@
</table>
<br/>
<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
-<!-- end: portlet content -->
+
Modified: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/support.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/support.html 2007-01-11 05:53:57 UTC (rev 5990)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/support.html 2007-01-11 11:01:02 UTC (rev 5991)
@@ -1,4 +1,3 @@
-<!-- begin: portlet content -->
<table width="100%" border="0" cellpadding="2">
<tr>
<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the Professional Support, Consulting, and Training that you need whether you are testing a proof of concept, deploying a mission-critical application, or rolling out JEMS across your enterprise. </font></td>
@@ -35,4 +34,3 @@
</table>
<br/>
<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
-<!-- end: portlet content -->
\ No newline at end of file
19 years, 3 months
JBoss Portal SVN: r5990 - in trunk/wsrp: src/main/org/jboss/portal/test/wsrp/portlet and 5 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-11 00:53:57 -0500 (Thu, 11 Jan 2007)
New Revision: 5990
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/
trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/
trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml
trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- Implicit cloning should now work on the producer.
- More fixes to use portlet context where appropriate instead of handle.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/build.xml 2007-01-11 05:53:57 UTC (rev 5990)
@@ -522,6 +522,9 @@
<!-- MultiValuedContext test portlet -->
<package-test-portlet archiveName="multivalued" portletName="MultiValued"/>
+
+ <!-- ImplicitCloning test portlet -->
+ <package-test-portlet archiveName="implicitcloning" portletName="ImplicitCloning"/>
</target>
<!-- Packages all the test related artifacts. Note that compilation should have been already executed -->
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -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.test.wsrp.portlet;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ImplicitCloningPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ String value = request.getParameter("value");
+ if (value == null)
+ {
+ value = "default";
+ }
+
+ PortletPreferences pp = request.getPreferences();
+ pp.setValue("name", value);
+ pp.store();
+ }
+
+
+ protected void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ response.setContentType("text/html");
+ PortletPreferences pp = request.getPreferences();
+ String value = pp.getValue("name", "default");
+ response.getWriter().write(value);
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -39,8 +39,10 @@
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;
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;
@@ -86,14 +88,9 @@
}
}
- /**
- * The consumer should never have access to or be able to set a sessionID. Sessions are handled by the Producer using
- * cookies.
- *
- * @throws Exception
- */
public void testGetMarkupWithSessionID() throws Exception
{
+ // The consumer should never have access to or be able to set a sessionID. Sessions are handled by the Producer using cookies.
GetMarkup getMarkup = createMarkupRequest();
getMarkup.getRuntimeContext().setSessionID("Hello World");
@@ -114,12 +111,12 @@
getMarkup.getMarkupParams().setMode(WSRPConstants.EDIT_MODE);
MarkupResponse response = markupService.getMarkup(getMarkup);
- /*
+
// commented out because fails with fragment processing de-activation
+// checkMarkupResponse(response, "<form method='post' action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
+// "-interactionState=JBPNS_/wsrp_rewrite' id='wsrp_rewrite_portfolioManager'><table><tr><td>Stock symbol</t" +
+// "d><td><input name='symbol'/></td></tr><tr><td><input type='submit' value='Submit'></td></tr></table></form>");
checkMarkupResponse(response, "<form method='post' action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
- "-interactionState=JBPNS_/wsrp_rewrite' id='wsrp_rewrite_portfolioManager'><table><tr><td>Stock symbol</t" +
- "d><td><input name='symbol'/></td></tr><tr><td><input type='submit' value='Submit'></td></tr></table></form>");*/
- checkMarkupResponse(response, "<form method='post' action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
"-interactionState=JBPNS_/wsrp_rewrite' id='portfolioManager'><table><tr><td>Stock symbol</t" +
"d><td><input name='symbol'/></td></tr><tr><td><input type='submit' value='Submit'></td></tr></table></form>");
}
@@ -193,17 +190,16 @@
checkMarkupResponseWithSession(response, 1);
// fix-me: try to reuse the old session id: what should happen?
- /*runtimeContext.setSessionID(sessionID);
- getMarkup.setRuntimeContext(runtimeContext);
- try
- {
- markupService.getMarkup(getMarkup);
- fail("The session should be invalid...");
- }
- catch (InvalidSessionFault fault)
- {
- // expected
- }*/
+// runtimeContext.setSessionID(sessionID);
+// getMarkup.setRuntimeContext(runtimeContext);
+// try
+// {
+// markupService.getMarkup(getMarkup);
+// fail("The session should be invalid...");
+// }
+// catch (InvalidSessionFault expected)
+// {
+// }
// reset state
undeploy(sessionPortletArchive);
@@ -247,12 +243,7 @@
checkMarkupResponse(response, "<p>" + symbol + " stock value: 123.45</p>");
}
- /**
- * The consumer should never have access to or be able to set a sessionID. The sessions are handled by the producer
- * using cookies.
- *
- * @throws Exception
- */
+
public void testPBIWithSessionID() throws Exception
{
String portletHandle = getDefaultHandle();
@@ -267,9 +258,8 @@
markupService.performBlockingInteraction(performBlockingInteraction);
ExtendedAssert.fail("Should not be able to pass a sessionID in a PerformBlockingInteraction()");
}
- catch (OperationFailedFault operationFailedFault)
+ catch (OperationFailedFault expected)
{
- // expected failure
}
}
@@ -296,50 +286,6 @@
undeploy(sessionPortletArchive);
}
- /*public void testReleaseSessions() throws Exception
- {
- undeploy(DEFAULT_MARKUP_PORTLET_WAR);
- String sessionPortletArchive = "test-session-portlet.war";
- deploy(sessionPortletArchive);
-
- initRegistrationInfo();
- RegistrationContext rc = registerConsumer();
-
- GetMarkup gm = createMarkupRequest(sessionPortletArchive);
- gm.setRegistrationContext(rc);
- MarkupResponse res = markupService.getMarkup(gm);
-
- ReleaseSessions releaseSessions = new ReleaseSessions(rc, null);
-
- try
- {
- markupService.releaseSessions(releaseSessions);
- fail("No session IDs provided when some were expected.");
- }
- catch (MissingParametersFault missingParametersFault)
- {
- //expected
- }
-
- String sessionID = res.getSessionContext().getSessionID();
- releaseSessions.setSessionIDs(new String[]{sessionID});
- markupService.releaseSessions(releaseSessions);
-
- gm.getRuntimeContext().setSessionID(sessionID);
- try
- {
- markupService.getMarkup(gm);
- fail("Should have failed: try to get markup using a released session id.");
- }
- catch (InvalidSessionFault invalidSessionFault)
- {
- // expected
- }
-
- undeploy(sessionPortletArchive);
- resetRegistrationInfo();
- }*/
-
public void testGetMarkupWithDispatcherPortlet() throws Exception
{
@@ -385,9 +331,8 @@
//fail("Should have trown an UnsupportetLocaleFault"); // ideally cf http://jira.jboss.com/jira/browse/JBPORTAL-857
ExtendedAssert.fail("Should have trown an exception"); // right now
}
- catch (Exception e)
+ catch (Exception expected)
{
- // expected
}
// checkMarkupResponse(response, "GetLocalesPortlet"); // should we return try to generate markup regardless?
@@ -457,6 +402,44 @@
undeploy(multiValuedPortletArchive);
}
+ public void testImplicitCloning() throws Exception
+ {
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String archiveName = "test-implicitcloning-portlet.war";
+ deploy(archiveName);
+
+ // check the initial value
+ GetMarkup gm = createMarkupRequestForCurrentlyDeployedPortlet();
+ MarkupResponse res = markupService.getMarkup(gm);
+ String markupString = res.getMarkupContext().getMarkupString();
+ ExtendedAssert.assertEquals("initial", markupString);
+
+ // modify the preference value
+ PerformBlockingInteraction pbi = WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ pbi.getInteractionParams().setPortletStateChange(StateChange.cloneBeforeWrite); // request cloning if needed
+ String value = "new value";
+ pbi.getInteractionParams().setFormParameters(new NamedString[]{new NamedString("value", value)});
+ BlockingInteractionResponse response = markupService.performBlockingInteraction(pbi);
+ ExtendedAssert.assertNotNull(response);
+
+ // check that we got a new portlet context
+ PortletContext pc = response.getUpdateResponse().getPortletContext();
+ ExtendedAssert.assertNotNull(pc);
+
+ // get the markup again and check that we still get the initial value with the initial portlet context
+ res = markupService.getMarkup(gm);
+ markupString = res.getMarkupContext().getMarkupString();
+ ExtendedAssert.assertEquals("initial", markupString);
+
+ // retrieving the markup with the new portlet context should return the new value
+ gm.setPortletContext(pc);
+ res = markupService.getMarkup(gm);
+ markupString = res.getMarkupContext().getMarkupString();
+ ExtendedAssert.assertEquals(value, markupString);
+
+ undeploy(archiveName);
+ }
+
private String checkPBIAndGetNavigationalState(String symbol) throws Exception
{
PerformBlockingInteraction performBlockingInteraction =
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -119,8 +119,8 @@
void initInvocation(StateString navigationalState, SecurityContext securityContext,
HTTPStreamInfo streamInfo, PortalContext portalContext,
UserContext userContext,
- WindowContext windowContext
- )
+ WindowContext windowContext,
+ org.jboss.portal.portlet.PortletContext portletContext)
{
PortletParameters parameters;
NamedString[] formParams = interactionParams.getFormParameters();
@@ -164,7 +164,7 @@
markupRequest.getCharacterSet(), markupRequest.getMimeType());
setInvocation(new ActionInvocation(actionContext));
actionContext.contextualize(invocation);
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
}
Object processResponse(PortletInvocationResponse response)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -111,8 +111,8 @@
void initInvocation(StateString navigationalState, SecurityContext securityContext,
HTTPStreamInfo streamInfo, PortalContext portalContext,
UserContext userContext,
- WindowContext windowContext
- )
+ WindowContext windowContext,
+ org.jboss.portal.portlet.PortletContext portletContext)
{
WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, streamInfo,
portalContext, userContext, instanceContext, windowContext,
@@ -121,7 +121,7 @@
setInvocation(new RenderInvocation(renderContext));
renderContext.contextualize(invocation);
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
}
Object processResponse(PortletInvocationResponse response)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -102,14 +102,12 @@
// get portlet handle
PortletContext wsrpPC = getPortletContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(wsrpPC, "PortletContext", getContextName());
- final String portletHandle = wsrpPC.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
- org.jboss.portal.portlet.PortletContext originalPortletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);
+ org.jboss.portal.portlet.PortletContext portletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);
// retrieve the portlet
try
{
- portlet = producer.getPortletWith(originalPortletContext);
+ portlet = producer.getPortletWith(portletContext);
}
catch (PortletInvokerException e)
{
@@ -118,7 +116,7 @@
// get portlet description for the desired portlet...
final String[] desiredLocales = params.getLocales();
- portletDescription = producer.getPortletDescription(wsrpPC, desiredLocales);
+ portletDescription = producer.getPortletDescription(portlet, desiredLocales);
if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
{
throw WSRPUtils.createOperationFailedFault(
@@ -139,11 +137,12 @@
HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
PortalContext portalContext = createPortalContext(params, markupRequest);
UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
- instanceContext = createInstanceContext(portletHandle, getAccessMode());
- WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
+ instanceContext = createInstanceContext(portletContext, getAccessMode());
+ WindowContext windowContext = createWindowContext(portletContext.getId(), runtimeContext);
// prepare the invocation
- initInvocation(navigationalState, securityContext, streamInfo, portalContext, userContext, windowContext);
+ // TODO: must pass the portlet context since the retrieved portlet points to the POP, not clones: is it expected?
+ initInvocation(navigationalState, securityContext, streamInfo, portalContext, userContext, windowContext, portletContext);
}
abstract RegistrationContext getRegistrationContext();
@@ -162,7 +161,7 @@
abstract void initInvocation(StateString navigationalState, SecurityContext securityContext,
HTTPStreamInfo streamInfo, PortalContext portalContext, UserContext userContext,
- WindowContext windowContext);
+ WindowContext windowContext, org.jboss.portal.portlet.PortletContext portletContext);
abstract Object processResponse(PortletInvocationResponse response);
@@ -310,9 +309,9 @@
}
}
- private WSRPInstanceContext createInstanceContext(final String portletHandle, final AccessMode accessMode)
+ private WSRPInstanceContext createInstanceContext(org.jboss.portal.portlet.PortletContext portletContext, final AccessMode accessMode)
{
- return new WSRPInstanceContext(portletHandle, accessMode);
+ return new WSRPInstanceContext(portletContext, accessMode);
}
private WindowContext createWindowContext(final String portletHandle, final RuntimeContext runtimeContext)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -104,7 +104,7 @@
for (Iterator iterator = portlets.iterator(); iterator.hasNext();)
{
Portlet portlet = (Portlet)iterator.next();
- PortletDescription desc = createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
+ PortletDescription desc = getPortletDescription(portlet, desiredLocales);
offeredPortletDescriptions.add(desc);
}
@@ -123,7 +123,7 @@
{
throw WSRPUtils.createOperationFailedFault(e);
}
- return createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
+ return getPortletDescription(portlet, desiredLocales);
}
/**
@@ -185,16 +185,17 @@
* Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
* specified component.
*
- * @param portletInfo
+ * @param portlet
* @param desiredLocales the user desired locales (ordered according to user preferences) to use for the description
- * @param id
* @return a PortletDescription describing the specified portlet
*/
- private PortletDescription createPortletDescriptionFrom(PortletInfo portletInfo, String[] desiredLocales, String id)
+ PortletDescription getPortletDescription(Portlet portlet, String[] desiredLocales)
{
+ String id = portlet.getContext().getId();
+ PortletInfo info = portlet.getInfo();
log.debug("Constructing portlet description for: " + id);
- CapabilitiesInfo capInfo = portletInfo.getCapabilities();
+ CapabilitiesInfo capInfo = info.getCapabilities();
Collection allMimeTypes = capInfo.getMimeTypes();
MarkupType[] markupTypes = new MarkupType[allMimeTypes.size()];
Iterator mimeTypes = allMimeTypes.iterator();
@@ -214,7 +215,7 @@
// todo: group ID
- MetaInfo metaInfo = portletInfo.getMeta();
+ MetaInfo metaInfo = info.getMeta();
// description
desc.setDescription(WSRPUtils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.DESCRIPTION), desiredLocales));
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.spi.InstanceContext;
import org.jboss.portal.portlet.state.AccessMode;
@@ -35,23 +36,22 @@
*/
class WSRPInstanceContext implements InstanceContext
{
- private String id;
- private byte[] state;
+ private PortletContext context;
private final AccessMode accessMode;
private boolean wasModified = false;
- public WSRPInstanceContext(String portletHandle, AccessMode accessMode)
+ public WSRPInstanceContext(PortletContext portletContext, AccessMode accessMode)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle, "portlet handle", "InstanceContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "AccessMode");
- this.id = portletHandle;
+ this.context = portletContext;
this.accessMode = accessMode;
}
public String getId()
{
- return id;
+ return context.getId();
}
public AccessMode getAccessMode()
@@ -61,11 +61,10 @@
public void onStateEvent(StateEvent event)
{
- org.jboss.portal.portlet.PortletContext portletContext = event.getPortletContext();
+ PortletContext portletContext = event.getPortletContext();
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
wasModified = true;
- id = portletContext.getId();
- state = portletContext.getState();
+ context = portletContext;
}
public boolean wasModified()
@@ -75,6 +74,6 @@
public byte[] getState()
{
- return state;
+ return context.getState();
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-01-11 05:53:57 UTC (rev 5990)
@@ -414,6 +414,11 @@
return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
}
+ public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
+ {
+ return serviceDescriptionHandler.getPortletDescription(portlet, locales);
+ }
+
/**
* Checks that the specified registration information is valid if this Producer requires registration.
*
Added: trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml 2007-01-11 05:53:57 UTC (rev 5990)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+ <portlet>
+ <portlet-name>Implicit Cloning Test Portlet</portlet-name>
+ <portlet-class>org.jboss.portal.test.wsrp.portlet.ImplicitCloningPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>view</portlet-mode>
+ </supports>
+
+ <portlet-info>
+ <title>title</title>
+ </portlet-info>
+
+ <portlet-preferences>
+ <preference>
+ <name>name</name>
+ <value>initial</value>
+ </preference>
+ </portlet-preferences>
+ </portlet>
+
+</portlet-app>
\ No newline at end of file
Added: trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml 2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml 2007-01-11 05:53:57 UTC (rev 5990)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+</web-app>
\ No newline at end of file
19 years, 3 months
JBoss Portal SVN: r5989 - trunk/portlet/src/main/org/jboss/portal/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-10 19:47:25 -0500 (Wed, 10 Jan 2007)
New Revision: 5989
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/InvalidPortletIdException.java
trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java
Log:
minor javadoc on NoSuchPortletException and InvalidPortletIdException
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/InvalidPortletIdException.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/InvalidPortletIdException.java 2007-01-11 00:44:24 UTC (rev 5988)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/InvalidPortletIdException.java 2007-01-11 00:47:25 UTC (rev 5989)
@@ -23,6 +23,8 @@
package org.jboss.portal.portlet;
/**
+ * Thrown by the portlet invoker when a portlet id that is not valid.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java 2007-01-11 00:44:24 UTC (rev 5988)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java 2007-01-11 00:47:25 UTC (rev 5989)
@@ -23,6 +23,8 @@
package org.jboss.portal.portlet;
/**
+ * Thrown by the portlet invoker when a portlet id does not exist.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
19 years, 3 months
JBoss Portal SVN: r5988 - in trunk: wsrp/src/main/org/jboss/portal/wsrp/producer and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-10 19:44:24 -0500 (Wed, 10 Jan 2007)
New Revision: 5988
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
Log:
make NoSuchPortletException extend InvalidPortletIdException because it makes more sense like that
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java 2007-01-10 23:27:44 UTC (rev 5987)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/NoSuchPortletException.java 2007-01-11 00:44:24 UTC (rev 5988)
@@ -26,37 +26,26 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class NoSuchPortletException extends PortletInvokerException
+public class NoSuchPortletException extends InvalidPortletIdException
{
- private String portletId;
-
public NoSuchPortletException(String portletId)
{
- super("No such portlet " + portletId);
- this.portletId = portletId;
+ super("No such portlet " + portletId, portletId);
}
public NoSuchPortletException(String message, String portletId)
{
- super(message);
- this.portletId = portletId;
+ super(message, portletId);
}
public NoSuchPortletException(Throwable cause, String portletId)
{
- super(cause);
- this.portletId = portletId;
+ super(cause, portletId);
}
public NoSuchPortletException(String message, Throwable cause, String portletId)
{
- super(message, cause);
- this.portletId = portletId;
+ super(message, cause, portletId);
}
-
- public String getPortletId()
- {
- return portletId;
- }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-01-10 23:27:44 UTC (rev 5987)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-01-11 00:44:24 UTC (rev 5988)
@@ -175,11 +175,11 @@
org.jboss.portal.portlet.PortletContext response = producer.getInvoker().createClone(portalPC);
return WSRPUtils.convertToWSRPPortletContext(response);
}
- catch (InvalidPortletIdException e)
+ catch (NoSuchPortletException e)
{
throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
}
- catch (NoSuchPortletException e)
+ catch (InvalidPortletIdException e)
{
throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
}
@@ -296,14 +296,14 @@
(PropertyChange[])changes.toArray(new PropertyChange[0]));
return WSRPUtils.convertToWSRPPortletContext(resultContext);
}
+ catch (NoSuchPortletException e)
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
+ }
catch (InvalidPortletIdException e)
{
throw (InconsistentParametersFault)WSRPUtils.createFaultFrom(InconsistentParametersFault.class, e);
}
- catch (NoSuchPortletException e)
- {
- throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
- }
catch (PortletInvokerException e)
{
throw WSRPUtils.createOperationFailedFault(e);
19 years, 3 months
JBoss Portal SVN: r5987 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: producer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-10 18:27:44 -0500 (Wed, 10 Jan 2007)
New Revision: 5987
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPActionContext.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- Re-factored MarkupHandler to extract common code into RequestProcessor and sub-classes.
- Use portlet context where appropriate.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPActionContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPActionContext.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPActionContext.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -58,7 +58,7 @@
public WSRPActionContext(StateString navigationalState,
SecurityContext securityContext, HTTPStreamInfo streamInfo, PortalContext portalContext,
UserContext userContext, InstanceContext instanceContext, WindowContext windowContext,
- StateString interactionState, Mode mode, WindowState windowState,
+ Mode mode, WindowState windowState, StateString interactionState,
PortletParameters formParameters, String characterEncoding, String contentType)
{
super(navigationalState, securityContext, streamInfo, portalContext, userContext, instanceContext,
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -0,0 +1,204 @@
+/******************************************************************************
+ * 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.producer;
+
+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.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+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.portlet.state.AccessMode;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.core.InteractionParams;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+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;
+import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.RuntimeContext;
+import org.jboss.portal.wsrp.core.StateChange;
+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.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$
+ * @since 2.6
+ */
+class ActionRequestProcessor extends RequestProcessor
+{
+ private final PerformBlockingInteraction performBlockingInteraction;
+ private final InteractionParams interactionParams;
+
+ public ActionRequestProcessor(WSRPProducerImpl producer, PerformBlockingInteraction performBlockingInteraction, InteractionParams interactionParams)
+ throws UnsupportedMimeTypeFault, UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault,
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault
+ {
+ super(producer);
+ this.performBlockingInteraction = performBlockingInteraction;
+ this.interactionParams = interactionParams;
+ prepareInvocation();
+ }
+
+ RegistrationContext getRegistrationContext()
+ {
+ return performBlockingInteraction.getRegistrationContext();
+ }
+
+ RuntimeContext getRuntimeContext()
+ {
+ return performBlockingInteraction.getRuntimeContext();
+ }
+
+ MarkupParams getMarkupParams()
+ {
+ return performBlockingInteraction.getMarkupParams();
+ }
+
+ PortletContext getPortletContext()
+ {
+ return performBlockingInteraction.getPortletContext();
+ }
+
+ org.jboss.portal.wsrp.core.UserContext getUserContext()
+ {
+ return performBlockingInteraction.getUserContext();
+ }
+
+ String getContextName()
+ {
+ return MarkupHandler.PBI;
+ }
+
+ AccessMode getAccessMode() throws MissingParametersFault
+ {
+ StateChange stateChange = interactionParams.getPortletStateChange();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(stateChange, "portletStateChange", "InteractionParams");
+ return WSRPUtils.getAccessModeFromStateChange(stateChange);
+ }
+
+ void initInvocation(StateString navigationalState, SecurityContext securityContext,
+ HTTPStreamInfo streamInfo, PortalContext portalContext,
+ UserContext userContext,
+ 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, streamInfo,
+ portalContext, userContext, instanceContext, windowContext,
+ WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
+ WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()), interactionState, parameters,
+ markupRequest.getCharacterSet(), markupRequest.getMimeType());
+ setInvocation(new ActionInvocation(actionContext));
+ actionContext.contextualize(invocation);
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ }
+
+ Object processResponse(PortletInvocationResponse response)
+ {
+ if (response instanceof RenderResponse)
+ {
+ RenderResponse renderResult = (RenderResponse)response;
+ UpdateResponse updateResponse = WSRPTypeFactory.createUpdateResponse();
+ updateResponse.setNewMode(WSRPUtils.convertJSR168PortletModeNameToWSRPName(getNewStateOrNull(renderResult, true)));
+ updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(renderResult, false)));
+ StateString ns = renderResult.getNavigationalState();
+ updateResponse.setNavigationalState(ns != null ? ns.getStringValue() : null);
+
+ // deal with implicit cloning and state modification
+ if (instanceContext.wasModified())
+ {
+ PortletContext updatedPortletContext = WSRPTypeFactory.createPortletContext(instanceContext.getId());
+ updatedPortletContext.setPortletState(instanceContext.getState());
+ updateResponse.setPortletContext(updatedPortletContext);
+ }
+
+ return WSRPTypeFactory.createBlockingInteractionResponse(updateResponse);
+ }
+ else
+ {
+ // result should be HTTPRedirectionResult
+ HTTPRedirectionResponse redirectionResult = (HTTPRedirectionResponse)response;
+ return WSRPTypeFactory.createBlockingInteractionResponse(redirectionResult.getLocation());
+ }
+ }
+
+ private String getNewStateOrNull(RenderResponse renderResult, boolean forMode)
+ {
+ Object state = forMode ? (Object)renderResult.getMode() : renderResult.getWindowState();
+ return state != null ? state.toString() : null;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -24,36 +24,13 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.MediaType;
-import org.jboss.portal.common.util.LocaleInfo;
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.portlet.OpaqueStateString;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateEvent;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.RenderResponse;
-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.portlet.state.AccessMode;
import org.jboss.portal.portlet.state.producer.PortletStateChangeRequiredException;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-import org.jboss.portal.wsrp.UserContextConverter;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
@@ -66,44 +43,23 @@
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.InvalidSessionFault;
import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
-import org.jboss.portal.wsrp.core.MarkupContext;
-import org.jboss.portal.wsrp.core.MarkupParams;
import org.jboss.portal.wsrp.core.MarkupResponse;
-import org.jboss.portal.wsrp.core.MarkupType;
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;
-import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
import org.jboss.portal.wsrp.core.ReleaseSessions;
import org.jboss.portal.wsrp.core.ReturnAny;
-import org.jboss.portal.wsrp.core.RuntimeContext;
-import org.jboss.portal.wsrp.core.StateChange;
import org.jboss.portal.wsrp.core.UnsupportedLocaleFault;
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.UpdateResponse;
import org.jboss.portal.wsrp.core.UploadContext;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
-import org.jboss.portal.wsrp.invocation.WSRPActionContext;
-import org.jboss.portal.wsrp.invocation.WSRPRenderContext;
-import javax.activation.MimeTypeParseException;
import javax.portlet.PortletModeException;
import javax.portlet.WindowStateException;
import java.rmi.RemoteException;
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -112,15 +68,12 @@
*/
class MarkupHandler extends ServiceHandler implements WSRP_v1_Markup_PortType
{
- private static final String WINDOW_STATE = "window state";
- private static final String PORTLET_MODE = "portlet mode";
- private static final String PBI = "PerformBlockingInteraction";
- private static final String GET_MARKUP = "GetMarkup";
+ static final String PBI = "PerformBlockingInteraction";
+ static final String GET_MARKUP = "GetMarkup";
private Logger log = Logger.getLogger(MarkupHandler.class);
- private static final String EMPTY = "";
- private static final String CHARSET_SEPARATOR = "; charset=";
+
MarkupHandler(WSRPProducerImpl producer)
{
super(producer);
@@ -134,71 +87,16 @@
OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault,
UnsupportedMimeTypeFault, RemoteException
{
+
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getMarkup, GET_MARKUP);
- producer.checkRegistration(getMarkup.getRegistrationContext());
- // get session information and deal with it
- final RuntimeContext runtimeContext = getMarkup.getRuntimeContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(runtimeContext, "RuntimeContext", GET_MARKUP);
+ RequestProcessor requestProcessor = new RenderRequestProcessor(producer, getMarkup);
- checkForSessionIDs(runtimeContext);
-
- // get markup parameters
- final MarkupParams params = getMarkup.getMarkupParams();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(params, "MarkupParams", GET_MARKUP);
-
- // get portlet handle
- PortletContext portletContext = getMarkup.getPortletContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", GET_MARKUP);
- final String portletHandle = portletContext.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
-
- // retrieve the portlet
- Portlet portlet;
- try
- {
- portlet = producer.getPortletWith(portletHandle);
- }
- catch (PortletInvokerException e)
- {
- throw WSRPUtils.createOperationFailedFault(e);
- }
-
- // get portlet description for the desired portlet...
- final String[] desiredLocales = params.getLocales();
- PortletDescription portletDescription = producer.getPortletDescription(portletHandle, desiredLocales);
- MarkupType[] markupTypes = portletDescription.getMarkupTypes();
-
- // based on the markup parameters and portlet description generate the most appropriate markup request
- final MarkupRequest markupRequest = createMarkupRequestFrom(markupTypes, params, portlet);
-
- // prepare information for invocation
- StateString navigationalState = createNavigationalState(params.getNavigationalState());
-
- final org.jboss.portal.wsrp.core.UserContext wsrpUserContext = getMarkup.getUserContext();
- checkUserContext(wsrpUserContext);
-
- SecurityContext securityContext = createSecurityContext(params, runtimeContext, wsrpUserContext);
- HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
- PortalContext portalContext = createPortalContext(params, markupRequest);
- UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
- InstanceContext instanceContext = createInstanceContext(portletHandle, AccessMode.READ_ONLY);
- WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
-
- // prepare the invocation
- WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, streamInfo,
- portalContext, userContext, instanceContext, windowContext,
- WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
- WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
- RenderInvocation render = new RenderInvocation(renderContext);
- renderContext.contextualize(render);
- render.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
-
PortletInvocationResponse response;
try
{
- log.debug("RenderInvocation on portlet '" + portletHandle + "'");
- response = producer.getInvoker().invoke(render);
+ log.debug("RenderInvocation on portlet '" + requestProcessor.getPortletContext().getPortletHandle() + "'");
+ response = producer.getInvoker().invoke(requestProcessor.getInvocation());
log.debug("RenderInvocation done");
}
catch (PortletInvokerException e)
@@ -208,64 +106,9 @@
checkForError(response);
- FragmentResponse fragment = (FragmentResponse)response;
- String markupString = null;
- byte[] markupBinary = null;
- switch (fragment.getType())
- {
- case FragmentResponse.TYPE_CHARS:
- markupString = fragment.getChars().toString();
- break;
- case FragmentResponse.TYPE_BYTES:
- markupBinary = fragment.getBytes().toByteArray(); // fix-me: might need to convert to Base64?
- break;
- case FragmentResponse.TYPE_EMPTY:
- markupString = EMPTY;
- break;
- }
-
- MarkupContext markupContext;
- if (markupString != null)
- {
- markupContext = WSRPTypeFactory.createMarkupContext(markupRequest.getMimeType(), markupString);
- }
- else
- {
- markupContext = WSRPTypeFactory.createMarkupContext(markupRequest.getMimeTypeWithCharset(), markupBinary);
- }
- markupContext.setLocale(markupRequest.getLocale());
- markupContext.setRequiresUrlRewriting(Boolean.TRUE);
- markupContext.setPreferredTitle(portletDescription.getTitle().getValue());
-
- // cache information
- CacheInfo cacheInfo = portlet.getInfo().getCache();
- if (cacheInfo != null)
- {
- int expires = cacheInfo.getExpirationSecs();
- // only create a CacheControl if expiration time is not 0
- if (expires != 0)
- {
- markupContext.setCacheControl(WSRPTypeFactory.createCacheControl(expires, WSRPConstants.CACHE_PER_USER));
- }
- }
-
- return new MarkupResponse(markupContext, null, null);
+ return (MarkupResponse)requestProcessor.processResponse(response);
}
- private void checkForSessionIDs(RuntimeContext runtimeContext) throws OperationFailedFault
- {
- if (runtimeContext.getSessionID() != null)
- {
- throwOperationFaultOnSessionOperation();
- }
- }
-
- private void throwOperationFaultOnSessionOperation() throws OperationFailedFault
- {
- throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException("JBoss Portal's Producer manages " +
- "sessions completely on the server side, passing or trying to release sessionIDs is therefore an error."));
- }
-
public BlockingInteractionResponse performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
throws InvalidSessionFault, UnsupportedModeFault, UnsupportedMimeTypeFault, OperationFailedFault,
UnsupportedWindowStateFault, UnsupportedLocaleFault, AccessDeniedFault, PortletStateChangeRequiredFault,
@@ -273,9 +116,7 @@
InvalidHandleFault, InvalidCookieFault, RemoteException
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(performBlockingInteraction, PBI);
- producer.checkRegistration(performBlockingInteraction.getRegistrationContext());
-
- InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
+ final InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(interactionParams, "InteractionParams", PBI);
// fix-me: upload contexts are not supported, fail fast!
@@ -285,106 +126,14 @@
throw WSRPUtils.createOperationFailedFault(new UnsupportedOperationException("UploadContexts are not currently supported."));
}
- PortletContext portletContext = performBlockingInteraction.getPortletContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", PBI);
- String portletHandle = portletContext.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
- RuntimeContext runtimeContext = performBlockingInteraction.getRuntimeContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(runtimeContext, "RuntimeContext", PBI);
+ RequestProcessor requestProcessor = new ActionRequestProcessor(producer, performBlockingInteraction, interactionParams);
- org.jboss.portal.wsrp.core.UserContext wsrpUserContext = performBlockingInteraction.getUserContext();
- checkUserContext(wsrpUserContext);
-
- PortletInvoker invoker = producer.getInvoker();
- final Portlet portlet;
- try
- {
- portlet = invoker.getPortlet(org.jboss.portal.portlet.PortletContext.createPortletContext(portletHandle));
- }
- catch (PortletInvokerException e)
- {
- throw WSRPUtils.createOperationFailedFault(e);
- }
- MarkupParams markupParams = performBlockingInteraction.getMarkupParams();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(markupParams, "MarkupParams", PBI);
-
- // get portlet description for the desired portlet...
- final String[] desiredLocales = markupParams.getLocales();
- PortletDescription portletDescription = producer.getPortletDescription(portletHandle, desiredLocales);
- if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
- {
- throw WSRPUtils.createOperationFailedFault(
- new UnsupportedOperationException("Portlets using GET method in forms are not currently supported."));
- }
- MarkupType[] markupTypes = portletDescription.getMarkupTypes();
-
- // based on the markup parameters and portlet description generate the most appropriate markup request
- final MarkupRequest markupRequest = createMarkupRequestFrom(markupTypes, markupParams, portlet);
-
- // create information for action context
- StateString navigationalState = createNavigationalState(markupParams.getNavigationalState());
- SecurityContext securityContext = createSecurityContext(markupParams, runtimeContext, wsrpUserContext);
- HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
- PortalContext portalContext = createPortalContext(markupParams, markupRequest);
- UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
- WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
-
- StateChange stateChange = interactionParams.getPortletStateChange();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(stateChange, "portletStateChange", "InteractionParams");
- WSRPInstanceContext instanceContext = createInstanceContext(portletHandle, WSRPUtils.getAccessModeFromStateChange(stateChange));
-
-
- 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();
- }
- log.debug("form parameters:\n" + parameters);
-
- StateString interactionState = createNavigationalState(interactionParams.getInteractionState());
-
- WSRPActionContext context = new WSRPActionContext(navigationalState, securityContext, streamInfo,
- portalContext, userContext, instanceContext, windowContext,
- interactionState, WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
- WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()), parameters,
- markupRequest.getCharacterSet(), markupRequest.getMimeType());
- ActionInvocation invocation = new ActionInvocation(context);
- context.contextualize(invocation);
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
-
PortletInvocationResponse response;
try
{
- log.debug("ActionInvocation on portlet '" + portletHandle + "'");
- response = producer.getInvoker().invoke(invocation);
+ log.debug("ActionInvocation on portlet '" + requestProcessor.getPortletContext().getPortletHandle() + "'");
+ response = producer.getInvoker().invoke(requestProcessor.getInvocation());
log.debug("ActionInvocation done");
}
catch (PortletStateChangeRequiredException e)
@@ -393,44 +142,34 @@
}
catch (PortletInvokerException e)
{
- log.fatal(e);
throw WSRPUtils.createOperationFailedFault(e);
}
checkForError(response);
- if (response instanceof RenderResponse)
- {
- RenderResponse renderResult = (RenderResponse)response;
- UpdateResponse updateResponse = WSRPTypeFactory.createUpdateResponse();
- updateResponse.setNewMode(WSRPUtils.convertJSR168PortletModeNameToWSRPName(getNewStateOrNull(renderResult, true)));
- updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(renderResult, false)));
- StateString ns = renderResult.getNavigationalState();
- updateResponse.setNavigationalState(ns != null ? ns.getStringValue() : null);
+ return (BlockingInteractionResponse)requestProcessor.processResponse(response);
+ }
- // deal with implicit cloning and state modification
- if (instanceContext.wasModified())
- {
- PortletContext updatedPortletContext = WSRPTypeFactory.createPortletContext(instanceContext.getId());
- updatedPortletContext.setPortletState(instanceContext.getState());
- updateResponse.setPortletContext(updatedPortletContext);
- }
+ public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
+ throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault, AccessDeniedFault, RemoteException
+ {
+ throwOperationFaultOnSessionOperation();
+ return null;
+ }
+ public ReturnAny initCookie(InitCookie initCookie)
+ throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(initCookie, "InitCookie");
+ producer.checkRegistration(initCookie.getRegistrationContext());
- return WSRPTypeFactory.createBlockingInteractionResponse(updateResponse);
- }
- else
- {
- // result should be HTTPRedirectionResult
- HTTPRedirectionResponse redirectionResult = (HTTPRedirectionResponse)response;
- return WSRPTypeFactory.createBlockingInteractionResponse(redirectionResult.getLocation());
- }
+ return new ReturnAny(); // todo: implement when actually needed
}
- private String getNewStateOrNull(RenderResponse renderResult, boolean forMode)
+ static void throwOperationFaultOnSessionOperation() throws OperationFailedFault
{
- Object state = forMode ? (Object)renderResult.getMode() : renderResult.getWindowState();
- return state != null ? state.toString() : null;
+ throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException("JBoss Portal's Producer manages " +
+ "sessions completely on the server side, passing or trying to release sessionIDs is therefore an error."));
}
private void checkForError(PortletInvocationResponse response)
@@ -468,459 +207,4 @@
+ response.getClass().getName()));
}
}
-
- public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
- throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault, AccessDeniedFault, RemoteException
- {
- throwOperationFaultOnSessionOperation();
- return null;
- }
-
- public ReturnAny initCookie(InitCookie initCookie)
- throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
- {
- WSRPUtils.throwOperationFailedFaultIfValueIsMissing(initCookie, "InitCookie");
- producer.checkRegistration(initCookie.getRegistrationContext());
-
- return new ReturnAny(); // todo: implement when actually needed
- }
-
- // Parameter checking methods ***************************************************************************************
-
- private void checkUserContext(org.jboss.portal.wsrp.core.UserContext wsrpUserContext) throws MissingParametersFault
- {
- if (wsrpUserContext != null)
- {
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(wsrpUserContext.getUserContextKey(), "User Context Key", "UserContext");
- }
- }
-
- // Invocation support methods ***************************************************************************************
- private StateString createNavigationalState(String navigationalState)
- {
- // fix-me: create opaque NS and implement an interceptor that does conversion to jboss NS
-// PortletNavigationalState navigationalState = new OpaquePortletNavigationalState(navigationalState);
- if (navigationalState == null)
- {
- return null;
- }
- else
- {
- return new OpaqueStateString(navigationalState);
- }
- }
-
- private WSRPInstanceContext createInstanceContext(final String portletHandle, final AccessMode accessMode)
- {
- return new WSRPInstanceContext(portletHandle, accessMode);
- }
-
- private WindowContext createWindowContext(final String portletHandle, final RuntimeContext runtimeContext)
- {
- return new WindowContext()
- {
- public String getId()
- {
- String prefix = runtimeContext.getNamespacePrefix();
- if (prefix != null && prefix.length() > 0)
- {
- return prefix;
- }
- else
- {
- log.debug("No provided namespace prefix for portlet '" + portletHandle + "'. Using portlet handle as namespace.");
- return portletHandle;
- }
- }
- };
- }
-
- private UserContext createUserContext(final org.jboss.portal.wsrp.core.UserContext userContext,
- String preferredLocale, final String[] supportedLocales)
- {
- // todo: investigate ways to cache this information?
- // fix-me: should getInformations be put in the request attribute PortletRequest.USER_INFO?
- return UserContextConverter.createPortalUserContextFrom(userContext, supportedLocales, preferredLocale);
- }
-
- private PortalContext createPortalContext(final MarkupParams params, final MarkupHandler.MarkupRequest markupRequest)
- {
- return new PortalContext()
- {
- public Set getWindowStates()
- {
- String[] validNewWindowStates = params.getValidNewWindowStates();
- if (validNewWindowStates != null)
- {
- Set states = new HashSet(validNewWindowStates.length);
- for (int i = 0; i < validNewWindowStates.length; i++)
- {
- String state = validNewWindowStates[i];
- states.add(WSRPUtils.getJSR168WindowStateFromWSRPName(state));
- }
- return states;
- }
- return markupRequest.getSupportedWindowStates();
- }
-
- public Set getModes()
- {
- String[] validNewModes = params.getValidNewModes();
- if (validNewModes != null)
- {
- Set modes = new HashSet(validNewModes.length);
- for (int i = 0; i < validNewModes.length; i++)
- {
- String mode = validNewModes[i];
- modes.add(WSRPUtils.getJSR168PortletModeFromWSRPName(mode));
- }
- return modes;
- }
- return markupRequest.getSupportedModes();
- }
-
- public Map getProperties()
- {
- return Collections.EMPTY_MAP;
- }
- };
- }
-
- private HTTPStreamInfo createStreamInfo(MarkupRequest markupRequest)
- throws UnsupportedMimeTypeFault
- {
- HTTPStreamInfo streamInfo;
- try
- {
- streamInfo = new HTTPStreamInfo(MediaType.parseMimeType(markupRequest.getMimeType()), markupRequest.getCharacterSet());
- }
- catch (MimeTypeParseException e)
- {
- throw (UnsupportedMimeTypeFault)WSRPUtils.createFaultFrom(UnsupportedMimeTypeFault.class, e);
- }
- return streamInfo;
- }
-
- // fix-me: check that the correct semantics is used.
- private SecurityContext createSecurityContext(final MarkupParams params, final RuntimeContext runtimeContext,
- final org.jboss.portal.wsrp.core.UserContext wsrpUserContext)
- {
- return new SecurityContext()
- {
- public boolean isSecure()
- {
- return params.isSecureClientCommunication();
- }
-
- public String getAuthType()
- {
- return runtimeContext.getUserAuthentication();
- }
-
- public String getRemoteUser()
- {
- if (wsrpUserContext != null)
- {
- return wsrpUserContext.getUserContextKey();
- }
- return null;
- }
-
- public Principal getUserPrincipal()
- {
- return null;
- }
-
- public boolean isUserInRole(String roleName)
- {
- if (wsrpUserContext != null)
- {
- List userCategories = Arrays.asList(wsrpUserContext.getUserCategories());
- return userCategories.contains(roleName);
- }
- return false;
- }
-
- public boolean isAuthenticated()
- {
- return wsrpUserContext != null;
- }
- };
- }
-
- /**
- * Returns the most appropriate information to base markup generation on based on a Portlet's specified markup types
- * and a markup request parameters.
- *
- * @param markupTypes the Portlet's specified markup types
- * @param params the markup request parameters
- * @param portlet
- * @return a MarkupRequest containing the most appropriate information to base markup generation for this request
- */
- private MarkupRequest createMarkupRequestFrom(MarkupType[] markupTypes, MarkupParams params, Portlet portlet)
- throws UnsupportedMimeTypeFault, UnsupportedModeFault, UnsupportedWindowStateFault
- {
- String[] desiredMIMETypes = params.getMimeTypes();
- MarkupType markupType = null;
-
- // Get the MIME type to use
- for (int i = 0; markupType == null && i < desiredMIMETypes.length; i++)
- {
- String desiredMIMEType = desiredMIMETypes[i];
- for (int j = 0; j < markupTypes.length; j++)
- {
- if (desiredMIMEType.equalsIgnoreCase(markupTypes[j].getMimeType()))
- {
- markupType = markupTypes[j];
- break;
- }
- }
- }
-
- // no MIME type was found: error!
- if (markupType == null)
- {
- throw (UnsupportedMimeTypeFault)WSRPUtils.createFaultFrom(UnsupportedMimeTypeFault.class,
- new IllegalArgumentException("None of the specified MIME types are supported by this Portlet."));
- }
-
- // get the mode
- String mode = null;
- try
- {
- mode = getMatchingOrFailFrom(markupType.getModes(), params.getMode(), PORTLET_MODE);
- }
- catch (IllegalArgumentException e)
- {
- throw (UnsupportedModeFault)WSRPUtils.createFaultFrom(UnsupportedModeFault.class, e);
- }
-
- // get the window state
- String windowState = null;
- try
- {
- windowState = getMatchingOrFailFrom(markupType.getWindowStates(), params.getWindowState(), WINDOW_STATE);
- }
- catch (IllegalArgumentException e)
- {
- throw (UnsupportedWindowStateFault)WSRPUtils.createFaultFrom(UnsupportedWindowStateFault.class, e);
- }
-
- // get the character set
- String characterSet = getMatchingOrDefaultFrom(new String[0], params.getMarkupCharacterSets(), WSRPConstants.DEFAULT_CHARACTER_SET);
-
- return new MarkupRequest(markupType, mode, windowState, characterSet, portlet);
- }
-
- /**
- * Retrieves the desired value from the set of possible values if such value exists or throw an
- * <code>IllegalArgumentException</code>.
- *
- * @param possibleValues the set of supported values
- * @param desired the desired value
- * @param valueType a name identifying the type of the desired value (for error reporting purpose)
- * @return the desired value
- * @throws IllegalArgumentException if the desired value is not found in the set of possible values
- */
- private String getMatchingOrFailFrom(String[] possibleValues, String desired, String valueType) throws IllegalArgumentException
- {
- List possibleList = Arrays.asList(possibleValues);
- if (possibleList.contains(desired))
- {
- return desired;
- }
- throw new IllegalArgumentException(desired + " is not a supported " + valueType);
- }
-
- /**
- * Retrieves the best matching value from a set of possible values based on an ordered set of preferred values or the
- * given default value if no matching value is found.
- *
- * @param possibleValues the set of possible values
- * @param preferredValues the ordered (according to user preferences) set of preferred values
- * @param defaultValue the default value to be used if no match can be found
- * @return the first match in the set of possible values from the ordered set of preferred values or the default
- * value if no such value can be found
- */
- private String getMatchingOrDefaultFrom(String[] possibleValues, String[] preferredValues, String defaultValue)
- {
- if (preferredValues != null && possibleValues != null)
- {
- List possibleList = Arrays.asList(possibleValues);
-
- for (int i = 0; i < preferredValues.length; i++)
- {
- if (possibleList.contains(preferredValues[i]))
- {
- return preferredValues[i];
- }
- }
- }
-
- return defaultValue;
- }
-
- /**
- * Retrieves the matching value from a set of possible values based on a desired value or the given default one if no
- * match can be found.
- *
- * @param possibleValues the set of possible values
- * @param desired the desired value
- * @param defaultValue the default value if no match can be found
- * @return the desired value if it's the set of possible values, the specified default value otherwise
- */
- private String getMatchingOrDefaultFrom(String[] possibleValues, String desired, String defaultValue)
- {
- List possibleList = Arrays.asList(possibleValues);
- if (possibleList.contains(desired))
- {
- return desired;
- }
- else
- {
- return defaultValue;
- }
- }
-
- /**
- * Wrapper around information needed to perform a Markup invocation.
- *
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @since 2.4
- */
- class MarkupRequest
- {
- private String mode;
- private String windowState;
- private MarkupType markupType;
- private String characterSet;
- private Portlet portlet;
-
- public MarkupRequest(MarkupType markupType, String mode, String windowState, String characterSet, Portlet portlet)
- {
- this.characterSet = characterSet;
- this.markupType = markupType;
- this.mode = mode;
- this.windowState = windowState;
- this.portlet = portlet;
- }
-
- public String getMimeTypeWithCharset()
- {
- return getMimeType() + CHARSET_SEPARATOR + getCharacterSet();
- }
-
- public String getMimeType()
- {
- return markupType.getMimeType();
- }
-
- public String getLocale()
- {
- String[] locales = markupType.getLocales();
- if (locales != null && locales.length != 0)
- {
- return locales[0];
- }
- else
- {
- return LocaleInfo.getRFC3066LanguageTagFor(Locale.ENGLISH); // no locale was provided, use English...
- }
- }
-
- public String getMode()
- {
- return mode;
- }
-
- public String getWindowState()
- {
- return windowState;
- }
-
- public MarkupType getMarkupType()
- {
- return markupType;
- }
-
- public String getCharacterSet()
- {
- return characterSet;
- }
-
- public Portlet getPortlet()
- {
- return portlet;
- }
-
- public Set getSupportedModes()
- {
- String[] modes = markupType.getModes();
- int length = modes.length;
- Set result = new HashSet(length);
- for (int i = 0; i < length; i++)
- {
- result.add(WSRPUtils.getJSR168PortletModeFromWSRPName(modes[i]));
- }
- return result;
- }
-
- public Set getSupportedWindowStates()
- {
- String[] states = markupType.getWindowStates();
- int length = states.length;
- Set result = new HashSet(length);
- for (int i = 0; i < length; i++)
- {
- result.add(WSRPUtils.getJSR168WindowStateFromWSRPName(states[i]));
- }
- return result;
- }
- }
-
- class WSRPInstanceContext implements InstanceContext
- {
- private String id;
- private byte[] state;
- private final AccessMode accessMode;
- private boolean wasModified = false;
-
- public WSRPInstanceContext(String portletHandle, AccessMode accessMode)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle, "portlet handle", "InstanceContext");
- ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "AccessMode");
-
- this.id = portletHandle;
- this.accessMode = accessMode;
- }
-
- public String getId()
- {
- return id;
- }
-
- public AccessMode getAccessMode()
- {
- return accessMode;
- }
-
- public void onStateEvent(StateEvent event)
- {
- org.jboss.portal.portlet.PortletContext portletContext = event.getPortletContext();
- ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
- wasModified = true;
- id = portletContext.getId();
- state = portletContext.getState();
- }
-
- public boolean wasModified()
- {
- return wasModified;
- }
-
- public byte[] getState()
- {
- return state;
- }
- }
}
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * 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.producer;
+
+import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.core.MarkupType;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Wrapper around information needed to perform a Markup invocation.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @since 2.6
+ */
+class MarkupRequest
+{
+ private String mode;
+ private String windowState;
+ private MarkupType markupType;
+ private String characterSet;
+ private Portlet portlet;
+ private static final String CHARSET_SEPARATOR = "; charset=";
+
+ public MarkupRequest(MarkupType markupType, String mode, String windowState, String characterSet, Portlet portlet)
+ {
+ this.characterSet = characterSet;
+ this.markupType = markupType;
+ this.mode = mode;
+ this.windowState = windowState;
+ this.portlet = portlet;
+ }
+
+ public String getMimeTypeWithCharset()
+ {
+ return getMimeType() + CHARSET_SEPARATOR + getCharacterSet();
+ }
+
+ public String getMimeType()
+ {
+ return markupType.getMimeType();
+ }
+
+ public String getLocale()
+ {
+ String[] locales = markupType.getLocales();
+ if (locales != null && locales.length != 0)
+ {
+ return locales[0];
+ }
+ else
+ {
+ return LocaleInfo.getRFC3066LanguageTagFor(Locale.ENGLISH); // no locale was provided, use English...
+ }
+ }
+
+ public String getMode()
+ {
+ return mode;
+ }
+
+ public String getWindowState()
+ {
+ return windowState;
+ }
+
+ public MarkupType getMarkupType()
+ {
+ return markupType;
+ }
+
+ public String getCharacterSet()
+ {
+ return characterSet;
+ }
+
+ public Portlet getPortlet()
+ {
+ return portlet;
+ }
+
+ public Set getSupportedModes()
+ {
+ String[] modes = markupType.getModes();
+ int length = modes.length;
+ Set result = new HashSet(length);
+ for (int i = 0; i < length; i++)
+ {
+ result.add(WSRPUtils.getJSR168PortletModeFromWSRPName(modes[i]));
+ }
+ return result;
+ }
+
+ public Set getSupportedWindowStates()
+ {
+ String[] states = markupType.getWindowStates();
+ int length = states.length;
+ Set result = new HashSet(length);
+ for (int i = 0; i < length; i++)
+ {
+ result.add(WSRPUtils.getJSR168WindowStateFromWSRPName(states[i]));
+ }
+ return result;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -104,13 +104,10 @@
PortletContext portletContext = getPortletDescription.getPortletContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_DESCRIPTION);
- String handle = portletContext.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(handle, "portlet handle", PORTLET_CONTEXT);
-
UserContext userContext = getPortletDescription.getUserContext();
checkUserAuthorization(userContext);
- return WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(handle, getPortletDescription.getDesiredLocales()));
+ return WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales()));
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -0,0 +1,173 @@
+/******************************************************************************
+ * 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.producer;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.info.CacheInfo;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+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.portlet.state.AccessMode;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.wsrp.WSRPConstants;
+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.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.MarkupContext;
+import org.jboss.portal.wsrp.core.MarkupParams;
+import org.jboss.portal.wsrp.core.MarkupResponse;
+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.RegistrationContext;
+import org.jboss.portal.wsrp.core.RuntimeContext;
+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>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RenderRequestProcessor extends RequestProcessor
+{
+ private static final String EMPTY = "";
+ private final GetMarkup getMarkup;
+
+ public RenderRequestProcessor(WSRPProducerImpl producer, GetMarkup getMarkup) throws UnsupportedMimeTypeFault,
+ UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault, MissingParametersFault,
+ InvalidRegistrationFault, OperationFailedFault
+ {
+ super(producer);
+ this.getMarkup = getMarkup;
+ prepareInvocation();
+ }
+
+ RegistrationContext getRegistrationContext()
+ {
+ return getMarkup.getRegistrationContext();
+ }
+
+ RuntimeContext getRuntimeContext()
+ {
+ return getMarkup.getRuntimeContext();
+ }
+
+ MarkupParams getMarkupParams()
+ {
+ return getMarkup.getMarkupParams();
+ }
+
+ PortletContext getPortletContext()
+ {
+ return getMarkup.getPortletContext();
+ }
+
+ org.jboss.portal.wsrp.core.UserContext getUserContext()
+ {
+ return getMarkup.getUserContext();
+ }
+
+ String getContextName()
+ {
+ return MarkupHandler.GET_MARKUP;
+ }
+
+ AccessMode getAccessMode()
+ {
+ return AccessMode.READ_ONLY;
+ }
+
+ void initInvocation(StateString navigationalState, SecurityContext securityContext,
+ HTTPStreamInfo streamInfo, PortalContext portalContext,
+ UserContext userContext,
+ WindowContext windowContext
+ )
+ {
+ WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, streamInfo,
+ portalContext, userContext, instanceContext, windowContext,
+ WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()),
+ WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
+ setInvocation(new RenderInvocation(renderContext));
+ renderContext.contextualize(invocation);
+
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ }
+
+ Object processResponse(PortletInvocationResponse response)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ String markupString = null;
+ byte[] markupBinary = null;
+ switch (fragment.getType())
+ {
+ case FragmentResponse.TYPE_CHARS:
+ markupString = fragment.getChars().toString();
+ break;
+ case FragmentResponse.TYPE_BYTES:
+ markupBinary = fragment.getBytes().toByteArray(); // fix-me: might need to convert to Base64?
+ break;
+ case FragmentResponse.TYPE_EMPTY:
+ markupString = EMPTY;
+ break;
+ }
+
+
+ MarkupContext markupContext;
+ if (markupString != null)
+ {
+ markupContext = WSRPTypeFactory.createMarkupContext(markupRequest.getMimeType(), markupString);
+ }
+ else
+ {
+ markupContext = WSRPTypeFactory.createMarkupContext(markupRequest.getMimeTypeWithCharset(), markupBinary);
+ }
+ markupContext.setLocale(markupRequest.getLocale());
+ markupContext.setRequiresUrlRewriting(Boolean.TRUE);
+ markupContext.setPreferredTitle(portletDescription.getTitle().getValue());
+
+ // cache information
+ CacheInfo cacheInfo = portlet.getInfo().getCache();
+ if (cacheInfo != null)
+ {
+ int expires = cacheInfo.getExpirationSecs();
+ // only create a CacheControl if expiration time is not 0
+ if (expires != 0)
+ {
+ markupContext.setCacheControl(WSRPTypeFactory.createCacheControl(expires, WSRPConstants.CACHE_PER_USER));
+ }
+ }
+
+ return new MarkupResponse(markupContext, null, null);
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -0,0 +1,460 @@
+/******************************************************************************
+ * 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.producer;
+
+import org.jboss.portal.common.MediaType;
+import org.jboss.portal.portlet.OpaqueStateString;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+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.portlet.state.AccessMode;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.wsrp.UserContextConverter;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+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;
+import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.RuntimeContext;
+import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
+import org.jboss.portal.wsrp.core.UnsupportedModeFault;
+import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+
+import javax.activation.MimeTypeParseException;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public abstract class RequestProcessor
+{
+ private static final String WINDOW_STATE = "window state";
+ private static final String PORTLET_MODE = "portlet mode";
+
+ protected PortletInvocation invocation;
+ protected MarkupRequest markupRequest;
+ protected PortletDescription portletDescription;
+ protected Portlet portlet;
+ protected WSRPInstanceContext instanceContext;
+ protected WSRPProducerImpl producer;
+
+
+ protected RequestProcessor(WSRPProducerImpl producer)
+ {
+ this.producer = producer;
+ }
+
+ void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault, InvalidHandleFault, UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
+ {
+ producer.checkRegistration(getRegistrationContext());
+
+ // get session information and deal with it
+ final RuntimeContext runtimeContext = getRuntimeContext();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(runtimeContext, "RuntimeContext", getContextName());
+
+ checkForSessionIDs(runtimeContext);
+
+ // get markup parameters
+ final MarkupParams params = getMarkupParams();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(params, "MarkupParams", getContextName());
+
+ // get portlet handle
+ PortletContext wsrpPC = getPortletContext();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(wsrpPC, "PortletContext", getContextName());
+ final String portletHandle = wsrpPC.getPortletHandle();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
+ org.jboss.portal.portlet.PortletContext originalPortletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);
+
+ // retrieve the portlet
+ try
+ {
+ portlet = producer.getPortletWith(originalPortletContext);
+ }
+ catch (PortletInvokerException e)
+ {
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+
+ // get portlet description for the desired portlet...
+ final String[] desiredLocales = params.getLocales();
+ portletDescription = producer.getPortletDescription(wsrpPC, desiredLocales);
+ if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
+ {
+ throw WSRPUtils.createOperationFailedFault(
+ new UnsupportedOperationException("Portlets using GET method in forms are not currently supported."));
+ }
+ MarkupType[] markupTypes = portletDescription.getMarkupTypes();
+
+ // based on the markup parameters and portlet description generate the most appropriate markup request
+ markupRequest = createMarkupRequestFrom(markupTypes, params, portlet);
+
+ // prepare information for invocation
+ StateString navigationalState = createNavigationalState(params.getNavigationalState());
+
+ final org.jboss.portal.wsrp.core.UserContext wsrpUserContext = getUserContext();
+ checkUserContext(wsrpUserContext);
+
+ SecurityContext securityContext = createSecurityContext(params, runtimeContext, wsrpUserContext);
+ HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
+ PortalContext portalContext = createPortalContext(params, markupRequest);
+ UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
+ instanceContext = createInstanceContext(portletHandle, getAccessMode());
+ WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
+
+ // prepare the invocation
+ initInvocation(navigationalState, securityContext, streamInfo, portalContext, userContext, windowContext);
+ }
+
+ abstract RegistrationContext getRegistrationContext();
+
+ abstract RuntimeContext getRuntimeContext();
+
+ abstract MarkupParams getMarkupParams();
+
+ abstract PortletContext getPortletContext();
+
+ abstract org.jboss.portal.wsrp.core.UserContext getUserContext();
+
+ abstract String getContextName();
+
+ abstract AccessMode getAccessMode() throws MissingParametersFault;
+
+ abstract void initInvocation(StateString navigationalState, SecurityContext securityContext,
+ HTTPStreamInfo streamInfo, PortalContext portalContext, UserContext userContext,
+ WindowContext windowContext);
+
+ abstract Object processResponse(PortletInvocationResponse response);
+
+
+ /**
+ * Returns the most appropriate information to base markup generation on based on a Portlet's specified markup types
+ * and a markup request parameters.
+ *
+ * @param markupTypes the Portlet's specified markup types
+ * @param params the markup request parameters
+ * @param portlet
+ * @return a MarkupRequest containing the most appropriate information to base markup generation for this request
+ */
+ private MarkupRequest createMarkupRequestFrom(MarkupType[] markupTypes, MarkupParams params, Portlet portlet)
+ throws UnsupportedMimeTypeFault, UnsupportedModeFault, UnsupportedWindowStateFault
+ {
+ String[] desiredMIMETypes = params.getMimeTypes();
+ MarkupType markupType = null;
+
+ // Get the MIME type to use
+ for (int i = 0; markupType == null && i < desiredMIMETypes.length; i++)
+ {
+ String desiredMIMEType = desiredMIMETypes[i];
+ for (int j = 0; j < markupTypes.length; j++)
+ {
+ if (desiredMIMEType.equalsIgnoreCase(markupTypes[j].getMimeType()))
+ {
+ markupType = markupTypes[j];
+ break;
+ }
+ }
+ }
+
+ // no MIME type was found: error!
+ if (markupType == null)
+ {
+ throw (UnsupportedMimeTypeFault)WSRPUtils.createFaultFrom(UnsupportedMimeTypeFault.class,
+ new IllegalArgumentException("None of the specified MIME types are supported by this Portlet."));
+ }
+
+ // get the mode
+ String mode = null;
+ try
+ {
+ mode = getMatchingOrFailFrom(markupType.getModes(), params.getMode(), PORTLET_MODE);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw (UnsupportedModeFault)WSRPUtils.createFaultFrom(UnsupportedModeFault.class, e);
+ }
+
+ // get the window state
+ String windowState = null;
+ try
+ {
+ windowState = getMatchingOrFailFrom(markupType.getWindowStates(), params.getWindowState(), WINDOW_STATE);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw (UnsupportedWindowStateFault)WSRPUtils.createFaultFrom(UnsupportedWindowStateFault.class, e);
+ }
+
+ // get the character set
+ String characterSet = getMatchingOrDefaultFrom(new String[0], params.getMarkupCharacterSets(), WSRPConstants.DEFAULT_CHARACTER_SET);
+
+ return new MarkupRequest(markupType, mode, windowState, characterSet, portlet);
+ }
+
+ /**
+ * Retrieves the desired value from the set of possible values if such value exists or throw an
+ * <code>IllegalArgumentException</code>.
+ *
+ * @param possibleValues the set of supported values
+ * @param desired the desired value
+ * @param valueType a name identifying the type of the desired value (for error reporting purpose)
+ * @return the desired value
+ * @throws IllegalArgumentException if the desired value is not found in the set of possible values
+ */
+ private String getMatchingOrFailFrom(String[] possibleValues, String desired, String valueType) throws IllegalArgumentException
+ {
+ List possibleList = Arrays.asList(possibleValues);
+ if (possibleList.contains(desired))
+ {
+ return desired;
+ }
+ throw new IllegalArgumentException(desired + " is not a supported " + valueType);
+ }
+
+ /**
+ * Retrieves the best matching value from a set of possible values based on an ordered set of preferred values or the
+ * given default value if no matching value is found.
+ *
+ * @param possibleValues the set of possible values
+ * @param preferredValues the ordered (according to user preferences) set of preferred values
+ * @param defaultValue the default value to be used if no match can be found
+ * @return the first match in the set of possible values from the ordered set of preferred values or the default
+ * value if no such value can be found
+ */
+ private String getMatchingOrDefaultFrom(String[] possibleValues, String[] preferredValues, String defaultValue)
+ {
+ if (preferredValues != null && possibleValues != null)
+ {
+ List possibleList = Arrays.asList(possibleValues);
+
+ for (int i = 0; i < preferredValues.length; i++)
+ {
+ if (possibleList.contains(preferredValues[i]))
+ {
+ return preferredValues[i];
+ }
+ }
+ }
+
+ return defaultValue;
+ }
+
+ private void checkUserContext(org.jboss.portal.wsrp.core.UserContext wsrpUserContext) throws MissingParametersFault
+ {
+ if (wsrpUserContext != null)
+ {
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(wsrpUserContext.getUserContextKey(), "User Context Key", "UserContext");
+ }
+ }
+
+
+ private void checkForSessionIDs(RuntimeContext runtimeContext) throws OperationFailedFault
+ {
+ if (runtimeContext.getSessionID() != null)
+ {
+ MarkupHandler.throwOperationFaultOnSessionOperation();
+ }
+ }
+
+ protected StateString createNavigationalState(String navigationalState)
+ {
+ // fix-me: create opaque NS and implement an interceptor that does conversion to jboss NS
+// PortletNavigationalState navigationalState = new OpaquePortletNavigationalState(navigationalState);
+ if (navigationalState == null)
+ {
+ return null;
+ }
+ else
+ {
+ return new OpaqueStateString(navigationalState);
+ }
+ }
+
+ private WSRPInstanceContext createInstanceContext(final String portletHandle, final AccessMode accessMode)
+ {
+ return new WSRPInstanceContext(portletHandle, accessMode);
+ }
+
+ private WindowContext createWindowContext(final String portletHandle, final RuntimeContext runtimeContext)
+ {
+ return new WindowContext()
+ {
+ public String getId()
+ {
+ String prefix = runtimeContext.getNamespacePrefix();
+ if (prefix != null && prefix.length() > 0)
+ {
+ return prefix;
+ }
+ else
+ {
+ // No provided namespace prefix for portlet, using portlet handle instead
+ return portletHandle;
+ }
+ }
+ };
+ }
+
+ private UserContext createUserContext(final org.jboss.portal.wsrp.core.UserContext userContext,
+ String preferredLocale, final String[] supportedLocales)
+ {
+ // todo: investigate ways to cache this information?
+ // fix-me: should getInformations be put in the request attribute PortletRequest.USER_INFO?
+ return UserContextConverter.createPortalUserContextFrom(userContext, supportedLocales, preferredLocale);
+ }
+
+ private PortalContext createPortalContext(final MarkupParams params, final MarkupRequest markupRequest)
+ {
+ return new PortalContext()
+ {
+ public Set getWindowStates()
+ {
+ String[] validNewWindowStates = params.getValidNewWindowStates();
+ if (validNewWindowStates != null)
+ {
+ Set states = new HashSet(validNewWindowStates.length);
+ for (int i = 0; i < validNewWindowStates.length; i++)
+ {
+ String state = validNewWindowStates[i];
+ states.add(WSRPUtils.getJSR168WindowStateFromWSRPName(state));
+ }
+ return states;
+ }
+ return markupRequest.getSupportedWindowStates();
+ }
+
+ public Set getModes()
+ {
+ String[] validNewModes = params.getValidNewModes();
+ if (validNewModes != null)
+ {
+ Set modes = new HashSet(validNewModes.length);
+ for (int i = 0; i < validNewModes.length; i++)
+ {
+ String mode = validNewModes[i];
+ modes.add(WSRPUtils.getJSR168PortletModeFromWSRPName(mode));
+ }
+ return modes;
+ }
+ return markupRequest.getSupportedModes();
+ }
+
+ public Map getProperties()
+ {
+ return Collections.EMPTY_MAP;
+ }
+ };
+ }
+
+ private HTTPStreamInfo createStreamInfo(MarkupRequest markupRequest)
+ throws UnsupportedMimeTypeFault
+ {
+ HTTPStreamInfo streamInfo;
+ try
+ {
+ streamInfo = new HTTPStreamInfo(MediaType.parseMimeType(markupRequest.getMimeType()), markupRequest.getCharacterSet());
+ }
+ catch (MimeTypeParseException e)
+ {
+ throw (UnsupportedMimeTypeFault)WSRPUtils.createFaultFrom(UnsupportedMimeTypeFault.class, e);
+ }
+ return streamInfo;
+ }
+
+ // fix-me: check that the correct semantics is used.
+ private SecurityContext createSecurityContext(final MarkupParams params, final RuntimeContext runtimeContext,
+ final org.jboss.portal.wsrp.core.UserContext wsrpUserContext)
+ {
+ return new SecurityContext()
+ {
+ public boolean isSecure()
+ {
+ return params.isSecureClientCommunication();
+ }
+
+ public String getAuthType()
+ {
+ return runtimeContext.getUserAuthentication();
+ }
+
+ public String getRemoteUser()
+ {
+ if (wsrpUserContext != null)
+ {
+ return wsrpUserContext.getUserContextKey();
+ }
+ return null;
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return null;
+ }
+
+ public boolean isUserInRole(String roleName)
+ {
+ if (wsrpUserContext != null)
+ {
+ List userCategories = Arrays.asList(wsrpUserContext.getUserCategories());
+ return userCategories.contains(roleName);
+ }
+ return false;
+ }
+
+ public boolean isAuthenticated()
+ {
+ return wsrpUserContext != null;
+ }
+ };
+ }
+
+ public PortletInvocation getInvocation()
+ {
+ return invocation;
+ }
+
+ public void setInvocation(PortletInvocation invocation)
+ {
+ this.invocation = invocation;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -25,6 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
@@ -41,6 +42,7 @@
import org.jboss.portal.wsrp.core.MarkupType;
import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
@@ -109,12 +111,13 @@
return offeredPortletDescriptions;
}
- public PortletDescription getPortletDescription(String handle, String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
Portlet portlet;
try
{
- portlet = producer.getPortletWith(handle);
+ portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext));
}
catch (PortletInvokerException e)
{
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * 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.producer;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.portlet.StateEvent;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.state.AccessMode;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+class WSRPInstanceContext implements InstanceContext
+{
+ private String id;
+ private byte[] state;
+ private final AccessMode accessMode;
+ private boolean wasModified = false;
+
+ public WSRPInstanceContext(String portletHandle, AccessMode accessMode)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle, "portlet handle", "InstanceContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "AccessMode");
+
+ this.id = portletHandle;
+ this.accessMode = accessMode;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public AccessMode getAccessMode()
+ {
+ return accessMode;
+ }
+
+ public void onStateEvent(StateEvent event)
+ {
+ org.jboss.portal.portlet.PortletContext portletContext = event.getPortletContext();
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ wasModified = true;
+ id = portletContext.getId();
+ state = portletContext.getState();
+ }
+
+ public boolean wasModified()
+ {
+ return wasModified;
+ }
+
+ public byte[] getState()
+ {
+ return state;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-01-10 22:41:12 UTC (rev 5986)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-01-10 23:27:44 UTC (rev 5987)
@@ -370,22 +370,22 @@
this.invoker = invoker;
}
- Portlet getPortletWith(String handle) throws InvalidHandleFault, PortletInvokerException
+ Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext) throws InvalidHandleFault, PortletInvokerException
{
Portlet portlet;
try
{
- portlet = invoker.getPortlet(org.jboss.portal.portlet.PortletContext.createPortletContext(handle));
+ portlet = invoker.getPortlet(portletContext);
}
catch (NoSuchPortletException e)
{
throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Couldn't find portlet with handle: " + handle));
+ new IllegalArgumentException("Couldn't find portlet with handle '" + portletContext.getId() + "'"));
}
if (!isRemotable(portlet))
{
throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Portlet with handle: " + handle + " is not remotely available."));
+ new IllegalArgumentException("Portlet '" + portletContext.getId() + "' is not remotely available."));
}
return portlet;
@@ -409,9 +409,9 @@
return remotablePortlets;
}
- public PortletDescription getPortletDescription(String handle, String[] locales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales) throws InvalidHandleFault, OperationFailedFault
{
- return serviceDescriptionHandler.getPortletDescription(handle, locales);
+ return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
}
/**
19 years, 3 months
JBoss Portal SVN: r5986 - trunk/theme.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-10 17:41:12 -0500 (Wed, 10 Jan 2007)
New Revision: 5986
Modified:
trunk/theme/build.xml
Log:
TestRenderContext does not seem to exist anymore, commented out
Modified: trunk/theme/build.xml
===================================================================
--- trunk/theme/build.xml 2007-01-10 22:37:23 UTC (rev 5985)
+++ trunk/theme/build.xml 2007-01-10 22:41:12 UTC (rev 5986)
@@ -271,7 +271,7 @@
<test todir="${test.reports}" name="org.jboss.portal.test.theme.metadata.TestRenderSetMetaData"/>
<!-- render tests -->
- <test todir="${test.reports}" name="org.jboss.portal.test.theme.render.TestRenderContext"/>
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.theme.render.TestRenderContext"/>-->
<test todir="${test.reports}" name="org.jboss.portal.test.theme.render.TestRenderedMarkup"/>
</x-test>
<x-classpath>
19 years, 3 months
JBoss Portal SVN: r5985 - in trunk: portlet and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-10 17:37:23 -0500 (Wed, 10 Jan 2007)
New Revision: 5985
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java
Modified:
trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml
trunk/portlet/build.xml
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java
trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml
trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java
trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java
trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java
Log:
- ported portlet session replication changes test from 2.4 to trunk
- make the multi server tests work in trunk (was disabled after the test framework refactorings)
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml 2007-01-10 22:37:23 UTC (rev 5985)
@@ -26,7 +26,7 @@
<security-domain>java:jaas/portal</security-domain>
<context-root>@portal.web.context-root@</context-root>
<replication-config>
- <replication-trigger>SET_AND_GET</replication-trigger>
+ <replication-trigger>SET</replication-trigger>
</replication-config>
<resource-ref>
<res-ref-name>jdbc/PortalDS</res-ref-name>
Modified: trunk/portlet/build.xml
===================================================================
--- trunk/portlet/build.xml 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/build.xml 2007-01-10 22:37:23 UTC (rev 5985)
@@ -345,6 +345,7 @@
<fileset dir="${build.resources}/test/ha/test-session-war"/>
<fileset dir="${build.classes}" includes="org/jboss/portal/test/portlet/ha/session/**"/>
<fileset dir="${build.classes}" includes="org/jboss/portal/test/framework/portlet/**"/>
+ <fileset dir="${build.classes}" includes="org/jboss/portal/test/portlet/framework/**"/>
</jar>
<!-- JSR 168 test case packaging -->
@@ -579,6 +580,35 @@
</execute-tests>
</target>
+ <target name="test-ha" depends="init">
+ <execute-tests>
+ <x-sysproperty>
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
+ <sysproperty key="test.root" value="${build.lib}"/>
+ <sysproperty key="test.uri" value="/test/redirect/"/>
+ </x-sysproperty>
+ <x-test>
+ <test todir="${test.reports}" name="org.jboss.portal.test.portlet.ha.session.SessionTestCase"/>
+ </x-test>
+ <x-classpath>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="jboss.remoting.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <pathelement location="${source.java}"/>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+
<target name="test2" depends="init">
<execute-tests>
<x-sysproperty>
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.portlet.ha.session;
import java.io.Serializable;
+import java.io.IOException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -61,4 +62,21 @@
}
return false;
}
+
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException
+ {
+ out.writeUTF(string);
+ System.out.print("Serializing " + string);
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+ {
+ string = in.readUTF();
+ System.out.print("Unserializing " + string);
+ }
+
+ public String toString()
+ {
+ return "MutableValue[" + string + "]";
+ }
}
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -25,6 +25,7 @@
import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
import org.jboss.portal.common.test.driver.DriverResponse;
import org.jboss.portal.common.test.driver.response.EndTestResponse;
+import org.jboss.portal.common.util.Tools;
import org.jboss.portal.test.framework.portlet.Sequence;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
@@ -41,6 +42,7 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import java.io.IOException;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -51,7 +53,7 @@
public void createTestReplicateImmutableValue(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+ registry.addSequence("TestReplicateImmutableValue", seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, PortletSecurityException, IOException
@@ -80,7 +82,7 @@
public void createTestReplicateMutableValue(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+ registry.addSequence("TestReplicateMutableValue", seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
@@ -111,7 +113,7 @@
public void createTestModifyExistingAttributeWithoutExplicitSetDoesNotReplicate(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+ registry.addSequence("TestModifyExistingAttributeWithoutExplicitSetDoesNotReplicate", seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
@@ -119,6 +121,7 @@
assertNull(request.getPortletSession(false));
PortletSession session = request.getPortletSession();
assertNotNull(session);
+ assertEquals(Collections.EMPTY_LIST, Tools.toList(session.getAttributeNames()));
MutableValue value = new MutableValue("abcdef");
session.setAttribute("mutable", value);
PortletURL portletURL = response.createRenderURL();
@@ -131,6 +134,7 @@
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
{
PortletSession session = request.getPortletSession();
+ assertEquals(Collections.singletonList("mutable"), Tools.toList(session.getAttributeNames()));
Object o = session.getAttribute("mutable");
assertNotNull(o);
assertEquals(MutableValue.class, o.getClass());
@@ -147,6 +151,7 @@
{
PortletSession session = request.getPortletSession();
assertNotNull(session);
+ assertEquals(Collections.singletonList("mutable"), Tools.toList(session.getAttributeNames()));
assertEquals(new MutableValue("abcdef"), session.getAttribute("mutable"));
return new EndTestResponse();
}
Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.ha.session;
+
+import org.jboss.portal.test.framework.server.runner.ServerTestRunner;
+import org.jboss.portal.test.framework.server.NodeId;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SessionTestCase extends ServerTestRunner
+{
+ public SessionTestCase()
+ {
+ super("test-ha-session.war", new NodeId[]{NodeId.PORTS_01,NodeId.PORTS_02});
+ }
+}
Modified: trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml 2007-01-10 22:37:23 UTC (rev 5985)
@@ -27,6 +27,5 @@
<security-domain>java:/jaas/other</security-domain>
<replication-config>
<replication-trigger>SET</replication-trigger>
- <replication-type>SYNC</replication-type>
</replication-config>
</jboss-web>
Modified: trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -24,14 +24,12 @@
import org.jboss.portal.test.framework.runner.BaseRunner;
import org.jboss.portal.test.framework.server.NodeId;
-import org.jboss.portal.common.test.TestParameterValue;
import org.jboss.portal.common.test.TestParametrization;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import junit.framework.AssertionFailedError;
import java.io.File;
import java.net.MalformedURLException;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -40,25 +38,49 @@
public class ServerTestRunner extends BaseRunner
{
+ /** . */
+ private String archiveName;
+
public ServerTestRunner()
{
- TestParametrization abc = JUnitAdapter.getParametrization();
- archiveName = (String)abc.getParameterValue("archive").get();
+ init(null);
}
+ public ServerTestRunner(NodeId[] nodeIds)
+ {
+ super(nodeIds);
+ init(null);
+ }
+
public ServerTestRunner(String archiveName)
{
- this.archiveName = archiveName;
+ init(archiveName);
}
- /** . */
- private String archiveName;
+ public ServerTestRunner(String archiveName, NodeId[] nodeIds)
+ {
+ super(nodeIds);
+ init(archiveName);
+ }
+ private void init(String archiveName)
+ {
+ if (archiveName == null)
+ {
+ TestParametrization abc = JUnitAdapter.getParametrization();
+ this.archiveName = (String)abc.getParameterValue("archive").get();
+ }
+ else
+ {
+ this.archiveName = archiveName;
+ }
+ }
+
public void startRunner() throws Exception
{
File root = new File(getArchivePath());
File f = new File(root, archiveName);
- getDeployer().deploy(f.toURL(), getNodeManager().getNode(NodeId.DEFAULT));
+ deploy(f.toURL());
}
public void stopRunner()
@@ -67,7 +89,7 @@
{
File root = new File(getArchivePath());
File f = new File(root, archiveName);
- getDeployer().undeploy(f.toURL());
+ undeploy(f.toURL());
}
catch (MalformedURLException e)
{
Modified: trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -29,8 +29,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -88,15 +86,15 @@
public void deploy(String url, Node node) throws Exception
{
- deploy(url, Collections.singleton(node));
+ deploy(url, new Node[]{node});
}
public void deploy(URL url, Node node) throws Exception
{
- deploy(url, Collections.singleton(node));
+ deploy(url, new Node[]{node});
}
- public void deploy(URL url, Collection nodes) throws Exception
+ public void deploy(URL url, Node[] nodes) throws Exception
{
Deployment deployment = new Deployment(nodes, url);
deployment.deploy(testAgentLookup);
@@ -112,7 +110,7 @@
}
}
- public void deploy(String url, Collection nodes) throws Exception
+ public void deploy(String url, Node[] nodes) throws Exception
{
this.deploy(getArchiveURL(url), nodes);
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -32,8 +32,6 @@
import java.io.IOException;
import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
/**
* A deployment in the portlet container.
@@ -47,7 +45,7 @@
private static final Logger log = Logger.getLogger(Deployment.class);
/** The nodes we must deploy to. */
- private final Collection nodes;
+ private final Node[] nodes;
/** The local url of the deployment to make. */
private URL url;
@@ -55,7 +53,7 @@
/** . */
private boolean deployed;
- public Deployment(Collection nodes, URL url)
+ public Deployment(Node[] nodes, URL url)
{
if (nodes == null)
{
@@ -89,9 +87,9 @@
//
try
{
- for (Iterator i = nodes.iterator(); i.hasNext();)
+ for (int i = 0;i < nodes.length;i++)
{
- Node node = (Node)i.next();
+ Node node = nodes[i];
TestAgent agent = (TestAgent)testAgentLookup.getService(node);
agent.deploy(url);
}
@@ -121,11 +119,11 @@
this.url = null;
//
- for (Iterator i = nodes.iterator(); i.hasNext();)
+ for (int i = 0;i < nodes.length;i++)
{
try
{
- Node node = (Node)i.next();
+ Node node = nodes[i];
TestAgent agent = (TestAgent)testAgentLookup.getService(node);
agent.undeploy(url);
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -133,15 +133,15 @@
this.serverLookup = serverLookup;
}
- private HttpTestDriverServer getServer()
+ private HttpTestDriverServer getServer(Node node)
{
- Node node = nodeManager.getNode(initialNodeId);
return (HttpTestDriverServer)serverLookup.getService(node);
}
public TestItemInfo getInfo()
{
- HttpTestDriverServer server = getServer();
+ Node node = nodeManager.getNode(initialNodeId);
+ HttpTestDriverServer server = getServer(node);
return server.getInfo();
}
@@ -340,14 +340,14 @@
{
requestCount = -1;
pushContext();
- DriverResponse response = getServer().invoke(testId, cmd);
+ DriverResponse response = getServer(node).invoke(testId, cmd);
requestCount = 0;
return new HttpDriverResponseContext(response);
}
else if (cmd instanceof SendResponseCommand)
{
pushContext();
- DriverResponse response = getServer().invoke(testId, cmd);
+ DriverResponse response = getServer(node).invoke(testId, cmd);
requestCount++;
return new HttpDriverResponseContext(response);
}
@@ -459,13 +459,13 @@
HttpTestContext ctx = new HttpTestContext(testId, requestCount, archivePath);
log.info("# Updating test case context of : " + node + " : " + ctx);
- HttpTestDriverServer agent = getServer();
+ HttpTestDriverServer agent = getServer(node);
agent.pushContext(testId, ctx);
}
private HttpTestContext popContext()
{
- HttpTestDriverServer agent = getServer();
+ HttpTestDriverServer agent = getServer(node);
return agent.popContext(testId);
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -38,6 +38,8 @@
import junit.framework.TestResult;
import junit.framework.TestCase;
+import java.net.URL;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -65,9 +67,6 @@
/** . */
private TestRuntimeContext runtimeContext;
- /** The node id list used for this test suite. */
- private NodeId[] nodeIds;
-
/** . */
private String archivePath;
@@ -86,6 +85,9 @@
/** . */
private ServiceLookup testAgentLookup;
+ /** The node id list used for this test suite. */
+ private NodeId[] nodeIds;
+
public Deployer getDeployer()
{
return deployer;
@@ -128,7 +130,7 @@
public BaseRunner()
{
- this("org/jboss/portal/test/framework/container/jboss-beans.xml");
+ this("org/jboss/portal/test/framework/container/jboss-beans.xml", new NodeId[]{NodeId.DEFAULT});
}
public BaseRunner(String beansDescriptorLocation)
@@ -136,16 +138,20 @@
this(beansDescriptorLocation, new NodeId[]{NodeId.DEFAULT});
}
+ public BaseRunner(NodeId[] nodeIds)
+ {
+ this("org/jboss/portal/test/framework/container/jboss-beans.xml", nodeIds);
+ }
+
public BaseRunner(String beansDescriptorLocation, NodeId[] nodeIds)
{
this.runtimeContext = new TestRuntimeContext(beansDescriptorLocation);
this.runtimeContext.addBean("TestBean", this);
- this.nodeIds = (NodeId[])nodeIds.clone();
this.archivePath = System.getProperty("test.root");
this.state = STOPPED;
+ this.nodeIds = nodeIds;
}
-
public String getArchivePath()
{
return archivePath;
@@ -171,10 +177,10 @@
//
HttpTestDriverClient driver = new HttpTestDriverClient();
+ driver.setInitialNodeId(nodeIds[0]);
driver.setArchivePath(archivePath);
driver.setNodeManager(nodeManager);
driver.setServerLookup(httpTestDriverServerLookup);
- driver.setInitialNodeId(NodeId.DEFAULT);
//
adapter = new JUnitAdapter(driver);
@@ -295,4 +301,14 @@
public final void destroy()
{
}
+
+ protected void deploy(URL url) throws Exception
+ {
+ getDeployer().deploy(url, getNodeManager().getNodes(nodeIds));
+ }
+
+ protected void undeploy(URL url)
+ {
+ getDeployer().undeploy(url);
+ }
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java 2007-01-10 22:37:23 UTC (rev 5985)
@@ -51,6 +51,17 @@
return nodeMap.values();
}
+ public Node[] getNodes(NodeId[] nodeIds)
+ {
+ Node[] nodes = new Node[nodeIds.length];
+ for (int i = 0;i < nodeIds.length;i++)
+ {
+ NodeId nodeId = nodeIds[i];
+ nodes[i] = getNode(nodeId);
+ }
+ return nodes;
+ }
+
public Node getNode(NodeId nodeId)
{
return (Node)nodeMap.get(nodeId);
19 years, 3 months