[Geoserver-users] write catalog.xml

hi everybody,
I am using geoserver1.7.3,I want to write some params to catalog.xml by geoserver api.
my code:
String datastoreId=“geo”;
Map<String, String> map=new HashMap<String, String>();
//map.put(“spatial index”, “true”);
map.put(“namespace”, “http://www.openplans.org/topp”);
//map.put(“memory mapped buffer”, “true”);
map.put(“url”, “file:data/g/geo.shp”);
map.put(“charset”, “ISO-8859-1”);

Map<String, Map> datastore=new HashMap<String, Map>();
datastore.put(datastoreId, map);
Map<String,String> namespace=new HashMap<String,String>();
namespace.put(datastoreId, “topp”);

CatalogWriter cw=new CatalogWriter();
cw.dataStores(datastore, namespace);
File catalog = new File(“C:\Program File\Apache Software Foundation\Tomcat 5.5\webapps \geoserver\data\catalog.xml”);
cw.write(catalog);

but after running,result is
java.io.IOException: Could not write catalog to C:\Program File\Apache Software Foundation\Tomcat 5.5\webapps\geoserver\data\catalog.xml

where is wrong? what should i do?

thank you
jack


网易邮箱,中国第一大电子邮件服务商

Hi Jack,

Have you considered using the REST api for this? It is the recommended way to programatically
add data, in this case upload and auto-configure a shapefile.

Here are some docs:

http://gridlock.openplans.org/geoserver/1.7.x/doc/user/extensions/rest/

That said, could there be a permissions issue with that directory. Does the user running the program
have write access?

-Justin

liuyunhuali wrote:

hi everybody,
     I am using geoserver1.7.3,I want to write some params to catalog.xml by geoserver api.
     my code:
               String datastoreId="geo";
                Map<String, String> map=new HashMap<String, String>();
                //map.put("spatial index", "true");
                map.put("namespace", "http://www.openplans.org/topp&quot;\);
                //map.put("memory mapped buffer", "true");
                map.put("url", "file:data/g/geo.shp");
                map.put("charset", "ISO-8859-1");

                Map<String, Map> datastore=new HashMap<String, Map>();
                datastore.put(datastoreId, map);
                Map<String,String> namespace=new HashMap<String,String>();
                namespace.put(datastoreId, "topp");
                               CatalogWriter cw=new CatalogWriter();
                cw.dataStores(datastore, namespace);
                File catalog = new File("C:\\Program File\\Apache Software Foundation\\Tomcat 5.5\\webapps \\geoserver\\data\\catalog.xml");
                cw.write(catalog);

            but after running,result is
             java.io.IOException: Could not write catalog to C:\Program File\Apache Software Foundation\Tomcat 5.5\webapps\geoserver\data\catalog.xml
              where is wrong? what should i do?

thank you
jack
    
------------------------------------------------------------------------
ÍøÒ×ÓÊÏ䣬ÖйúµÚÒ»´óµç×ÓÓʼþ·þÎñÉÌ <http://email.163.com>

------------------------------------------------------------------------

------------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.