Class RosterServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- jmri.web.servlet.roster.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)
Generate the JSON, XML, or HTML output specified bydoList(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,doGroup(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
, ordoEntry(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
.void
init()
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Constructor Detail
-
RosterServlet
public RosterServlet()
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletException
- Overrides:
init
in classjavax.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 classjavax.servlet.http.HttpServlet
- Parameters:
request
- servlet requestresponse
- 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 classjavax.servlet.http.HttpServlet
- Parameters:
request
- servlet requestresponse
- servlet response- Throws:
javax.servlet.ServletException
- if unable to process uploadsjava.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 requestresponse
- servlet responsegroup
- The group name- Throws:
java.io.IOException
- if communications is cut with client
-
doList
protected void doList(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
List roster entries.Lists roster entries and return an XML document conforming to the JMRI Roster XML schema. This method can be passed multiple filter filter 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/
/roster/list
/roster/list?filter=filter[&filter=filter]
- Parameters:
request
- servlet requestresponse
- servlet response- 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
Images and icons can be rescaled using the following parameters:
- height
- maxHeight
- minHeight
- width
- maxWidth
- minWidth
- Parameters:
request
- servlet requestresponse
- servlet response- Throws:
java.io.IOException
- if communications is cut with client
-
doRoster
protected void doRoster(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.fasterxml.jackson.databind.JsonNode filter) throws java.io.IOException
Generate the JSON, XML, or HTML output specified bydoList(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,doGroup(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
, ordoEntry(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
.- Parameters:
request
- servlet request with format and locale for responseresponse
- servlet responsefilter
- a JSON object with name-value pairs of parameters forRoster.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)
.- 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 imagerequest
- contains parameters for drawing the imageresponse
- sends a PNG image or a 403 Not Found error.- Throws:
java.io.IOException
- if communications is cut with client
-
-