001package jmri.server.json.panel; 002 003import com.fasterxml.jackson.databind.ObjectMapper; 004import com.fasterxml.jackson.databind.JsonNode; 005import javax.annotation.Nonnull; 006import javax.servlet.http.HttpServletResponse; 007import jmri.server.json.JsonException; 008import jmri.server.json.JsonHttpService; 009import jmri.server.json.JsonRequest; 010 011public class JsonPanelHttpService extends JsonHttpService { 012 public JsonPanelHttpService(ObjectMapper mapper) { 013 super(mapper); 014 } 015 016 @Override 017 public JsonNode doGet(@Nonnull String type, @Nonnull String name, @Nonnull JsonNode data, @Nonnull JsonRequest request) 018 throws JsonException { 019 throw new JsonException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Panel subscriptions are available over WebSocket.", request.id); 020 } 021 022 @Override 023 public JsonNode doPost(@Nonnull String type, @Nonnull String name, @Nonnull JsonNode data, @Nonnull JsonRequest request) 024 throws JsonException { 025 throw new JsonException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Panel subscriptions are available over WebSocket.", request.id); 026 } 027 028 @Override 029 public JsonNode doGetList(@Nonnull String type, @Nonnull JsonNode data, @Nonnull JsonRequest request) 030 throws JsonException { 031 throw new JsonException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Panel subscriptions are available over WebSocket.", request.id); 032 } 033 034 @Override 035 public JsonNode doSchema(@Nonnull String type, boolean server, @Nonnull JsonRequest request) 036 throws JsonException { 037 if (JsonPanelServiceFactory.PANEL_DISPLAY_OPTIONS.equals(type)) { 038 return mapper.createObjectNode(); 039 } else { 040 throw new JsonException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 041 Bundle.getMessage(request.locale, JsonException.ERROR_UNKNOWN_TYPE, type), request.id); 042 } 043 } 044}