Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overwrite=True does not update SLD version when re-uploading a style #38

Open
fvicent opened this issue Jul 13, 2023 · 0 comments
Open

Comments

@fvicent
Copy link

fvicent commented Jul 13, 2023

Describe the bug

You are able to update the content of an existing style by using Catalog.create_style() with overwrite=True, but you can't change the style version (e.g. from 1.0 to 1.1). If the existing style is 1.0 and the new content is 1.1, GeoServer tries to fix the format and completely breaks the XML.

To Reproduce

After a fresh GeoNode installation run the following script:

from geoserver.catalog import Catalog
from pathlib import Path
import time

catalog = Catalog("http://localhost/geoserver/rest")
catalog.create_style(
    "test_style",
    Path("sld10.xml").read_text("utf8"),
    style_format="sld10"
)
time.sleep(10)
catalog.create_style(
    "test_style",
    Path("sld11.xml").read_text("utf8"),
    style_format="sld11",
    overwrite=True
)

sld10.xml:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>test_layer.shp</Name>
    <UserStyle>
      <Name>test_style</Name>
      <FeatureTypeStyle>
        <Rule>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#e3e3e3</CssParameter>
            </Stroke>
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

sld11.xml:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <se:Name>test_layer.shp</se:Name>
    <UserStyle>
      <se:Name>test_style</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#e3e3e3</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

You will note the style version is still 1.0:

geoserver-styles

But the content was replaced and reverted to 1.0, and now is broken:

geoserver-style-content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant