Class JsonRosterHttpService
- java.lang.Object
- 
- jmri.server.json.JsonHttpService
- 
- jmri.server.json.roster.JsonRosterHttpService
 
 
- 
 public class JsonRosterHttpService extends JsonHttpService 
- 
- 
Field Summary- 
Fields inherited from class jmri.server.json.JsonHttpServicemapper
 
- 
 - 
Constructor SummaryConstructors Constructor Description JsonRosterHttpService(com.fasterxml.jackson.databind.ObjectMapper mapper)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNodedoGet(java.lang.String type, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)Respond to an HTTP GET request for the requested name.com.fasterxml.jackson.databind.JsonNodedoGetList(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)Respond to an HTTP GET request for a list of items of type.com.fasterxml.jackson.databind.JsonNodedoPost(java.lang.String type, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)Respond to an HTTP POST request for the requested name.com.fasterxml.jackson.databind.JsonNodedoSchema(java.lang.String type, boolean server, JsonRequest request)Get the JSON Schema for thedataproperty of the requested type of JSON object.com.fasterxml.jackson.databind.JsonNodegetRoster(java.util.Locale locale, com.fasterxml.jackson.databind.JsonNode data, int id)com.fasterxml.jackson.databind.JsonNodegetRosterEntry(java.util.Locale locale, java.lang.String name, int id)Returns the JSON representation of a roster entry.com.fasterxml.jackson.databind.JsonNodegetRosterEntry(java.util.Locale locale, RosterEntry entry, int id)Returns the JSON representation of a roster entry.com.fasterxml.jackson.databind.JsonNodegetRosterGroup(java.util.Locale locale, java.lang.String name, int id)com.fasterxml.jackson.databind.JsonNodegetRosterGroups(JsonRequest request)Get a list of roster groups.com.fasterxml.jackson.databind.JsonNodepostRosterEntry(java.util.Locale locale, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, int id)Edit an existing roster entry.- 
Methods inherited from class jmri.server.json.JsonHttpServiceacceptForceDeleteToken, doDelete, doPut, doSchema, doSchema, getObjectMapper, message, message, message, message, message, throwDeleteConflictException
 
- 
 
- 
- 
- 
Constructor Detail- 
JsonRosterHttpServicepublic JsonRosterHttpService(com.fasterxml.jackson.databind.ObjectMapper mapper) 
 
- 
 - 
