@RequestMapping(value = "/{wsName}/{name}", method = RequestMethod.PATCH)
  public @ResponseBody JSONObj patch(
      @PathVariable String wsName,
      @PathVariable String name,
      @RequestBody JSONObj obj,
      HttpServletRequest req)
      throws IOException {
    Catalog cat = geoServer.getCatalog();
    StoreInfo store = cat.getStoreByName(wsName, name, StoreInfo.class);

    boolean refresh = define(store, obj);
    cat.save(store);
    if (refresh) {
      resetConnection(store);
    }
    return storeDetails(new JSONObj(), store, req);
  }
  @RequestMapping(
      value = "/{wsName}/{name}",
      method = RequestMethod.PUT,
      consumes = MediaType.APPLICATION_JSON_VALUE)
  public @ResponseBody JSONObj put(
      @PathVariable String wsName,
      @PathVariable String name,
      @RequestBody JSONObj obj,
      HttpServletRequest req)
      throws IOException {
    Catalog cat = geoServer.getCatalog();
    StoreInfo store = cat.getStoreByName(wsName, name, StoreInfo.class);

    // pending: clear store to defaults
    boolean refresh = define(store, obj);
    cat.save(store);
    if (refresh) {
      resetConnection(store);
    }
    return storeDetails(new JSONObj(), store, req);
  }
  @Test
  public void testCascadeStore() {
    Catalog catalog = getCatalog();
    CascadeRemovalReporter visitor = new CascadeRemovalReporter(catalog);

    String citeStore = MockData.CITE_PREFIX;
    StoreInfo store = catalog.getStoreByName(citeStore, StoreInfo.class);
    String buildings = getLayerId(MockData.BUILDINGS);
    String lakes = getLayerId(MockData.LAKES);
    LayerInfo bl = catalog.getLayerByName(buildings);
    ResourceInfo br = catalog.getResourceByName(buildings, ResourceInfo.class);
    LayerInfo ll = catalog.getLayerByName(lakes);
    ResourceInfo lr = catalog.getResourceByName(lakes, ResourceInfo.class);

    visitor.visit((DataStoreInfo) store);

    assertEquals(store, visitor.getObjects(StoreInfo.class, ModificationType.DELETE).get(0));
    List<LayerInfo> layers = visitor.getObjects(LayerInfo.class, ModificationType.DELETE);
    assertTrue(layers.contains(bl));
    assertTrue(layers.contains(ll));
    List<ResourceInfo> resources = visitor.getObjects(ResourceInfo.class, ModificationType.DELETE);
    assertTrue(resources.contains(br));
    assertTrue(resources.contains(lr));
  }
Example #4
0
  <T extends StoreInfo> void initStore(
      T s, Class<T> clazz, String sId, String name, WorkspaceInfo ws) {
    expect(s.getId()).andReturn(sId).anyTimes();
    expect(s.getName()).andReturn(name).anyTimes();
    expect(s.getWorkspace()).andReturn(ws).anyTimes();
    expect(s.getCatalog()).andReturn(catalog).anyTimes();
    expect(s.isEnabled()).andReturn(true).anyTimes();

    expect(catalog.getStore(sId, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStore(sId, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(name, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(ws.getName(), name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(ws.getName(), name, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(ws, name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(ws, name, StoreInfo.class)).andReturn(s).anyTimes();
  }