Author: chris.laprun(a)jboss.com
Date: 2010-06-28 08:24:52 -0400 (Mon, 28 Jun 2010)
New Revision: 3502
Added:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EventHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/NavigationalStateUpdatingHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/EventRequestProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/UpdateNavigationalStateResponseProcessor.java
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ActionHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/InvocationHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RegistrationInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ActionRequestProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupInterface.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/BasicPortlet.java
Log:
- GTNWSRP-39:
+ Added EventHandler to deal with event dispatching.
+ Introduced NavigationalStateUpdatingHandler to gather common behavior between
InvocationHandler and EventHandler.
+ Introduced UpdateNavigationalStateResponderProcessor to gather common behavior between
EventRequestProcessor and ActionRequestProcessor.
- GTNWSRP-38: moved handling of PRPs to WSRPUtils.
- Use more factory methods instead of direct constructor calls.
- Protect debugging calls
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ActionHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ActionHandler.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ActionHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -28,16 +28,13 @@
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.gatein.common.util.ParameterValidation;
-import org.gatein.pc.api.OpaqueStateString;
import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.pc.api.StateEvent;
import org.gatein.pc.api.StateString;
import org.gatein.pc.api.invocation.ActionInvocation;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.HTTPRedirectionResponse;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
-import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
import org.gatein.pc.api.spi.InstanceContext;
import org.gatein.pc.api.state.AccessMode;
import org.gatein.wsrp.WSRPTypeFactory;
@@ -46,7 +43,6 @@
import org.oasis.wsrp.v2.Extension;
import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.NamedString;
-import org.oasis.wsrp.v2.NavigationalContext;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.RuntimeContext;
@@ -60,7 +56,6 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -69,7 +64,7 @@
* @version $Revision: 13121 $
* @since 2.4 (May 31, 2006)
*/
-public class ActionHandler extends InvocationHandler
+public class ActionHandler extends NavigationalStateUpdatingHandler
{
protected ActionHandler(WSRPConsumerImpl consumer)
{
@@ -87,16 +82,21 @@
ActionInvocation actionInvocation = (ActionInvocation)invocation;
PortletContext portletContext = requestPrecursor.getPortletContext();
- log.debug("Consumer about to attempt action on portlet '" +
portletContext.getPortletHandle() + "'");
+ if (debug)
+ {
+ log.debug("Consumer about to attempt action on portlet '" +
portletContext.getPortletHandle() + "'");
+ }
// access mode
InstanceContext instanceContext = invocation.getInstanceContext();
ParameterValidation.throwIllegalArgExceptionIfNull(instanceContext, "instance
context");
AccessMode accessMode = instanceContext.getAccessMode();
ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access
mode");
- log.debug("Portlet is requesting " + accessMode + " access
mode");
- InteractionParams interactionParams =
-
WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));
+ if (debug)
+ {
+ log.debug("Portlet is requesting " + accessMode + " access
mode");
+ }
+ InteractionParams interactionParams =
WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));
// interaction state
StateString interactionState = actionInvocation.getInteractionState();
@@ -127,8 +127,12 @@
if (!item.isFormField())
{
String contentType = item.getContentType();
- log.debug("File field " + item.getFieldName() + " with
file name " + item.getName() + " and content type "
- + contentType + " detected.");
+ if (debug)
+ {
+ log.debug("File field " + item.getFieldName() + "
with file name " + item.getName() + " and content type "
+ + contentType + " detected.");
+ }
+
BufferedInputStream bufIn = new BufferedInputStream(stream);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -150,16 +154,13 @@
List<NamedString> mimeAttributes = new
ArrayList<NamedString>(2);
- NamedString mimeAttribute = new NamedString();
- mimeAttribute.setName(FileUpload.CONTENT_DISPOSITION);
- mimeAttribute.setValue(FileUpload.FORM_DATA + ";"
+ String value = FileUpload.FORM_DATA + ";"
+ " name=\"" + item.getFieldName() +
"\";"
- + " filename=\"" + item.getName() +
"\"");
+ + " filename=\"" + item.getName() +
"\"";
+ NamedString mimeAttribute =
WSRPTypeFactory.createNamedString(FileUpload.CONTENT_DISPOSITION, value);
mimeAttributes.add(mimeAttribute);
- mimeAttribute = new NamedString();
- mimeAttribute.setName(FileUpload.CONTENT_TYPE);
- mimeAttribute.setValue(item.getContentType());
+ mimeAttribute =
WSRPTypeFactory.createNamedString(FileUpload.CONTENT_TYPE, item.getContentType());
mimeAttributes.add(mimeAttribute);
uploadContext.getMimeAttributes().addAll(mimeAttributes);
@@ -168,9 +169,7 @@
}
else
{
- NamedString formParameter = new NamedString();
- formParameter.setName(item.getFieldName());
- formParameter.setValue(Streams.asString(stream));
+ NamedString formParameter =
WSRPTypeFactory.createNamedString(item.getFieldName(), Streams.asString(stream));
formParameters.add(formParameter);
}
}
@@ -192,9 +191,7 @@
NamedString formParameter;
for (String value : values)
{
- formParameter = new NamedString();
- formParameter.setName(name);
- formParameter.setValue(value);
+ formParameter = WSRPTypeFactory.createNamedString(name, value);
formParameters.add(formParameter);
}
}
@@ -209,7 +206,10 @@
// todo: need to deal with GET method in forms
- log.debug(WSRPUtils.toString(interactionParams));
+ if (trace)
+ {
+ log.trace(WSRPUtils.toString(interactionParams));
+ }
// Create the blocking action request
return WSRPTypeFactory.createPerformBlockingInteraction(portletContext,
requestPrecursor.runtimeContext,
@@ -219,7 +219,6 @@
protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
{
BlockingInteractionResponse blockingInteractionResponse =
(BlockingInteractionResponse)response;
- log.debug("Starting processing response");
String redirectURL = blockingInteractionResponse.getRedirectURL();
UpdateResponse updateResponse = blockingInteractionResponse.getUpdateResponse();
@@ -241,75 +240,7 @@
{
// updateResponse.getMarkupContext(); // ignore bundled markup for now.
- UpdateNavigationalStateResponse result = new UpdateNavigationalStateResponse();
- // new mode
- String newMode = updateResponse.getNewMode();
- if (newMode != null)
- {
- result.setMode(WSRPUtils.getJSR168PortletModeFromWSRPName(newMode));
- }
- // new window state
- String newWindowState = updateResponse.getNewWindowState();
- if (newWindowState != null)
- {
-
result.setWindowState(WSRPUtils.getJSR168WindowStateFromWSRPName(newWindowState));
- }
- // navigational state
- NavigationalContext navigationalContext =
updateResponse.getNavigationalContext();
- if (navigationalContext != null)
- {
- String navigationalState = navigationalContext.getOpaqueValue();
- if (navigationalState != null) // todo: check meaning of empty private NS
- {
- result.setNavigationalState(new OpaqueStateString(navigationalState));
- }
-
- // todo: public NS GTNWSRP-38
- }
-
- // check if the portlet was cloned
- PortletContext portletContext = updateResponse.getPortletContext();
- if (portletContext != null)
- {
- PortletContext originalContext = requestPrecursor.getPortletContext();
- InstanceContext context = invocation.getInstanceContext();
-
- String handle = portletContext.getPortletHandle();
- if (!originalContext.getPortletHandle().equals(handle))
- {
- // todo: GTNWSRP-36 If the Producer returns a new portletHandle without
returning a new sessionID, the Consumer MUST
- // associate the current sessionID with the new portletHandle rather than
the previous portletHandle.
- log.debug("Portlet '" + requestPrecursor.getPortletHandle()
+ "' was implicitely cloned. New handle is '"
- + handle + "'");
- StateEvent event = new
StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext),
StateEvent.Type.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.Type.PORTLET_MODIFIED_EVENT);
- context.onStateEvent(event);
- }
- }
-
- // update the session information associated with the portlet handle
-
consumer.getSessionHandler().updateSessionInfoFor(originalContext.getPortletHandle(),
handle, invocation);
- }
- else
- {
- portletContext = requestPrecursor.getPortletContext();
- }
-
- // update the session info, using either the original or cloned portlet context,
as appropriate
-
consumer.getSessionHandler().updateSessionIfNeeded(updateResponse.getSessionContext(),
invocation,
- portletContext.getPortletHandle());
-
- log.debug("Response processed");
- return result;
+ return processUpdateResponse(invocation, requestPrecursor, updateResponse);
}
}
@@ -335,17 +266,24 @@
Holder<String> redirectURL = new Holder<String>();
// invocation
- log.debug("performBlockingInteraction on '" +
interaction.getPortletContext().getPortletHandle() + "'");
+ if (debug)
+ {
+ log.debug("performBlockingInteraction on '" +
interaction.getPortletContext().getPortletHandle() + "'");
+ }
consumer.getMarkupService().performBlockingInteraction(interaction.getRegistrationContext(),
interaction.getPortletContext(), interaction.getRuntimeContext(),
interaction.getUserContext(),
interaction.getMarkupParams(), interaction.getInteractionParams(),
updateResponseHolder, redirectURL,
new Holder<List<Extension>>());
// construct response
- BlockingInteractionResponse response = new BlockingInteractionResponse();
- response.setRedirectURL(redirectURL.value);
- response.setUpdateResponse(updateResponseHolder.value);
- return response;
+ if (redirectURL.value != null)
+ {
+ return WSRPTypeFactory.createBlockingInteractionResponse(redirectURL.value);
+ }
+ else
+ {
+ return
WSRPTypeFactory.createBlockingInteractionResponse(updateResponseHolder.value);
+ }
}
private PerformBlockingInteraction getActionRequest(Object request)
Added:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EventHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EventHandler.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EventHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.consumer;
+
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.invocation.EventInvocation;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.ErrorResponse;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.spi.InstanceContext;
+import org.gatein.pc.api.state.AccessMode;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.WSRPUtils;
+import org.oasis.wsrp.v2.Event;
+import org.oasis.wsrp.v2.EventParams;
+import org.oasis.wsrp.v2.Extension;
+import org.oasis.wsrp.v2.HandleEvents;
+import org.oasis.wsrp.v2.HandleEventsFailed;
+import org.oasis.wsrp.v2.HandleEventsResponse;
+import org.oasis.wsrp.v2.PortletContext;
+import org.oasis.wsrp.v2.RuntimeContext;
+import org.oasis.wsrp.v2.UpdateResponse;
+import org.oasis.wsrp.v2.UserContext;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class EventHandler extends NavigationalStateUpdatingHandler
+{
+ public EventHandler(WSRPConsumerImpl consumer)
+ {
+ super(consumer);
+ }
+
+ @Override
+ protected void updateUserContext(Object request, UserContext userContext)
+ {
+ getHandleEvents(request).setUserContext(userContext);
+ }
+
+ @Override
+ protected void updateRegistrationContext(Object request) throws
PortletInvokerException
+ {
+
getHandleEvents(request).setRegistrationContext(consumer.getRegistrationContext());
+ }
+
+ @Override
+ protected RuntimeContext getRuntimeContextFrom(Object request)
+ {
+ return getHandleEvents(request).getRuntimeContext();
+ }
+
+ @Override
+ protected Object performRequest(Object request) throws Exception
+ {
+ HandleEvents eventRequest = getHandleEvents(request);
+
+ if (debug)
+ {
+ log.debug("handleEvents on '" +
eventRequest.getPortletContext().getPortletHandle() + "'");
+ }
+
+ Holder<List<HandleEventsFailed>> failedEvents = new
Holder<List<HandleEventsFailed>>();
+ Holder<UpdateResponse> updateResponse = new Holder<UpdateResponse>();
+ consumer.getMarkupService().handleEvents(eventRequest.getRegistrationContext(),
eventRequest.getPortletContext(),
+ eventRequest.getRuntimeContext(), eventRequest.getUserContext(),
eventRequest.getMarkupParams(),
+ eventRequest.getEventParams(), updateResponse, failedEvents,
+ new Holder<List<Extension>>());
+
+ HandleEventsResponse response = WSRPTypeFactory.createHandleEventsReponse();
+ response.setUpdateResponse(updateResponse.value);
+ if (ParameterValidation.existsAndIsNotEmpty(failedEvents.value))
+ {
+ response.getFailedEvents().addAll(failedEvents.value);
+ }
+ return response;
+ }
+
+ @Override
+ protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation
invocation)
+ {
+ if (!(invocation instanceof EventInvocation))
+ {
+ throw new IllegalArgumentException("EventHandler can only handle
EventInvocations!");
+ }
+
+ EventInvocation eventInvocation = (EventInvocation)invocation;
+
+ PortletContext portletContext = requestPrecursor.getPortletContext();
+ if (debug)
+ {
+ log.debug("Consumer about to attempt action on portlet '" +
portletContext.getPortletHandle() + "'");
+ }
+
+ // access mode
+ InstanceContext instanceContext = invocation.getInstanceContext();
+ ParameterValidation.throwIllegalArgExceptionIfNull(instanceContext, "instance
context");
+ AccessMode accessMode = instanceContext.getAccessMode();
+ ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access
mode");
+ if (debug)
+ {
+ log.debug("Portlet is requesting " + accessMode + " access
mode");
+ }
+
+ // events
+ QName name = eventInvocation.getName();
+ Serializable payload = eventInvocation.getPayload();
+ Event event = WSRPTypeFactory.createEvent(name, payload);
+ EventParams eventParams =
WSRPTypeFactory.createEventParams(Collections.singletonList(event),
WSRPUtils.getStateChangeFromAccessMode(accessMode));
+
+ return WSRPTypeFactory.createHandleEvents(portletContext,
requestPrecursor.runtimeContext,
+ requestPrecursor.markupParams, eventParams);
+ }
+
+ @Override
+ protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
+ {
+ HandleEventsResponse handleEventsResponse = (HandleEventsResponse)response;
+
+ List<HandleEventsFailed> failed = handleEventsResponse.getFailedEvents();
+ if (ParameterValidation.existsAndIsNotEmpty(failed))
+ {
+ return new ErrorResponse("Couldn't process events: " + failed);
+ }
+
+ return processUpdateResponse(invocation, requestPrecursor,
handleEventsResponse.getUpdateResponse());
+ }
+
+ private HandleEvents getHandleEvents(Object request)
+ {
+ if (request instanceof HandleEvents)
+ {
+ return (HandleEvents)request;
+ }
+
+ throw new IllegalArgumentException("EventHandler: request is not a
HandleEvents request!");
+ }
+}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/InvocationHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/InvocationHandler.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/InvocationHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -51,6 +51,8 @@
protected WSRPConsumerImpl consumer;
protected static Logger log = LoggerFactory.getLogger(InvocationHandler.class);
+ protected static boolean debug = log.isDebugEnabled();
+ protected static boolean trace = log.isTraceEnabled();
/**
* Value indicating that we should not try further (unrecoverable error) for getMarkup
and
@@ -93,7 +95,7 @@
// as long as we don't get a non-null response and we're allowed to try
again, try to perform the request
while (response == null && retryCount++ <= MAXIMUM_RETRY_NUMBER)
{
- if (log.isDebugEnabled())
+ if (debug)
{
log.debug("performRequest: " + retryCount + " attempt(s) out
of " + MAXIMUM_RETRY_NUMBER + " possible");
}
@@ -148,7 +150,7 @@
"properly transmitted. Look at server.log for clues as to what
happened..."));
}
- if (log.isDebugEnabled())
+ if (debug)
{
log.debug("performRequest finished. Response is " + (response != null
? response.getClass().getName() : null));
}
Added:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/NavigationalStateUpdatingHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/NavigationalStateUpdatingHandler.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/NavigationalStateUpdatingHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.consumer;
+
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.OpaqueStateString;
+import org.gatein.pc.api.StateEvent;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
+import org.gatein.pc.api.spi.InstanceContext;
+import org.gatein.wsrp.WSRPUtils;
+import org.oasis.wsrp.v2.Event;
+import org.oasis.wsrp.v2.EventPayload;
+import org.oasis.wsrp.v2.NamedString;
+import org.oasis.wsrp.v2.NavigationalContext;
+import org.oasis.wsrp.v2.PortletContext;
+import org.oasis.wsrp.v2.UpdateResponse;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public abstract class NavigationalStateUpdatingHandler extends InvocationHandler
+{
+ public NavigationalStateUpdatingHandler(WSRPConsumerImpl consumer)
+ {
+ super(consumer);
+ }
+
+ protected UpdateNavigationalStateResponse processUpdateResponse(PortletInvocation
invocation, RequestPrecursor requestPrecursor, UpdateResponse updateResponse)
+ {
+ UpdateNavigationalStateResponse result = new UpdateNavigationalStateResponse();
+
+ // new mode
+ String newMode = updateResponse.getNewMode();
+ if (newMode != null)
+ {
+ result.setMode(WSRPUtils.getJSR168PortletModeFromWSRPName(newMode));
+ }
+
+ // new window state
+ String newWindowState = updateResponse.getNewWindowState();
+ if (newWindowState != null)
+ {
+
result.setWindowState(WSRPUtils.getJSR168WindowStateFromWSRPName(newWindowState));
+ }
+
+ // navigational state
+ NavigationalContext navigationalContext = updateResponse.getNavigationalContext();
+ if (navigationalContext != null)
+ {
+ String navigationalState = navigationalContext.getOpaqueValue();
+ if (navigationalState != null) // todo: check meaning of empty private NS
+ {
+ result.setNavigationalState(new OpaqueStateString(navigationalState));
+ }
+
+ List<NamedString> publicParams = navigationalContext.getPublicValues();
+ if (ParameterValidation.existsAndIsNotEmpty(publicParams))
+ {
+ Map<String, String[]> publicNS =
WSRPUtils.createPublicNSFrom(publicParams);
+ result.setPublicNavigationalStateUpdates(publicNS);
+ }
+ }
+
+ // events
+ List<Event> events = updateResponse.getEvents();
+ if (ParameterValidation.existsAndIsNotEmpty(events))
+ {
+ for (Event event : events)
+ {
+ EventPayload payload = event.getPayload();
+ result.queueEvent(new UpdateNavigationalStateResponse.Event(event.getName(),
WSRPUtils.getPayloadAsSerializable(payload)));
+ }
+ }
+
+ // check if the portlet was cloned
+ PortletContext portletContext = updateResponse.getPortletContext();
+ if (portletContext != null)
+ {
+ PortletContext originalContext = requestPrecursor.getPortletContext();
+ InstanceContext context = invocation.getInstanceContext();
+
+ String handle = portletContext.getPortletHandle();
+ if (!originalContext.getPortletHandle().equals(handle))
+ {
+ // todo: GTNWSRP-36 If the Producer returns a new portletHandle without
returning a new sessionID, the Consumer MUST
+ // associate the current sessionID with the new portletHandle rather than the
previous portletHandle.
+ if (debug)
+ {
+ log.debug("Portlet '" + requestPrecursor.getPortletHandle()
+ "' was implicitely cloned. New handle is '"
+ + handle + "'");
+ }
+
+ StateEvent event = new
StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext),
StateEvent.Type.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.Type.PORTLET_MODIFIED_EVENT);
+ context.onStateEvent(event);
+ }
+ }
+
+ // update the session information associated with the portlet handle
+
consumer.getSessionHandler().updateSessionInfoFor(originalContext.getPortletHandle(),
handle, invocation);
+ }
+ else
+ {
+ portletContext = requestPrecursor.getPortletContext();
+ }
+
+ // update the session info, using either the original or cloned portlet context, as
appropriate
+
consumer.getSessionHandler().updateSessionIfNeeded(updateResponse.getSessionContext(),
invocation,
+ portletContext.getPortletHandle());
+ return result;
+ }
+}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -81,6 +81,7 @@
public class ProducerInfo
{
private final static Logger log = LoggerFactory.getLogger(ProducerInfo.class);
+ private final static boolean debug = log.isDebugEnabled();
// Persistent information
@@ -1047,10 +1048,16 @@
registrationContext.setRegistrationState(registrationState.value);
persistentRegistrationInfo.setRegistrationContext(registrationContext);
- String msg = "Consumer with id '" + persistentId +
"' successfully registered with handle: '"
- + registrationContext.getRegistrationHandle() + "'";
- log.debug(msg);
+
+ if (debug)
+ {
+ String msg = "Consumer with id '" + persistentId +
"' successfully registered with handle: '"
+ + registrationContext.getRegistrationHandle() +
"'";
+ log.debug(msg);
+ }
+
RefreshResult res = new RefreshResult();
+
res.setRegistrationResult(result);
return res;
}
@@ -1211,6 +1218,13 @@
public EventInfo getInfoForEvent(QName name)
{
- return eventDescriptions.get(name);
+ if (eventDescriptions == null)
+ {
+ return null;
+ }
+ else
+ {
+ return eventDescriptions.get(name);
+ }
}
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RegistrationInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RegistrationInfo.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RegistrationInfo.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -69,6 +69,7 @@
private transient boolean modifiedSinceLastRefresh;
private transient boolean modifyRegistrationNeeded;
private transient ProducerInfo parent;
+ private transient RegistrationContext registrationContext;
/**
* Marker string to identify a RegistrationInfo created for a producer that might not
require registration as a work
@@ -671,8 +672,7 @@
setRegistrationValidInternalState();
}
- /** todo: revert to package-only once the tests are moved to same package */
- public void setRegistrationValidInternalState()
+ void setRegistrationValidInternalState()
{
// update RegistrationData if needed
getRegistrationData();
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -74,14 +74,16 @@
// Create the markup request
PortletContext portletContext = requestPrecursor.getPortletContext();
- log.debug("Consumer about to attempt rendering portlet '" +
portletContext.getPortletHandle() + "'");
+ if (debug)
+ {
+ 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)
{
MarkupResponse markupResponse = (MarkupResponse)response;
- log.debug("Starting processing response");
// process the response
consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(),
invocation,
@@ -137,11 +139,8 @@
// generate appropriate CacheControl
org.gatein.pc.api.cache.CacheControl cacheControl =
createCacheControl(markupContext);
- FragmentResponse result = new FragmentResponse(null, null, mimeType, null, markup,
+ return new FragmentResponse(null, null, mimeType, null, markup,
markupContext.getPreferredTitle(), cacheControl,
invocation.getPortalContext().getModes());
-
- log.debug("Response processed");
- return result;
}
protected void updateUserContext(Object request, UserContext userContext)
@@ -162,7 +161,10 @@
protected Object performRequest(Object request) throws Exception
{
GetMarkup renderRequest = getRenderRequest(request);
- log.debug("getMarkup on '" +
renderRequest.getPortletContext().getPortletHandle() + "'");
+ if (debug)
+ {
+ log.debug("getMarkup on '" +
renderRequest.getPortletContext().getPortletHandle() + "'");
+ }
// invocation
Holder<SessionContext> sessionContextHolder = new
Holder<SessionContext>();
@@ -220,7 +222,10 @@
// check that we support the user scope...
if (consumer.supportsUserScope(userScope))
{
- log.debug("RenderHandler.processRenderRequest: trying to cache markup
" + userScope + " for " + expires + " seconds.");
+ if (debug)
+ {
+ log.debug("RenderHandler.processRenderRequest: trying to cache markup
" + userScope + " for " + expires + " seconds.");
+ }
CacheScope scope;
if (WSRPConstants.CACHE_FOR_ALL.equals(userScope))
{
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -31,6 +31,7 @@
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.invocation.ActionInvocation;
+import org.gatein.pc.api.invocation.EventInvocation;
import org.gatein.pc.api.invocation.InvocationException;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.RenderInvocation;
@@ -88,10 +89,11 @@
*/
public class WSRPConsumerImpl implements WSRPConsumer
{
- private ActionHandler actionHandler;
- private RenderHandler renderHandler;
- private ResourceHandler resourceHandler;
- private SessionHandler sessionHandler;
+ private final ActionHandler actionHandler;
+ private final RenderHandler renderHandler;
+ private final ResourceHandler resourceHandler;
+ private final SessionHandler sessionHandler;
+ private final EventHandler eventHandler;
private ProducerInfo producerInfo;
@@ -133,6 +135,7 @@
renderHandler = new RenderHandler(this);
sessionHandler = new SessionHandler(this);
resourceHandler = new ResourceHandler(this);
+ eventHandler = new EventHandler(this);
}
public ProducerInfo getProducerInfo()
@@ -187,6 +190,10 @@
{
handler = resourceHandler;
}
+ else if (invocation instanceof EventInvocation)
+ {
+ handler = eventHandler;
+ }
else
{
throw new InvocationException("Unknown invocation type: " +
invocation);
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -1,28 +1,28 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.services.v2;
-import org.gatein.common.NotYetImplemented;
import org.gatein.wsrp.services.MarkupService;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.EventParams;
@@ -80,7 +80,7 @@
@Override
public void getResource(RegistrationContext registrationContext,
Holder<PortletContext> portletContext, RuntimeContext runtimeContext, UserContext
userContext, ResourceParams resourceParams, Holder<ResourceContext> resourceContext,
Holder<SessionContext> sessionContext, Holder<List<Extension>>
extensions) throws AccessDenied, InconsistentParameters, InvalidCookie, InvalidHandle,
InvalidRegistration, InvalidSession, InvalidUserCategory, MissingParameters,
ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended,
UnsupportedLocale, UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState
{
- throw new NotYetImplemented();
+ service.getResource(registrationContext, portletContext, runtimeContext,
userContext, resourceParams, resourceContext, sessionContext, extensions);
}
@Override
@@ -92,7 +92,7 @@
@Override
public void handleEvents(RegistrationContext registrationContext, PortletContext
portletContext, RuntimeContext runtimeContext, UserContext userContext, MarkupParams
markupParams, EventParams eventParams, Holder<UpdateResponse> updateResponse,
Holder<List<HandleEventsFailed>> failedEvents,
Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, PortletStateChangeRequired, ResourceSuspended, UnsupportedLocale,
UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState
{
- throw new NotYetImplemented();
+ service.handleEvents(registrationContext, portletContext, runtimeContext,
userContext, markupParams, eventParams, updateResponse, failedEvents, extensions);
}
@Override
@@ -106,28 +106,4 @@
{
return service.initCookie(registrationContext, userContext);
}
-
- /*@Override
- public void performBlockingInteraction(RegistrationContext registrationContext,
PortletContext portletContext, RuntimeContext runtimeContext, UserContext userContext,
MarkupParams markupParams, InteractionParams interactionParams,
Holder<UpdateResponse> updateResponseHolder, Holder<String> redirectURL,
Holder<List<Extension>> listHolder) throws InvalidCookie, MissingParameters,
InvalidSession, UnsupportedWindowState, InconsistentParameters, InvalidUserCategory,
InvalidRegistration, OperationFailed, PortletStateChangeRequired, UnsupportedMode,
InvalidHandle, ResourceSuspended, UnsupportedMimeType, ModifyRegistrationRequired,
AccessDenied, UnsupportedLocale
- {
- service.performBlockingInteraction(registrationContext, portletContext,
runtimeContext, userContext, markupParams, interactionParams, updateResponseHolder,
redirectURL, listHolder);
- }
-
- @Override
- public void getMarkup(RegistrationContext registrationContext, PortletContext
portletContext, RuntimeContext runtimeContext, UserContext userContext, MarkupParams
markupParams, Holder<MarkupContext> markupContextHolder,
Holder<SessionContext> sessionContextHolder, Holder<List<Extension>>
listHolder) throws InvalidCookie, MissingParameters, InvalidSession,
UnsupportedWindowState, InconsistentParameters, InvalidUserCategory, InvalidRegistration,
OperationFailed, UnsupportedMode, InvalidHandle, ResourceSuspended, UnsupportedMimeType,
ModifyRegistrationRequired, AccessDenied, UnsupportedLocale
- {
- service.getMarkup(registrationContext, portletContext, runtimeContext, userContext,
markupParams, markupContextHolder, sessionContextHolder, listHolder);
- }
-
- @Override
- public void initCookie(RegistrationContext registrationContext, UserContext
userContext) throws OperationFailed, ResourceSuspended, OperationNotSupported,
AccessDenied, ModifyRegistrationRequired, InvalidRegistration
- {
- service.initCookie(registrationContext, userContext);
- }
-
- @Override
- public void releaseSessions(RegistrationContext registrationContext,
List<String> idsToRelease, UserContext userContext) throws OperationFailed,
ResourceSuspended, MissingParameters, OperationNotSupported, AccessDenied,
ModifyRegistrationRequired, InvalidRegistration
- {
- service.releaseSessions(registrationContext, idsToRelease, userContext);
- }*/
}
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -354,6 +354,11 @@
assertFalse(invalid);
}
+ public void testGetInfoForEvent()
+ {
+ assertNull(info.getInfoForEvent(null));
+ }
+
private static class TestPortletManagementBehavior extends PortletManagementBehavior
{
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ActionRequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ActionRequestProcessor.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ActionRequestProcessor.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -38,7 +38,6 @@
import org.oasis.wsrp.v2.InvalidRegistration;
import org.oasis.wsrp.v2.MarkupParams;
import org.oasis.wsrp.v2.MissingParameters;
-import org.oasis.wsrp.v2.NavigationalContext;
import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
import org.oasis.wsrp.v2.PortletContext;
@@ -55,18 +54,16 @@
* @version $Revision: 13121 $
* @since 2.6
*/
-class ActionRequestProcessor extends RequestProcessor
+class ActionRequestProcessor extends UpdateNavigationalStateResponseProcessor
{
private final PerformBlockingInteraction performBlockingInteraction;
- private final InteractionParams interactionParams;
- public ActionRequestProcessor(WSRPProducerImpl producer, PerformBlockingInteraction
performBlockingInteraction, InteractionParams interactionParams)
+ ActionRequestProcessor(WSRPProducerImpl producer, PerformBlockingInteraction
performBlockingInteraction)
throws UnsupportedMimeType, UnsupportedWindowState, InvalidHandle, UnsupportedMode,
MissingParameters,
InvalidRegistration, OperationFailed
{
super(producer);
this.performBlockingInteraction = performBlockingInteraction;
- this.interactionParams = interactionParams;
prepareInvocation();
}
@@ -102,7 +99,7 @@
AccessMode getAccessMode() throws MissingParameters
{
- StateChange stateChange = interactionParams.getPortletStateChange();
+ StateChange stateChange =
performBlockingInteraction.getInteractionParams().getPortletStateChange();
WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(stateChange,
"portletStateChange", "InteractionParams");
return WSRPUtils.getAccessModeFromStateChange(stateChange);
}
@@ -110,6 +107,7 @@
PortletInvocation initInvocation(WSRPPortletInvocationContext context)
{
ActionInvocation invocation = new ActionInvocation(context);
+ InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
// Request context
WSRPRequestContext requestContext =
WSRPRequestContext.createRequestContext(markupRequest, interactionParams);
@@ -129,23 +127,9 @@
{
if (response instanceof UpdateNavigationalStateResponse)
{
- UpdateNavigationalStateResponse renderResult =
(UpdateNavigationalStateResponse)response;
- UpdateResponse updateResponse = WSRPTypeFactory.createUpdateResponse();
-
updateResponse.setNewMode(WSRPUtils.convertJSR168PortletModeNameToWSRPName(getNewStateOrNull(renderResult,
true)));
-
updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(renderResult,
false)));
- NavigationalContext navigationalContext =
WSRPTypeFactory.createNavigationalContextOrNull(
- renderResult.getNavigationalState(),
- renderResult.getPublicNavigationalStateUpdates()
- );
- updateResponse.setNavigationalContext(navigationalContext);
+ UpdateNavigationalStateResponse stateResponse =
(UpdateNavigationalStateResponse)response;
+ UpdateResponse updateResponse = createUpdateResponse(stateResponse);
- // deal with implicit cloning and state modification
- if (instanceContext.wasModified())
- {
- PortletContext updatedPortletContext =
WSRPUtils.convertToWSRPPortletContext(instanceContext.getPortletContext());
- updateResponse.setPortletContext(updatedPortletContext);
- }
-
return WSRPTypeFactory.createBlockingInteractionResponse(updateResponse);
}
else
@@ -155,10 +139,4 @@
return
WSRPTypeFactory.createBlockingInteractionResponse(redirectionResult.getLocation());
}
}
-
- private String getNewStateOrNull(UpdateNavigationalStateResponse renderResult, boolean
forMode)
- {
- Object state = forMode ? renderResult.getMode() : renderResult.getWindowState();
- return state != null ? state.toString() : null;
- }
}
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/EventRequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/EventRequestProcessor.java
(rev 0)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/EventRequestProcessor.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.producer;
+
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.invocation.EventInvocation;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
+import org.gatein.pc.api.state.AccessMode;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.WSRPUtils;
+import org.gatein.wsrp.spec.v2.WSRP2ExceptionFactory;
+import org.oasis.wsrp.v2.Event;
+import org.oasis.wsrp.v2.EventParams;
+import org.oasis.wsrp.v2.EventPayload;
+import org.oasis.wsrp.v2.HandleEvents;
+import org.oasis.wsrp.v2.HandleEventsResponse;
+import org.oasis.wsrp.v2.InvalidHandle;
+import org.oasis.wsrp.v2.InvalidRegistration;
+import org.oasis.wsrp.v2.MarkupParams;
+import org.oasis.wsrp.v2.MissingParameters;
+import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.OperationNotSupported;
+import org.oasis.wsrp.v2.PortletContext;
+import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.RuntimeContext;
+import org.oasis.wsrp.v2.StateChange;
+import org.oasis.wsrp.v2.UnsupportedMimeType;
+import org.oasis.wsrp.v2.UnsupportedMode;
+import org.oasis.wsrp.v2.UnsupportedWindowState;
+import org.oasis.wsrp.v2.UpdateResponse;
+import org.oasis.wsrp.v2.UserContext;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class EventRequestProcessor extends UpdateNavigationalStateResponseProcessor
+{
+ private HandleEvents handleEvents;
+
+ public EventRequestProcessor(WSRPProducerImpl producer, HandleEvents handleEvents)
throws OperationFailed, UnsupportedMode, InvalidHandle, MissingParameters,
UnsupportedMimeType, UnsupportedWindowState, InvalidRegistration, OperationNotSupported
+ {
+ super(producer);
+ this.handleEvents = handleEvents;
+
+ // validate request parameters
+ EventParams eventParams = handleEvents.getEventParams();
+ WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(eventParams,
"event params", "HandleEvents");
+
WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(eventParams.getPortletStateChange(),
"portletStateChange", "EventParams");
+ List<Event> events = eventParams.getEvents();
+ if (!ParameterValidation.existsAndIsNotEmpty(events))
+ {
+ throw WSRP2ExceptionFactory.createWSException(MissingParameters.class,
+ "EventParams must provide at least one event to process", null);
+ }
+
+ if (events.size() > 1)
+ {
+ throw WSRP2ExceptionFactory.createWSException(OperationNotSupported.class,
+ "GateIn currently doesn't support sending multiple events to process
at once.", null);
+ }
+ prepareInvocation();
+ }
+
+ @Override
+ RegistrationContext getRegistrationContext()
+ {
+ return handleEvents.getRegistrationContext();
+ }
+
+ @Override
+ RuntimeContext getRuntimeContext()
+ {
+ return handleEvents.getRuntimeContext();
+ }
+
+ @Override
+ MarkupParams getMarkupParams()
+ {
+ return handleEvents.getMarkupParams();
+ }
+
+ @Override
+ PortletContext getPortletContext()
+ {
+ return handleEvents.getPortletContext();
+ }
+
+ @Override
+ UserContext getUserContext()
+ {
+ return handleEvents.getUserContext();
+ }
+
+ @Override
+ String getContextName()
+ {
+ return "HandleEvents";
+ }
+
+ @Override
+ AccessMode getAccessMode() throws MissingParameters
+ {
+ StateChange stateChange = handleEvents.getEventParams().getPortletStateChange();
+
+ return WSRPUtils.getAccessModeFromStateChange(stateChange);
+ }
+
+ @Override
+ PortletInvocation initInvocation(WSRPPortletInvocationContext context)
+ {
+ EventInvocation eventInvocation = new EventInvocation(context);
+
+ List<Event> events = handleEvents.getEventParams().getEvents();
+
+ // since we currently don't support sending multiple events to process at once,
assume there's only one
+ Event event = events.get(0);
+
+ eventInvocation.setName(event.getName());
+ EventPayload payload = event.getPayload();
+
+ eventInvocation.setPayload(WSRPUtils.getPayloadAsSerializable(payload));
+
+ return eventInvocation;
+ }
+
+ @Override
+ Object processResponse(PortletInvocationResponse response)
+ {
+ if (response instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse unsResponse =
(UpdateNavigationalStateResponse)response;
+ HandleEventsResponse eventsResponse =
WSRPTypeFactory.createHandleEventsReponse();
+
+ UpdateResponse updateResponse = createUpdateResponse(unsResponse);
+ eventsResponse.setUpdateResponse(updateResponse);
+
+ return eventsResponse;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot process response: " +
response);
+ }
+ }
+}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupHandler.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -23,6 +23,7 @@
package org.gatein.wsrp.producer;
+import org.gatein.common.NotYetImplemented;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.FragmentResponse;
@@ -35,6 +36,9 @@
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.BlockingInteractionResponse;
import org.oasis.wsrp.v2.GetMarkup;
+import org.oasis.wsrp.v2.GetResource;
+import org.oasis.wsrp.v2.HandleEvents;
+import org.oasis.wsrp.v2.HandleEventsResponse;
import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InitCookie;
import org.oasis.wsrp.v2.InteractionParams;
@@ -45,10 +49,14 @@
import org.oasis.wsrp.v2.InvalidUserCategory;
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.MissingParameters;
+import org.oasis.wsrp.v2.ModifyRegistrationRequired;
import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.OperationNotSupported;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
import org.oasis.wsrp.v2.PortletStateChangeRequired;
import org.oasis.wsrp.v2.ReleaseSessions;
+import org.oasis.wsrp.v2.ResourceResponse;
+import org.oasis.wsrp.v2.ResourceSuspended;
import org.oasis.wsrp.v2.ReturnAny;
import org.oasis.wsrp.v2.UnsupportedLocale;
import org.oasis.wsrp.v2.UnsupportedMimeType;
@@ -106,7 +114,7 @@
final InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(interactionParams,
"InteractionParams", PBI);
- RequestProcessor requestProcessor = new ActionRequestProcessor(producer,
performBlockingInteraction, interactionParams);
+ RequestProcessor requestProcessor = new ActionRequestProcessor(producer,
performBlockingInteraction);
PortletInvocationResponse response;
String handle = requestProcessor.getPortletContext().getPortletHandle();
@@ -150,6 +158,41 @@
return new ReturnAny();
}
+ public HandleEventsResponse handleEvents(HandleEvents handleEvents) throws
AccessDenied, InconsistentParameters,
+ InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters,
+ ModifyRegistrationRequired, OperationFailed, OperationNotSupported,
PortletStateChangeRequired, ResourceSuspended,
+ UnsupportedLocale, UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState
+ {
+ EventRequestProcessor requestProcessor = new EventRequestProcessor(producer,
handleEvents);
+
+ PortletInvocationResponse response;
+ String handle = requestProcessor.getPortletContext().getPortletHandle();
+
+ try
+ {
+ log.debug("EventInvocation on portlet '" + handle +
"'");
+ response =
producer.getPortletInvoker().invoke(requestProcessor.getInvocation());
+ log.debug("EventInvocation done");
+ }
+ catch (PortletStateChangeRequiredException e)
+ {
+ throw WSRP2ExceptionFactory.throwWSException(PortletStateChangeRequired.class,
e.getLocalizedMessage(), e);
+ }
+ catch (PortletInvokerException e)
+ {
+ throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "Could
not handle event on portlet '" + handle + "'", e);
+ }
+
+ checkForError(response);
+
+ return (HandleEventsResponse)requestProcessor.processResponse(response);
+ }
+
+ public ResourceResponse getResource(GetResource getResource) throws AccessDenied,
InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
+ {
+ throw new NotYetImplemented();
+ }
+
static void throwOperationFaultOnSessionOperation() throws OperationFailed
{
throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "JBoss
Portal's Producer" +
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupInterface.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupInterface.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/MarkupInterface.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -26,6 +26,9 @@
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.BlockingInteractionResponse;
import org.oasis.wsrp.v2.GetMarkup;
+import org.oasis.wsrp.v2.GetResource;
+import org.oasis.wsrp.v2.HandleEvents;
+import org.oasis.wsrp.v2.HandleEventsResponse;
import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InitCookie;
import org.oasis.wsrp.v2.InvalidCookie;
@@ -35,10 +38,14 @@
import org.oasis.wsrp.v2.InvalidUserCategory;
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.MissingParameters;
+import org.oasis.wsrp.v2.ModifyRegistrationRequired;
import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.OperationNotSupported;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
import org.oasis.wsrp.v2.PortletStateChangeRequired;
import org.oasis.wsrp.v2.ReleaseSessions;
+import org.oasis.wsrp.v2.ResourceResponse;
+import org.oasis.wsrp.v2.ResourceSuspended;
import org.oasis.wsrp.v2.ReturnAny;
import org.oasis.wsrp.v2.UnsupportedLocale;
import org.oasis.wsrp.v2.UnsupportedMimeType;
@@ -68,4 +75,15 @@
ReturnAny initCookie(InitCookie initCookie)
throws AccessDenied, OperationFailed, InvalidRegistration;
+
+ HandleEventsResponse handleEvents(HandleEvents handleEvents)
+ throws AccessDenied, InconsistentParameters, InvalidCookie, InvalidHandle,
InvalidRegistration, InvalidSession,
+ InvalidUserCategory, MissingParameters, ModifyRegistrationRequired,
OperationFailed, OperationNotSupported,
+ PortletStateChangeRequired, ResourceSuspended, UnsupportedLocale,
UnsupportedMimeType, UnsupportedMode,
+ UnsupportedWindowState;
+
+ ResourceResponse getResource(GetResource getResource)
+ throws AccessDenied, InconsistentParameters, InvalidCookie, InvalidHandle,
InvalidRegistration, InvalidSession,
+ InvalidUserCategory, MissingParameters, ModifyRegistrationRequired,
OperationFailed, ResourceSuspended,
+ UnsupportedLocale, UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState;
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -63,7 +63,6 @@
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -161,29 +160,10 @@
StateString navigationalState =
createNavigationalState(navigationalContext.getOpaqueValue());
invocation.setNavigationalState(navigationalState);
- // GTNWSRP-38: public NS
List<NamedString> publicParams = navigationalContext.getPublicValues();
if (ParameterValidation.existsAndIsNotEmpty(publicParams))
{
- Map<String, String[]> publicNS = new HashMap<String,
String[]>(publicParams.size());
- for (NamedString publicParam : publicParams)
- {
- String paramName = publicParam.getName();
- String[] values = publicNS.get(paramName);
- if (ParameterValidation.existsAndIsNotEmpty(values))
- {
- int valuesNb = values.length;
- String[] newValues = new String[valuesNb + 1];
- System.arraycopy(values, 0, newValues, 0, valuesNb);
- newValues[valuesNb] = publicParam.getValue();
- publicNS.put(paramName, newValues);
- }
- else
- {
- values = new String[]{publicParam.getValue()};
- publicNS.put(paramName, values);
- }
- }
+ Map<String, String[]> publicNS =
WSRPUtils.createPublicNSFrom(publicParams);
invocation.setPublicNavigationalState(publicNS);
}
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -106,7 +106,8 @@
// if we don't have registration information but a registration is required,
send registration props information
boolean needsRegistrationProperties = registration == null &&
requirements.isRegistrationRequired();
-
+
+ // if we allow sending portlet descriptions even when not registered
boolean needsPortletDescriptions = !(registration == null &&
requirements.isRegistrationRequired()
&& requirements.isRegistrationRequiredForFullDescription());
if (needsPortletDescriptions)
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/UpdateNavigationalStateResponseProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/UpdateNavigationalStateResponseProcessor.java
(rev 0)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/UpdateNavigationalStateResponseProcessor.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.producer;
+
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.WSRPUtils;
+import org.oasis.wsrp.v2.NavigationalContext;
+import org.oasis.wsrp.v2.PortletContext;
+import org.oasis.wsrp.v2.UpdateResponse;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public abstract class UpdateNavigationalStateResponseProcessor extends RequestProcessor
+{
+ public UpdateNavigationalStateResponseProcessor(WSRPProducerImpl producer)
+ {
+ super(producer);
+ }
+
+ protected String getNewStateOrNull(UpdateNavigationalStateResponse renderResult,
boolean forMode)
+ {
+ Object state = forMode ? renderResult.getMode() : renderResult.getWindowState();
+ return state != null ? state.toString() : null;
+ }
+
+ protected UpdateResponse createUpdateResponse(UpdateNavigationalStateResponse
stateResponse)
+ {
+ UpdateResponse updateResponse = WSRPTypeFactory.createUpdateResponse();
+
updateResponse.setNewMode(WSRPUtils.convertJSR168PortletModeNameToWSRPName(getNewStateOrNull(stateResponse,
true)));
+
updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(stateResponse,
false)));
+ NavigationalContext navigationalContext =
WSRPTypeFactory.createNavigationalContextOrNull(
+ stateResponse.getNavigationalState(),
+ stateResponse.getPublicNavigationalStateUpdates()
+ );
+ updateResponse.setNavigationalContext(navigationalContext);
+
+ // events
+ List<UpdateNavigationalStateResponse.Event> events =
stateResponse.getEvents();
+ if (ParameterValidation.existsAndIsNotEmpty(events))
+ {
+ for (UpdateNavigationalStateResponse.Event event : events)
+ {
+ updateResponse.getEvents().add(WSRPTypeFactory.createEvent(event.getName(),
event.getPayload()));
+ }
+ }
+
+ // deal with implicit cloning and state modification
+ if (instanceContext.wasModified())
+ {
+ PortletContext updatedPortletContext =
WSRPUtils.convertToWSRPPortletContext(instanceContext.getPortletContext());
+ updateResponse.setPortletContext(updatedPortletContext);
+ }
+ return updateResponse;
+ }
+}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -47,7 +47,10 @@
import org.oasis.wsrp.v2.GetPortletDescription;
import org.oasis.wsrp.v2.GetPortletProperties;
import org.oasis.wsrp.v2.GetPortletPropertyDescription;
+import org.oasis.wsrp.v2.GetResource;
import org.oasis.wsrp.v2.GetServiceDescription;
+import org.oasis.wsrp.v2.HandleEvents;
+import org.oasis.wsrp.v2.HandleEventsResponse;
import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InitCookie;
import org.oasis.wsrp.v2.InvalidCookie;
@@ -58,7 +61,9 @@
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.MissingParameters;
import org.oasis.wsrp.v2.ModifyRegistration;
+import org.oasis.wsrp.v2.ModifyRegistrationRequired;
import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.OperationNotSupported;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
@@ -70,6 +75,8 @@
import org.oasis.wsrp.v2.RegistrationData;
import org.oasis.wsrp.v2.RegistrationState;
import org.oasis.wsrp.v2.ReleaseSessions;
+import org.oasis.wsrp.v2.ResourceResponse;
+import org.oasis.wsrp.v2.ResourceSuspended;
import org.oasis.wsrp.v2.ReturnAny;
import org.oasis.wsrp.v2.ServiceDescription;
import org.oasis.wsrp.v2.SetPortletProperties;
@@ -195,6 +202,22 @@
return returnAny;
}
+ public HandleEventsResponse handleEvents(HandleEvents handleEvents) throws
AccessDenied, InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration,
InvalidSession, InvalidUserCategory, MissingParameters, ModifyRegistrationRequired,
OperationFailed, OperationNotSupported, PortletStateChangeRequired, ResourceSuspended,
UnsupportedLocale, UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState
+ {
+ log.debug("handleEvents invoked");
+ HandleEventsResponse response = markupHandler.handleEvents(handleEvents);
+ log.debug("end handleEvents");
+ return response;
+ }
+
+ public ResourceResponse getResource(GetResource getResource) throws AccessDenied,
InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
+ {
+ log.debug("getResource invoked");
+ ResourceResponse response = markupHandler.getResource(getResource);
+ log.debug("end getResource");
+ return response;
+ }
+
// Registration implementation
**************************************************************************************
public RegistrationContext register(RegistrationData register) throws
MissingParameters, OperationFailed
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -23,13 +23,17 @@
package org.gatein.wsrp.endpoints.v2;
+import org.gatein.common.NotYetImplemented;
+import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.BlockingInteractionResponse;
import org.oasis.wsrp.v2.EventParams;
import org.oasis.wsrp.v2.Extension;
import org.oasis.wsrp.v2.GetMarkup;
+import org.oasis.wsrp.v2.HandleEvents;
import org.oasis.wsrp.v2.HandleEventsFailed;
+import org.oasis.wsrp.v2.HandleEventsResponse;
import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InitCookie;
import org.oasis.wsrp.v2.InteractionParams;
@@ -101,7 +105,17 @@
PortletStateChangeRequired, ResourceSuspended, UnsupportedLocale,
UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
{
- //To change body of implemented methods use File | Settings | File Templates.
+ forceSessionAccess();
+
+ HandleEvents handleEvents = WSRPTypeFactory.createHandleEvents(portletContext,
runtimeContext, markupParams, eventParams);
+ handleEvents.setRegistrationContext(registrationContext);
+ handleEvents.setUserContext(userContext);
+
+ HandleEventsResponse response = producer.handleEvents(handleEvents);
+
+ updateResponse.value = response.getUpdateResponse();
+ failedEvents.value = response.getFailedEvents();
+ extensions.value = response.getExtensions();
}
public List<Extension> releaseSessions(
@@ -168,7 +182,7 @@
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired,
OperationFailed, OperationNotSupported,
ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
{
- //To change body of implemented methods use File | Settings | File Templates.
+ throw new NotYetImplemented();
}
public void performBlockingInteraction(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types")
MarkupParams markupParams, @WebParam(name = "interactionParams", targetNamespace
= "urn:oasis:names:tc:wsrp:v2:types") InteractionParams interactionParams,
@WebParam(name = "updateResponse", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<UpdateResponse> updateResponse, @WebParam(name = "redirectURL",
targetNamespace = "urn:oasis:na!
mes:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<String> redirectURL,
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
PortletStateChangeRequired, ResourceSuspended, UnsupportedLocale, UnsupportedMimeType,
UnsupportedMode, UnsupportedWindowState
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/BasicPortlet.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/BasicPortlet.java 2010-06-28
08:36:04 UTC (rev 3501)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/BasicPortlet.java 2010-06-28
12:24:52 UTC (rev 3502)
@@ -1,34 +1,35 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2010, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.portlet;
-import java.io.IOException;
-
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
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>
@@ -42,4 +43,9 @@
System.out.println("do view");
}
+ @Override
+ public void processEvent(EventRequest request, EventResponse response) throws
PortletException, IOException
+ {
+ System.out.println("zipcode: " + request.getEvent().getValue());
+ }
}