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

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

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

GeoServer.add介绍

[英]Adds a service to the configuration.
[中]将服务添加到配置中。

代码示例

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

if (!global && s.getWorkspace() == null) continue;
geoServer.add(s);

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

try {
  SettingsInfo settings = depersist(xp, f, SettingsInfo.class);
  geoServer.add(settings);
} catch (Exception e) {
  LOGGER.log(

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

if (service != null) {
  LOGGER.info("Loading service '" + service.getId() + "'");
  geoServer.add(service);

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

@Test
public void testAddWorkspaceLocalService() throws Exception {
  File dataDirRoot = getTestData().getDataDirectoryRoot();
  WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
  ServiceInfo s = geoServer.getFactory().createService();
  s.setName("foo");
  s.setWorkspace(ws);
  File f = new File(dataDirRoot, "workspaces" + "/" + ws.getName() + "/service.xml");
  assertFalse(f.exists());
  geoServer.add(s);
  assertTrue(f.exists());
}

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

geoServer.add(created);

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

settings.setLocalWorkspaceIncludesPrefix(true);
settings.setWorkspace(workspace);
gs.add(settings);
assertEquals("sf:localGroup", catalog.getLayerGroupByName("localGroup").prefixedName());
assertEquals("sf:localGroup", catalog.getLayerGroups().get(0).prefixedName());

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

@Test
public void testAddSettings() throws Exception {
  testAddWorkspace();
  WorkspaceInfo ws = catalog.getWorkspaceByName("acme");
  SettingsInfo settings = getGeoServer().getFactory().createSettings();
  settings.setTitle("ACME");
  settings.setWorkspace(ws);
  File f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml");
  assertNull(f);
  getGeoServer().add(settings);
  f = catalog.getResourceLoader().find("workspaces", ws.getName(), "settings.xml");
  assertNotNull(f);
  Document dom = dom(f);
  assertXpathEvaluatesTo("ACME", "/settings/title", dom);
}

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

@Test
public void testReloadWithLocalServices() throws Exception {
  // setup a non default workspace
  WorkspaceInfo ws = getCatalog().getFactory().createWorkspace();
  ws.setName("nonDefault");
  NamespaceInfo ni = getCatalog().getFactory().createNamespace();
  ni.setPrefix("nonDefault");
  ni.setURI("http://www.geoserver.org/nonDefault");
  getCatalog().add(ws);
  getCatalog().add(ni);
  // create a ws specific setting
  SettingsInfo s = geoServer.getFactory().createSettings();
  s.setWorkspace(ws);
  geoServer.add(s);
  getGeoServer().reload();
}

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

geoServer.save(settings);
} else {
  geoServer.add(settings);

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

@PostMapping(
  consumes = {
    MediaType.APPLICATION_JSON_VALUE,
    MediaTypeExtensions.TEXT_JSON_VALUE,
    MediaType.APPLICATION_XML_VALUE,
    MediaType.TEXT_XML_VALUE
  }
)
@ResponseStatus(HttpStatus.CREATED)
public String localSettingsCreate(
    @PathVariable String workspaceName, @RequestBody SettingsInfo settingsInfo) {
  String name = "";
  if (workspaceName != null) {
    Catalog catalog = geoServer.getCatalog();
    WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspaceName);
    settingsInfo.setWorkspace(workspaceInfo);
    geoServer.add(settingsInfo);
    geoServer.save(geoServer.getSettings(workspaceInfo));
    name = settingsInfo.getWorkspace().getName();
  }
  return name;
}

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

@PutMapping(
  consumes = {
    MediaType.APPLICATION_JSON_VALUE,
    MediaTypeExtensions.TEXT_JSON_VALUE,
    MediaType.APPLICATION_XML_VALUE,
    MediaType.TEXT_XML_VALUE
  }
)
public void localSettingsPut(
    @PathVariable String workspaceName, @RequestBody SettingsInfo settingsInfo) {
  if (workspaceName != null) {
    WorkspaceInfo workspaceInfo = geoServer.getCatalog().getWorkspaceByName(workspaceName);
    SettingsInfo original = geoServer.getSettings(workspaceInfo);
    if (original == null) {
      settingsInfo.setWorkspace(workspaceInfo);
      geoServer.add(settingsInfo);
      geoServer.save(geoServer.getSettings(workspaceInfo));
    } else {
      OwsUtils.copy(settingsInfo, original, SettingsInfo.class);
      original.setWorkspace(workspaceInfo);
      geoServer.save(original);
    }
  }
}

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

public void serviceSettingsPut(ServiceInfo info, String workspaceName) {
  WorkspaceInfo ws = null;
  if (workspaceName != null) ws = geoServer.getCatalog().getWorkspaceByName(workspaceName);
  ServiceInfo originalInfo;
  if (ws != null) {
    originalInfo = geoServer.getService(ws, clazz);
  } else {
    originalInfo = geoServer.getService(clazz);
  }
  if (originalInfo != null) {
    OwsUtils.copy(info, originalInfo, clazz);
    geoServer.save(originalInfo);
  } else {
    if (ws != null) {
      info.setWorkspace(ws);
    }
    geoServer.add(info);
  }
}

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

@Override
protected String handleObjectPost(Object obj) throws Exception {
  String name = "";
  String workspace = getAttribute("workspace");
  if (workspace != null) {
    Catalog catalog = geoServer.getCatalog();
    WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspace);
    SettingsInfo settings = (SettingsInfo) obj;
    settings.setWorkspace(workspaceInfo);
    geoServer.add(settings);
    geoServer.save(geoServer.getSettings(workspaceInfo));
    name = settings.getWorkspace().getName();
  }
  return name;
}

代码示例来源: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/restconfig

@Override
protected void handleObjectPut(Object obj) throws Exception {
  String workspace = getAttribute("workspace");
  if (workspace != null) {
    WorkspaceInfo workspaceInfo = catalog.getWorkspaceByName(workspace);
    SettingsInfo settingsInfo = (SettingsInfo) obj;
    SettingsInfo original = geoServer.getSettings(workspaceInfo);
    if (original == null) {
      settingsInfo.setWorkspace(workspaceInfo);
      geoServer.add(settingsInfo);
      geoServer.save(geoServer.getSettings(workspaceInfo));
    } else {
      OwsUtils.copy(settingsInfo, original, SettingsInfo.class);
      original.setWorkspace(workspaceInfo);
      geoServer.save(original);
    }
  }
}

代码示例来源: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/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);
}

相关文章