Solr
  1. Solr
  2. SOLR-142

RawResponseWriter - replace /admin/get-file.jsp

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Component/s: web gui
    • Labels:
      None

      Description

      A RawResponseWriter writes a ContentStream directly to the response.

      This is useful to spit back a file directly from solr. This implementation looks for a response property named "content" and sends it to the client. If it can't find one, it delegates the response to another ResponseWriter.

      As an example, I added a GetAdminFileRequestHandler to replace /admin/get-file.jsp

      1. SOLR-142-RawResponseWriter.patch
        16 kB
        Ryan McKinley
      2. SOLR-142-RawResponseWriter.patch
        47 kB
        Ryan McKinley
      3. SOLR-142-RawResponseWriter.patch
        3 kB
        Ryan McKinley
      4. SOLR-142-RawResponseWriter.patch
        5 kB
        Hoss Man
      5. SOLR-142-RawResponseWriter.patch
        18 kB
        Ryan McKinley
      6. SOLR-142-RawResponseWriter.patch
        17 kB
        Ryan McKinley
      7. SOLR-142-RawResponseWriter.patch
        17 kB
        Ryan McKinley

        Issue Links

          Activity

          Hide
          Ryan McKinley added a comment -

          The RawResponseWriter is configured by default (just like JSON etc)

          One could create it explicitly and specify what 'base' response writer it should use (JSON etc)

          <queryResponseWriter name="raw" class="org.apache.solr.request.RawResponseWriter">
          <int name="base">JSON</int>
          </queryResponseWriter>

          • - - - - - -

          I added a GetAdminFileRequestHandler that is configured to use wt=raw by default. I wanted to delete get-file.jsp, but it is needed to include:

          <jsp:include page="get-file.jsp?file=admin-extra.html&optional=y" flush="true"/>

          (which, by the way, spits out HTML in the middle of a table declaration)

          • - - - - - - - -

          I deleted raw-schema.jsp that did not appear to be referenced by anything

          • - - - - - - -

          I could not help myself and added: GetSystemPropertiesRequestHandler and deleted get-properties.jsp. Unlike get-properties.jsp, GetSystemPropertiesRequestHandler spits back properties formatted by the selected ResponseWriter. It also added the ability to get a single property

          Show
          Ryan McKinley added a comment - The RawResponseWriter is configured by default (just like JSON etc) One could create it explicitly and specify what 'base' response writer it should use (JSON etc) <queryResponseWriter name="raw" class="org.apache.solr.request.RawResponseWriter"> <int name="base">JSON</int> </queryResponseWriter> - - - - - - I added a GetAdminFileRequestHandler that is configured to use wt=raw by default. I wanted to delete get-file.jsp, but it is needed to include: <jsp:include page="get-file.jsp?file=admin-extra.html&optional=y" flush="true"/> (which, by the way, spits out HTML in the middle of a table declaration) - - - - - - - - I deleted raw-schema.jsp that did not appear to be referenced by anything - - - - - - - I could not help myself and added: GetSystemPropertiesRequestHandler and deleted get-properties.jsp. Unlike get-properties.jsp, GetSystemPropertiesRequestHandler spits back properties formatted by the selected ResponseWriter. It also added the ability to get a single property
          Hide
          Hoss Man added a comment -

          Ryan, i really like the idea of a RawResponseWriter, and your GetAdminFileRequestHandler ... for a hwile now i've been thinking that it would be good to change the admin/gettableFiles section of hte solrconfig so that...

          • files could have a default content-type specified
          • direcotries could be listed (with a content-type to assume for all files in that directory)
            ...and then replace get-file.jsp with a servlet that used the extra path info to find the filename, and supported query args to override the default content-type with text/plain

          my motivation being to help with things like SOLR-75 where we sometimes need the schema as XML, but othertimes we want to return it as plain text ... and to let the XmlResponseWriter start supporting useful params telling it what stylesheet from the xslt directory to include in the response (for client site styling using a stylesheet served from the solr server)

          – but i like your idea of a RequestHandler/ResponseWriter better.

          we should consier deprecating admin/gettableFiles completley, and moving the info about what file are gettable directly into the init params for the GetAdminFileRequestHandler (where it can also support the content-type/direcotry stuff that i described)

          in that case, we'd need to leave get-files.jsp where it is, so something still supports the legacy admin/gettableFiles list of files.

          Show
          Hoss Man added a comment - Ryan, i really like the idea of a RawResponseWriter, and your GetAdminFileRequestHandler ... for a hwile now i've been thinking that it would be good to change the admin/gettableFiles section of hte solrconfig so that... files could have a default content-type specified direcotries could be listed (with a content-type to assume for all files in that directory) ...and then replace get-file.jsp with a servlet that used the extra path info to find the filename, and supported query args to override the default content-type with text/plain my motivation being to help with things like SOLR-75 where we sometimes need the schema as XML, but othertimes we want to return it as plain text ... and to let the XmlResponseWriter start supporting useful params telling it what stylesheet from the xslt directory to include in the response (for client site styling using a stylesheet served from the solr server) – but i like your idea of a RequestHandler/ResponseWriter better. we should consier deprecating admin/gettableFiles completley, and moving the info about what file are gettable directly into the init params for the GetAdminFileRequestHandler (where it can also support the content-type/direcotry stuff that i described) in that case, we'd need to leave get-files.jsp where it is, so something still supports the legacy admin/gettableFiles list of files.
          Hide
          Ryan McKinley added a comment -

          Posted an update to this patch. It may be getting away from my original goal to get a RawRequestHandler committed soon... but oh well.

          This adds RequestHandlers for a bunch of admin thing that could (should) be spit back in the standard response writer format.

          some urls to check:

          http://localhost:8983/solr/admin/file
          http://localhost:8983/solr/admin/file?file=protwords.txt
          http://localhost:8983/solr/admin/file?file=schema.xml
          http://localhost:8983/solr/admin/file?file=schema.xml&txt=true
          http://localhost:8983/solr/admin/threads
          http://localhost:8983/solr/admin/registry
          http://localhost:8983/solr/admin/registry?wt=json&indent=true
          http://localhost:8983/solr/admin/stats
          http://localhost:8983/solr/admin/ping
          http://localhost:8983/solr/admin/properties
          http://localhost:8983/solr/admin/properties?name=java.home
          http://localhost:8983/solr/admin/logging
          http://localhost:8983/solr/admin/logging?set=FINE

          To get these to display nicely, we would need an xls file and link to:
          http://localhost:8983/solr/admin/stats?stylesheet=admin.xls

          I like this direction because it moves solr away from the need for a JDK, removes a bunch of code from jsp scriptlets, and makes the admin info easily available to clients through JSON/xml etc.

          Show
          Ryan McKinley added a comment - Posted an update to this patch. It may be getting away from my original goal to get a RawRequestHandler committed soon... but oh well. This adds RequestHandlers for a bunch of admin thing that could (should) be spit back in the standard response writer format. some urls to check: http://localhost:8983/solr/admin/file http://localhost:8983/solr/admin/file?file=protwords.txt http://localhost:8983/solr/admin/file?file=schema.xml http://localhost:8983/solr/admin/file?file=schema.xml&txt=true http://localhost:8983/solr/admin/threads http://localhost:8983/solr/admin/registry http://localhost:8983/solr/admin/registry?wt=json&indent=true http://localhost:8983/solr/admin/stats http://localhost:8983/solr/admin/ping http://localhost:8983/solr/admin/properties http://localhost:8983/solr/admin/properties?name=java.home http://localhost:8983/solr/admin/logging http://localhost:8983/solr/admin/logging?set=FINE To get these to display nicely, we would need an xls file and link to: http://localhost:8983/solr/admin/stats?stylesheet=admin.xls I like this direction because it moves solr away from the need for a JDK, removes a bunch of code from jsp scriptlets, and makes the admin info easily available to clients through JSON/xml etc.
          Hide
          Ryan McKinley added a comment -

          this version of the patch is only the RawResponseWriter. I am moving all the admin changes to SOLR-162. For an example of the RawResponseWriter in use, see that patch.

          Show
          Ryan McKinley added a comment - this version of the patch is only the RawResponseWriter. I am moving all the admin changes to SOLR-162 . For an example of the RawResponseWriter in use, see that patch.
          Hide
          Hoss Man added a comment -

          revised version of Ryan's latest patch – just adds some documentation.

          the patch is nice and clean and simple – but without anything illustrating it's use i'm hesitent to commit it.

          (i know a lot of the previous code in this issue got migrated to SOLR-162, but perhaps at least the GetAdminFileRequestHandler should be part of this patch so the basic functionality for getting a file and writing it's raw stream is commited all at once.

          Show
          Hoss Man added a comment - revised version of Ryan's latest patch – just adds some documentation. the patch is nice and clean and simple – but without anything illustrating it's use i'm hesitent to commit it. (i know a lot of the previous code in this issue got migrated to SOLR-162 , but perhaps at least the GetAdminFileRequestHandler should be part of this patch so the basic functionality for getting a file and writing it's raw stream is commited all at once.
          Hide
          Ryan McKinley added a comment -

          Thanks for looking at that. Here is an updated version that includes GetAdminFileRequestHandler.java from SOLR-162

          This patch also deletes /admin/get-file.jsp and changes to /admin/index.jsp that point to this handler. That is good because it moves away from some ugly jsp scriptlet code - it is bad because if someone just updates the .war file without updating solrconfig.xml they will get a 404.

          You make the call on what part is appropriate to add at this time.

          thanks
          ryan

          Show
          Ryan McKinley added a comment - Thanks for looking at that. Here is an updated version that includes GetAdminFileRequestHandler.java from SOLR-162 This patch also deletes /admin/get-file.jsp and changes to /admin/index.jsp that point to this handler. That is good because it moves away from some ugly jsp scriptlet code - it is bad because if someone just updates the .war file without updating solrconfig.xml they will get a 404. You make the call on what part is appropriate to add at this time. thanks ryan
          Hide
          Hoss Man added a comment -

          I still haven't looked at Ryan's latest patch on this issue (from Feb!) but if the only issue is that /admin/get-file.jsp has been deleted so links on the admin screen won't work because they assume the new handler, then maybe the best way to solve this is:

          1) change the admin.jsp screen not to include links to either get-file.jsp or the new GetFile handler by default (a good idea since people might want to change the name of the handler) but if a gettableFiles section exists in the solrconfig, continue to link to get-files.jsp
          2) document in the CHANGES recommending that people use the new GetFile handler and add links to it in an admin-extras.html file (since only they know which handler name they used)
          3) makr get-files.jsp as heavily deprecated (so we can eventually get rid of it) and make it delegate to an anonymous on the fly created instance of the GetFile handler.

          Show
          Hoss Man added a comment - I still haven't looked at Ryan's latest patch on this issue (from Feb!) but if the only issue is that /admin/get-file.jsp has been deleted so links on the admin screen won't work because they assume the new handler, then maybe the best way to solve this is: 1) change the admin.jsp screen not to include links to either get-file.jsp or the new GetFile handler by default (a good idea since people might want to change the name of the handler) but if a gettableFiles section exists in the solrconfig, continue to link to get-files.jsp 2) document in the CHANGES recommending that people use the new GetFile handler and add links to it in an admin-extras.html file (since only they know which handler name they used) 3) makr get-files.jsp as heavily deprecated (so we can eventually get rid of it) and make it delegate to an anonymous on the fly created instance of the GetFile handler.
          Hide
          Ryan McKinley added a comment -

          I think the best thing to do now is split this into two issues:

          1. just the RawResponseWriter and the GetFile handler. (you did review this way back in feb!)
          2. Update the admin .jsp to use the new handlers wherever possible and provide a path to support path based request handlers going forward

          Show
          Ryan McKinley added a comment - I think the best thing to do now is split this into two issues: 1. just the RawResponseWriter and the GetFile handler. (you did review this way back in feb!) 2. Update the admin .jsp to use the new handlers wherever possible and provide a path to support path based request handlers going forward
          Hide
          Ryan McKinley added a comment -

          resurrecting an old patch from February. This uses the request handler framework to return raw admin files.

          Show
          Ryan McKinley added a comment - resurrecting an old patch from February. This uses the request handler framework to return raw admin files.
          Hide
          Ryan McKinley added a comment -

          The ShowFileRequestHander should be added to the standard /admin request handlers in SOLR-447

          Show
          Ryan McKinley added a comment - The ShowFileRequestHander should be added to the standard /admin request handlers in SOLR-447
          Hide
          Ryan McKinley added a comment -

          Updated so that SOLR-447 AdminHandler automatically registers the ShowFile handler

          Show
          Ryan McKinley added a comment - Updated so that SOLR-447 AdminHandler automatically registers the ShowFile handler
          Hide
          Hoss Man added a comment -

          adding some linked issues for posterity.

          Show
          Hoss Man added a comment - adding some linked issues for posterity.

            People

            • Assignee:
              Ryan McKinley
              Reporter:
              Ryan McKinley
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development