Пример #1
0
 @Override
 public void handlePostModifyEvent(CatalogPostModifyEvent event) throws CatalogException {
   if (event.getSource() instanceof StyleInfo) {
     // invalidate updated styles
     invalidateStyleSample((StyleInfo) event.getSource());
   }
 }
  /**
   * In case the event refers to the addition or removal of a {@link LayerInfo} or {@link
   * LayerGroupInfo} adds or removes the corresponding {@link GeoServerTileLayer} through {@link
   * GWC#createLayer}.
   *
   * <p>Note this method does not discriminate whether the change in the layer or layergroup
   * deserves a change in its matching TileLayer, it just re-creates the TileLayer
   *
   * @see
   *     org.geoserver.catalog.event.CatalogListener#handlePostModifyEvent(org.geoserver.catalog.event.CatalogPostModifyEvent)
   */
  public void handlePostModifyEvent(final CatalogPostModifyEvent event) throws CatalogException {
    final CatalogInfo source = event.getSource();
    if (!(source instanceof LayerInfo
        || source instanceof LayerGroupInfo
        || source instanceof FeatureTypeInfo
        || source instanceof CoverageInfo
        || source instanceof WMSLayerInfo)) {
      return;
    }

    final GeoServerTileLayerInfo tileLayerInfo = PRE_MODIFY_TILELAYER.get();
    PRE_MODIFY_TILELAYER.remove();

    final CatalogModifyEvent preModifyEvent = PRE_MODIFY_EVENT.get();
    PRE_MODIFY_EVENT.remove();

    if (tileLayerInfo == null) {
      return; // no tile layer assiociated, no need to continue
    }
    if (preModifyEvent == null) {
      throw new IllegalStateException(
          "PostModifyEvent called without having called handlePreModify first?");
    }

    final List<String> changedProperties = preModifyEvent.getPropertyNames();
    final List<Object> oldValues = preModifyEvent.getOldValues();
    final List<Object> newValues = preModifyEvent.getNewValues();

    log.finer("Handling modify event for " + source);
    if (source instanceof FeatureTypeInfo
        || source instanceof CoverageInfo
        || source instanceof WMSLayerInfo
        || source instanceof LayerGroupInfo) {
      /*
       * Handle the rename case. For LayerInfos it's actually the related ResourceInfo what
       * gets renamed, at least until the data/publish split is implemented in GeoServer. For
       * LayerGroupInfo it's either the group name itself or its workspace
       */
      if (changedProperties.contains("name")
          || changedProperties.contains("namespace")
          || changedProperties.contains("workspace")) {
        handleRename(tileLayerInfo, source, changedProperties, oldValues, newValues);
      }
    }

    if (source instanceof LayerInfo) {
      final LayerInfo li = (LayerInfo) source;

      handleLayerInfoChange(changedProperties, oldValues, newValues, li, tileLayerInfo);

    } else if (source instanceof LayerGroupInfo) {
      LayerGroupInfo lgInfo = (LayerGroupInfo) source;
      handleLayerGroupInfoChange(changedProperties, oldValues, newValues, lgInfo, tileLayerInfo);
    }
  }