Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-82156

OutputStream can't be used inside MCVResourceCommands added to Journal portlet

    Details

    • Fix Priority:
      1

      Description

      Attempts to add an MVCResourceCommand into the Journal portlet will lead to an java.lang.IllegalStateException if the response is to send binary data back to the client.

      It seems a writer is opened before the request reaches its destination, obligating the function to use only capabilities derived from writers; thus making the usage of OutputStreams an impossible alternative for files that are not character based.

      For instance (https://stackoverflow.com/questions/50751442/mvcresourcecommand-to-send-binary-data-inside-native-journal-portlet):

      {{@Component( immediate = true,
      property =

      { "javax.portlet.name=" + JOURNAL, "mvc.command.name=/command" }

      ,
      service = MVCResourceCommand.class )
      public class Resource extends BaseMVCResourceCommand {

      @Override
      public void doServeResource( ResourceRequest request, ResourceResponse response ) throws PortletException {

      try

      { response.getPortletOutputStream(); }

      catch ( Exception e )

      { throw new PortletException( e ); }

      }

      }}}

      Extra details at: https://stackoverflow.com/questions/50751442/mvcresourcecommand-to-send-binary-data-inside-native-journal-portlet

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                1 year, 23 weeks, 3 days ago

                Packages

                Version Package