/** Adds a layer to the {@link CatalogConfiguration} and saves it. */ public void add(GeoServerTileLayer tileLayer) { tld.addLayer(tileLayer); }
/** * Adds a layer to the {@link CatalogConfiguration} and saves it. */ public void add(GeoServerTileLayer tileLayer) { Configuration config = tld.addLayer(tileLayer); try { config.save(); } catch (IOException e) { propagate(getRootCause(e)); } }
@RequestMapping(value = "/layers/{layerName}", method = RequestMethod.PUT) public ResponseEntity<?> layerPut(@RequestBody TileLayer tl, @PathVariable String layerName) throws GeoWebCacheException, RestException, IOException { tl = checkLayer(layerName, tl); TileLayer testtl = null; try { testtl = findTileLayer(tl.getName(), layerDispatcher); } catch (RestException re) { // This is the expected behavior, it should not exist } if (testtl == null) { layerDispatcher.addLayer(tl); } else { layerDispatcher.modify(tl); } return new ResponseEntity<Object>("layer saved", HttpStatus.OK); }
public void testAddTileLayer() throws Exception { when(tld.addLayer(same(tileLayer))).thenThrow(new IllegalArgumentException("fake")); when(tld.addLayer(same(tileLayerGroup))).thenReturn(config); try { mediator.add(tileLayer); fail("Expected IAE"); } catch (IllegalArgumentException e) { assertTrue(true); } mediator.add(tileLayerGroup); verify(config, times(1)).save(); }
/** * PUT creates a new layer * * @param req * @param resp * @throws RestletException */ private void doPut(Request req, Response resp) throws RestletException, IOException, GeoWebCacheException { TileLayer tl = deserializeAndCheckLayer(req, resp, true); TileLayer testtl = null; try { testtl = findTileLayer(tl.getName(), layerDispatcher); } catch (RestletException re) { // This is the expected behavior, it should not exist } if (testtl == null) { Configuration config = layerDispatcher.addLayer(tl); config.save(); } else { throw new RestletException("Layer with name " + tl.getName() + " already exists, " + "use POST if you want to replace it.", Status.CLIENT_ERROR_BAD_REQUEST); } }
tileLayerDispatcher.addLayer(layer); fail("Expected error when adding a layer that already exists"); } catch (IllegalArgumentException e) { tileLayerDispatcher.addLayer(layer); fail("Expected error when adding a transient layer"); } catch (IllegalArgumentException e) { tileLayerDispatcher.addLayer(null); fail("Expected error when adding a null layer"); } catch (NullPointerException e) {
@Test public void testAddLayer() throws GeoWebCacheException { String layerName = "newLayer"; WMSLayer layer = new WMSLayer( layerName, new String[] {"http://example.com/"}, null, null, null, null, null, null, null, false, null); tileLayerDispatcher.addLayer(layer); assertTrue(tileLayerDispatcher.getLayerNames().contains(layerName)); assertEquals(layer, tileLayerDispatcher.getTileLayer(layerName)); }