@Override
  public void encode(Translator tx, WMSInfo wms, GetCapabilitiesRequest request)
      throws IOException {
    Version requestVersion = WMS.version(request.getVersion());
    // if this is not a wms 1.3.0 request
    if (!WMS.VERSION_1_3_0.equals(requestVersion)) {
      return;
    }
    MetadataMap serviceMetadata = wms.getMetadata();
    Boolean createExtendedCapabilities =
        serviceMetadata.get(CREATE_EXTENDED_CAPABILITIES.key, Boolean.class);
    String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key);
    // Don't create extended capabilities element if mandatory content not present
    // or turned off
    if (metadataURL == null || createExtendedCapabilities != null && !createExtendedCapabilities) {
      return;
    }
    String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key);
    String language = (String) serviceMetadata.get(LANGUAGE.key);

    // IGN : INSPIRE SCENARIO 1
    tx.start("inspire_vs:ExtendedCapabilities");
    tx.start("inspire_common:MetadataUrl");
    tx.start("inspire_common:URL");
    tx.chars(metadataURL);
    tx.end("inspire_common:URL");
    if (mediaType != null) {
      tx.start("inspire_common:MediaType");
      tx.chars(mediaType);
      tx.end("inspire_common:MediaType");
    }
    tx.end("inspire_common:MetadataUrl");
    tx.start("inspire_common:SupportedLanguages");
    language = language != null ? language : "eng";
    tx.start("inspire_common:DefaultLanguage");
    tx.start("inspire_common:Language");
    tx.chars(language);
    tx.end("inspire_common:Language");
    tx.end("inspire_common:DefaultLanguage");
    tx.end("inspire_common:SupportedLanguages");
    tx.start("inspire_common:ResponseLanguage");
    tx.start("inspire_common:Language");
    tx.chars(language);
    tx.end("inspire_common:Language");
    tx.end("inspire_common:ResponseLanguage");
    tx.end("inspire_vs:ExtendedCapabilities");
  }
  /**
   * @see
   *     org.geoserver.wms.ExtendedCapabilitiesProvider#encode(org.geoserver.wms.ExtendedCapabilitiesProvider.Translator,
   *     org.geoserver.wms.WMSInfo, org.geotools.util.Version)
   */
  public void encode(final Translator tx, final WMSInfo wms, final GetCapabilitiesRequest request)
      throws IOException {
    Version version = WMS.version(request.getVersion(), true);
    if (!WMS.VERSION_1_1_1.equals(version) || !isTiled(request)) {
      return;
    }

    String namespacePrefixFilter = request.getNamespace();
    Iterable<TileLayer> tileLayers = gwc.getTileLayersByNamespacePrefix(namespacePrefixFilter);

    for (TileLayer layer : tileLayers) {

      Set<String> layerGrids = layer.getGridSubsets();

      for (String gridId : layerGrids) {
        GridSubset grid = layer.getGridSubset(gridId);
        for (MimeType mime : layer.getMimeTypes()) {
          vendorSpecificTileset(tx, layer, grid, mime.getFormat());
        }
      }
    }
  }