Method Detail- 
doGetpublic com.fasterxml.jackson.databind.JsonNode doGet(java.lang.String type, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException Description copied from class:JsonHttpServiceRespond to an HTTP GET request for the requested name.If name is null, return a list of all objects for the given type, if appropriate. This method should throw a 500 Internal Server Error if type is not recognized. - Specified by:
- doGetin class- JsonHttpService
- Parameters:
- type- the type of the requested object
- name- the system name of the requested object
- data- JSON data set of attributes of the requested object
- request- the JSON request
- Returns:
- a JSON description of the requested object
- Throws:
- JsonException- if the named object does not exist or other error occurs
 
 - 
doPostpublic com.fasterxml.jackson.databind.JsonNode doPost(java.lang.String type, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException Description copied from class:JsonHttpServiceRespond to an HTTP POST request for the requested name.This method should throw a 400 Invalid Request error if the named object does not exist. - Specified by:
- doPostin class- JsonHttpService
- Parameters:
- type- the type of the requested object
- name- the system name of the requested object
- data- JSON data set of attributes of the requested object to be updated
- request- the JSON request
- Returns:
- a JSON description of the requested object after updates have been applied
- Throws:
- JsonException- if the named object does not exist or other error occurs
 
 - 
doGetListpublic com.fasterxml.jackson.databind.JsonNode doGetList(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException Description copied from class:JsonHttpServiceRespond to an HTTP GET request for a list of items of type.This is called by the JsonServletto handle get requests for a type, but no name. Services that do not have named objects, such as theJsonTimeHttpServiceshould respond to this with a list containing a single JSON object. Services that can't return a list may throw a 400 Bad Request JsonException in this case.- Specified by:
- doGetListin class- JsonHttpService
- Parameters:
- type- the type of the requested list
- data- JSON data set of attributes of the requested objects
- request- the JSON request
- Returns:
- a JSON list or message containing type "list", the list as data, and the passed in id
- Throws:
- JsonException- may be thrown by concrete implementations
 
 - 
getRoster@Nonnull public com.fasterxml.jackson.databind.JsonNode getRoster(@Nonnull java.util.Locale locale, @Nonnull com.fasterxml.jackson.databind.JsonNode data, int id) throws JsonException - Throws:
- JsonException
 
 - 
getRosterEntrypublic com.fasterxml.jackson.databind.JsonNode getRosterEntry(java.util.Locale locale, java.lang.String name, int id) throws JsonException Returns the JSON representation of a roster entry.Note that this returns, for images and icons, a URL relative to the root folder of the JMRI server. It is expected that clients will fill in the server IP address and port as they know it to be. - Parameters:
- locale- the client's locale
- name- the id of an entry in the roster
- id- the message id set by the client
- Returns:
- a roster entry in JSON notation
- Throws:
- JsonException- If no roster entry exists for the given id
 
 - 
getRosterEntrypublic com.fasterxml.jackson.databind.JsonNode getRosterEntry(java.util.Locale locale, @Nonnull RosterEntry entry, int id) throws JsonException Returns the JSON representation of a roster entry.Note that this returns, for images and icons, a URL relative to the root folder of the JMRI server. It is expected that clients will fill in the server IP address and port as they know it to be. - Parameters:
- locale- the client's Locale
- entry- A RosterEntry that may or may not be in the roster.
- id- message id set by client
- Returns:
- a roster entry in JSON notation
- Throws:
- JsonException- if an error needs to be reported to the user
 
 - 
getRosterGroups@Nonnull public com.fasterxml.jackson.databind.JsonNode getRosterGroups(JsonRequest request) throws JsonException Get a list of roster groups.- Parameters:
- request- the JSON request
- Returns:
- a message containing the roster groups
- Throws:
- JsonException- if a requested roster group does not exist
 
 - 
getRosterGroup@Nonnull public com.fasterxml.jackson.databind.JsonNode getRosterGroup(java.util.Locale locale, java.lang.String name, int id) throws JsonException - Throws:
- JsonException
 
 - 
doSchemapublic com.fasterxml.jackson.databind.JsonNode doSchema(java.lang.String type, boolean server, JsonRequest request) throws JsonException Description copied from class:JsonHttpServiceGet the JSON Schema for thedataproperty of the requested type of JSON object. It is a invalid for implementations to not return a valid schema that clients can use to validate a request to or response from the JSON services.Note that a schema must be contained in a standard object as: {"type":"schema", "data":{"schema":<em>schema</em>, "server":boolean}}If using JsonHttpService.doSchema(String, boolean, String, String, int), an implementation can be as simple as:return doSchema(type, server, "path/to/client/schema.json", "path/to/server/schema.json", id);- Specified by:
- doSchemain class- JsonHttpService
- Parameters:
- type- the type for which a schema is requested
- server- true if the schema is for a message from the server; false if the schema is for a message from the client
- request- the JSON request
- Returns:
- a JSON Schema valid for the type
- Throws:
- JsonException- if an error occurs preparing schema; if type is is not a type handled by this service, this must be thrown with an error code of 500 and the localized message ERROR_UNKNOWN_TYPE
 
 - 
postRosterEntrypublic com.fasterxml.jackson.databind.JsonNode postRosterEntry(java.util.Locale locale, java.lang.String name, com.fasterxml.jackson.databind.JsonNode data, int id) throws JsonException Edit an existing roster entry.- Parameters:
- locale- the locale of the client
- name- the roster entry id
- data- the roster entry attributes to be edited
- id- message id set by client
- Returns:
- the roster entry as edited
- Throws:
- JsonException- if an error needs to be reported to the user
 
 
- 
 
-