Examples of UpdateNavigationalStateResponse


Examples of org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse

      //
      if (response instanceof UpdateNavigationalStateResponse)
      {
         // Update portlet NS
         UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;

         //
         updateNavigationalState(context, portletRequest.getWindowId(), updateResponse, pageNavigationalState);

         //
         ResponseProperties update = updateResponse.getProperties();
         if (update != null)
         {
            requestProperties.append(update);
         }

         //
         EventControllerContext eventCC = context.getEventControllerContext();

         //
         EventPhaseContext phaseContext = new EventPhaseContext(controller, context, log);

         // Feed session it with the events that may have been produced
         for (UpdateNavigationalStateResponse.Event portletEvent : updateResponse.getEvents())
         {
            if (!phaseContext.push(new WindowEvent(portletEvent.getName(), portletEvent.getPayload(), portletRequest.getWindowId())))
            {
               return new PageUpdateResponse(updateResponse, requestProperties, pageNavigationalState, PortletResponse.INTERRUPTED);
            }
         }

         // Deliver events
         while (phaseContext.hasNext())
         {
            WindowEvent toConsumeEvent = phaseContext.next();

            // Apply consumed event quota if necessary
            int consumedEventThreshold = controller.getConsumedEventThreshold();
            if (consumedEventThreshold >= 0)
            {
               if (phaseContext.consumedEventSize + 1 > consumedEventThreshold)
               {
                  log.trace("Event distribution interrupted because the maximum number of consumed event is reached");
                  safeInvoker.eventDiscarded(eventCC, phaseContext, toConsumeEvent, EventControllerContext.CONSUMED_EVENT_FLOODED);
                  return new PageUpdateResponse(updateResponse, requestProperties, pageNavigationalState, PortletResponse.INTERRUPTED);
               }
            }

            //
            PortletInvocationResponse eventResponse;
            try
            {
               eventResponse = deliverEvent(context, toConsumeEvent, pageNavigationalState, requestProperties.getCookies());
            }
            catch (Exception e)
            {
               log.trace("Event delivery of " + toConsumeEvent + " failed", e);
               safeInvoker.eventFailed(eventCC, phaseContext, toConsumeEvent, e);
               continue;
            }

            // Now it is consumed
            phaseContext.consumedEventSize++;

            // Update nav state if needed
            if (eventResponse instanceof UpdateNavigationalStateResponse)
            {
               UpdateNavigationalStateResponse eventStateResponse = (UpdateNavigationalStateResponse)eventResponse;

               // Update ns
               updateNavigationalState(context, toConsumeEvent.getWindowId(), eventStateResponse, pageNavigationalState);

               // Add events to source event queue
               for (UpdateNavigationalStateResponse.Event portletEvent : eventStateResponse.getEvents())
               {
                  WindowEvent toRouteEvent = new WindowEvent(portletEvent.getName(), portletEvent.getPayload(), toConsumeEvent.getWindowId());

                  //
                  if (!phaseContext.push(toConsumeEvent,  toRouteEvent))
                  {
                     return new PageUpdateResponse(updateResponse, requestProperties, pageNavigationalState, PortletResponse.INTERRUPTED);
                  }
               }

               //
               ResponseProperties updateProperties = eventStateResponse.getProperties();
               if (updateProperties != null)
               {
                  requestProperties.append(updateProperties);
               }
            }
View Full Code Here

Examples of org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse

   }

   @Override
   public PortletInvocationResponse invoke(ControllerContext controllerContext) throws PortletInvokerException
   {
      UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
      updateNavigationalState.setMode(windowNavigationalState.getMode());
      updateNavigationalState.setWindowState(windowNavigationalState.getWindowState());
      updateNavigationalState.setNavigationalState(windowNavigationalState.getPortletNavigationalState());
      updateNavigationalState.setPublicNavigationalStateUpdates(publicNavigationalStateChanges);
      return updateNavigationalState;
   }
View Full Code Here

Examples of org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse

      {
         EventAcknowledgement.Consumed consumedAck = (EventAcknowledgement.Consumed)ack;
         PortletInvocationResponse response = consumedAck.getResponse();
         if (response instanceof UpdateNavigationalStateResponse)
         {
            UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;

            //
            String[] strings = new String[4];

            //
            if (updateResponse.getMode() != null)
            {
               strings[0] = "mode=" + updateResponse.getMode();
            }

            //
            if (updateResponse.getWindowState() != null)
            {
               strings[1] = "windowstate=" + updateResponse.getWindowState();
            }

            // Should be ok, we are not consuming remote portlets
            ParametersStateString newNS = (ParametersStateString)updateResponse.getNavigationalState();
            if (newNS != null)
            {
               StringBuilder sb = new StringBuilder();
               sb.append("private=");
               formatMap(newNS.getParameters(), sb);
               strings[2] = sb.toString();
            }

            //
            Map<String, String[]> publicChanges = updateResponse.getPublicNavigationalStateUpdates();
            if (publicChanges != null)
            {
               StringBuilder sb = new StringBuilder();
               sb.append("public=");
               formatMap(publicChanges, sb);
View Full Code Here

Examples of org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse

                    throw new Exception("Unexpected response type [" + piResponse
                            + "]. Expected a UpdateNavigationResponse or an ErrorResponse.");
                }
            }

            UpdateNavigationalStateResponse navResponse = (UpdateNavigationalStateResponse) piResponse;

            //

            /*
             * Update the portlet window state according to the action output information
             *
             * If the current node is displaying a usual layout page, also tells the page which portlet to render or not when
             * the state is maximized
             */
            WindowState state = new WindowState(getWindowStateOrDefault(navResponse));
            setNextState(uiPortlet, state);

            // update the portlet with the next mode to display
            PortletMode mode = new PortletMode(getPortletModeOrDefault(navResponse));
            setNextMode(uiPortlet, mode);

            StateString navState = navResponse.getNavigationalState();
            if (navState != null) {
                uiPortlet.setNavigationalState(navResponse.getNavigationalState());
            }
            setupPublicRenderParams(uiPortlet, navResponse.getPublicNavigationalStateUpdates());

            // TODO: (mwringe) add this to the UpdateNavigationStateResponse.Event class instead of here
            class PortletEvent implements javax.portlet.Event {
                QName qName;

                Serializable value;

                public PortletEvent(QName qName, Serializable value) {
                    this.qName = qName;
                    this.value = value;
                }

                public String getName() {
                    return qName.getLocalPart();
                }

                public QName getQName() {
                    return qName;
                }

                public Serializable getValue() {
                    return value;
                }
            }

            List<UpdateNavigationalStateResponse.Event> nsEvents = navResponse.getEvents();
            List<javax.portlet.Event> events = new ArrayList<javax.portlet.Event>(nsEvents.size());
            if (nsEvents != null && !nsEvents.isEmpty()) {
                for (UpdateNavigationalStateResponse.Event nsEvent : nsEvents) {
                    javax.portlet.Event portletEvent = new PortletEvent(nsEvent.getName(), nsEvent.getPayload());
                    events.add(portletEvent);
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

      PortletInvocationResponse response = super.invoke(invocation);

      //
      if (response instanceof UpdateNavigationalStateResponse)
      {
         UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)response;

         //
         Map<String, Object> attributes = update.getAttributes();

         //
         if (attributes != null && attributes.size() > 0)
         {
            ParametersStateString outNS = (ParametersStateString)update.getNavigationalState();
            outNS.setValue("javax.portlet.as", conversation.id);

            //
            conversation.setAttributes(attributes);
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

      //
      if (response instanceof UpdateNavigationalStateResponse)
      {
         // Update portlet NS
         UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
         updateNavigationalState(context, portletRequest.getWindowId(), updateResponse, pageNavigationalState);

         //
         ResponseProperties update = updateResponse.getProperties();
         if (update != null)
         {
            requestProperties.append(update);
         }

         //
         EventControllerContext eventCC = context.getEventControllerContext();
         UpdateNavigationalStateResponse stateResponse = (UpdateNavigationalStateResponse)response;

         //
         EventPhaseContextImpl phaseContext = new EventPhaseContextImpl(log);

         // Feed session it with the events that may have been produced
         for (UpdateNavigationalStateResponse.Event portletEvent : stateResponse.getEvents())
         {
            PortletWindowEvent producedEvent = new PortletWindowEvent(portletEvent.getName(), portletEvent.getPayload(), portletRequest.getWindowId());
            phaseContext.producedEvents.add(new EventProduction(null, producedEvent));
         }

         //
         int eventDistributionStatus = PortletResponse.DISTRIBUTION_DONE;

         // Deliver events
         while (phaseContext.producedEvents.size() > 0)
         {
            EventProduction eventProduction = phaseContext.producedEvents.removeFirst();
            PortletWindowEvent producedEvent = eventProduction.getProducedEvent();

            //
            String producerId = producedEvent.getWindowId();
            PortletInfo producerPortletInfo = context.getPortletInfo(producerId);

            //
            if (producerPortletInfo == null)
            {
               log.trace("Cannot deliver event " + producedEvent +" because the producer does not have portlet info");
               safeInvoker.eventDiscarded(eventCC, phaseContext, producedEvent, EventControllerContext.EVENT_PRODUCER_INFO_NOT_AVAILABLE);
               continue;
            }

            //
            if (!controller.getDistributeNonProduceableEvents())
            {
               if (!producerPortletInfo.getEventing().getProducedEvents().containsKey(producedEvent.getName()))
               {
                  log.trace("Cannot deliver event " + producedEvent +" because the producer of the event does not produce the event name");
                  safeInvoker.eventDiscarded(eventCC, phaseContext, producedEvent, EventControllerContext.PORTLET_DOES_NOT_CONSUME_EVENT);
                  continue;
               }
            }

            // Apply produced event quota if necessary
            int producedEventThreshold = controller.getProducedEventThreshold();
            if (producedEventThreshold >= 0)
            {
               if (phaseContext.producedEventSize + 1 > producedEventThreshold)
               {
                  log.trace("Event distribution interrupted because the maximum number of produced event is reached");
                  eventDistributionStatus = PortletResponse.PRODUCED_EVENT_FLOODED;
                  safeInvoker.eventDiscarded(eventCC, phaseContext, producedEvent, EventControllerContext.PRODUCED_EVENT_FLOODED);
                  break;
               }
            }

            // Give control to the event context
            phaseContext.mode = EventPhaseContextImpl.READ_WRITE_MODE;
            if (!safeInvoker.eventProduced(eventCC, phaseContext, eventProduction.getConsumedEvent(), producedEvent))
            {
               continue;
            }

            // Perform flow control
            if (phaseContext.mode == EventPhaseContextImpl.INTERRUPTED_MODE)
            {
               log.trace("Event distribution interrupted by controller context");
               eventDistributionStatus = PortletResponse.INTERRUPTED;
               break;
            }

            //
            while (phaseContext.toConsumeEvents.size() > 0)
            {
               PortletWindowEvent toConsumeEvent = phaseContext.toConsumeEvents.removeFirst();
               String consumedId = toConsumeEvent.getWindowId();

               //
               PortletInfo consumerPortletInfo = context.getPortletInfo(consumedId);
               if (consumerPortletInfo == null)
               {
                  log.trace("Cannot deliver event " + producedEvent +" because the consumer of the event does not have a portlet info");
                  safeInvoker.eventDiscarded(eventCC, phaseContext, toConsumeEvent, EventControllerContext.EVENT_CONSUMER_INFO_NOT_AVAILABLE);
                  continue;
               }

               //
               if (!controller.getDistributeNonConsumableEvents())
               {
                  if (!consumerPortletInfo.getEventing().getConsumedEvents().containsKey(toConsumeEvent.getName()))
                  {
                     log.trace("Cannot deliver event " + producedEvent +" because the consumer of the event does not accept the event name");
                     safeInvoker.eventDiscarded(eventCC, phaseContext, toConsumeEvent, EventControllerContext.PORTLET_DOES_NOT_CONSUME_EVENT);
                     continue;
                  }
               }

               // Apply consumed event quota if necessary
               int consumedEventThreshold = controller.getConsumedEventThreshold();
               if (consumedEventThreshold >= 0)
               {
                  if (phaseContext.consumedEventSize + 1 > consumedEventThreshold)
                  {
                     log.trace("Event distribution interrupted because the maximum number of consumed event is reached");
                     safeInvoker.eventDiscarded(eventCC, phaseContext, toConsumeEvent, EventControllerContext.CONSUMED_EVENT_FLOODED);
                     eventDistributionStatus = PortletResponse.CONSUMED_EVENT_FLOODED;
                     break;
                  }
               }

               //
               PortletInvocationResponse eventResponse;
               try
               {
                  eventResponse = deliverEvent(context, toConsumeEvent, pageNavigationalState, requestProperties.getCookies());
               }
               catch (Exception e)
               {
                  log.trace("Event delivery of " + toConsumeEvent + " failed", e);
                  safeInvoker.eventFailed(eventCC, phaseContext, toConsumeEvent, e);
                  continue;
               }

               // Now it is consumed
               phaseContext.consumedEventSize++;

               // Update nav state if needed
               if (eventResponse instanceof UpdateNavigationalStateResponse)
               {
                  UpdateNavigationalStateResponse eventStateResponse = (UpdateNavigationalStateResponse)eventResponse;

                  // Update ns
                  updateNavigationalState(context, toConsumeEvent.getWindowId(), eventStateResponse, pageNavigationalState);

                  // Add events to source event queue
                  for (UpdateNavigationalStateResponse.Event portletEvent : eventStateResponse.getEvents())
                  {
                     PortletWindowEvent toRouteEvent = new PortletWindowEvent(portletEvent.getName(), portletEvent.getPayload(), toConsumeEvent.getWindowId());
                     phaseContext.producedEvents.add(new EventProduction(toConsumeEvent, toRouteEvent));
                  }

                  //
                  ResponseProperties updateProperties = eventStateResponse.getProperties();
                  if (updateProperties != null)
                  {
                     requestProperties.append(updateProperties);
                  }
               }
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

      if (portletRequest instanceof PortletRenderRequest)
      {
         PortletRenderRequest portletRenderRequest = (PortletRenderRequest)portletRequest;

         //
         UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
         updateNavigationalState.setMode(portletRenderRequest.getWindowNavigationalState().getMode());
         updateNavigationalState.setWindowState(portletRenderRequest.getWindowNavigationalState().getWindowState());
         updateNavigationalState.setNavigationalState(portletRenderRequest.getWindowNavigationalState().getPortletNavigationalState());
         updateNavigationalState.setPublicNavigationalStateUpdates(portletRenderRequest.getPublicNavigationalStateChanges());

         //
         return updateNavigationalState;
      }
      else
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

      /** The new mode requested. */
      protected Mode mode = new Mode(preq.getPortletMode().toString());

      protected PortletInvocationResponse getResponse()
      {
         UpdateNavigationalStateResponse response = new UpdateNavigationalStateResponse();

         //
         response.setProperties(getProperties(false));
         response.setAttributes(preq.attributes.getAttributeMap());

         //
         response.setMode(mode);
         response.setWindowState(windowState);
         response.setPublicNavigationalStateUpdates(navigationalState.getPublicMapSnapshot());
         response.setNavigationalState(ParametersStateString.create(navigationalState.getPrivateMapSnapshot()));

         //
         if (events != null)
         {
            for (UpdateNavigationalStateResponse.Event event : events)
            {
               response.queueEvent(event);
            }
         }

         //
         return response;
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

      PortletInvocationResponse response = super.invoke(invocation);

      //
      if (response instanceof UpdateNavigationalStateResponse)
      {
         UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)response;

         //
         Map<String, Object> attributes = update.getAttributes();

         //
         if (attributes != null && attributes.size() > 0)
         {
            ParametersStateString outNS = (ParametersStateString)update.getNavigationalState();
            outNS.setValue("javax.portlet.as", conversation.id);

            //
            conversation.setAttributes(attributes);
View Full Code Here

Examples of org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse

   public ActionResponseImpl(ActionInvocation invocation, PortletRequestImpl preq)
   {
      super(invocation, preq);

      //
      UpdateNavigationalStateResponse rr = new UpdateNavigationalStateResponse();
      rr.setNavigationalState(ParametersStateString.create());

      //
      this.response = rr;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.