@Test public void testGet() { ctrl = new FormatController(geoServer); JSONObj obj = ctrl.get("shapefile"); assertEquals("shapefile", obj.get("name")); assertEquals("vector", obj.get("kind")); assertEquals("file", obj.get("type")); obj = ctrl.get("h2"); assertEquals("h2", obj.get("name")); assertEquals("vector", obj.get("kind")); assertEquals("database", obj.get("type")); obj = ctrl.get("geotiff"); assertEquals("geotiff", obj.get("name")); assertEquals("raster", obj.get("kind")); assertEquals("file", obj.get("type")); obj = ctrl.get("wms"); assertEquals("wms", obj.get("name")); assertEquals("service", obj.get("kind")); try { ctrl.get("foo"); fail(); } catch(NotFoundException e) { } }
@RequestMapping(value = "/{name}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String name) { DataFormat<DataAccessFactory> f = findVectorFormat(name); if( f != null ){ JSONObj obj = encode(new JSONObj(), f); JSONObj params = obj.putObject("params"); for(Param p : f.real.getParametersInfo()){ IO.param(params, p); } return obj; } DataFormat<Format> g = findRasterFormat(name); if( g != null ){ JSONObj obj = encode(new JSONObj(), g); obj.put("vendor", g.real.getVendor()) .put("version", g.real.getVersion()); JSONArr connection = obj.putArray("params"); IO.param(connection.addObject(), g.real); return obj; } DataFormat<Class<?>> s = findServiceFormat(name); if ( s != null) { JSONObj obj = encode(new JSONObj(), s); obj.putArray("params").addObject() .put("name","wms") .put("title","URL") .put("description","GetCapabilities URL for WMS Service") .put("type",URL.class.getSimpleName()) .put("default",null) .put("level","user") .put("required",true); return obj; } throw new NotFoundException("Unrecognized format: " + name); }
FormatController extends ApiController { @RequestMapping(value = "/{name}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String name) { DataFormat<DataAccessFactory> f = findVectorFormat(name); if( f != null ){ JSONObj obj = encode(new JSONObj(), f); JSONObj params = obj.putObject("params"); for(Param p : f.real.getParametersInfo()){ IO.param(params, p); } return obj; } DataFormat<Format> g = findRasterFormat(name); if( g != null ){ JSONObj obj = encode(new JSONObj(), g); obj.put("vendor", g.real.getVendor()) .put("version", g.real.getVersion()); JSONArr connection = obj.putArray("params"); IO.param(connection.addObject(), g.real); return obj; } DataFormat<Class<?>> s = findServiceFormat(name); if ( s != null) { JSONObj obj = encode(new JSONObj(), s); obj.putArray("params").addObject() .put("name","wms") .put("title","URL") .put("description","GetCapabilities URL for WMS Service") .put("type",URL.class.getSimpleName()) .put("default",null) .put("level","user") .put("required",true); return obj; } throw new NotFoundException("Unrecognized format: " + name); } }
FormatController extends ApiController { @RequestMapping(value = "/{name}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String name) { DataFormat<DataAccessFactory> f = findVectorFormat(name); if( f != null ){ JSONObj obj = encode(new JSONObj(), f); JSONObj params = obj.putObject("params"); for(Param p : f.real.getParametersInfo()){ IO.param(params, p); } return obj; } DataFormat<Format> g = findRasterFormat(name); if( g != null ){ JSONObj obj = encode(new JSONObj(), g); obj.put("vendor", g.real.getVendor()) .put("version", g.real.getVersion()); JSONArr connection = obj.putArray("params"); IO.param(connection.addObject(), g.real); return obj; } DataFormat<Class<?>> s = findServiceFormat(name); if ( s != null) { JSONObj obj = encode(new JSONObj(), s); obj.putArray("params").addObject() .put("name","wms") .put("title","URL") .put("description","GetCapabilities URL for WMS Service") .put("type",URL.class.getSimpleName()) .put("default",null) .put("level","user") .put("required",true); return obj; } throw new NotFoundException("Unrecognized format: " + name); } @Autowired  FormatController(GeoServer geoServer); }
FormatController extends ApiController { @RequestMapping(value = "/{name}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String name) { DataFormat<DataAccessFactory> f = findVectorFormat(name); if( f != null ){ JSONObj obj = encode(new JSONObj(), f); JSONObj params = obj.putObject("params"); for(Param p : f.real.getParametersInfo()){ IO.param(params, p); } return obj; } DataFormat<Format> g = findRasterFormat(name); if( g != null ){ JSONObj obj = encode(new JSONObj(), g); obj.put("vendor", g.real.getVendor()) .put("version", g.real.getVersion()); JSONArr connection = obj.putArray("params"); IO.param(connection.addObject(), g.real); return obj; } DataFormat<Class<?>> s = findServiceFormat(name); if ( s != null) { JSONObj obj = encode(new JSONObj(), s); obj.putArray("params").addObject() .put("name","wms") .put("title","URL") .put("description","GetCapabilities URL for WMS Service") .put("type",URL.class.getSimpleName()) .put("default",null) .put("level","user") .put("required",true); return obj; } throw new NotFoundException("Unrecognized format: " + name); } @Autowired  FormatController(GeoServer geoServer); @RequestMapping(method = RequestMethod.GET) @ResponseBody JSONArr list(); @RequestMapping(value = "/{name}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String name); }
FormatController extends ApiController { @RequestMapping(value = "/{name}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String name) { DataFormat<DataAccessFactory> f = findVectorFormat(name); if( f != null ){ JSONObj obj = encode(new JSONObj(), f); JSONObj params = obj.putObject("params"); for(Param p : f.real.getParametersInfo()){ IO.param(params, p); } return obj; } DataFormat<Format> g = findRasterFormat(name); if( g != null ){ JSONObj obj = encode(new JSONObj(), g); obj.put("vendor", g.real.getVendor()) .put("version", g.real.getVersion()); JSONArr connection = obj.putArray("params"); IO.param(connection.addObject(), g.real); return obj; } DataFormat<Class<?>> s = findServiceFormat(name); if ( s != null) { JSONObj obj = encode(new JSONObj(), s); obj.putArray("params").addObject() .put("name","wms") .put("title","URL") .put("description","GetCapabilities URL for WMS Service") .put("type",URL.class.getSimpleName()) .put("default",null) .put("level","user") .put("required",true); return obj; } throw new NotFoundException("Unrecognized format: " + name); } @Autowired  FormatController(GeoServer geoServer); @RequestMapping(method = RequestMethod.GET) @ResponseBody JSONArr list(); @RequestMapping(value = "/{name}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String name);  }