@BeforeClass
  public static void setUpData() throws Exception {
    MonitorDAO dao = new MemoryMonitorDAO();
    new MonitorTestData(dao).setup();

    MonitorConfig mc =
        new MonitorConfig() {

          @Override
          public MonitorDAO createDAO() {
            MonitorDAO dao = new MemoryMonitorDAO();
            try {
              new MonitorTestData(dao).setup();
              return dao;
            } catch (java.text.ParseException e) {
              throw new RuntimeException(e);
            }
          }

          @Override
          public BboxMode getBboxMode() {
            return BboxMode.FULL;
          }
        };

    GeoServer gs = createMock(GeoServer.class);
    monitor = new Monitor(mc);
    monitor.setServer(gs);

    catalog = new CatalogImpl();

    expect(gs.getCatalog()).andStubReturn(catalog);
    replay(gs);

    NamespaceInfo ns = catalog.getFactory().createNamespace();
    ns.setPrefix("acme");
    ns.setURI("http://acme.org");
    catalog.add(ns);
    DataStoreInfo ds = catalog.getFactory().createDataStore();
    FeatureTypeInfo ftFoo = catalog.getFactory().createFeatureType();
    ftFoo.setName("foo");
    ftFoo.setSRS("EPSG:4326");
    ftFoo.setNamespace(ns);
    ftFoo.setStore(ds);
    catalog.add(ftFoo);
    FeatureTypeInfo ftBar = catalog.getFactory().createFeatureType();
    ftBar.setName("bar");
    ftBar.setSRS("EPSG:3348");
    ftBar.setNamespace(ns);
    ftBar.setStore(ds);
    catalog.add(ftBar);
  }
