Publishing Layers Advanced - simboss/geoserver-manager GitHub Wiki
The basic methods only allow you to define a restricted set of parameters:
e.g.: {{{public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, String srs, String defaultStyle);}}}
What if you need to define some more parameters?
Take a look to the method: `public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder, GSLayerEncoder layerEncoder)`
Here you need to define an instance of GSCoverageEncoder. This class allows you to specify some more parameters than the ones defined in the basic GeoServerRESTPublisher methods. As for the other encoders/decoders, we only have implemented the parameters we found useful in our use cases.
final GSCoverageEncoder encoder=new GSImageMosaicEncoder(); //add a name to the coverage encoder.setName("coverageName"); encoder.setSRS(srs); encoder.addKeyword("KEYWORD_1"); encoder.addKeyword("KEYWORD_2"); encoder.addKeyword("..."); encoder.addKeyword("KEYWORD_N"); //add an active (true) dimension final GSDimensionInfoEncoder dim=new GSDimensionInfoEncoder(true); //add presentation dimension dim.setPresentation( Presentation.CONTINUOUS_INTERVAL); //add dimension to the coverage as time encoder.setMetadata("time", dim); final GSDimensionInfoEncoder dim2=new GSDimensionInfoEncoder(true); dim2.setPresentation( Presentation.LIST); encoder.setMetadata("elevation", dim2); encoder.setLatLonBoundingBox(minx, miny, maxx, maxy, crs); GSResourceEncoder coverageEncoder = new GSCoverageEncoder(); GSLayerEncoder layerEncoder = new GSLayerEncoder(); layerEncoder.setDefaultStyle(defaultStyle); publishExternalMosaic(workspace, storeName, mosaicDir, encoder, layerEncoder);
Change default style
Next lines are an example how to change the default style for a layer:
String layerName = ...; String newStyleName = ...; GeoServerRESTPublisher publisher = ...; GSLayerEncoder le = new GSLayerEncoder(); le.setDefaultStyle(newStyleName); publisher.configureLayer(le, layerName);