Author: chris.laprun(a)jboss.com
Date: 2007-01-09 23:44:22 -0500 (Tue, 09 Jan 2007)
New Revision: 5974
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- Now initializing the ProducerInfo when we start the Consumer instead of trying to
protect each methods.
- Added implicit cloning support but needs testing.
- Use PortletContext where it should be used instead of generating one from portlet
handle.
- Renamed refreshIfNeeded to refresh on ProducerInfo and added option to force refresh.
Cleaned up code.
- Consumer will now refresh the Producer Info on InitCookieFault to account for possible
changes in producer cookie policy.
- Fixed incorrect behavior of initCookie tests.
- TestWSRPProducerImpl now forces an error if initCookie is called when it shouldn't
have.
- Proper re-init of producer info in tests setUp.
- Removed ServiceDescriptionUnavailbleException.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -29,6 +29,7 @@
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicServiceDescriptionBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -153,6 +154,7 @@
registerMarkupBehavior(new SessionMarkupBehavior());
registerMarkupBehavior(new NullMarkupBehavior());
registerMarkupBehavior(new EmptyMarkupBehavior());
+ registerMarkupBehavior(new InitCookieMarkupBehavior());
sequence = new SingleBehaviorSequence(new TestBehaviorSequence.TestBehaviorSet(new
BasicServiceDescriptionBehavior()));
sequenceOrder = 0;
@@ -206,7 +208,9 @@
{
if (sequence != null)
{
- return sequence.getMarkupBehaviorFor(sequenceOrder);
+ MarkupBehavior markupBehavior = sequence.getMarkupBehaviorFor(sequenceOrder);
+ System.out.println("Using markup behavior for " +
markupBehavior.getPortletHandle() + " portlet handle.");
+ return markupBehavior;
}
throw new IllegalStateException("Don't have a MarkupBehavior to
return!");
}
@@ -276,6 +280,12 @@
public ReturnAny initCookie(InitCookie initCookie)
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
+ // should only be called if we required cookies to be initialized
+ if (requiresInitCookie == null)
+ {
+ throw new OperationFailedFault();
+ }
+
response.addCookie(new Cookie("cookieName", USER_COOKIE));
incrementBehaviorCallCount();
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -42,6 +42,7 @@
import org.jboss.portal.test.wsrp.framework.support.TestPortletInvocationContext;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
@@ -56,8 +57,7 @@
*/
public class MarkupTestCase extends V1ConsumerBaseTest
{
- public MarkupTestCase()
- throws Exception
+ public MarkupTestCase() throws Exception
{
super();
}
@@ -131,7 +131,7 @@
public void testInitCookie() throws Exception
{
// first test that we don't initialize cookies if we don't need it
- RenderInvocation render =
createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
+ RenderInvocation render =
createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
TestPortletInvocationContext invocationContext =
(TestPortletInvocationContext)render.getContext();
HttpSession session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
@@ -144,7 +144,7 @@
// now require cookie initialization and check that everything went well
producer.setRequiresInitCookie(CookieProtocol.perUser);
- render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
+ render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
invocationContext = (TestPortletInvocationContext)render.getContext();
session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -49,9 +49,12 @@
ExtendedAssert.assertEquals(ServiceObjectFactory.SAMPLE_KEYWORD + suffix,
ServiceObjectFactory.extractString(meta.getMetaValue(MetaInfo.KEYWORDS)));
}
- public void tearDown() throws Exception
+
+ public void setUp() throws Exception
{
+ super.setUp();
producer.reset();
- super.tearDown();
+ // make sure we use clean producer info for each test
+ consumer.refreshProducerInfo();
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -83,7 +83,8 @@
String suffix;
if (handle.startsWith(BasicMarkupBehavior.PORTLET_HANDLE)
|| NullMarkupBehavior.PORTLET_HANDLE.equals(handle)
- || EmptyMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ || EmptyMarkupBehavior.PORTLET_HANDLE.equals(handle)
+ || InitCookieMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
suffix = "";
}
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.v1.consumer.behaviors;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class InitCookieMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "initcookiehandle";
+
+
+ public InitCookieMarkupBehavior()
+ {
+ portletHandle = PORTLET_HANDLE;
+ }
+
+ protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup) throws InvalidCookieFault, OperationFailedFault
+ {
+ System.out.println("InitCookieMarkupBehavior getMarkupString call count:
" + callCount);
+ String markup = "markup";
+ switch (callCount++)
+ {
+ case 0:
+ return markup;
+
+ case 1:
+ // simulate change of configuration between calls: upon receiving this, the
consumer should invoke initCookie
+ throw new InvalidCookieFault();
+
+ case 2:
+ return markup;
+
+ default:
+ // shouldn't be called more than 3 times
+ throw new OperationFailedFault();
+ }
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.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/PortletManagementTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -65,15 +65,17 @@
public void testClonePortlet() throws Exception
{
String handle = getDefaultHandle();
+ PortletContext initialContext = WSRPTypeFactory.createPortletContext(handle);
+
// first check that we get a new PortletContext
- PortletContext portletContext = clonePortlet(handle);
- ExtendedAssert.assertNotNull(portletContext);
-
ExtendedAssert.assertFalse(WSRPTypeFactory.createPortletContext(handle).equals(portletContext));
+ PortletContext cloneContext = clonePortlet(handle);
+ ExtendedAssert.assertNotNull(cloneContext);
+ ExtendedAssert.assertFalse(initialContext.equals(cloneContext));
// then check that the initial state is identical
- GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, portletContext.getPortletHandle());
+ GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, cloneContext);
Property[] result =
portletManagementService.getPortletProperties(getPortletProperties).getProperties();
- getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, handle);
+ getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null,
initialContext);
checkGetPropertiesResponse(portletManagementService.getPortletProperties(getPortletProperties),
result);
// check that new clone is not listed in service description
@@ -127,7 +129,8 @@
public void testGetPortletPropertiesNoRegistration() throws Exception
{
String handle = getDefaultHandle();
- GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, handle);
+ PortletContext initialContext = WSRPTypeFactory.createPortletContext(handle);
+ GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, initialContext);
getPortletProperties.setNames(new String[]{"prefName1",
"prefName2"});
PropertyList response =
portletManagementService.getPortletProperties(getPortletProperties);
@@ -184,7 +187,7 @@
SetPortletProperties setPortletProperties =
WSRPTypeFactory.createSetPortletProperties(portletContext, propertyList);
PortletContext response =
portletManagementService.setPortletProperties(setPortletProperties);
- GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, portletContext.getPortletHandle());
+ GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(null, response);
checkGetPropertiesResponse(portletManagementService.getPortletProperties(getPortletProperties),
properties);
portletContext = WSRPTypeFactory.createPortletContext(handle);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-01-10 02:28:08 UTC
(rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-01-10 04:44:22 UTC
(rev 5974)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp;
import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
@@ -89,4 +90,10 @@
* @since 2.6
*/
void setProducerInfo(ProducerInfo producerInfo);
+
+ /**
+ * @throws PortletInvokerException
+ * @since 2.6
+ */
+ void refreshProducerInfo() throws PortletInvokerException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-01-10 02:28:08 UTC
(rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-01-10 04:44:22 UTC
(rev 5974)
@@ -104,25 +104,26 @@
*/
public static GetMarkup createDefaultMarkupRequest(String handle)
{
- return createMarkupRequest(handle, createDefaultRuntimeContext(),
createDefaultMarkupParams());
+ return createMarkupRequest(createPortletContext(handle),
createDefaultRuntimeContext(), createDefaultMarkupParams());
}
/**
* registrationContext(RegistrationContext)?, portletContext(PortletContext),
runtimeContext(RuntimeContext),
* userContext(UserContext)?, markupParams(MarkupParams)
*
- * @param handle
+ * @param portletContext
* @param runtimeContext
* @param markupParams
* @return
* @throws IllegalArgumentException if one of the required parameters is
<code>null</code>
*/
- public static GetMarkup createMarkupRequest(String handle, RuntimeContext
runtimeContext, MarkupParams markupParams)
+ public static GetMarkup createMarkupRequest(PortletContext portletContext,
RuntimeContext runtimeContext, MarkupParams markupParams)
{
ParameterValidation.throwIllegalArgExceptionIfNull(runtimeContext,
"RuntimeContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNull(markupParams,
"MarkupParams");
- return new GetMarkup(null, createPortletContext(handle), runtimeContext, null,
markupParams);
+ return new GetMarkup(null, portletContext, runtimeContext, null, markupParams);
}
/**
@@ -134,7 +135,7 @@
*/
public static PerformBlockingInteraction
createDefaultPerformBlockingInteraction(String portletHandle)
{
- return createPerformBlockingInteraction(portletHandle,
createDefaultRuntimeContext(), createDefaultMarkupParams(),
+ return createPerformBlockingInteraction(createPortletContext(portletHandle),
createDefaultRuntimeContext(), createDefaultMarkupParams(),
createDefaultInteractionParams());
}
@@ -142,22 +143,24 @@
* {@link org.jboss.portal.wsrp.core.RegistrationContext}?, {@link PortletContext},
{@link RuntimeContext}, {@link
* org.jboss.portal.wsrp.core.UserContext}?, {@link MarkupParams}, {@link
InteractionParams}
*
- * @param portletHandle
+ * @param portletContext
* @param runtimeContext
* @param markupParams
* @param interactionParams
* @return
*/
- public static PerformBlockingInteraction createPerformBlockingInteraction(String
portletHandle,
-
RuntimeContext runtimeContext,
- MarkupParams
markupParams,
-
InteractionParams interactionParams)
+ public static PerformBlockingInteraction createPerformBlockingInteraction(
+ PortletContext portletContext, RuntimeContext runtimeContext,
+ MarkupParams markupParams,
+ InteractionParams interactionParams)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
+
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletContext.getPortletHandle(),
"portlet handle", "PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNull(runtimeContext,
"RuntimeContext");
ParameterValidation.throwIllegalArgExceptionIfNull(markupParams,
"MarkupParams");
ParameterValidation.throwIllegalArgExceptionIfNull(interactionParams,
"InteractionParams");
- return new PerformBlockingInteraction(null, createPortletContext(portletHandle),
runtimeContext, null,
+ return new PerformBlockingInteraction(null, portletContext, runtimeContext, null,
markupParams, interactionParams);
}
@@ -180,13 +183,14 @@
* desiredLocales(xsd:string)*
*
* @param registrationContext
- * @param portletHandle
+ * @param portletContext
* @return
* @since 2.4.1
*/
- public static GetPortletProperties createGetPortletProperties(RegistrationContext
registrationContext, String portletHandle)
+ public static GetPortletProperties createGetPortletProperties(RegistrationContext
registrationContext, PortletContext portletContext)
{
- return new GetPortletProperties(registrationContext,
createPortletContext(portletHandle), null, null);
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
+ return new GetPortletProperties(registrationContext, portletContext, null, null);
}
/** ====== WSRP Response objects ====== **/
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -27,6 +27,7 @@
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -48,6 +49,7 @@
import org.jboss.portal.wsrp.core.UserContext;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -66,7 +68,8 @@
protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation
invocation)
{
- log.debug("Consumer about to attempt rendering portlet '" +
requestPrecursor.portletHandle + "'");
+ PortletContext portletContext = requestPrecursor.getPortletContext();
+ log.debug("Consumer about to attempt rendering portlet '" +
portletContext.getPortletHandle() + "'");
// access mode
InstanceContext instanceContext = invocation.getInstanceContext();
@@ -110,9 +113,8 @@
// todo: need to deal with GET method in forms
// Create the blocking action request
- return WSRPTypeFactory.createPerformBlockingInteraction(
- requestPrecursor.portletHandle, requestPrecursor.runtimeContext,
requestPrecursor.markupParams,
- interactionParams);
+ return WSRPTypeFactory.createPerformBlockingInteraction(portletContext,
requestPrecursor.runtimeContext,
+ requestPrecursor.markupParams, interactionParams);
}
protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
@@ -156,14 +158,34 @@
result.setNavigationalState(StateString.createFrom(navigationalState));
}
- // todo: deal with new portlet handle and portlet state
+ // check if the portlet was cloned
PortletContext portletContext = updateResponse.getPortletContext();
- if (portletContext != null &&
!requestPrecursor.portletHandle.equals(portletContext.getPortletHandle()))
+ if (portletContext != null)
{
- throw new UnsupportedOperationException("Portlet cloning not currently
supported: producer '" + consumer.getProducerId()
- + "' updated the portlet handle.");
+ PortletContext originalContext = requestPrecursor.getPortletContext();
+ InstanceContext context = invocation.getInstanceContext();
+
+ if
(!originalContext.getPortletHandle().equals(portletContext.getPortletHandle()))
+ {
+ log.debug("Portlet '" + requestPrecursor.getPortletHandle()
+ "' was implicitely cloned. New handle is '"
+ + portletContext.getPortletHandle() + "'");
+ StateEvent event = new
StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext),
StateEvent.PORTLET_CLONED_EVENT);
+ context.onStateEvent(event);
+ }
+ else
+ {
+ // check if the state was modified
+ byte[] originalState = originalContext.getPortletState();
+ byte[] newState = portletContext.getPortletState();
+ if (!Arrays.equals(originalState, newState))
+ {
+ StateEvent event = new
StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext),
StateEvent.PORTLET_MODIFIED_EVENT);
+ context.onStateEvent(event);
+ }
+ }
}
+
return result;
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -24,7 +24,6 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.logging.Logger;
-import org.jboss.portal.portlet.InvokerUnavailableException;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -76,15 +75,7 @@
Object request = prepareRequest(requestPrecursor, invocation);
// Perform the request
- Object response;
- try
- {
- response = performRequest(request, invocation);
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new InvokerUnavailableException(e.getMessage(), e);
- }
+ Object response = performRequest(request, invocation);
if (response instanceof ErrorResponse)
{
return unwrapWSRPError((ErrorResponse)response);
@@ -93,8 +84,7 @@
return processResponse(response, invocation, requestPrecursor);
}
- protected Object performRequest(Object request, PortletInvocation invocation)
- throws ServiceDescriptionUnavailableException, PortletInvokerException
+ protected Object performRequest(Object request, PortletInvocation invocation) throws
PortletInvokerException
{
int retryCount = 0;
Object response = null;
@@ -160,7 +150,7 @@
* handled
*/
private ErrorResponse dealWithError(Exception error, PortletInvocation invocation,
RuntimeContext runtimeContext)
- throws ServiceDescriptionUnavailableException, PortletInvokerException
+ throws PortletInvokerException
{
log.error("The portlet threw an exception", error);
@@ -169,8 +159,10 @@
// recoverable errors
if (error instanceof InvalidCookieFault)
{
- log.debug("Re-initializing cookies after InvalidCookieFault.");
// we need to re-init the cookies
+ log.debug("Re-initializing cookies after InvalidCookieFault.");
+ // force a producer info refresh because the invalid cookie might be due to a
change of cookie policy on the producer
+ consumer.refreshProducerInfo();
try
{
sessionHandler.initCookieIfNeeded(invocation);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -130,18 +130,23 @@
return requiresInitCookie;
}
-
public boolean isInitialized()
{
return isInitialized;
}
- public boolean refreshIfNeeded() throws PortletInvokerException,
ServiceDescriptionUnavailableException
+ public void start() throws Exception
{
+ refresh(true);
+ endpointConfigurationInfo.getServiceFactory().start();
+ }
+
+ public boolean refresh(boolean forceRefresh) throws PortletInvokerException
+ {
ServiceDescription serviceDescription;
// might neeed a different cache value: right now, we cache the whole producer info
but we might want to cache
// POPs and rest of producer info separetely...
- if (isCacheExpired() || !isInitialized())
+ if (forceRefresh || isCacheExpired() || !isInitialized())
{
log.debug("ProducerInfo refresh needed for producer '" +
producerId + "'");
serviceDescription = getServiceDescription();
@@ -181,7 +186,7 @@
}
catch (Exception e)
{
- registrationInfo.resetRegistration();
+ resetRegistration(false);
throw new PortletInvokerException("Couldn't register with
producer '" + producerId + "'", e);
}
@@ -321,24 +326,12 @@
public Portlet getPortlet(String portletId) throws PortletInvokerException
{
- try
- {
- if (!refreshIfNeeded())
- {
- throw new PortletInvokerException("Couldn't initialize producer
'" + producerId + "'");
- }
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new PortletInvokerException("Couldn't initialize producer
'" + producerId + "'", e);
- }
-
// if cache is still valid, use information from cached service description
if (useCache() && !isCacheExpired())
{
log.debug("getPortlet from cached service description");
- return (Portlet)popsMap.get(portletId);
+ return (Portlet)getPortletMap().get(portletId);
}
else // otherwise, retrieve just the information for the appropriate portlet
{
@@ -363,14 +356,13 @@
}
}
- public Map getPortletGroupMap() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ public Map getPortletGroupMap() throws PortletInvokerException
{
refreshPOPsIfNeeded();
-
return portletGroups;
}
- public Map getPortletMap() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ public Map getPortletMap() throws PortletInvokerException
{
refreshPOPsIfNeeded();
return popsMap;
@@ -383,9 +375,9 @@
return expirationCacheSeconds != null && expirationCacheSeconds.intValue()
> 0;
}
- private void refreshPOPsIfNeeded() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ private void refreshPOPsIfNeeded() throws PortletInvokerException
{
- refreshIfNeeded();
+ refresh(false);
if (isCacheExpired())
{
extractOfferedPortlets(getServiceDescription());
@@ -422,7 +414,7 @@
this.expirationCacheSeconds = expirationCacheSeconds;
}
- private ServiceDescription getServiceDescription() throws
ServiceDescriptionUnavailableException, PortletInvokerException
+ private ServiceDescription getServiceDescription() throws PortletInvokerException
{
GetServiceDescription request = getServiceDescriptionRequest();
request.setRegistrationContext(getRegistrationContext());
@@ -449,7 +441,7 @@
{
log.debug("Caught Exception in getServiceDescription:\n", e);
Throwable cause = e.getCause();
- throw new ServiceDescriptionUnavailableException("Problem getting service
description for producer "
+ throw new InvokerUnavailableException("Problem getting service description
for producer "
+ producerId, cause == null ? e : cause);
}
}
@@ -492,4 +484,15 @@
{
return registrationInfo.getRegistrationContext();
}
+
+ public void resetRegistration() throws PortletInvokerException
+ {
+ resetRegistration(true);
+ }
+
+ private void resetRegistration(boolean refresh) throws PortletInvokerException
+ {
+ registrationInfo.resetRegistration();
+ refresh(refresh);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -39,6 +39,7 @@
import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.MarkupContext;
import org.jboss.portal.wsrp.core.MarkupResponse;
+import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.UserContext;
@@ -81,9 +82,9 @@
protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation
invocation)
{
// Create the markup request
- log.debug("Consumer about to attempt rendering portlet '" +
requestPrecursor.portletHandle + "'");
- return WSRPTypeFactory.createMarkupRequest(requestPrecursor.portletHandle,
- requestPrecursor.runtimeContext, requestPrecursor.markupParams);
+ PortletContext portletContext = requestPrecursor.getPortletContext();
+ log.debug("Consumer about to attempt rendering portlet '" +
portletContext.getPortletHandle() + "'");
+ return WSRPTypeFactory.createMarkupRequest(portletContext,
requestPrecursor.runtimeContext, requestPrecursor.markupParams);
}
protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -37,6 +37,7 @@
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.MarkupParams;
+import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.RuntimeContext;
/**
@@ -49,7 +50,7 @@
class RequestPrecursor
{
Logger log = Logger.getLogger(getClass());
- String portletHandle;
+ private PortletContext portletContext;
RuntimeContext runtimeContext;
MarkupParams markupParams;
private static final String PORTLET_HANDLE = "portlet handle";
@@ -62,9 +63,9 @@
public RequestPrecursor(WSRPConsumerImpl wsrpConsumer, PortletInvocation invocation)
throws PortletInvokerException
{
// retrieve handle
- portletHandle = WSRPConsumerImpl.getPortletHandle(invocation);
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
PORTLET_HANDLE, null);
- log.debug("About to invoke on portlet: " + portletHandle);
+ portletContext =
WSRPUtils.convertToWSRPPortletContext(WSRPConsumerImpl.getPortletContext(invocation));
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(getPortletHandle(),
PORTLET_HANDLE, null);
+ log.debug("About to invoke on portlet: " + getPortletHandle());
// create runtime context
SecurityContext securityContext = invocation.getSecurityContext();
@@ -122,4 +123,15 @@
}
}
}
+
+ public String getPortletHandle()
+ {
+ return portletContext.getPortletHandle();
+ }
+
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java 2007-01-10
02:28:08 UTC (rev 5973)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.consumer;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4 (May 12, 2006)
- */
-public class ServiceDescriptionUnavailableException extends Exception
-{
- public ServiceDescriptionUnavailableException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -112,20 +112,12 @@
RequestHeaderClientHandler.resetCurrentInfo();
}
- public void initCookieIfNeeded(PortletInvocation invocation) throws Exception
+ public void initCookieIfNeeded(PortletInvocation invocation) throws
PortletInvokerException
{
- try
- {
- initCookieIfNeeded(invocation, true);
- }
- catch (InvokerUnavailableException e)
- {
- throw new ServiceDescriptionUnavailableException(e.getLocalizedMessage(), e);
- }
+ initCookieIfNeeded(invocation, true);
}
- private void initCookieIfNeeded(PortletInvocation invocation, boolean retryIfFails)
- throws Exception, InvokerUnavailableException
+ private void initCookieIfNeeded(PortletInvocation invocation, boolean retryIfFails)
throws PortletInvokerException
{
// check if the cookie protocol requires cookie initialization
if (!requiresInitCookie())
@@ -175,8 +167,7 @@
sessionInformation.setInitCookieDone(true);
}
- private void initCookie(InitCookie initCookie, PortletInvocation invocation, boolean
retryIfFails)
- throws Exception, InvokerUnavailableException
+ private void initCookie(InitCookie initCookie, PortletInvocation invocation, boolean
retryIfFails) throws PortletInvokerException
{
try
{
@@ -192,8 +183,7 @@
}
catch (Exception e)
{
- log.fatal("initCookie failed!", e);
- throw e;
+ throw new InvokerUnavailableException("Couldn't init cookies!",
e);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-01-10
02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-01-10
04:44:22 UTC (rev 5974)
@@ -167,7 +167,6 @@
// the portlet is not cloned, so try POP ones...
if (portlet == null)
{
- refreshProducerInfo();
portlet = producerInfo.getPortlet(portletId);
}
@@ -184,7 +183,6 @@
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
InvocationHandler handler;
- refreshProducerInfo();
if (invocation instanceof RenderInvocation)
{
@@ -212,8 +210,6 @@
throw new PortletInvokerException("No portlet '" +
portletContext.getId() + "' to clone!");
}
- refreshProducerInfo();
-
// todo: deal with user context
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(getRegistrationContext(),
WSRPUtils.convertToWSRPPortletContext(portletContext), null);
@@ -256,8 +252,6 @@
handles.add(id);
}
- refreshProducerInfo();
-
DestroyPortlets destroyPortlets =
WSRPTypeFactory.createDestroyPortlets(getRegistrationContext(),
(String[])handles.toArray(new String[0]));
@@ -307,10 +301,8 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
- refreshProducerInfo();
-
GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(getRegistrationContext(),
- portletContext.getId());
+ WSRPUtils.convertToWSRPPortletContext(portletContext));
getPortletProperties.setNames(keys);
try
@@ -362,8 +354,6 @@
+ "' because there is no such portlet.");
}
- refreshProducerInfo();
-
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
int changesNumber = changes.length;
List updates = new ArrayList(changesNumber);
@@ -424,16 +414,26 @@
// Portlet-related methods
******************************************************************************************
- public Map getPortletGroupMap() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ public Map getPortletGroupMap() throws PortletInvokerException
{
return producerInfo.getPortletGroupMap();
}
static String getPortletHandle(PortletInvocation invocation)
{
- return ((PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE)).getId();
+ return getPortletContext(invocation).getId();
}
+ /**
+ * @param invocation
+ * @return
+ * @since 2.6
+ */
+ static PortletContext getPortletContext(PortletInvocation invocation)
+ {
+ return (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ }
+
WSRPPortletInfo getPortletInfo(PortletInvocation invocation) throws
PortletInvokerException
{
return (WSRPPortletInfo)getWSRPPortlet(getPortletHandle(invocation)).getInfo();
@@ -444,16 +444,16 @@
return (WSRPPortlet)getPortlet(portletId);
}
- private Map getPortletMap() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ private Map getPortletMap() throws PortletInvokerException
{
- refreshProducerInfo();
+ Map portletMap = producerInfo.getPortletMap();
if (ccpsMap.isEmpty())
{
- return producerInfo.getPortletMap();
+ return portletMap;
}
else
{
- Map all = new HashMap(producerInfo.getPortletMap());
+ Map all = new HashMap(portletMap);
all.putAll(ccpsMap);
return all;
}
@@ -477,11 +477,10 @@
// Registration
*****************************************************************************************************
- void handleInvalidRegistrationFault() throws ServiceDescriptionUnavailableException,
PortletInvokerException
+ void handleInvalidRegistrationFault() throws PortletInvokerException
{
// reset registration data and try again
- producerInfo.getRegistrationInfo().resetRegistration();
- refreshProducerInfo();
+ producerInfo.resetRegistration();
}
RegistrationContext getRegistrationContext()
@@ -505,7 +504,7 @@
protected void startService() throws Exception
{
- getServiceFactory().start();
+ producerInfo.start();
}
// Web services access
**********************************************************************************************
@@ -540,23 +539,9 @@
return producerInfo.getEndpointConfigurationInfo().getRegistrationService();
}
- /**
- * Refreshes the producer information if needed
- *
- * @throws org.jboss.portal.portlet.PortletInvokerException
- *
- * @since 2.6
- */
- private void refreshProducerInfo() throws PortletInvokerException
+ public void refreshProducerInfo() throws PortletInvokerException
{
- try
- {
- producerInfo.refreshIfNeeded();
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new PortletInvokerException("Unable to initialize producer
'" + producerInfo.getId() + "'", e);
- }
+ producerInfo.refresh(true);
sessionHandler.setRequiresInitCookie(producerInfo.getRequiresInitCookie());
}