Пример #2
0
  void createCssTemplate(String name) {
    try {
      Catalog catalog = getCatalog();
      if (catalog.getStyleByName(name) == null) {
        StyleInfo style = catalog.getFactory().createStyle();
        style.setName(name);
        style.setFilename(name + ".sld");
        catalog.add(style);

        File sld = findStyleFile(style.getFilename());
        if (sld == null || !sld.exists()) {
          catalog
              .getResourcePool()
              .writeStyle(
                  style, new ByteArrayInputStream(cssText2sldText(defaultStyle).getBytes()));
        }

        File css = findStyleFile(name + ".css");
        if (!css.exists()) {
          FileWriter writer = new FileWriter(css);
          writer.write(defaultStyle);
          writer.close();
        }
      }
    } catch (IOException ioe) {
      throw new WicketRuntimeException(ioe);
    }
  }
  void setupExtras(org.geoserver.data.test.SystemTestData testData, Catalog catalog)
      throws IOException {
    // associate Lakes to Buildings as an extra style
    LayerInfo buildings = catalog.getLayerByName(getLayerId(BUILDINGS));
    buildings.getStyles().add(catalog.getStyleByName(LAKES.getLocalPart()));
    catalog.save(buildings);

    // add a layer group
    CatalogFactory factory = catalog.getFactory();
    LayerGroupInfo globalGroup = factory.createLayerGroup();
    globalGroup.setName(LAKES_GROUP);
    globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(LAKES)));
    globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(FORESTS)));
    globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(BRIDGES)));
    catalog.add(globalGroup);

    // add a layer group containing a layer group
    LayerGroupInfo nestGroup = factory.createLayerGroup();
    nestGroup.setName(NEST_GROUP);
    nestGroup.getLayers().add(catalog.getLayerByName(getLayerId(LAKES)));
    nestGroup.getLayers().add(globalGroup);
    catalog.add(nestGroup);

    // add a workspace specific style
    WorkspaceInfo ws = catalog.getWorkspaceByName(CITE_PREFIX);
    testData.addStyle(ws, WS_STYLE, "Streams.sld", SystemTestData.class, catalog);
  };
  private void configureGeogigDataStore() throws Exception {

    helper.insertAndAdd(helper.lines1);
    helper.getGeogig().command(CommitOp.class).call();

    Catalog catalog = getCatalog();
    CatalogFactory factory = catalog.getFactory();
    NamespaceInfo ns = factory.createNamespace();
    ns.setPrefix(WORKSPACE);
    ns.setURI(NAMESPACE);
    catalog.add(ns);
    WorkspaceInfo ws = factory.createWorkspace();
    ws.setName(ns.getName());
    catalog.add(ws);

    DataStoreInfo ds = factory.createDataStore();
    ds.setEnabled(true);
    ds.setDescription("Test Geogig DataStore");
    ds.setName(STORE);
    ds.setType(GeoGigDataStoreFactory.DISPLAY_NAME);
    ds.setWorkspace(ws);
    Map<String, Serializable> connParams = ds.getConnectionParameters();

    Optional<URI> geogigDir = helper.getGeogig().command(ResolveGeogigURI.class).call();
    File repositoryUrl = new File(geogigDir.get()).getParentFile();
    assertTrue(repositoryUrl.exists() && repositoryUrl.isDirectory());

    connParams.put(GeoGigDataStoreFactory.REPOSITORY.key, repositoryUrl);
    connParams.put(GeoGigDataStoreFactory.DEFAULT_NAMESPACE.key, ns.getURI());
    catalog.add(ds);

    DataStoreInfo dsInfo = catalog.getDataStoreByName(WORKSPACE, STORE);
    assertNotNull(dsInfo);
    assertEquals(GeoGigDataStoreFactory.DISPLAY_NAME, dsInfo.getType());
    DataAccess<? extends FeatureType, ? extends Feature> dataStore = dsInfo.getDataStore(null);
    assertNotNull(dataStore);
    assertTrue(dataStore instanceof GeoGigDataStore);

    FeatureTypeInfo fti = factory.createFeatureType();
    fti.setNamespace(ns);
    fti.setCatalog(catalog);
    fti.setStore(dsInfo);
    fti.setSRS("EPSG:4326");
    fti.setName("Lines");
    fti.setAdvertised(true);
    fti.setEnabled(true);
    fti.setCqlFilter("INCLUDE");
    fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
    ReferencedEnvelope bounds = new ReferencedEnvelope(-180, 180, -90, 90, CRS.decode("EPSG:4326"));
    fti.setNativeBoundingBox(bounds);
    fti.setLatLonBoundingBox(bounds);
    catalog.add(fti);

    fti = catalog.getFeatureType(fti.getId());

    FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
    featureSource = fti.getFeatureSource(null, null);
    assertNotNull(featureSource);
  }
Пример #5
0
  /**
   * Adds a workspace to the test setup.
   *
   * @param name The name of the workspace.
   * @param uri The namespace uri associated with the workspace.
   */
  public void addWorkspace(String name, String uri, Catalog catalog) {

    WorkspaceInfo ws = catalog.getWorkspaceByName(name);
    if (ws == null) {
      ws = catalog.getFactory().createWorkspace();
      ws.setName(name);
      catalog.add(ws);
    }

    NamespaceInfo ns = catalog.getNamespaceByPrefix(name);
    if (ns == null) {
      ns = catalog.getFactory().createNamespace();
      ns.setPrefix(name);
      ns.setURI(uri);
      catalog.add(ns);
    } else {
      ns.setURI(uri);
      catalog.save(ns);
    }
  }
