LayerInfo layerInfo = layerModel.getObject();
GeoServerTileLayerInfo tileLayerInfo;
final GWC mediator = GWC.get();
final GWCConfig defaultSettings = mediator.getConfig();
final GeoServerTileLayer tileLayer = isNew ? null : mediator.getTileLayer(layerInfo);
if (isNew || tileLayer == null) {
/*
* Ensure a sane config for defaults, in case automatic cache of new layers is defined
* and the defaults is misconfigured
*/
final GWCConfig saneDefaults = defaultSettings.saneConfig();
tileLayerInfo = TileLayerInfoUtil.loadOrCreate(layerInfo, saneDefaults);
} else {
GeoServerTileLayerInfo info = ((GeoServerTileLayer) tileLayer).getInfo();
tileLayerInfo = info.clone();
}