[Geoserver-devel] [jira] (GEOS-5507) Can't assign workspace-specific style to a layer in the same workspace via REST

Landry Breuil created BugGEOS-5507
Can’t assign workspace-specific style to a layer in the same workspace via REST

Issue Type:

BugBug

Affects Versions:

2.2.2

Assignee:

Andrea Aime

Components:

REST

Created:

14/Dec/12 9:16 AM

Description:

Maybe linked to issue 5498, it seems not possible to assign a style to a layer via REST if the style is in a workspace and not global.

By default ‘polygon’ style is assigned to a polygon layer. If i try via rest to assign it ‘ZAC_style’, i get a code 200, but the modification is not done on the layer.

#curl -H"sec-username:breuil" http://localhost:8080/geoserver/rest/workspaces/public/styles/ZAC_style.xml

<style>
<name>ZAC_style</name>
<workspace>
<name>public</name>
</workspace>
<sldVersion>
<version>1.0.0</version>
</sldVersion>
<filename>ZAC.sld</filename>
</style>

#curl -H"sec-username:breuil" http://localhost:8080/geoserver/rest/layers/ZAC.xml
<layer>
<name>ZAC</name>
<type>VECTOR</type>
<defaultStyle>
<name>polygon</name>
<atom:link xmlns:atom=“http://www.w3.org/2005/Atom” rel=“alternate” href=“http://localhost:8080/geoserver/rest/styles/polygon.xml” type=“application/xml”/>
</defaultStyle>
<resource class=“featureType”>
<name>ZAC</name>
<atom:link xmlns:atom=“http://www.w3.org/2005/Atom” rel=“alternate” href=“http://localhost:8080/geoserver/rest/workspaces/public/datastores/ZAC/featuretypes/ZAC.xml” type=“application/xml”/>
</resource>
<enabled>true</enabled>
<advertised>true</advertised>
<queryable>true</queryable>
<attribution>
<logoWidth>0</logoWidth>
<logoHeight>0</logoHeight>
</attribution>

I’ve tried two things : modifiying the XML returned by a GET on the layer, sending the whole layer xml with only that part changed :

<defaultStyle>
<name>ZAC_style</name>
<atom:link xmlns:atom=“http://www.w3.org/2005/Atom” rel=“alternate” href=“http://localhost:8080/geoserver/rest/workspaces/public/styles/ZAC_style.xml” type=“application/xml”/>
</defaultStyle>

or with a small definition of the layer inlined in the curl command :

curl -v -u admin:admin -XPUT -H"Content-type: text/xml" -d ‘<layer><defaultStyle><name>ZAC_style</name></defaultStyle><enabled>true</enabled></layer>’ http://localhost:8080/geoserver/rest/layers/ZAC

It works (ie the layer definition is correctly modified) if i assign it a global style (be it the default ‘population’, or ‘polygon’ again). As soon as i try with a workspace-specific style, the modification is not applied.

Dunno if that’s an acl issue, but the ZAC_style style doesnt appear in rest/layers output. My users have access to that style with a GET.

#cat security/layers.properties
..r=*
public..r=
public.*.a=ROLE_AUTHENTICATED

#cat security/rest.properties
/rest//styles/;POST,DELETE,PUT=ROLE_AUTHENTICATED
/rest/**;GET=IS_AUTHENTICATED_ANONYMOUSLY,ROLE_AUTHENTICATED

Project:

GeoServer

Priority:

MajorMajor

Reporter:

Landry Breuil

This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your [JIRA administrators](https://jira.codehaus.org/secure/ContactAdministrators!default.jspa). For more information on JIRA, see: [http://www.atlassian.com/software/jira](http://www.atlassian.com/software/jira)