org.geoserver.config.GeoServer.remove()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.geoserver.config.GeoServer.remove()方法的一些代码示例,展示了GeoServer.remove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoServer.remove()方法的具体详情如下:
包路径:org.geoserver.config.GeoServer
类名称:GeoServer
方法名:remove

GeoServer.remove介绍

[英]Removes a service from the configuration.
[中]从配置中删除服务。

代码示例

代码示例来源:origin: geoserver/geoserver

@Test
public void testRemoveWorkspaceLocalService() throws Exception {
  testAddWorkspaceLocalService();
  File dataDirRoot = getTestData().getDataDirectoryRoot();
  WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
  File f = new File(dataDirRoot, "workspaces" + "/" + ws.getName() + "/service.xml");
  assertTrue(f.exists());
  Logger logger = Logging.getLogger(GeoServerImpl.class);
  Level level = logger.getLevel();
  try {
    logger.setLevel(Level.OFF);
    ServiceInfo s = geoServer.getServiceByName(ws, "foo", ServiceInfo.class);
    geoServer.remove(s);
    assertFalse(f.exists());
  } finally {
    logger.setLevel(level);
  }
}

代码示例来源:origin: geoserver/geoserver

@Before
public void removeFooService() throws IOException {
  GeoServer geoServer = getGeoServer();
  WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
  ServiceInfo s = geoServer.getServiceByName(ws, "foo", ServiceInfo.class);
  if (s != null) {
    geoServer.remove(s);
  }
  File serviceFile = getDataDirectory().findFile("service.xml");
  if (serviceFile != null) {
    serviceFile.delete();
  }
}

代码示例来源:origin: geoserver/geoserver

@Test
public void testRemoveSettings() throws Exception {
  testAddSettings();
  WorkspaceInfo ws = catalog.getWorkspaceByName("acme");
  File f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml");
  assertNotNull(f);
  SettingsInfo settings = getGeoServer().getSettings(ws);
  getGeoServer().remove(settings);
  f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml");
  assertNull(f);
}

代码示例来源:origin: geoserver/geoserver

assertEquals("sf:localGroup", catalog.getLayerGroupByName("localGroup").prefixedName());
assertEquals("sf:localGroup", catalog.getLayerGroups().get(0).prefixedName());
gs.remove(settings);

代码示例来源:origin: org.geoserver/gs-restconfig

@DeleteMapping
public void localSetingsDelete(@PathVariable String workspaceName) {
  if (workspaceName != null) {
    WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspaceName);
    SettingsInfo settingsInfo = geoServer.getSettings(workspaceInfo);
    geoServer.remove(settingsInfo);
  }
}

代码示例来源:origin: org.geoserver/gs-restconfig

@DeleteMapping(value = "/workspaces/{workspaceName}/settings")
public void serviceDelete(@PathVariable String workspaceName) {
  WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName(workspaceName);
  if (ws == null) {
    throw new RestException(
        "Workspace " + workspaceName + " does not exist", HttpStatus.NOT_FOUND);
  }
  ServiceInfo serviceInfo = geoServer.getService(ws, clazz);
  if (serviceInfo != null) {
    geoServer.remove(serviceInfo);
  }
}

代码示例来源:origin: org.geoserver/restconfig

@Override
public void handleObjectDelete() throws Exception {
  String workspace = getAttribute("workspace");
  if (workspace != null) {
    WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspace);
    SettingsInfo settingsInfo = geoServer.getSettings(workspaceInfo);
    geoServer.remove(settingsInfo);
  }
}

代码示例来源:origin: org.geoserver/restconfig

@Override
protected void handleObjectDelete() throws Exception {
  String workspace = getAttribute("workspace");
  if (workspace != null) {
    WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName(workspace);
    ServiceInfo serviceInfo = geoServer.getService(ws, clazz);
    if (serviceInfo != null) {
      geoServer.remove(serviceInfo);
    }
  }
}

代码示例来源:origin: org.geoserver.community/gs-jms-geoserver

/**
 * Helper method that removes some services and settings from the provided GeoServer instance.
 */
