[Geoserver-users] LayerGroup creation from REST Configruation

You don't need to specify the href, could be throwing stuff off, not sure, here is an xml example that i know works:

curl -XPOST -d '<layerGroup> <name>spearfish</name> <layers> <layer> <name>sfdem</name> </layer> <layer> <name>streams</name> </layer> <layer> <name>roads</name> </layer> <layer> <name>restricted</name> </layer> <layer> <name>archsites</name> </layer> <layer> <name>bugsites</name> </layer> </layers> </layerGroup>' -H 'Content-type: text/xml' http://localhost:8080/geoserver/rest/layergroups

Also, can you turn the logs up on your server to get the stack trace (GEOSERVER_DEVELOPER_LOGGING), not sure where the error is.

Patel, Ronak Avinash (US SSA) wrote:

Justin,

If that's so, I get an HTTP 500 from Geoserver 1.7.3 when I perform the
following HTTP query:

POST /geoserver/rest/layergroups HTTP/1.1
Authorization: Basic YWRtaW46Z2Vvc2VydmVy
Content-Type: application/json
User-Agent: Java/1.6.0_13
Host: localhost:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 1081

{"layerGroup":{"layers":{"layer":[{"enabled":"true","href":"http://local
host:8080/geoserver/rest/layers/Arc_Sample.json","name":"Arc_Sample"},{"
enabled":"true","href":"http://localhost:8080/geoserver/rest/layers/Arc_
Sample.json","name":"Arc_Sample"},{"enabled":"true","href":"http://local
host:8080/geoserver/rest/layers/Pk50095.json","name":"Pk50095"},{"enable
d":"true","href":"http://localhost:8080/geoserver/rest/layers/Pk50095.js
on","name":"Pk50095"},{"enabled":"true","href":"http://localhost:8080/ge
oserver/rest/layers/mosaic.json","name":"mosaic"},{"enabled":"true","hre
f":"http://localhost:8080/geoserver/rest/layers/sfdem.json&quot;,&quot;name&quot;:&quot;sfde
m"},{"enabled":"true","href":"http://localhost:8080/geoserver/rest/layer
s/Img_Sample.json","name":"Img_Sample"},{"enabled":"true","href":"http:/
/localhost:8080/geoserver/rest/layers/image_WGS84_1242678004681_1430.jso
n","name":"image_WGS84_1242678004681_1430"},{"enabled":"true","href":"ht
tp://localhost:8080/geoserver/rest/layers/image_WGS84_1242685755119_70.j
son","name":"image_WGS84_1242685755119_70"}]},"name":"ronak-test-group"}
}

HTTP/1.1 500 Internal Server Error
X-Powered-By: Servlet/2.5
Server: Sun GlassFish Enterprise Server v2.1
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Date: Thu, 11 Jun 2009 19:30:01 GMT
Connection: close

5
:null
0

From the Geoserver logs:

[#|2009-06-11T12:27:08.210-0700|INFO|sun-appserver2.1|javax.enterprise.s
ystem.stream.out|_ThreadID=21;_ThreadName=httpSSLWorkerThread-8080-4;|11
Jun 12:27:08 INFO [catalog.rest] - POST layer group ronak-test-group
|#]

[#|2009-06-11T12:27:08.210-0700|INFO|sun-appserver2.1|javax.enterprise.s
ystem.stream.out|_ThreadID=21;_ThreadName=httpSSLWorkerThread-8080-4;|11
Jun 12:27:08 ERROR [geoserver.rest] - :null
|#]

Do I smell yet another bug inside Geoserver??

-----Original Message-----
From: Justin Deoliveira [mailto:jdeolive@anonymised.com] Sent: Thursday, June 11, 2009 1:01 PM
To: Patel, Ronak Avinash (US SSA)
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: LayerGroup creation from REST Configruation

Hi Ronak,

You have found yet another hole in the docs. I will try to update when i

get a sec. But the quick answer is yes, only the name and the layers are

necessary when posting a layer group. The bounding box is the spatial extent of the layer group. You can specify a bounding box, but it is not

necessary, it will be calculated automatically if not specified. Usually

the only reason to specify it would be if perhaps one of the layers in the group is quite big and you want the group to be constrained to a smaller spatial extent. Like the tiger-ny layer group that comes with vanilla geoserver configuration.

The styles are optional, if you don't specify them then the default style for each layer will be used. If you do specify them, then you specify a style for each layer specified.

Hope that helps.

-Justin

Patel, Ronak Avinash (US SSA) wrote:

Justin,

I was looking at the LayerGroup REST API Documentation and I see that

it

has a POST API Document:

http://docs.geoserver.org/1.7.4/user/extensions/rest/rest-config-api.htm
l#id8

However, it does not list what are the required parameters for a POST for a LayerGroup.

I assume I have to pass the name and the list of Layers. Do I need to specify a bounding box? What is that the bounding box of? How can I compile that bounding box?

What are the Styles? Do I have to specify those as well?

Ronak

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