Пример #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());
      }
    }
  }
Пример #2
0
  /**
   * Adds a settings configuration to the test setup. If the settings object already exists it is
   * simply reverted to its original state.
   *
   * @param workspace The optional workspace for the settings, may be <code>null</code>
   * @param geoServer The GeoServer configuration object.
   */
  public void addSettings(String workspace, GeoServer geoServer) {
    WorkspaceInfo ws =
        workspace != null ? geoServer.getCatalog().getWorkspaceByName(workspace) : null;

    GeoServerInfo global = geoServer.getGlobal();
    SettingsInfo settings = ws != null ? geoServer.getSettings(ws) : global.getSettings();
    if (settings == null) {
      settings = geoServer.getFactory().createSettings();
    }
    settings.setWorkspace(ws);
    settings.getContact().setContactPerson("Andrea Aime");
    settings.setNumDecimals(8);
    settings.setOnlineResource("http://geoserver.org");
    settings.setVerbose(false);
    settings.setVerboseExceptions(false);
    settings.setLocalWorkspaceIncludesPrefix(false);

    if (ws != null) {
      if (settings.getId() != null) {
        geoServer.save(settings);
      } else {
        geoServer.add(settings);
      }
    } else {
      // global
      geoServer.save(global);
    }
  }