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

Fix catalog facade's getStyleByName(String name) #264

Merged

Conversation

groldan
Copy link
Member

@groldan groldan commented Aug 18, 2022

RepositoryCatalogFacade.getStyleByName(String name) had a bug
that made it not match the behavior of upstream's
DefaultCatalogFacade.getStyleByName(String name).

As a consequence, GetLegendGraphic requests with JSON output format
produced kml icon urls with missing workspace path
(e.g. /kml/icon/<stylename>?... instead of
/kml/icon/<workspace>/<stylename>?..., when the GetLegendGraphic
request itself did not contain the workspace in the URLi and the
StyleInfo does belong to a workspace).

That said, the way JSONLegendGraphicBuilder.processGraphic(...)
resolves the icon URL is WRONG, as it uses the unqualified style
name to call Catalog.getStyleByName(String name), relying in
DefaultCatalogFacade.getStyleByName(String name), which will
look for a global style with that name, if none exists will look
for one in the "default workspace", and eventually for one in
any workspace, with no order guarantee. This is on itself a buggy
behaviour and only works by accident sometimes, but can easily
lead to returning a URL for a style named the same that belongs
to a different workspace than the layer for which the request
is being performed.

`RepositoryCatalogFacade.getStyleByName(String name)` had a bug
that made it not match the behavior of upstream's
`DefaultCatalogFacade.getStyleByName(String name)`.

As a consequence, `GetLegendGraphic` requests with JSON output format
produced kml icon urls with missing workspace path
(e.g. `/kml/icon/<stylename>?...` instead of
`/kml/icon/<workspace>/<stylename>?...`, when the GetLegendGraphic
request itself did not contain the workspace in the URLi and the
`StyleInfo` does belong to a workspace).

That said, the way `JSONLegendGraphicBuilder.processGraphic(...)`
resolves the icon URL is WRONG, as it uses the unqualified style
name to call `Catalog.getStyleByName(String name)`, relying in
`DefaultCatalogFacade.getStyleByName(String name)`, which will
look for a global style with that name, if none exists will look
for one in the "default workspace", and eventually for one in
any workspace, with no order guarantee. This is on itself a buggy
behaviour and only works by accident sometimes, but can easily
lead to returning a URL for a style named the same that belongs
to a different workspace than the layer for which the request
is being performed.
@groldan groldan added the bug Something isn't working label Aug 18, 2022
@groldan groldan merged commit 494f31d into geoserver:main Aug 18, 2022
@groldan groldan deleted the bug/kml_getlegendgraphics_workspace_link branch August 18, 2022 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant