final GWC mediator = GWC.get();
final IModel<String> createTileLayerLabelModel;
final CatalogInfo info = layerModel.getObject();
final GeoServerTileLayerInfo tileLayerInfo = tileLayerModel.getObject();
if (info instanceof LayerInfo) {
createTileLayerLabelModel = new ResourceModel("createTileLayerForLayer");
ResourceInfo resource = ((LayerInfo) info).getResource();
// we need the _current_ name, regardless of it's name is being changed
resource = ModificationProxy.unwrap(resource);
originalLayerName = resource.getPrefixedName();
} else if (info instanceof LayerGroupInfo) {
createTileLayerLabelModel = new ResourceModel("createTileLayerForLayerGroup");
// we need the _current_ name, regardless of if it's name is being changed
LayerGroupInfo lgi = ModificationProxy.unwrap((LayerGroupInfo) info);
originalLayerName = tileLayerName(lgi);
} else {
throw new IllegalArgumentException(
"Provided model does not target a LayerInfo nor a LayerGroupInfo: " + info);
}
TileLayer tileLayer = null;
if (originalLayerName != null) {
try {
tileLayer = mediator.getTileLayerByName(originalLayerName);
} catch (IllegalArgumentException notFound) {
//
}
}
cachedLayerExistedInitially = tileLayer != null;
// UI construction phase
add(confirmRemovalDialog = new GeoServerDialog("confirmRemovalDialog"));
confirmRemovalDialog.setInitialWidth(360);
confirmRemovalDialog.setInitialHeight(180);
add(new Label("createTileLayerLabel", createTileLayerLabelModel));
boolean doCreateTileLayer;
if (tileLayerInfo.getId() != null) {
doCreateTileLayer = true;
} else if (isNew() && mediator.getConfig().isCacheLayersByDefault()) {
doCreateTileLayer = true;
} else {
doCreateTileLayer = false;