Package org.gatein.pc.api.invocation.response

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


      String contentType = urlConnection.getContentType();

      // init ResponseProperties for ContentResponse result
      Map<String, List<String>> headers = urlConnection.getHeaderFields();
      ResponseProperties props = new ResponseProperties();
      MultiValuedPropertyMap<String> transportHeaders = props.getTransportHeaders();
      for (Map.Entry<String, List<String>> entry : headers.entrySet())
      {
         String key = entry.getKey();
         if (key != null)
         {
            List<String> values = entry.getValue();
            if (values != null)
            {
               if (CookieUtil.SET_COOKIE.equals(key))
               {
                  final List<CookieUtil.Cookie> cookies = CookieUtil.extractCookiesFrom(url, values);
                  List<javax.servlet.http.Cookie> propCookies = props.getCookies();
                  for (CookieUtil.Cookie cookie : cookies)
                  {
                     propCookies.add(CookieUtil.convertFrom(cookie));
                  }
               }
View Full Code Here


      {
         return new RevalidateMarkupResponse(cc);
      }
      else
      {
         ResponseProperties props = getProperties(false);
         Map<String, Object> attrs = preq.attributes.getAttributeMap();
         if (buffer instanceof CharBuffer)
         {
            return createResponse(props, attrs, contentType, ((CharBuffer)buffer).getChars(), cc);
         }
View Full Code Here

   protected final ResponseProperties getProperties(boolean create)
   {
      if (properties == null && create)
      {
         properties = new ResponseProperties();
      }
      return properties;
   }
View Full Code Here

            }
         }
      }

      // GTNWSRP-336
      final ResponseProperties properties = getResponsePropertiesFrom(mimeResponse, consumer.getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL());
      return createContentResponse(mimeResponse, invocation, properties, mimeType, binary, markup, createCacheControl(mimeResponse));
   }
View Full Code Here

   }

   private ResponseProperties getResponsePropertiesFrom(MimeResponse mimeResponse, String producerURLAsString)
   {
      final List<NamedString> clientAttributes = mimeResponse.getClientAttributes();
      final ResponseProperties properties;
      if (ParameterValidation.existsAndIsNotEmpty(clientAttributes))
      {
         URL producerURL;
         try
         {
            producerURL = new URL(producerURLAsString);
         }
         catch (MalformedURLException e)
         {
            // shouldn't happen
            throw new RuntimeException(e);
         }
         properties = new ResponseProperties();
         for (NamedString attribute : clientAttributes)
         {
            final String name = attribute.getName();
            final String value = attribute.getValue();
            if (javax.portlet.MimeResponse.MARKUP_HEAD_ELEMENT.equals(name))
            {
               final Element element = PayloadUtils.parseFromXMLString(value);
               properties.getMarkupHeaders().addValue(name, element);
            }
            else
            {
               properties.getTransportHeaders().addValue(name, value);
            }
         }
      }
      else
      {
View Full Code Here

      String contentType = urlConnection.getContentType();

      // init ResponseProperties for ContentResponse result
      Map<String, List<String>> headers = urlConnection.getHeaderFields();
      ResponseProperties props = new ResponseProperties();
      MultiValuedPropertyMap<String> transportHeaders = props.getTransportHeaders();
      for (Map.Entry<String, List<String>> entry : headers.entrySet())
      {
         String key = entry.getKey();
         if (key != null)
         {
            List<String> values = entry.getValue();
            if (values != null)
            {
               if (CookieUtil.SET_COOKIE.equals(key))
               {
                  Cookie[] cookies = CookieUtil.extractCookiesFrom(url, values.toArray(new String[values.size()]));
                  List<javax.servlet.http.Cookie> propCookies = props.getCookies();
                  for (Cookie cookie : cookies)
                  {
                     propCookies.add(CookieUtil.convertFrom(cookie));
                  }
               }
View Full Code Here

      {
         pageNavigationalState = new PageNavigationalState(pageNavigationalState, true);
      }

      //
      ResponseProperties requestProperties = new ResponseProperties();

      //
      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

               if (response instanceof ContentResponse)
               {
                  ContentResponse fragmentResponse = (ContentResponse)response;

                  //
                  ResponseProperties properties = fragmentResponse.getProperties();

                  //
                  if (properties != null)
                  {
                     MultiValuedPropertyMap<Element> markupHeaders = properties.getMarkupHeaders();
                     for (String key : markupHeaders.keySet())
                     {
                        List<Element> headElement = markupHeaders.getValues(key);
                        for (Element headerValue : headElement)
                        {
View Full Code Here

                    transportHeaders = null;
                    content = null;
                } else {
                    //
                    ContentResponse piResponse = (ContentResponse) portletResponse;
                    ResponseProperties properties = piResponse.getProperties();
                    transportHeaders = properties != null ? properties.getTransportHeaders() : null;

                    // Look at status code if there is one and honour it
                    String status = transportHeaders != null ? transportHeaders.getValue(ResourceResponse.HTTP_STATUS_CODE)
                            : null;
                    if (status != null) {
View Full Code Here

TOP

Related Classes of org.gatein.pc.api.invocation.response.ResponseProperties

Copyright © 2018 www.massapicom. 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.