Package javax.portlet

Examples of javax.portlet.ResourceResponse


    @Test
    public void testResourcePortletRequest() throws NoSuchFieldException, IllegalAccessException {
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        PortletContext portletContext = createMock(PortletContext.class);
        ResourceRequest request = createMock(ResourceRequest.class);
        ResourceResponse response = createMock(ResourceResponse.class);

        replay(applicationContext, portletContext, request, response);
        ResourcePortletRequest req = new ResourcePortletRequest(applicationContext,
                portletContext, request, response);
        Class<? extends ResourcePortletRequest> clazz = req.getClass();
View Full Code Here


        PortletInvokerService invoker = getContainerServices().getPortletInvokerService();

        PortletResourceRequestContext requestContext = rcService.getPortletResourceRequestContext(this, request, response, portletWindow);
        PortletResourceResponseContext responseContext = rcService.getPortletResourceResponseContext(this, request, response, portletWindow);
        ResourceRequest portletRequest = envService.createResourceRequest(requestContext, responseContext);
        ResourceResponse portletResponse = envService.createResourceResponse(responseContext, requestContext.getCacheability());

        FilterManager filterManager = filterInitialisation(portletWindow,PortletRequest.RESOURCE_PHASE);

        try
        {
View Full Code Here

    }
    if (isMimeResponse)
    {
      MimeResponse mimeResponse = (MimeResponse)response;
      RenderResponse renderResponse = isRenderResponse ? (RenderResponse)response : null;
      ResourceResponse resourceResponse = isResourceResponse ? (ResourceResponse)response
        : null;

      if (locale != null)
      {
        try
        {
          resourceResponse.setLocale(locale);
        }
        catch (UnsupportedOperationException usoe)
        {
          // TODO: temporary "fix" for JBoss Portal which doesn't yet support this
          // (although required by the Portlet API 2.0!)
        }
      }

      if (contentType != null)
      {
        if (characterEncoding != null)
        {
          if (setContentTypeAfterEncoding)
          {
            resourceResponse.setCharacterEncoding(characterEncoding);
            resourceResponse.setContentType(contentType);
          }
          else
          {
            resourceResponse.setContentType(contentType);
            resourceResponse.setCharacterEncoding(characterEncoding);
          }
        }
        else
        {
          mimeResponse.setContentType(contentType);
        }
      }
      else if (characterEncoding != null)
      {
        resourceResponse.setCharacterEncoding(characterEncoding);
      }

      if (headers != null)
      {
        for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet())
        {
          for (String value : entry.getValue())
          {
            mimeResponse.addProperty(entry.getKey(), value);
          }
        }
        headers = null;
      }
      if (isResourceResponse && hasStatus)
      {
        resourceResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE,
          Integer.toString(statusCode));
      }
      if (isResourceResponse && contentLength > -1)
      {
        try
        {
          resourceResponse.setContentLength(contentLength);
        }
        catch (UnsupportedOperationException usoe)
        {
          // TODO: temporary "fix" for JBoss Portal which doesn't yet support this
          // (although required by the Portlet API 2.0!)
View Full Code Here

   * @throws IOException if content cannot be written
   */
  public void flushMarkupToWrappedResponse()
    throws IOException
  {
    ResourceResponse response = getResponse();
   
    flushBuffer();

    if (isBytes())
    {
      response.getPortletOutputStream().write(getBytes());
      mByteStream.reset();
    }
    else if (isChars())
    {
      response.getWriter().write(getChars());
      mCharWriter.reset();
    }

  }
View Full Code Here

    ExternalContext extCtx = ctx.getExternalContext();

    if (BridgeUtil.getPortletRequestPhase() ==
        Bridge.PortletPhase.RESOURCE_PHASE)
    {
      ResourceResponse resourceResponse = (ResourceResponse) extCtx.getResponse();

      String charEncoding = extCtx.getResponseCharacterEncoding();
      String resourceCharEncoding = resourceResponse.getCharacterEncoding();
     
      if ((charEncoding == null && resourceCharEncoding == null) || charEncoding.equals(resourceCharEncoding))
      {
        testRunner.setTestResult(true,
                                 "extCtx.getResponseCharacterEncoding() correctly returned the same value as resourceResponse.getCharacterEncoding()");
View Full Code Here

    ExternalContext extCtx = ctx.getExternalContext();

    if (BridgeUtil.getPortletRequestPhase() ==
        Bridge.PortletPhase.RESOURCE_PHASE)
    {
      ResourceResponse resourceResponse = (ResourceResponse) extCtx.getResponse();
      String contentType = extCtx.getResponseContentType();
      String resourceContentType = resourceResponse.getContentType();
      if ((contentType == null && resourceContentType == null) ||
          contentType.equals(resourceContentType))
      {
        testRunner.setTestResult(true,
                                 "extCtx.getResponseContentType() correctly returned the same value as resourceRequest.getContentType()");
View Full Code Here

      cookies = null;
    }
    if (isMimeResponse)
    {
      MimeResponse mimeResponse = (MimeResponse)response;
      ResourceResponse resourceResponse = isResourceResponse ? (ResourceResponse)response
        : null;

      if (locale != null)
      {
        try
        {
          resourceResponse.setLocale(locale);
        }
        catch (UnsupportedOperationException usoe)
        {
          // TODO: temporary "fix" for JBoss Portal which doesn't yet support this
          // (although required by the Portlet API 2.0!)
        }
      }

      if (contentType != null)
      {
        if (characterEncoding != null)
        {
          if (setContentTypeAfterEncoding)
          {
            resourceResponse.setCharacterEncoding(characterEncoding);
            resourceResponse.setContentType(contentType);
          }
          else
          {
            resourceResponse.setContentType(contentType);
            resourceResponse.setCharacterEncoding(characterEncoding);
          }
        }
        else
        {
          mimeResponse.setContentType(contentType);
        }
      }
      else if (characterEncoding != null)
      {
        resourceResponse.setCharacterEncoding(characterEncoding);
      }

      if (headers != null)
      {
        for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet())
        {
          for (String value : entry.getValue())
          {
            mimeResponse.addProperty(entry.getKey(), value);
          }
        }
        headers = null;
      }
      if (isResourceResponse && hasStatus)
      {
        resourceResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE,
          Integer.toString(statusCode));
      }
      if (isResourceResponse && contentLength > -1)
      {
        try
        {
          resourceResponse.setContentLength(contentLength);
        }
        catch (UnsupportedOperationException usoe)
        {
          // TODO: temporary "fix" for JBoss Portal which doesn't yet support this
          // (although required by the Portlet API 2.0!)
View Full Code Here

   * @throws IOException if content cannot be written
   */
  public void flushMarkupToWrappedResponse()
    throws IOException
  {
    ResourceResponse response = getResponse();
   
    flushBuffer();

    if (isBytes())
    {
      response.getPortletOutputStream().write(getBytes());
      mByteStream.reset();
    }
    else if (isChars())
    {
      response.getWriter().write(getChars());
      mCharWriter.reset();
    }

  }
View Full Code Here

  public void setLocale(Locale locale) {
    if (!(_portletResponse instanceof MimeResponse)) {
      return;
    }

    ResourceResponse resourceResponse = (ResourceResponse)_portletResponse;

    resourceResponse.setLocale(locale);
  }
View Full Code Here

      }
    }
  }

  private void sendAjaxViewExpired(FacesContext facesContext, Exception e) {
      ResourceResponse response = (ResourceResponse) facesContext
              .getExternalContext().getResponse();
      try {
        response.reset();
        String message;
        try {
          ResourceBundle resourceBundle = ResourceBundle
                  .getBundle("org.ajax4jsf.messages",
                          facesContext.getApplication()
                                  .getViewHandler()
                                  .calculateLocale(facesContext),
                          Thread.currentThread()
                                  .getContextClassLoader());
          message = resourceBundle.getString("AJAX_VIEW_EXPIRED");

        } catch (MissingResourceException e2) {
          message = "%AJAX_VIEW_EXPIRED%";
        }
        response.setProperty(AJAX_EXPIRED, message);
        response.setContentType("text/xml");
        PrintWriter output = response.getWriter();
        output
                .write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                        + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
                        + "<meta name=\""
                        + AJAX_FLAG_HEADER
View Full Code Here

TOP

Related Classes of javax.portlet.ResourceResponse

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.