Пример #6
0
  /** Copies a well known style out to the data directory and adds a catalog entry for it. */
  void initializeStyle(Catalog catalog, String styleName, String sld) throws IOException {

    // copy the file out to the data directory if necessary
    if (resourceLoader.find("styles", sld) == null) {
      FileUtils.copyURLToFile(
          GeoServerLoader.class.getResource(sld),
          new File(resourceLoader.findOrCreateDirectory("styles"), sld));
    }

    // create a style for it
    StyleInfo s = catalog.getFactory().createStyle();
    s.setName(styleName);
    s.setFilename(sld);
    catalog.add(s);
  }
  void addLayerGroups(SystemTestData testData) throws Exception {
    // setup basic layergroups
    testData.addStyle("Accident3_2", getClass(), this.catalog);

    CoordinateReferenceSystem nativeCrs = CRS.decode("EPSG:4326", true);
    ReferencedEnvelope nativeBounds = new ReferencedEnvelope(-180, 180, -90, 90, nativeCrs);

    LayerGroupInfo layerGroup1 = catalog.getFactory().createLayerGroup();
    layerGroup1.setName("testLayerGroup1");
    layerGroup1.setBounds(nativeBounds);

    LayerGroupInfo layerGroup2 = catalog.getFactory().createLayerGroup();
    layerGroup2.setName("testLayerGroup2");
    layerGroup2.setBounds(nativeBounds);

    LayerGroupInfo layerGroup3 = catalog.getFactory().createLayerGroup();
    layerGroup3.setName("testLayerGroup3");
    layerGroup3.setBounds(nativeBounds);

    // add layers & styles
    layerGroup1.getLayers().add(catalog.getLayerByName(getLayerId(REGIONATED)));
    layerGroup1.getStyles().add(null);
    layerGroup1.getLayers().add(catalog.getLayerByName(getLayerId(ACCIDENT3)));
    layerGroup1.getStyles().add(catalog.getStyleByName("Accident3_2"));

    layerGroup2.getLayers().add(catalog.getLayerByName(getLayerId(REGIONATED)));
    layerGroup2.getLayers().add(catalog.getLayerByName(getLayerId(ACCIDENT)));
    layerGroup2.getLayers().add(catalog.getLayerByName(getLayerId(ACCIDENT2)));

    layerGroup3.getLayers().add(layerGroup2);
    layerGroup3.getLayers().add(catalog.getLayerByName(getLayerId(ACCIDENT3)));

    catalog.add(layerGroup1);
    catalog.add(layerGroup2);
    catalog.add(layerGroup3);
  }
  @Override
  protected void setUpInternal(SystemTestData data) throws Exception {
    // run all the tests against a store that can do native paging (h2) and one that
    // can't (property)
    Catalog cat = getCatalog();
    DataStoreInfo ds = cat.getFactory().createDataStore();
    ds.setName("foo");
    ds.setWorkspace(cat.getDefaultWorkspace());

    Map params = ds.getConnectionParameters();
    params.put("dbtype", "h2");
    params.put("database", getTestData().getDataDirectoryRoot().getAbsolutePath());
    cat.add(ds);

    FeatureSource fs1 = getFeatureSource(SystemTestData.FIFTEEN);
    FeatureSource fs2 = getFeatureSource(SystemTestData.SEVEN);

    DataStore store = (DataStore) ds.getDataStore(null);
    SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();

    tb.init((SimpleFeatureType) fs1.getSchema());
    tb.add("num", Integer.class);
    tb.remove("boundedBy");
    store.createSchema(tb.buildFeatureType());

    tb.init((SimpleFeatureType) fs2.getSchema());
    tb.add("num", Integer.class);
    tb.remove("boundedBy");
    store.createSchema(tb.buildFeatureType());

    CatalogBuilder cb = new CatalogBuilder(cat);
    cb.setStore(ds);

    FeatureStore fs = (FeatureStore) store.getFeatureSource("Fifteen");
    addFeatures(fs, fs1.getFeatures());

    FeatureTypeInfo ft = cb.buildFeatureType(fs);
    cat.add(ft);

    fs = (FeatureStore) store.getFeatureSource("Seven");
    addFeatures(fs, fs2.getFeatures());

    ft = cb.buildFeatureType(fs);
    cat.add(ft);
  }
