org.geoserver.data.CatalogReader Maven / Gradle / Ivy
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, availible at the root
* application directory.
*/
package org.geoserver.data;
import org.geoserver.util.ReaderUtils;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Reads the GeoServer catalog.xml file.
*
* Usage:
*
*
*
* File catalog = new File( ".../catalog.xml" );
* CatalogReader reader = new CatalogReader();
* reader.read( catalog );
* List dataStores = reader.dataStores();
* LIst nameSpaces = reader.nameSpaces();
*
*
*
*
* @author Justin Deoliveira, The Open Planning Project, [email protected]
*
*/
public class CatalogReader {
/**
* Root catalog element.
*/
Element catalog;
/**
* Parses the catalog.xml file into a DOM.
*
* 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(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
catalog = ReaderUtils.parse(reader);
} finally {
reader.close();
}
}
/**
* Reads "datastore" elements from the catalog.xml file.
*
* For each datastore element read, a map of the connection parameters is
* created.
*
*
* @return A list of Map objects containg the datastore connection parameters.
*
* @throws Exception If error processing "datastores" element.
*/
public List /*