[GIS] GeoServer + dynamic datapath layer

geoservertime

My app based on Mapserver contains dynamic layers and using PHPMapscript I modify MAPFILE->LAYER->DATA value based on a parameter that comes via GET.
Or I could even use RegEXP in the LAYER->DATA (http://osdir.com/ml/mapserver-users-gis/2012-02/msg00208.html)

I know GeoServer has good REST support and most probably after my analysis this will be one of the reasons why I'm going to change.

Is it possible to define a GeoServer layer dynamically?
E.G.
I will create datastores for specific topics
Layers (shp or raster) are stored following the criteria:

/data/layers/topic1/2013/201305/Layer1.shp,
/data/layers/topic1/2013/201305/Layer2.shp,
/data/layers/topic2/2013/201305/Layer3.shp

/data/layers/raster/2013/201304/Raster1.{png,geotiff,},
/data/layers/raster/2013/201304/Raster2.{png,geotiff,
}

The layers change each month and absolutely I don't want to recreate them via GeoServer admin. Using OpenLayers I can pass a parameter mergeNewParams=YYYYMM and get the specific OWS out of the layer (WMS or WFS), but how?

Something like this when I define the datastore URL http://docs.geoserver.org/latest/en/user/webadmin/data/stores.html#adding-a-store in the connection URL I would like to specify file:/data//YYYY/YYYYMM/YYYYMMDDUTC
Is it possible?

Thanks!

Best Answer

Yes and No. :)

It's possible to create a datastore dynamically with REST, but not with parameters (I know of no method to do that). But, you can create a script, that use Geoserver REST interface to achieve the aim.

For REST in Geoserver, look the documentation: http://docs.geoserver.org/stable/en/user/rest/api/datastores.html

I recommend to you the "geoserver-manager" Java library, because it's easy way to achieve this funcionality. If you don't want to use Java, you can use "cURL" and follow this example: http://docs.geoserver.org/2.1.x/en/user/restconfig/rest-config-examples/rest-config-examples-curl.html

You can do a monthly task to publish the new datastore and publish the layer.