Class RosterServlet

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    @WebServlet(name="RosterServlet",
                urlPatterns={"/roster","/prefs/roster.xml"})
    public class RosterServlet
    extends javax.servlet.http.HttpServlet
    Provide roster data to HTTP clients.

    Each method of this Servlet responds to a unique URL pattern.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      RosterServlet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doEntry​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Provide the XML representation of a roster entry given its ID.
      protected void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Route the request and response to the appropriate methods.
      protected void doGroup​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String group)
      Get a roster group.
      (package private) void doImage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.io.File file)
      Process the image for a roster entry image or icon request.
      protected void doList​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      List roster entries.
      protected void doPost​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handle any POST request as an upload of a roster file from client.
      protected void doRoster​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.fasterxml.jackson.databind.JsonNode filter)
      void init()  
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

        public void init()
                  throws javax.servlet.ServletException
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException
        Route the request and response to the appropriate methods.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        java.io.IOException - if communications is cut with client
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws java.io.IOException,
                              javax.servlet.ServletException
        Handle any POST request as an upload of a roster file from client.
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        javax.servlet.ServletException - if unable to process uploads
        java.io.IOException - if communications is cut with client
      • doGroup

        protected void doGroup​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               java.lang.String group)
                        throws java.io.IOException
        Get a roster group.

        Lists roster entries in the specified group and return an XML document conforming to the JMRI JSON schema. This method can be passed multiple filters matching the filter in Roster.getEntriesMatchingCriteria(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String). Note: Any given filter can be specified only once.

        This method responds to the following GET URL patterns:

        • /roster/group/<group name>
        • /roster/group/<group name>?filter=filter[&filter=filter]

        This method responds to the POST URL /roster/group/<group name> with a JSON payload for the filter.

        Parameters:
        request - servlet request
        response - servlet response
        group - The group name
        Throws:
        java.io.IOException - if communications is cut with client
      • doEntry

        protected void doEntry​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws java.io.IOException
        Provide the XML representation of a roster entry given its ID.

        Lists roster entries and return an XML document conforming to the JMRI Roster XML schema. Requests for roster entry images and icons can include width and height specifiers, and always return PNG images.

        This method responds to the following URL patterns:

        • /roster/<ID>
        • /roster/entry/<ID>
        • /roster/<ID>/image
        • /roster/<ID>/icon
        Note: The use of the term entry in URLs is optional.

        Images and icons can be rescaled using the following parameters:

        • height
        • maxHeight
        • minHeight
        • width
        • maxWidth
        • minWidth
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        java.io.IOException - if communications is cut with client
      • doImage

        void doImage​(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.io.File file)
              throws java.io.IOException
        Process the image for a roster entry image or icon request.
        Parameters:
        file - File object containing an image
        request - contains parameters for drawing the image
        response - sends a PNG image or a 403 Not Found error.
        Throws:
        java.io.IOException - if communications is cut with client