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

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            victorlima02 Victor de Lima Soares
            Participants of an Issue:
            Recent user:
            Sherry Zhu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              3 years, 25 weeks, 4 days ago

                Packages

                Version Package