/** * Parses the info.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The info.xml file. * @throws IOException In event of a parser error. */ public void read(File file) throws IOException { parentDirectory = file.getParentFile(); Reader reader = XmlCharsetDetector.getCharsetAwareReader(new FileInputStream(file)); try { coverage = ReaderUtils.parse(reader); } finally { reader.close(); } }
/** * Parses the servivces.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The services.xml file. * @throws IOException In event of a parser error. */ public void read(File file) throws IOException { Reader reader = XmlCharsetDetector.getCharsetAwareReader(new FileInputStream(file)); try { serverConfiguration = ReaderUtils.parse(reader); global = null; contact = null; wfs = null; wms = null; wcs = null; } finally { reader.close(); } }
/** * Parses the catalog.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The catalog.xml file. * @throws IOException In event of a parser error. */ public void read(Resource file) throws IOException { Reader reader = XmlCharsetDetector.getCharsetAwareReader(file.in()); try { catalog = ReaderUtils.parse(reader); } finally { reader.close(); } }
/** * Parses the info.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The info.xml file. * @throws IOException In event of a parser error. */ public void read(Resource file) throws IOException { parentDirectory = file.parent(); Reader reader = XmlCharsetDetector.getCharsetAwareReader(file.in()); try { featureType = ReaderUtils.parse(reader); } finally { reader.close(); } }
@RunTestSetup @Test public void testGeoServerReload() throws Exception { Catalog cat = getCatalog(); FeatureTypeInfo lakes = cat.getFeatureTypeByName( MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart()); assertFalse("foo".equals(lakes.getTitle())); GeoServerDataDirectory dd = new GeoServerDataDirectory(getResourceLoader()); File info = dd.findResourceFile(lakes); // File info = getResourceLoader().find("featureTypes", "cite_Lakes", "info.xml"); FileReader in = new FileReader(info); Element dom = ReaderUtils.parse(in); Element title = ReaderUtils.getChildElement(dom, "title"); title.getFirstChild().setNodeValue("foo"); OutputStream output = new FileOutputStream(info); try { TransformerFactory.newInstance() .newTransformer() .transform(new DOMSource(dom), new StreamResult(output)); } finally { output.close(); } getGeoServer().reload(); lakes = cat.getFeatureTypeByName( MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart()); assertEquals("foo", lakes.getTitle()); }