GeoServer is an open source GIS server that propagates geospatially enabled information. Data is ingested as shapefiles, GeoTIFFs, geospatially enabled databases etc. and then displayed using Open Geospatial Consortium standards, namely WMS and WFS. This allows any software product that has a WMS/WFS ingest to accept these served layers, i.e. Google Earth, OpenLayers, ESRI products.
Many users have run into the issue of updating their GeoServer installation with new data programmatically. There is a partial module for a RESTful configuration, but has not been fully implemented. There is also an excellent code sample here that is the basis for this tutorial. However, with 1.6.0, and the new integrated security subsystem, the code no longer functions properly.
This tutorial will encompass getting the code to work again, as well as going through the process of adding a new GeoServer layer programmatically. This code can be used directly, or adapted to other GeoServer maintenance.
2. Add CoverageStore.
3. Add Coverage.
This will be done using Java, URL, and URLConnection. I have Java code that runs every fifteen minutes, it pulls satellite raster data (GeoTIFFs) from an outside source, and creates a new GeoServer layer from the new GeoTIFF.
This code can be done with two functions, login() and geoserverAction(String address). Both functions are similar, with the login function catching a cookie which will be put in a global variable, and used during each of the following actions.
Public global variables: geoserverurl, cookieString, geoserverusername, and geoserverpassword.
Just like in the tutorial from Geoserver, no problem. All println calls have been removed, and cookieString is a global variable that will be accessed by the next function. A cleaner implementation might involve actual passing of the cookie, but this will suffice for tutorial-purposes.
The above function is the “meat” of this code task. From any passed in address, we will be able to fully control GeoServer. The only thing left is to find what addresses are passed around using Firefox’s “Live HTTP headers”.
The above code will complete our task. Making the url string for coverageEditorSubmit was highly unweildy, so I made a helper function: coverageSubmitBuilder(), and it can be viewed here.
Any task in GeoServer. Using “Live HTTP headers” and stepping through each task manually will give us the information needed to have full and automatic control of GeoServer.