public void truncate(final String layerName, final String styleName, final String gridSetName,
final BoundingBox bounds, final String format) {
checkNotNull(layerName, "layerName can't be null");
final TileLayer layer = getTileLayerByName(layerName);
final Set<String> styleNames;
final Set<String> gridSetIds;
final List<MimeType> mimeTypes;
if (styleName == null) {
styleNames = getCachedStyles(layerName);
if (styleNames.size() == 0) {
styleNames.add("");
}
} else {
styleNames = Collections.singleton(styleName);
}
if (gridSetName == null) {
gridSetIds = layer.getGridSubsets();
} else {
gridSetIds = Collections.singleton(gridSetName);
}
if (format == null) {
mimeTypes = layer.getMimeTypes();
} else {
try {
mimeTypes = Collections.singletonList(MimeType.createFromFormat(format));
} catch (MimeException e) {
throw new RuntimeException();
}
}
final String defaultStyle = layer.getStyles();
for (String gridSetId : gridSetIds) {
GridSubset gridSubset = layer.getGridSubset(gridSetId);
if (gridSubset == null) {
// layer may no longer have this gridsubset, but we want to truncate any remaining
// tiles
GridSet gridSet = gridSetBroker.get(gridSetId);
gridSubset = GridSubsetFactory.createGridSubSet(gridSet);