예제 #1
0
  /**
   * Adds a service configuration to the test setup. If the service object already exists it is
   * simply reverted to its original state.
   *
   * @param serviceClass The class of the service
   * @param workspace The optional workspace for the service, may be <code>null</code>
   * @param geoServer The GeoServer configuration object.
   */
  public <T extends ServiceInfo> void addService(
      Class<T> serviceClass, String workspace, GeoServer geoServer) {

    Catalog catalog = geoServer.getCatalog();

    List<XStreamServiceLoader> loaders = GeoServerExtensions.extensions(XStreamServiceLoader.class);
    for (XStreamServiceLoader loader : loaders) {
      if (serviceClass.equals(loader.getServiceClass())) {
        // create a new one
        T created = (T) loader.create(geoServer);

        // grab the old one, if it exists
        T old = null;
        WorkspaceInfo ws = null;
        if (workspace != null) {
          ws = catalog.getWorkspaceByName(workspace);
          old = geoServer.getService(ws, serviceClass);
        } else {
          old = geoServer.getService(serviceClass);
        }

        if (old != null) {
          // update the old copy
          OwsUtils.copy(created, old, serviceClass);
          geoServer.save(old);
        } else {
          // add the new one
          created.setWorkspace(ws);
          geoServer.add(created);
        }

        break;
      }
    }
  }
예제 #2
0
 /** Creates a new WFSCapsTransformer object. */
 public Wcs10CapsTransformer(GeoServer geoServer) {
   super();
   this.geoServer = geoServer;
   this.wcs = geoServer.getService(WCSInfo.class);
   this.catalog = geoServer.getCatalog();
   setNamespaceDeclarationEnabled(false);
 }
  @Override
  protected void setUpInternal() throws Exception {
    // configure the GSS service
    GeoServer gs = getGeoServer();
    GSSInfo gssInfo = gs.getService(GSSInfo.class);
    gssInfo.setMode(GSSMode.Central);
    gssInfo.setVersioningDataStore(getCatalog().getDataStoreByName("synch"));
    gs.save(gssInfo);

    // initialize the GSS service
    Map gssBeans = applicationContext.getBeansOfType(DefaultGeoServerSynchronizationService.class);
    gss = (DefaultGeoServerSynchronizationService) gssBeans.values().iterator().next();
    gss.core.ensureCentralEnabled();

    // grab the synch manager
    synch =
        (SynchronizationManager)
            applicationContext
                .getBeansOfType(SynchronizationManager.class)
                .values()
                .iterator()
                .next();

    // disable automated scheduling, we control how does what here
    Timer timer = (Timer) applicationContext.getBean("gssTimerFactory");
    timer.cancel();

    // make some tables synchronised
    synchStore = (VersioningDataStore) getCatalog().getDataStoreByName("synch").getDataStore(null);
    FeatureStore<SimpleFeatureType, SimpleFeature> fs =
        (FeatureStore<SimpleFeatureType, SimpleFeature>) synchStore.getFeatureSource(SYNCH_TABLES);
    long restrectedId = addFeature(fs, "restricted", "2");
    long roadsId = addFeature(fs, "roads", "2");
    synchStore.setVersioned("restricted", true, null, null);
    synchStore.setVersioned("roads", true, null, null);

    // add some units
    fsUnits =
        (FeatureStore<SimpleFeatureType, SimpleFeature>) synchStore.getFeatureSource(SYNCH_UNITS);
    long mangoId =
        addFeature(
            fsUnits,
            "unit1",
            "http://localhost:8081/geoserver/ows",
            null,
            null,
            null,
            null,
            60,
            10,
            false);

    // link units and tables
    fsUnitTables =
        (FeatureStore<SimpleFeatureType, SimpleFeature>)
            synchStore.getFeatureSource(SYNCH_UNIT_TABLES);
    addFeature(fsUnitTables, mangoId, restrectedId, null, null, null, null);
    // addFeature(fsUnitTables, mangoId, roadsId, null, null, null, null);
  }
예제 #4
0
 /**
  * Before using {@code gwc-gs.xml} to hold the integrated GWC configuration, the only property
  * configured was whether the direct WMS integration option was enabled, and it was saved as part
  * of the {@link WMSInfo} metadata map under the {@code GWC_WMS_Integration} key. This method
  * removes that key from WMSInfo if present and sets its value to the {@code gwcConfig} instead.
  */
 private void upgradeWMSIntegrationConfig(final GeoServer geoServer, final GWCConfig gwcConfig)
     throws IOException {
   // Check whether we're using the old way of storing this information, and get rid of it
   WMSInfo service = geoServer.getService(WMSInfo.class);
   if (service != null) {
     MetadataMap metadata = service.getMetadata();
     if (service != null && metadata != null) {
       Boolean storedValue = metadata.get(WMS_INTEGRATION_ENABLED_KEY, Boolean.class);
       if (storedValue != null) {
         boolean enabled = storedValue.booleanValue();
         gwcConfig.setDirectWMSIntegrationEnabled(enabled);
         metadata.remove(WMS_INTEGRATION_ENABLED_KEY);
         geoServer.save(service);
       }
     }
   }
 }
예제 #5
0
 private void setOutputLimit(int kbytes) {
   GeoServer gs = getGeoServer();
   WCSInfo info = gs.getService(WCSInfo.class);
   info.setMaxOutputMemory(kbytes);
   gs.save(info);
 }
예제 #6
0
파일: WMS.java 프로젝트: roarbra/geoserver
 public WMSInfo getServiceInfo() {
   return geoserver.getService(WMSInfo.class);
 }