Package org.geoserver.catalog

Examples of org.geoserver.catalog.Catalog


        });

        add(new AjaxLink("clear.resourceCache") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                Catalog cat = getCatalog();
                try {
                    cat.getResourcePool().dispose();
                    info(getLocalizer().getString("resourceCacheClearedSuccessfully", this));
                }
                catch( Exception e ) {
                    error(e);
                }
View Full Code Here


     * @param coverageFactoryName
     *            the {@link Format#getName() name} of the format to create a new raster coverage
     *            for
     */
    public CoverageStoreNewPage(final String coverageFactoryName) {
        Catalog catalog = getCatalog();
        final WorkspaceInfo workspace = catalog.getDefaultWorkspace();
        CoverageStoreInfo store = catalog.getFactory().createCoverageStore();
        store.setWorkspace(workspace);
        store.setType(coverageFactoryName);
        store.setEnabled(true);
        store.setURL("file:data/example.extension");

View Full Code Here

        initUI(store);
    }

    @Override
    protected void onSave(final CoverageStoreInfo info, AjaxRequestTarget target) throws IllegalArgumentException {
        final Catalog catalog = getCatalog();

        /*
         * Try saving a copy of it so if the process fails somehow the original "info" does not end
         * up with an id set
         */
        CoverageStoreInfo savedStore = catalog.getFactory().createCoverageStore();
        clone(info, savedStore);

        // GR: this shouldn't fail, the Catalog.save(StoreInfo) API does not declare any action in
        // case
        // of a failure!... strange, why a save can't fail?
        // Still, be cautious and wrap it in a try/catch block so the page does not blow up
        try {
            catalog.save(savedStore);
        } catch (RuntimeException e) {
            LOGGER.log(Level.INFO, "Adding the store for " + info.getURL(), e);
            throw new IllegalArgumentException(
                    "The coverage store could not be saved. Failure message: " + e.getMessage());
        }

        // the StoreInfo save succeeded... try to present the list of coverages (well, _the_
        // coverage while the getotools coverage api does not allow for more than one
        NewLayerPage layerChooserPage;
        try {
            layerChooserPage = new NewLayerPage(savedStore.getId());
        } catch (RuntimeException e) {
            LOGGER.log(Level.INFO, "Getting list of coverages for saved store " + info.getURL(), e);
            // doh, can't present the list of coverages, means saving the StoreInfo is meaningless.
            try {// be extra cautious
                catalog.remove(savedStore);
            } catch (RuntimeErrorException shouldNotHappen) {
                LOGGER.log(Level.WARNING, "Can't remove CoverageStoreInfo after adding it!", e);
            }
            // tell the caller why we failed...
            throw new IllegalArgumentException(e.getMessage(), e);
View Full Code Here

            this.id = store.getId();
        }

        @Override
        protected Object load() {
            Catalog catalog = GeoServerApplication.get().getCatalog();
            StoreInfo storeInfo = catalog.getStore(id, StoreInfo.class);
            return storeInfo;
        }
View Full Code Here

     *
     * @param storeId
     *            the store id
     */
    public CoverageStoreEditPage(final String storeId) throws IllegalArgumentException {
        Catalog catalog = getCatalog();
        CoverageStoreInfo store = catalog.getCoverageStore(storeId);
        if (store == null) {
            throw new IllegalArgumentException("Cannot find coverage store " + storeId);
        }

        initUI(store);
View Full Code Here

        if (null == info.getType()) {
            throw new IllegalArgumentException("Coverage type has not been set");
        }

        final Catalog catalog = getCatalog();
        final ResourcePool resourcePool = catalog.getResourcePool();
        resourcePool.clear(info);

        // Map<String, Serializable> connectionParameters = info.getConnectionParameters();

        if (info.isEnabled()) {
View Full Code Here

        });
    }

    private void doSaveStore(final CoverageStoreInfo info) {
        try {
            Catalog catalog = getCatalog();

            final String prefix = info.getWorkspace().getName();
            final NamespaceInfo namespace = catalog.getNamespaceByPrefix(prefix);

            List<CoverageInfo> alreadyConfigured;
            alreadyConfigured = catalog.getResourcesByStore(info, CoverageInfo.class);

            for (CoverageInfo coverage : alreadyConfigured) {
                coverage.setNamespace(namespace);
            }

            ResourcePool resourcePool = catalog.getResourcePool();
            resourcePool.clear(info);
            catalog.save(info);

            for (CoverageInfo coverage : alreadyConfigured) {
                catalog.save(coverage);
            }
            LOGGER.finer("Saved store " + info.getName());
        } catch (RuntimeException e) {
            LOGGER.log(Level.WARNING, "Saving the store for " + info.getURL(), e);
            throw new IllegalArgumentException("Unable to save the store: " + e.getMessage());
View Full Code Here

    @Override
    protected void onSubmit() {
        LayerGroupInfo lg = (LayerGroupInfo) lgModel.getObject();

        Catalog catalog = getCatalog();
        try {
            catalog.add(lg);

            lg = catalog.getLayerGroup(lg.getId());
            setResponsePage(LayerGroupPage.class);
        } catch (Exception e) {
            error(e);
            LOGGER.log(Level.WARNING, "Error creating new layer group.", e);
        }
View Full Code Here

    private SubmitLink saveLink() {
        return new SubmitLink("save") {
            @Override
            public void onSubmit() {
                try {
                    Catalog catalog = getCatalog();
                    ResourceInfo resourceInfo = getResourceInfo();
                    if (isNew) {
                      ReferencedEnvelope bounds;
            // updating grid if is a coverage
                      if(resourceInfo instanceof CoverageInfo) {
                            // the coverage bounds computation path is a bit more linear, the
                            // readers always return the bounds and in the proper CRS (afaik)
                            CoverageInfo cinfo = (CoverageInfo) resourceInfo;
                            AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) cinfo.getGridCoverageReader(null, null);
                            bounds = new ReferencedEnvelope(reader.getOriginalEnvelope());
                            // apply the bounds, taking into account the reprojection policy if need be
                            if (resourceInfo.getProjectionPolicy() == ProjectionPolicy.REPROJECT_TO_DECLARED && bounds != null) {
                                try {
                                    bounds = bounds.transform(resourceInfo.getCRS(), true);
                                    GridGeometry grid = ((CoverageInfo) resourceInfo).getGrid();
                                    ((CoverageInfo) resourceInfo).setGrid(new GridGeometry2D(grid.getGridRange(),grid.getGridToCRS(), resourceInfo.getCRS()));
                                } catch(Exception e) {
                                    throw (IOException) new IOException("transform error").initCause(e);
                                }
                            }
                        }
                     
                        catalog.add(resourceInfo);
                        try {
                            catalog.add(getLayerInfo());
                        } catch (IllegalArgumentException e) {
                            catalog.remove(resourceInfo);
                            throw e;
                        }
                    } else {
                        ResourceInfo oldState = catalog.getResource(resourceInfo.getId(), ResourceInfo.class);
                        catalog.save(resourceInfo);
                        try {
                            catalog.save(getLayerInfo());
                        } catch (IllegalArgumentException e) {
                            catalog.save(oldState);
                            throw e;
                        }
                    }
                    onSuccessfulSave();
                } catch (Exception e) {
View Full Code Here

            // code at the moment is in KML3VectorTransfomer
        }

        protected String getFeatureTypeURL() throws IOException {
            GeoServer gs = mapContext.getRequest().getWMS().getGeoServer();
            Catalog catalog = gs.getCatalog();
            String nsUri = mapLayer.getFeatureSource().getSchema().getName().getNamespaceURI();
            NamespaceInfo ns = catalog.getNamespaceByURI(nsUri);
            String featureTypeName = mapLayer.getFeatureSource().getSchema()
                    .getName().getLocalPart();
            GetMapRequest request = mapContext.getRequest();

            return buildURL(baseURL(request.getHttpServletRequest()),
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.Catalog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.