示例#1
0
  /**
   * This method is called only the first time the {@link GWCConfig} is initialized and is used to
   * maintain backwards compatibility with the old GWC defaults.
   */
  private void createDefaultTileLayerInfos(final GWCConfig defaultSettings) {
    checkArgument(defaultSettings.isSane());
    for (LayerInfo layer : rawCatalog.getLayers()) {
      if (!CatalogConfiguration.isLayerExposable(layer)) {
        continue;
      }
      try {
        GeoServerTileLayerInfo tileLayerInfo;
        tileLayerInfo = TileLayerInfoUtil.loadOrCreate(layer, defaultSettings);
        tileLayerCatalog.save(tileLayerInfo);
        MetadataMap metadata = layer.getMetadata();
        if (metadata.containsKey(LegacyTileLayerInfoLoader.CONFIG_KEY_ENABLED)) {
          LegacyTileLayerInfoLoader.clear(metadata);
          rawCatalog.save(layer);
        }
      } catch (RuntimeException e) {
        LOGGER.log(
            Level.WARNING,
            "Error occurred saving default GWC Tile Layer settings for Layer '"
                + layer.getName()
                + "'",
            e);
      }
    }

    for (LayerGroupInfo layer : rawCatalog.getLayerGroups()) {
      try {
        GeoServerTileLayerInfo tileLayerInfo;
        tileLayerInfo = TileLayerInfoUtil.loadOrCreate(layer, defaultSettings);
        tileLayerCatalog.save(tileLayerInfo);

        MetadataMap metadata = layer.getMetadata();
        if (metadata.containsKey(LegacyTileLayerInfoLoader.CONFIG_KEY_ENABLED)) {
          LegacyTileLayerInfoLoader.clear(metadata);
          rawCatalog.save(layer);
        }
      } catch (RuntimeException e) {
        LOGGER.log(
            Level.WARNING,
            "Error occurred saving default GWC Tile Layer settings for LayerGroup '"
                + tileLayerName(layer)
                + "'",
            e);
      }
    }
  }
示例#2
0
  /**
   * Migrates the configuration of geoserver tile layers from the Layer/GroupInfo metadata maps to
   * the {@link #tileLayerCatalog}
   */
  private void moveTileLayerInfosToTileLayerCatalog() {

    for (LayerInfo layer : rawCatalog.getLayers()) {
      if (!CatalogConfiguration.isLayerExposable(layer)) {
        continue;
      }
      try {
        GeoServerTileLayerInfo tileLayerInfo;
        tileLayerInfo = LegacyTileLayerInfoLoader.load(layer);
        if (tileLayerInfo != null) {
          tileLayerCatalog.save(tileLayerInfo);
          MetadataMap metadata = layer.getMetadata();
          LegacyTileLayerInfoLoader.clear(metadata);
          rawCatalog.save(layer);
        }
      } catch (RuntimeException e) {
        LOGGER.log(
            Level.WARNING,
            "Error migrating GWC Tile Layer settings for Layer '" + layer.getName() + "'",
            e);
      }
    }

    for (LayerGroupInfo layer : rawCatalog.getLayerGroups()) {
      try {
        GeoServerTileLayerInfo tileLayerInfo;
        tileLayerInfo = LegacyTileLayerInfoLoader.load(layer);
        if (tileLayerInfo != null) {
          tileLayerCatalog.save(tileLayerInfo);
          MetadataMap metadata = layer.getMetadata();
          LegacyTileLayerInfoLoader.clear(metadata);
          rawCatalog.save(layer);
        }
      } catch (RuntimeException e) {
        LOGGER.log(
            Level.WARNING,
            "Error occurred saving default GWC Tile Layer settings for LayerGroup '"
                + tileLayerName(layer)
                + "'",
            e);
      }
    }
  }