public void reload() throws Exception { if (loader != null) { loader.reload(); } }
public void reload() throws Exception { destroy(); // reload catalog, make sure we reload the underlying catalog, not any wrappers Catalog catalog = geoserver.getCatalog(); if (catalog instanceof Wrapper) { catalog = ((Wrapper) geoserver.getCatalog()).unwrap(Catalog.class); } XStreamPersister xp = xpf.createXMLPersister(); xp.setCatalog(catalog); loadCatalog(catalog, xp); loadGeoServer(geoserver, xp); reloadInitializers(geoserver); }
/** * Does some post processing on the catalog to ensure that the "well-known" styles are always * around. */ protected void initializeStyles(Catalog catalog, XStreamPersister xp) throws IOException { initializeDefaultStyles(catalog); }
XStreamPersister xp = xpf.createXMLPersister(); xp.setCatalog(catalog); loadCatalog(catalog, xp); initializeStyles(catalog, xp); } catch (Exception e) { throw new RuntimeException(e); XStreamPersister xp = xpf.createXMLPersister(); xp.setCatalog(geoserver.getCatalog()); loadGeoServer(geoserver, xp); loadInitializers(geoserver); } catch (Exception e) { throw new RuntimeException(e);
boolean checkStores = checkStoresOnStartup(xp); if (!checkStores) { catalog.setExtendedValidation(false); loadStyles(resourceLoader.get("styles"), catalog, xp); if (Resources.exists(dws)) { try { defaultWorkspace = depersist(xp, dws, WorkspaceInfo.class); LOGGER.info("Loaded default workspace " + defaultWorkspace.getName()); } catch (Exception e) { final Resource workspaceResource = wc.resource; try { ws = depersist(xp, wc.contents, WorkspaceInfo.class); catalog.add(ws); if (LOGGER.isLoggable(Level.INFO)) { ns = depersist(xp, wc.nsContents, NamespaceInfo.class); catalog.add(ns); } catch (Exception e) { if (defaultWorkspace != null) { try { persist(xp, defaultWorkspace, dws); } catch (Exception e) { LOGGER.log( loadStyles(styles, catalog, xp);
@Override protected void tearDownInternal() throws Exception { super.tearDownInternal(); // reset the legacy flag so that other tests are not getting affected by it GeoServerLoader.setLegacy(false); }
if (Resources.exists(f)) { try { GeoServerInfo global = depersist(xp, f, GeoServerInfo.class); geoServer.setGlobal(global); } catch (Exception e) { if (Resources.exists(f)) { try { LoggingInfo logging = depersist(xp, f, LoggingInfo.class); geoServer.setLogging(logging); } catch (Exception e) { if (Resources.exists(f)) { try { SettingsInfo settings = depersist(xp, f, SettingsInfo.class); geoServer.add(settings); } catch (Exception e) { loadServices(resourceLoader.get(""), true, loaders, geoServer); if (dir.getType() != Type.DIRECTORY) continue; loadServices(dir, false, loaders, geoServer);
public void destroy() throws Exception { if (loader != null) { loader.destroy(); } }
protected void initializeDefaultStyles(Catalog catalog) throws IOException { if (catalog.getStyleByName(StyleInfo.DEFAULT_POINT) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_POINT, "default_point.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_LINE) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_LINE, "default_line.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_POLYGON) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_POLYGON, "default_polygon.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_RASTER) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_RASTER, "default_raster.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_GENERIC) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_GENERIC, "default_generic.sld"); } }
@Override protected void initializeStyles(Catalog catalog, XStreamPersister xp) throws IOException { // add a persister temporarily in case the styles don't exist on disk GeoServerConfigPersister cp = new GeoServerConfigPersister(resourceLoader, xp); GeoServerResourcePersister rp = new GeoServerResourcePersister(resourceLoader); catalog.addListener(cp); catalog.addListener(rp); super.initializeStyles(catalog, xp); catalog.removeListener(cp); catalog.removeListener(rp); } }
GeoServerLoader.setLegacy(useLegacyDataDirectory());
boolean checkStoresOnStartup(XStreamPersister xp) { Resource f = resourceLoader.get("global.xml"); if (Resources.exists(f)) { try { GeoServerInfo global = depersist(xp, f, GeoServerInfo.class); final ResourceErrorHandling resourceErrorHandling = global.getResourceErrorHandling(); return resourceErrorHandling != null && !ResourceErrorHandling.SKIP_MISCONFIGURED_LAYERS.equals( resourceErrorHandling); } catch (IOException e) { LOGGER.log( Level.INFO, "Failed to determine the capabilities resource error handling", e); } } return true; }
@Override public void onClick(AjaxRequestTarget target) { try { GeoServerLoader loader = (GeoServerLoader) GeoServerApplication.get().getBean("geoServerLoader"); synchronized (org.geoserver.config.GeoServer.CONFIGURATION_LOCK) { loader.reload(); } info("Catalog and configuration reloaded"); } catch(Exception e) { error(e); } } });
@Override protected void oneTimeTearDown() throws Exception { super.oneTimeTearDown(); // reset the legacy flag so that other tests are not getting affected by it GeoServerLoader.setLegacy(false); }
void loadLayerGroups(Resource layerGroups, Catalog catalog, XStreamPersister xp) { try (AsynchResourceIterator<byte[]> it = new AsynchResourceIterator<>(layerGroups, XML_FILTER, r -> r.getContents())) { while (it.hasNext()) { try { LayerGroupInfo lg = depersist(xp, it.next(), LayerGroupInfo.class); if (lg.getLayers() == null || lg.getLayers().size() == 0) { LOGGER.warning( "Skipping empty layer group '" + lg.getName() + "', it is invalid"); continue; } catalog.add(lg); LOGGER.info("Loaded layer group '" + lg.getName() + "'"); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load layer group", e); } } } }
@Override public void initialize(GeoServer geoServer) throws Exception { loader.initializeDefaultStyles(geoServer.getCatalog()); } }
@Override public void onClick(AjaxRequestTarget target) { try { GeoServerLoader loader = (GeoServerLoader) GeoServerApplication.get().getBean("geoServerLoader"); synchronized (org.geoserver.config.GeoServer.CONFIGURATION_LOCK) { loader.reload(); } info("Catalog and configuration reloaded"); } catch (Exception e) { error(e); } } });
@Override protected void oneTimeTearDown() throws Exception { super.oneTimeTearDown(); // reset the legacy flag so that other tests are not getting affected by it GeoServerLoader.setLegacy(false); }
void loadStyles(Resource styles, Catalog catalog, XStreamPersister xp) throws IOException { Filter<Resource> styleFilter = r -> XML_FILTER.accept(r) && !Resources.exists(styles.get(r.name() + ".xml")); try (AsynchResourceIterator<byte[]> it = new AsynchResourceIterator<>(styles, styleFilter, r -> r.getContents())) { while (it.hasNext()) { try { StyleInfo s = depersist(xp, it.next(), StyleInfo.class); catalog.add(s); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Loaded style '" + s.getName() + "'"); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load style", e); } } } }