0

I have 300+ layers in my GeoServer layer library, I have just created a custom gridset I would like to use for all of my layers. I don't want to go through my whole library adding the gridset manually through the UI, so I have played around with the GeoServer rest API and I am able to modify layers with the following command:

curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d @ui_UI00000ENNR.xml  "http://localhost:8080/geoserver/gwc/rest/layers/ui:UI00000ENNR.xml"

And this is the contents of the ui_UI00000ENNR.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<GeoServerLayer>
  <id>LayerInfoImpl-288ccd00:163bb872e8d:-7ff6</id>
  <enabled>true</enabled>
  <inMemoryCached>true</inMemoryCached>
  <name>ui:UI00000ENNR</name>
  <mimeFormats>
    <string>image/png</string>
    <string>image/jpeg</string>
  </mimeFormats>
  <gridSubsets>
    <gridSubset>
      <gridSetName>EPSG:3857</gridSetName>
    </gridSubset>
    <gridSubset>
      <gridSetName>EPSG:4326</gridSetName>
    </gridSubset>
    <gridSubset>
      <gridSetName>EPSG:27700</gridSetName>
    </gridSubset>
    <gridSubset>
      <gridSetName>EPSG:900913</gridSetName>
    </gridSubset>
  </gridSubsets>
  <metaWidthHeight>
    <int>4</int>
    <int>4</int>
  </metaWidthHeight>
  <expireCache>0</expireCache>
  <expireClients>0</expireClients>
  <parameterFilters>
    <styleParameterFilter>
      <key>STYLES</key>
      <defaultValue></defaultValue>
    </styleParameterFilter>
  </parameterFilters>
  <gutter>0</gutter>
</GeoServerLayer>

My plan is to create a template xml file and then loop through my list of layers, populating the xml file and running the curl command for each layer. The only problem is I don't know the id for each layer, <id>LayerInfoImpl-288ccd00:163bb872e8d:-7ff6</id>, in the example above. Does anyone know how I could pull all layer names and there associated ids from GeoServer? Or is there a much quicker way of doing what I want to accomplish?

  • I think you can leave that ID out and GeoServer will auto populate it – Ian Turton Jun 1 '18 at 16:11
1

As Ian Turton said GeoServer autopopulates the ID and my method that I proposed worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.