예제 #1
0
  public void onPostLoad(PostLoadEvent event) {
    if (!active) return;

    Object entity = event.getEntity();

    if (entity instanceof StoreInfoImpl) {
      ((StoreInfoImpl) entity).setCatalog(catalog);
    } else if (entity instanceof ResourceInfoImpl) {
      ((ResourceInfoImpl) entity).setCatalog(catalog);
    } else if (entity instanceof StyleInfoImpl) {
      ((StyleInfoImpl) entity).setCatalog(catalog);
    } else if (entity instanceof LayerGroupInfoImpl) {
      // hack to get around default styles being represented by null
      // TODO: see if we can coax the hibernate mappings into doing this for us
      LayerGroupInfoImpl lg = (LayerGroupInfoImpl) entity;
      if (lg.getStyles().isEmpty()) {
        for (LayerInfo l : lg.getLayers()) {
          lg.getStyles().add(null);
        }
      }
    } else if (entity instanceof ServiceInfoImpl) {
      ((ServiceInfoImpl) entity).setGeoServer(geoServer);
    } else if (entity instanceof GeoServerInfoImpl) {
      // contact is mapped as a component... and hibernate assumes that all null values
      // means a null object... i don't think this is configurable but coudl be wrong
      GeoServerInfoImpl global = (GeoServerInfoImpl) entity;
      if (global.getContact() == null) {
        global.setContact(geoServer.getFactory().createContact());
      }
    }
  }
  public void testLoadLayerGroup() {
    LayerGroupInfoImpl lg = mockGroup("tesGroup", mockLayer("L1"), mockLayer("L2"));

    assertNull(LegacyTileLayerInfoLoader.load(lg));
    GeoServerTileLayerInfo info = defaultVectorInfo;
    info.getMimeFormats().clear();
    info.getMimeFormats().addAll(defaults.getDefaultOtherCacheFormats());

    LegacyTileLayerInfoLoader.save(info, lg.getMetadata());

    GeoServerTileLayerInfo actual;
    actual = LegacyTileLayerInfoLoader.load(lg);

    info.setId(lg.getId());
    info.setName(GWC.tileLayerName(lg));
    assertEquals(info, actual);
  }