Package org.geoserver.catalog

Examples of org.geoserver.catalog.ResourceInfo


        this.policy = policy;
    }

    @Override
    public ResourceInfo getResource() {
        ResourceInfo r = super.getResource();
        if (r == null)
            return null;
        else if (r instanceof FeatureTypeInfo)
            return new SecuredFeatureTypeInfo((FeatureTypeInfo) r, policy);
        else if (r instanceof CoverageInfo)
            return new SecuredCoverageInfo((CoverageInfo) r, policy);
        else
            throw new RuntimeException("Don't know how to make resource of type " + r.getClass());
    }
View Full Code Here


        refForm.add(declaredCRS);

        projectionPolicy = new DropDownChoice("srsHandling", new PropertyModel(model,
                "projectionPolicy"), Arrays.asList(ProjectionPolicy.values()),
                new ProjectionPolicyRenderer());
        ResourceInfo ri = (ResourceInfo) model.getObject();
        if (((ResourceInfo) model.getObject()).getCRS() == null) {
            // no native, the only meaningful policy is to force
            ri.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
        }
        if (model.getObject() instanceof CoverageInfo) {
            // coverages projection policy choice is not allowed, if there is a native a
            // reprojection will occurr
            CoverageInfo ci = (CoverageInfo) model.getObject();
View Full Code Here

            @Override
            public void onSubmit(final AjaxRequestTarget target, Form form) {
                // perform manual processing otherwise the component contents won't be updated
                form.process();
                ResourceInfo resource = (ResourceInfo) BasicResourceConfig.this.getModelObject();
                try {
                    CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog());
                    ReferencedEnvelope bounds = cb.getNativeBounds(resource);
                    resource.setNativeBoundingBox(bounds);
                    nativeBBox.setModelObject(bounds);
                } catch(IOException e) {
                    LOGGER.log(Level.SEVERE, "Error computing the native BBOX", e);
                    error("Error computing the native BBOX:" + e.getMessage());
                }
View Full Code Here

        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);
View Full Code Here

        }

        validate(resource, true);
        resolve(resource);
        // resources.put(resource.getClass(), resource);
        ResourceInfo unwrappedResource = ModificationProxy.unwrap(resource);
        unwrappedResource.setNamespace(ModificationProxy.unwrap(unwrappedResource.getNamespace()));
        StoreInfo unwrappedStore = ModificationProxy.unwrap(resource.getStore());
        unwrappedResource.setStore(unwrappedStore);
        unwrappedStore.setWorkspace(ModificationProxy.unwrap(unwrappedStore.getWorkspace()));

        fixNativeName(unwrappedResource);

        catalogDAO.save(unwrappedResource);
View Full Code Here

        if (resource.getNamespace() == null) {
            throw new IllegalArgumentException("Resource must be part of a namespace");
        }

        StoreInfo store = resource.getStore();
        ResourceInfo existing = getResourceByStore(store, resource.getName(), ResourceInfo.class);
        if (existing != null && !existing.getId().equals(resource.getId())) {
            String msg = "Resource named '" + resource.getName() + "' already exists in store: '"
                    + store.getName() + "'";
            throw new IllegalArgumentException(msg);
        }

        NamespaceInfo namespace = resource.getNamespace();
        existing = getResourceByName(namespace, resource.getName(), ResourceInfo.class);
        if (existing != null && !existing.getId().equals(resource.getId())) {
            String msg = "Resource named '" + resource.getName()
                    + "' already exists in namespace: '" + namespace.getPrefix() + "'";
            throw new IllegalArgumentException(msg);
        }
View Full Code Here

        validate(resource, false);
        saved(resource);
    }

    public <T extends ResourceInfo> T getResource(String id, Class<T> clazz) {
        ResourceInfo resource = catalogDAO.getResource(id, clazz);
        if (resource == null)
            return null;
        else {
            resolve(resource);
            return createProxy((T) resource, clazz);
View Full Code Here

                namespace = getNamespaceByURI(ns);
            }
        }

        if (namespace != null) {
            ResourceInfo resource = catalogDAO.getResourceByName(namespace.getName(), name, clazz);
            if (resource != null) {
                resolve(resource);
            // return ModificationProxy.create( (T) resource, clazz );
                return createProxy((T) resource, (Class<T>) mapResourceClass(resource));
            }
        }

        // List l = lookup(clazz, resources);
        // if ( namespace != null ) {
        // for (Iterator i = l.iterator(); i.hasNext();) {
        // ResourceInfo resource = (ResourceInfo) i.next();
        // if (name.equals(resource.getName())) {
        // NamespaceInfo namespace1 = resource.getNamespace();
        // if (namespace1 != null && namespace1.equals( namespace )) {
        // return ModificationProxy.create( (T) resource, clazz );
        // }
        // }
        // }
        // }

        if (ns == null) {
            // no namespace was specified, so do an exhaustive lookup
            List<ResourceInfo> matches = (List<ResourceInfo>) catalogDAO.getResourcesByName(name,
                    clazz);
            // List matches = new ArrayList();
            // for (Iterator i = l.iterator(); i.hasNext();) {
            // ResourceInfo resource = (ResourceInfo) i.next();
            // if (name.equals(resource.getName())) {
            // matches.add( resource );
            // }
            // }

            if (matches.size() == 1) {
                ResourceInfo ret = matches.get(0);
                resolve(ret);
                return createProxy((T) ret, (Class<T>) mapResourceClass(ret));
                // return ModificationProxy.create( (T) matches.get( 0 ), clazz );
            }
        }
View Full Code Here

    public <T extends ResourceInfo> T getResourceByName(Name name, Class<T> clazz) {
        return getResourceByName(name.getNamespaceURI(), name.getLocalPart(), clazz);
    }

    public <T extends ResourceInfo> T getResourceByName(String name, Class<T> clazz) {
        ResourceInfo resource;

        // check is the name is a fully qualified one
        int colon = name.indexOf(':');
        if (colon != -1) {
            String ns = name.substring(0, colon);
View Full Code Here

    public <T extends ResourceInfo> T getResourceByStore(StoreInfo store, String name,
            Class<T> clazz) {

        store = ModificationProxy.unwrap(store);
        ResourceInfo resource = catalogDAO.getResourceByStore(store, name, clazz);
        if (resource == null)
            return null;
        else {
            resolve(resource);
            return createProxy((T) resource, (Class<T>) mapResourceClass(resource));
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.ResourceInfo

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.