Пример #9
0
  @Override
  protected void setUpInternal() throws Exception {
    super.setUpInternal();

    Catalog cat = getCatalog();

    store = cat.getFactory().createDataStore();
    store.setWorkspace(cat.getDefaultWorkspace());
    store.setName("spearfish");
    store.setType("H2");

    Map params = new HashMap();
    params.put("database", getTestData().getDataDirectoryRoot().getPath() + "/spearfish");
    params.put("dbtype", "h2");
    store.getConnectionParameters().putAll(params);
    store.setEnabled(true);
    cat.add(store);
  }
Пример #10
0
  /**
   * Adds a style to the test setup.
   *
   * <p>To set up the style a file named <tt>filename</tt> is copied from the classpath relative to
   * the <tt>scope</tt> parameter.
   *
   * @param name The name of the style.
   * @param filename The filename to copy from classpath.
   * @param scope Class from which to load sld resource from.
   */
  public void addStyle(String name, String filename, Class scope, Catalog catalog)
      throws IOException {
    File styles = catalog.getResourceLoader().findOrCreateDirectory(data, "styles");

    catalog.getResourceLoader().copyFromClassPath(filename, new File(styles, filename), scope);

    StyleInfo style = catalog.getStyleByName(name);
    if (style == null) {
      style = catalog.getFactory().createStyle();
      style.setName(name);
    }
    style.setFilename(filename);
    if (style.getId() == null) {
      catalog.add(style);
    } else {
      catalog.save(style);
    }
  }
Пример #11
0
  @Test
  public void testMetadataLink() throws Exception {
    Catalog catalog = getCatalog();
    CoverageInfo ci = catalog.getCoverageByName(getLayerId(TASMANIA_DEM));
    MetadataLinkInfo ml = catalog.getFactory().createMetadataLink();
    ml.setContent("http://www.geoserver.org/tasmania/dem.xml");
    ml.setAbout("http://www.geoserver.org");
    ci.getMetadataLinks().add(ml);
    catalog.save(ci);

    Document dom = getAsDOM("wcs?request=GetCapabilities");
    // print(dom);
    checkValidationErrors(dom, WCS11_SCHEMA);
    String xpathBase =
        "//wcs:CoverageSummary[wcs:Identifier = '"
            + TASMANIA_DEM.getLocalPart()
            + "']/ows:Metadata";
    assertXpathEvaluatesTo("http://www.geoserver.org", xpathBase + "/@about", dom);
    assertXpathEvaluatesTo("simple", xpathBase + "/@xlink:type", dom);
    assertXpathEvaluatesTo(
        "http://www.geoserver.org/tasmania/dem.xml", xpathBase + "/@xlink:href", dom);
  }
Пример #12
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  @RequestMapping(value = "/{wsName}/{name}", method = RequestMethod.POST)
  public @ResponseBody JSONObj create(
      @PathVariable String wsName,
      @PathVariable String name,
      @RequestBody JSONObj obj,
      HttpServletRequest req)
      throws IOException {
    Catalog cat = geoServer.getCatalog();
    CatalogFactory factory = cat.getFactory();

    WorkspaceInfo workspace = findWorkspace(wsName);
    StoreInfo store = null;

    JSONObj params = obj.object("connection");
    if (params == null) {
      throw new IllegalArgumentException("connection parameters required");
    }
    if (params.has("raster")) {
      String url = params.str("raster");
      CoverageStoreInfo info = factory.createCoverageStore();
      info.setWorkspace(workspace);
      info.setType(name);

      // connect and defaults
      info.setURL(url);
      info.setType(obj.str("type"));
      try {
        GridCoverageReader reader = info.getGridCoverageReader(null, null);
        Format format = reader.getFormat();
        info.setDescription(format.getDescription());
        info.setEnabled(true);
      } catch (IOException e) {
        info.setError(e);
        info.setEnabled(false);
      }
      store = info;
    } else if (params.has("url")
        && params.str("url").toLowerCase().contains("Service=WMS")
        && params.str("url").startsWith("http")) {
      WMSStoreInfo info = factory.createWebMapServer();
      info.setWorkspace(workspace);
      info.setType(name);

      // connect and defaults
      info.setCapabilitiesURL(params.str("url"));
      try {
        WebMapServer service = info.getWebMapServer(new NullProgressListener());
        info.setDescription(service.getInfo().getDescription());
        info.setEnabled(true);
      } catch (Throwable e) {
        info.setError(e);
        info.setEnabled(false);
      }
      store = info;
    } else {
      HashMap map = new HashMap(params.raw());
      Map resolved = ResourcePool.getParams(map, cat.getResourceLoader());
      DataAccess dataStore = DataAccessFinder.getDataStore(resolved);
      if (dataStore == null) {
        throw new IllegalArgumentException(
            "Connection parameters incomplete (does not match an available data store, coverage store or wms store).");
      }
      DataStoreInfo info = factory.createDataStore();
      info.setWorkspace(workspace);
      info.setType(name);
      info.getConnectionParameters().putAll(map);
      try {
        info.setDescription(dataStore.getInfo().getDescription());
        info.setEnabled(true);
      } catch (Throwable e) {
        info.setError(e);
        info.setEnabled(false);
      }
      store = info;
    }
    boolean refresh = define(store, obj);
    if (refresh) {
      LOG.log(
          Level.FINE, "Inconsistent: default connection used for store creation required refresh");
    }
    cat.add(store);

    return storeDetails(new JSONObj(), store, req);
  }
