I have a geoserver instance into which I want to add many styles. Specifically, they are styles from a different instance.
I realize that I could do this via the API but I thought it would be easier to just bulk copy the style files from one data_dir into the other.
I copied the style files into the new instance's workspace's styles folder, which has the path:
/opt/geoserver/data_dir/workspaces/lc2-workspace/styles
An example style's XML file looks like this:
<style>
<id>StyleInfoImpl--7d85fe9e:18bd86044f6:-61df</id>
<name>lc2-style-99-system_load_factor</name>
<workspace>
<id>WorkspaceInfoImpl--6761a99c:189e51b8074:-7ff6</id>
</workspace>
<format>sld</format>
<languageVersion>
<version>1.1.0</version>
</languageVersion>
<filename>lc2-style-99-system_load_factor.sld</filename>
<dateCreated>2023-11-16 14:27:47.940 UTC</dateCreated>
<dateModified>2023-11-16 14:27:47.955 UTC</dateModified>
</style>
(There is an associated .sld file for each of them)
And the workspace's workspace.xml file looks like this:
<workspace>
<id>WorkspaceInfoImpl--6761a99c:189e51b8074:-7ff6</id>
<name>lc2-workspace</name>
<isolated>false</isolated>
<dateCreated>2023-08-11 14:59:36.44 UTC</dateCreated>
</workspace>
But they simply do not appear in the "Styles" tab.
I have tried restarting the service (rather I stopped and started the docker compose service running it), and I also tried clicking on "Reload" for "Configuration and catalog" in the "Server Status" tab of the GUI, but they still do not show up in the "Styĺes" tab, and they return 404 when requested via a WMS request.
Am I just out of luck here and I have to do it via the API? It seems to me like you should be able to just bulk-copy between data dirs like this, as long as you have the tags right in the XML files.
Well they wouldn't! You need to tell GeoServer that you want to add a new style based on the SLD file either through the GUI or the REST interface. This then allows GeoServer to create the necessary XML files that it uses to store the configuration.