private void applyDeleteConfigurationChanges(GeoServerInstance instance) {
  GeoServer geoServer = instance.getGeoServer();
  Catalog catalog = instance.getCatalog();
  WorkspaceInfo workspace = catalog.getWorkspaceByName(MockData.DEFAULT_PREFIX);
  // remove workspace specific settings
  geoServer.remove(geoServer.getSettings(workspace));
  // remove WMS workspace specific settings
  geoServer.remove(geoServer.getService(workspace, WMSInfo.class));
}

代码示例来源:origin: org.geoserver/gs-restconfig-wcs

private void removeLocalWorkspace() {
    GeoServer geoServer = getGeoServer();
    WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName("sf");
    WCSInfo wcsInfo = geoServer.getService(ws, WCSInfo.class);
    geoServer.remove(wcsInfo);
  }
}

代码示例来源:origin: org.geoserver/gs-restconfig-wfs

private void removeLocalWorkspace() {
    GeoServer geoServer = getGeoServer();
    WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName("sf");
    WFSInfo wfsInfo = geoServer.getService(ws, WFSInfo.class);
    geoServer.remove(wfsInfo);
  }
}

代码示例来源:origin: org.geoserver/gs-restconfig-wms

private void removeLocalWorkspace() {
    GeoServer geoServer = getGeoServer();
    WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName("sf");
    WMSInfo wmsInfo = geoServer.getService(ws, WMSInfo.class);
    geoServer.remove(wmsInfo);
  }
}

代码示例来源:origin: org.geoserver/gs-wms

public void testSldDisabled() throws Exception {
  HashMap kvp = new HashMap();
  URL url = GetMapKvpRequestReader.class.getResource("BasicPolygonsLibraryDefault.sld");
  String decoded = URLDecoder.decode(url.toExternalForm(), "UTF-8");
  kvp.put("sld", decoded);
  kvp.put(
      "layers",
      MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart());
  WMS wms = new WMS(getGeoServer());
  WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class);
  WMSInfo info = new WMSInfoImpl();
  info.setDynamicStylingDisabled(Boolean.TRUE);
  getGeoServer().remove(oldInfo);
  getGeoServer().add(info);
  reader = new GetMapKvpRequestReader(wms);
  GetMapRequest request = (GetMapRequest) reader.createRequest();
  boolean error = false;
  try {
    request = (GetMapRequest) reader.read(request, parseKvp(kvp), kvp);
  } catch (ServiceException e) {
    error = true;
  }
  getGeoServer().remove(info);
  getGeoServer().add(oldInfo);
  assertTrue(error);
}

代码示例来源:origin: org.geoserver/gs-wms

public void testSldDisabled() throws Exception {
  HashMap kvp = new HashMap();
  URL url = GetMapKvpRequestReader.class.getResource("BasicPolygonsLibraryDefault.sld");
  String decoded = URLDecoder.decode(url.toExternalForm(), "UTF-8");
  kvp.put("sld", decoded);
  kvp.put(
      "layers",
      MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart());
  WMS wms = new WMS(getGeoServer());
  WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class);
  WMSInfo info = new WMSInfoImpl();
  info.setDynamicStylingDisabled(Boolean.TRUE);
  getGeoServer().remove(oldInfo);
  getGeoServer().add(info);
  reader = new GetFeatureInfoKvpReader(wms);
  GetFeatureInfoRequest request = (GetFeatureInfoRequest) reader.createRequest();
  boolean error = false;
  try {
    request = (GetFeatureInfoRequest) reader.read(request, parseKvp(kvp), kvp);
  } catch (ServiceException e) {
    error = true;
  }
  getGeoServer().remove(info);
  getGeoServer().add(oldInfo);
  assertTrue(error);
}

代码示例来源:origin: org.geoserver/gs-wms

public void testSldBodyDisabled() throws Exception {
  HashMap kvp = new HashMap();
  kvp.put("sld_body", STATES_SLD);
  kvp.put(
      "layers",
      MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart());
  WMS wms = new WMS(getGeoServer());
  WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class);
  WMSInfo info = new WMSInfoImpl();
  info.setDynamicStylingDisabled(Boolean.TRUE);
  getGeoServer().remove(oldInfo);
  getGeoServer().add(info);
  reader = new GetMapKvpRequestReader(wms);
  GetMapRequest request = (GetMapRequest) reader.createRequest();
  boolean error = false;
  try {
    request = (GetMapRequest) reader.read(request, parseKvp(kvp), kvp);
  } catch (ServiceException e) {
    error = true;
  }
  getGeoServer().remove(info);
  getGeoServer().add(oldInfo);
  assertTrue(error);
}

代码示例来源:origin: org.geoserver/gs-wms

public void testSldBodyDisabled() throws Exception {
    HashMap kvp = new HashMap();
    kvp.put("sld_body", STATES_SLD);
    kvp.put(
        "layers",
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart());

    WMS wms = new WMS(getGeoServer());
    WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class);
    WMSInfo info = new WMSInfoImpl();
    info.setDynamicStylingDisabled(Boolean.TRUE);
    getGeoServer().remove(oldInfo);
    getGeoServer().add(info);
    reader = new GetFeatureInfoKvpReader(wms);
    GetFeatureInfoRequest request = (GetFeatureInfoRequest) reader.createRequest();
    boolean error = false;
    try {
      request = (GetFeatureInfoRequest) reader.read(request, parseKvp(kvp), kvp);
    } catch (ServiceException e) {
      error = true;
    }
    getGeoServer().remove(info);
    getGeoServer().add(oldInfo);
    assertTrue(error);
  }
}

代码示例来源:origin: org.geoserver/gs-wms

public void testAllowDynamicStyles() throws Exception {
  GetMapRequest request = (GetMapRequest) reader.createRequest();
  BufferedReader input = getResourceInputStream("WMSPostLayerGroupNonDefaultStyle.xml");
  WMS wms = new WMS(getGeoServer());
  WMSInfo oldInfo = wms.getGeoServer().getService(WMSInfo.class);
  WMSInfo info = new WMSInfoImpl();
  info.setDynamicStylingDisabled(Boolean.TRUE);
  getGeoServer().remove(oldInfo);
  getGeoServer().add(info);
  GetMapXmlReader reader = new GetMapXmlReader(wms);
  boolean error = false;
  try {
    request = (GetMapRequest) reader.read(request, input, new HashMap());
  } catch (ServiceException e) {
    error = true;
  }
  getGeoServer().remove(info);
  getGeoServer().add(oldInfo);
  assertTrue(error);
}

代码示例来源:origin: org.geoserver.community/gs-jms-geoserver

@After
public void clean() {
  // remove test workspace
  getCatalog().remove(getCatalog().getWorkspace("jms-test-workspace"));
  // remove any created service
  Collection<? extends ServiceInfo> services = getGeoServer().getServices();
  for (ServiceInfo service : services) {
    ServiceInfo finalService = ModificationProxy.unwrap(service);
    if (finalService instanceof JmsTestServiceInfoImpl) {
      getGeoServer().remove(finalService);
    }
  }
}

代码示例来源:origin: org.geoserver/gs-restconfig-wms

@Before
public void initLocalWMS() throws Exception {
  GeoServer geoServer = getGeoServer();
  WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName("sf");
  WMSInfo wmsInfo = geoServer.getService(ws, WMSInfo.class);
  if (wmsInfo != null) {
    geoServer.remove(wmsInfo);
  }
  wmsInfo = geoServer.getFactory().create(WMSInfo.class);
  wmsInfo.setName("WMS");
  wmsInfo.setWorkspace(ws);
  geoServer.add(wmsInfo);
}

代码示例来源:origin: org.geoserver/gs-restconfig

@Test
public void testCreateLocalAlreadyExists() throws Exception {
  GeoServer geoServer = getGeoServer();
  geoServer.remove(geoServer.getSettings(geoServer.getCatalog().getWorkspaceByName("sf")));
  String xml =
      "<settings>"

相关文章