Пример #13
0
  /**
   * Adds a raster layer to the setup.
   *
   * <p>This method configures a raster layer with the name <code>qName.getLocalPart()</code>. A
   * coverage store is created (if it doesn't already exist) with the same name. The workspace of
   * the resulting store and layer is determined by <code>qName.getPrefix()</code>.
   *
   * <p>The <tt>filename</tt> parameter defines the raster file to be loaded from the classpath and
   * copied into the data directory. The <tt>scope</tt> is used as the class from which to load the
   * file from.
   *
   * <p>In the case of adding a zipped archive that contains multiple file the <tt>filename</tt>
   * paramter should have a ".zip" extension and the <tt>extension</tt> parameter must define the
   * extension of the main raster file. The parameter is not necessary and may be null if the
   * <tt>filename</tt> does not refer to a zip file.
   *
   * <p>The <tt>props</tt> parameter is used to define custom properties for the layer. See the
   * {@link LayerProperty} class for supported properties.
   *
   * @param qName The name of the raster layer.
   * @param filename The name of the file containing the raster, to be loaded from the classpath.
   * @param extension The file extension (without a ".") of the main raster file. This parameter my
   *     be <code>null</code> only if <tt>filename</tt> does not refer to a zip file.
   * @param props Custom properties to assign to the created raster layer.
   * @param scope The class from which to load the <tt>filename</tt> resource from.
   */
  public void addRasterLayer(
      QName qName,
      String filename,
      String extension,
      Map<LayerProperty, Object> props,
      Class scope,
      Catalog catalog)
      throws IOException {

    String prefix = qName.getPrefix();
    String name = qName.getLocalPart();

    // setup the data
    File dir = new File(data, name);
    dir.mkdirs();

    File file = new File(dir, filename);
    catalog.getResourceLoader().copyFromClassPath(filename, file, scope);

    String ext = FilenameUtils.getExtension(filename);
    if ("zip".equalsIgnoreCase(ext)) {

      // unpack the archive
      IOUtils.decompress(file, dir);

      // delete archive
      file.delete();

      if (extension == null) {
        // zip with no extension, we just the directory as the file
        file = dir;
      } else {
        // files may have been top level, or one directory level deep
        file = new File(dir, FilenameUtils.getBaseName(filename) + "." + extension);
        if (!file.exists()) {
          File file2 = new File(new File(dir, dir.getName()), file.getName());
          if (file2.exists()) {
            file = file2;
          }
        }
      }

      if (!file.exists()) {
        throw new FileNotFoundException(file.getPath());
      }
    }

    // load the format/reader
    AbstractGridFormat format = (AbstractGridFormat) GridFormatFinder.findFormat(file);
    if (format == null) {
      throw new RuntimeException("No format for " + file.getCanonicalPath());
    }
    AbstractGridCoverage2DReader reader = null;
    try {
      reader = (AbstractGridCoverage2DReader) format.getReader(file);
      if (reader == null) {
        throw new RuntimeException(
            "No reader for " + file.getCanonicalPath() + " with format " + format.getName());
      }

      // configure workspace if it doesn;t already exist
      if (catalog.getWorkspaceByName(prefix) == null) {
        addWorkspace(prefix, qName.getNamespaceURI(), catalog);
      }
      // create the store
      CoverageStoreInfo store = catalog.getCoverageStoreByName(prefix, name);
      if (store == null) {
        store = catalog.getFactory().createCoverageStore();
      }

      store.setName(name);
      store.setWorkspace(catalog.getWorkspaceByName(prefix));
      store.setEnabled(true);
      store.setURL(DataUtilities.fileToURL(file).toString());
      store.setType(format.getName());

      if (store.getId() == null) {
        catalog.add(store);
      } else {
        catalog.save(store);
      }

      // create the coverage
      CatalogBuilder builder = new CatalogBuilder(catalog);
      builder.setStore(store);

      CoverageInfo coverage = null;

      try {

        coverage = builder.buildCoverage(reader, null);
        // coverage read params
        if (format instanceof ImageMosaicFormat) {
          //  make sure we work in immediate mode
          coverage
              .getParameters()
              .put(AbstractGridFormat.USE_JAI_IMAGEREAD.getName().getCode(), Boolean.FALSE);
        }
      } catch (Exception e) {
        throw new IOException(e);
      }

      coverage.setName(name);
      coverage.setTitle(name);
      coverage.setDescription(name);
      coverage.setEnabled(true);

      CoverageInfo cov = catalog.getCoverageByCoverageStore(store, name);
      if (cov == null) {
        catalog.add(coverage);
      } else {
        builder.updateCoverage(cov, coverage);
        catalog.save(cov);
        coverage = cov;
      }

      LayerInfo layer = catalog.getLayerByName(new NameImpl(qName));
      if (layer == null) {
        layer = catalog.getFactory().createLayer();
      }
      layer.setResource(coverage);

      layer.setDefaultStyle(
          catalog.getStyleByName(LayerProperty.STYLE.get(props, DEFAULT_RASTER_STYLE)));
      layer.setType(LayerInfo.Type.RASTER);
      layer.setEnabled(true);

      if (layer.getId() == null) {
        catalog.add(layer);
      } else {
        catalog.save(layer);
      }
    } finally {
      if (reader != null) {
        reader.dispose();
      }
    }
  }
