private synchronized void loadConfig() throws IOException { File configFile = findConfigFile(); checkNotNull(configFile, "gwc config file does not exist: ", GWC_CONFIG_FILE); XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister(); configureXstream(xmlPersister.getXStream()); try { InputStream in = new FileInputStream(configFile); try { this.config = xmlPersister.load(in, GWCConfig.class); } finally { in.close(); } LOGGER.fine("GWC GeoServer specific configuration loaded from " + GWC_CONFIG_FILE); } catch (Exception e) { LOGGER.log( Level.WARNING, "Error loading GWC GeoServer specific " + "configuration from " + configFile.getAbsolutePath() + ". Applying defaults.", e); this.config = new GWCConfig(); } }
/** * Saves and applies the integrated GWC's GeoServer specific configuration to the * {@code <data dir>/gwc-gs.xml} file. * * @param config * * @throws IOException */ public void save(final GWCConfig config) throws IOException { LOGGER.finer("Saving integrated GWC configuration"); File tmp = new File(getConfigRoot(), GWC_CONFIG_FILE + ".tmp"); XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister(); configureXstream(xmlPersister.getXStream()); OutputStream out = new FileOutputStream(tmp); try { xmlPersister.save(config, out); } finally { out.close(); } File configFile = new File(getConfigRoot(), GWC_CONFIG_FILE); IOUtils.rename(tmp, configFile); this.config = config; LOGGER.finer("Integrated GWC configuration saved to " + configFile.getAbsolutePath()); }
private synchronized void loadConfig() throws IOException { Resource configFile = findConfigFile(); checkNotNull(configFile, "gwc config file does not exist: ", GWC_CONFIG_FILE); XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister(); configureXstream(xmlPersister.getXStream()); try { try (InputStream in = configFile.in()) { this.config = xmlPersister.load(in, GWCConfig.class); } LOGGER.fine("GWC GeoServer specific configuration loaded from " + GWC_CONFIG_FILE); } catch (Exception e) { LOGGER.log( Level.WARNING, "Error loading GWC GeoServer specific " + "configuration from " + configFile.path() + ". Applying defaults.", e); this.config = new GWCConfig(); } }
/** * Saves and applies the integrated GWC's GeoServer specific configuration to the {@code <data * dir>/gwc-gs.xml} file. * * @param config * @throws IOException */ public void save(final GWCConfig config) throws IOException { LOGGER.finer("Saving integrated GWC configuration"); Resource tmp = getConfigRoot().get(GWC_CONFIG_FILE + ".tmp"); XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister(); configureXstream(xmlPersister.getXStream()); OutputStream out = tmp.out(); try { xmlPersister.save(config, out); } finally { out.close(); } Resource configFile = getConfigRoot().get(GWC_CONFIG_FILE); tmp.renameTo(configFile); this.config = config; LOGGER.finer("Integrated GWC configuration saved to " + configFile.path()); }