001package jmri.server.json.logixngicon; 002 003import com.fasterxml.jackson.databind.JsonNode; 004 005import java.io.IOException; 006 007import javax.servlet.http.HttpServletResponse; 008 009import jmri.JmriException; 010import jmri.server.json.JSON; 011import jmri.server.json.JsonConnection; 012import jmri.server.json.JsonException; 013import jmri.server.json.JsonRequest; 014import jmri.server.json.JsonSocketService; 015 016/** 017 * JSON socket service provider for managing {@link jmri.jmrit.display.LogixNGIcon}s. 018 * 019 * @author Randall Wood 020 * @author Daniel Bergqvist (C) 2023 021 */ 022public class JsonLogixNGIconSocketService extends JsonSocketService<JsonLogixNGIconHttpService> { 023 024 public JsonLogixNGIconSocketService(JsonConnection connection) { 025 super(connection, new JsonLogixNGIconHttpService(connection.getObjectMapper())); 026 } 027 028 @Override 029 public void onList(String type, JsonNode data, JsonRequest request) throws IOException, JmriException, JsonException { 030 throw new JsonException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, Bundle.getMessage(request.locale, "GetListNotAllowed", type), request.id); 031 } 032 033 @Override 034 public void onMessage(String type, JsonNode data, JsonRequest request) throws IOException, JmriException, JsonException { 035 if (request.method.equals(JSON.POST)) { 036 connection.sendMessage(service.doPost(type, "logixngicon", data, request), request.id); 037 } 038 } 039 040 @Override 041 public void onClose() { 042 } 043 044}