Пример #14
0
  /**
   * Adds a vector layer to the catalog setup.
   *
   * <p>The layer is created within a store named <code>qName.getPrefix()</code>, creating it if it
   * does not exist. The resulting store is a {@link PropertyDataStore} that points at the directory
   * <code>getDataDirectoryRoot()/qName.getPrefix()</code>. Similarily the layer and store are
   * created within a workspace named <code>qName.getPrefix()</code>, which is created if it does
   * not already exist.
   *
   * <p>The properties data for the layer is copied from the classpath, with a file name of "<code>
   * filename</code>.properties". The <tt>scope</tt> parameter is used as the class from which to
   * load the properties file relative to.
   *
   * <p>The <tt>props</tt> parameter is used to define custom properties for the layer. See the
   * {@link LayerProperty} class for supported properties.
   */
  public void addVectorLayer(
      QName qName, Map<LayerProperty, Object> props, String filename, Class scope, Catalog catalog)
      throws IOException {
    String prefix = qName.getPrefix();
    String name = qName.getLocalPart();
    String uri = qName.getNamespaceURI();

    // configure workspace if it doesn;t already exist
    if (catalog.getWorkspaceByName(prefix) == null) {
      addWorkspace(prefix, uri, catalog);
    }

    // configure store if it doesn't already exist

    File storeDir = catalog.getResourceLoader().findOrCreateDirectory(prefix);

    DataStoreInfo store = catalog.getDataStoreByName(prefix);
    if (store == null) {
      store = catalog.getFactory().createDataStore();
      store.setName(prefix);
      store.setWorkspace(catalog.getWorkspaceByName(prefix));
      store.setEnabled(true);

      store.getConnectionParameters().put(PropertyDataStoreFactory.DIRECTORY.key, storeDir);
      store.getConnectionParameters().put(PropertyDataStoreFactory.NAMESPACE.key, uri);
      catalog.add(store);
    }

    // copy the properties file over

    catalog.getResourceLoader().copyFromClassPath(filename, new File(storeDir, filename), scope);

    // configure feature type
    FeatureTypeInfo featureType = catalog.getFactory().createFeatureType();
    featureType.setStore(store);
    featureType.setNamespace(catalog.getNamespaceByPrefix(prefix));
    featureType.setName(LayerProperty.NAME.get(props, name));
    featureType.setNativeName(FilenameUtils.getBaseName(filename));
    featureType.setTitle(name);
    featureType.setAbstract("abstract about " + name);

    Integer srs = LayerProperty.SRS.get(props, SRS.get(qName));
    if (srs == null) {
      srs = 4326;
    }
    featureType.setSRS("EPSG:" + srs);
    try {
      featureType.setNativeCRS(CRS.decode("EPSG:" + srs));
    } catch (Exception e) {
      LOGGER.warning("Failed to decode EPSG:" + srs + ", setting the native SRS to null");
    }
    featureType.setNumDecimals(8);
    featureType.getKeywords().add(new Keyword(name));
    featureType.setEnabled(true);
    featureType.setProjectionPolicy(
        LayerProperty.PROJECTION_POLICY.get(props, ProjectionPolicy.NONE));
    featureType.setLatLonBoundingBox(
        LayerProperty.LATLON_ENVELOPE.get(props, DEFAULT_LATLON_ENVELOPE));
    featureType.setNativeBoundingBox(LayerProperty.ENVELOPE.get(props, null));

    FeatureTypeInfo ft = catalog.getFeatureTypeByDataStore(store, name);
    LayerInfo layer = catalog.getLayerByName(new NameImpl(prefix, name));
    if (ft == null) {
      ft = featureType;
      catalog.add(featureType);
    } else {
      if (layer == null) {
        // handles the case of layer removed, but feature type not
        catalog.remove(ft);
        ft = featureType;
        catalog.add(featureType);
      } else {
        new CatalogBuilder(catalog).updateFeatureType(ft, featureType);
        catalog.save(ft);
      }
    }

    if (layer == null
        || !layer.getResource().getNamespace().equals(catalog.getNamespaceByPrefix(prefix))) {
      layer = catalog.getFactory().createLayer();
    }

    layer.setResource(ft);

    StyleInfo defaultStyle = null;
    if (LayerProperty.STYLE.get(props, null) != null) {
      defaultStyle = catalog.getStyleByName(LayerProperty.STYLE.get(props, null));
    } else {
      // look for a style matching the layer name
      defaultStyle = catalog.getStyleByName(name);
      if (defaultStyle == null) {
        // see if the resource exists and we just need to create it
        if (getClass().getResource(name + ".sld") != null) {
          addStyle(name, catalog);
          defaultStyle = catalog.getStyleByName(name);
        }
      }
    }

    if (defaultStyle == null) {
      defaultStyle = catalog.getStyleByName(DEFAULT_VECTOR_STYLE);
    }

    layer.getStyles().clear();
    layer.setDefaultStyle(defaultStyle);
    layer.setType(LayerInfo.Type.VECTOR);
    layer.setEnabled(true);

    if (layer.getId() == null) {
      catalog.add(layer);
    } else {
      catalog.save(layer);
    }
  }