Package org.geoserver.catalog

Examples of org.geoserver.catalog.ResourceInfo


               
                // may have multiple type names in each query, so add them all
                for (QName name : queryType.getTypeNames()) {
                    // get a feature type name from the query
                    Name featureTypeName = new NameImpl(name.getNamespaceURI(), name.getLocalPart());
                    ResourceInfo meta = catalog.getResourceByName(featureTypeName, ResourceInfo.class);
                   
                    if (meta == null) {
                        throw new WFSException(request, "Could not find feature type " + featureTypeName
                                + " in the GeoServer catalog");
                    }
                   
                    // add it to the map
                    Set<ResourceInfo> metas = ns2metas.get(featureTypeName.getNamespaceURI());
                   
                    if (metas == null) {
                        metas = new HashSet<ResourceInfo>();
                        ns2metas.put(featureTypeName.getNamespaceURI(), metas);
                    }
                    metas.add(meta);
                }
            } else {
                FeatureType featureType = ((FeatureCollection) featureCollections.get(fcIndex)).getSchema();

                //load the metadata for the feature type
                String namespaceURI = featureType.getName().getNamespaceURI();
                FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName());
               
                if(meta == null)
                    throw new WFSException(request, "Could not find feature type " +
                        featureType.getName() + " in the GeoServer catalog");

                //add it to the map
                Set metas = (Set) ns2metas.get(namespaceURI);

                if (metas == null) {
                    metas = new HashSet();
                    ns2metas.put(namespaceURI, metas);
                }

                metas.add(meta);
            }
        }

        WFSInfo wfs = getInfo();
       
        //set feature bounding parameter
        //JD: this is quite bad as its not at all thread-safe, once we remove the configuration
        // as being a singleton on trunk/2.0.x this should not be an issue
        if ( wfs.isFeatureBounding() ) {
            configuration.getProperties().remove( GMLConfiguration.NO_FEATURE_BOUNDS );
        }
        else {
            configuration.getProperties().add( GMLConfiguration.NO_FEATURE_BOUNDS);
        }

        if (wfs.isCiteCompliant()) {
            //cite compliance forces us to forgo srsDimension attribute
            configuration.getProperties().add(GMLConfiguration.NO_SRS_DIMENSION);
        }
        else {
            configuration.getProperties().remove(GMLConfiguration.NO_SRS_DIMENSION);
        }

        //set up the srsname syntax
        configuration.setSrsSyntax(wfs.getGML().get(WFSInfo.Version.V_11).getSrsNameStyle().toSrsSyntax());

        /*
         * Set property encoding featureMemeber as opposed to featureMembers
         *
         */
        if (wfs.isEncodeFeatureMember()) {
            configuration.getProperties().add(GMLConfiguration.ENCODE_FEATURE_MEMBER);
        } else {
            configuration.getProperties().remove(GMLConfiguration.ENCODE_FEATURE_MEMBER);
        }
       
        //declare wfs schema location
        Object gft = getFeature.getParameters()[0];
       
        Encoder encoder = createEncoder(configuration, ns2metas, gft);
        encoder.setEncoding(Charset.forName( geoServer.getSettings().getCharset() ));

        if (wfs.isCanonicalSchemaLocation()) {
            encoder.setSchemaLocation(getWfsNamespace(), getCanonicalWfsSchemaLocation());
        } else {
            encoder.setSchemaLocation(getWfsNamespace(),
                    buildSchemaURL(request.getBaseURL(), getRelativeWfsSchemaLocation()));
        }

        //declare application schema namespaces
       
        Map<String, String> params = params("service", "WFS", "version", request.getVersion(),
                "request", "DescribeFeatureType");
        for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();

            String namespaceURI = (String) entry.getKey();
            Set metas = (Set) entry.getValue();

            StringBuffer typeNames = new StringBuffer();
            for (Iterator m = metas.iterator(); m.hasNext();) {
                ResourceInfo ri = (ResourceInfo) m.next();
                if(ri instanceof FeatureTypeInfo) {
                    FeatureTypeInfo meta = (FeatureTypeInfo) ri;
                    FeatureType featureType = meta.getFeatureType();
                    Object userSchemaLocation = featureType.getUserData().get("schemaURI");
                    if (userSchemaLocation != null && userSchemaLocation instanceof Map) {
View Full Code Here


        assertEquals(1, context.getTasks().size());
       
        importer.run(context);

        LayerInfo l = context.getTasks().get(0).getLayer();
        ResourceInfo r = l.getResource();
        assertTrue(r.getMetadata().containsKey("time"));

        DimensionInfo d = (DimensionInfo) r.getMetadata().get("time");
        assertNotNull(d);

        runChecks(l.getName());

        Document dom = getAsDOM(String.format("/%s/%s/wms?request=getcapabilities",
            r.getStore().getWorkspace().getName(), l.getName()));
        XMLAssert.assertXpathExists(
            "//wms:Layer[wms:Name = '" + m.getName() + "']/wms:Dimension[@name = 'time']", dom);
       
    }
View Full Code Here

        assertEquals(1, context.getTasks().size());

        importer.run(context);

        LayerInfo l = context.getTasks().get(0).getLayer();
        ResourceInfo r = l.getResource();
        assertTrue(r.getMetadata().containsKey("time"));

        DimensionInfo d = (DimensionInfo) r.getMetadata().get("time");
        assertNotNull(d);

        runChecks(l.getName());

        Document dom = getAsDOM(String.format("/%s/%s/wms?request=getcapabilities",
            r.getStore().getWorkspace().getName(), l.getName()));
        XMLAssert.assertXpathExists(
            "//wms:Layer[wms:Name = '" + m.getName() + "']/wms:Dimension[@name = 'time']", dom);
    }
View Full Code Here

            super(clazz);
        }
       
        public Object doUnmarshal(Object result,
                HierarchicalStreamReader reader, UnmarshallingContext context) {
            ResourceInfo obj = (ResourceInfo) super.doUnmarshal(result, reader, context);
           
            String enabled = obj.isEnabled() ? "enabled" : "disabled";
            String type = obj instanceof CoverageInfo ? "coverage" :
                obj instanceof FeatureTypeInfo ? "feature type" : "resource";
           
            log(Level.INFO, "Loaded " + type + " '" + obj.getName() + "', " + enabled);
            return obj;
        }
View Full Code Here

        return 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 if (r instanceof WMSLayerInfo)
            return new SecuredWMSLayerInfo((WMSLayerInfo) r, policy);
        else
            throw new RuntimeException("Don't know how to make resource of type " + r.getClass());
    }
View Full Code Here

        List<Object> elevations = wrapIntoList(elevation);

        // reuse the same logic as dimension selection to restrict the domain of possible values
        final Filter filter = wms.getTimeElevationToFilter(times, elevations, resource);

        ResourceInfo restrictedResource;
        if (filter != null && !Filter.INCLUDE.equals(filter)) {
            restrictedResource = new DecoratingFeatureTypeInfo(resource) {

                @Override
                public FeatureSource getFeatureSource(ProgressListener listener, Hints hints)
View Full Code Here

    }
   
    static void updateLayer(ImportTask orig, LayerInfo l, Importer importer) {
        //update the original layer and resource from the new

        ResourceInfo r = l.getResource();
       
        //TODO: this is not thread safe, clone the object before overwriting it
        //save the existing resource, which will be overwritten below, 
        ResourceInfo resource = orig.getLayer().getResource();

        if (r != null) {
            // we support the following resource info properties:
            // (don't just use blindly copy everything)
            if (r.getTitle() != null) {
                resource.setTitle(r.getTitle());
            }
            if (r.getAbstract() != null) {
                resource.setAbstract(r.getAbstract());
            }
            if (r.getDescription() != null) {
                resource.setDescription(r.getDescription());
            }
        }
       
        CatalogBuilder cb = new CatalogBuilder(importer.getCatalog());
        l.setResource(resource);
        // @hack workaround OWSUtils bug - trying to copy null collections
        // why these are null in the first place is a different question
        LayerInfoImpl impl = (LayerInfoImpl) orig.getLayer();
        if (impl.getAuthorityURLs() == null) {
            impl.setAuthorityURLs(new ArrayList(1));
        }
        if (impl.getIdentifiers() == null) {
            impl.setIdentifiers(new ArrayList(1));
        }
        // @endhack
        cb.updateLayer(orig.getLayer(), l);

        // validate SRS - an invalid one will destroy capabilities doc and make
        // the layer totally broken in UI
        CoordinateReferenceSystem newRefSystem = null;

        String srs = r != null ? r.getSRS() : null;
        if (srs != null) {
            try {
                newRefSystem = CRS.decode(srs);
            } catch (NoSuchAuthorityCodeException ex) {
                String msg = "Invalid SRS " + srs;
                LOGGER.warning(msg + " in PUT request");
                throw ImportJSONWriter.badRequest(msg);
            } catch (FactoryException ex) {
                throw new RestletException("Error with referencing",Status.SERVER_ERROR_INTERNAL,ex);
            }
            // make this the specified native if none exists
            // useful for csv or other files
            if (resource.getNativeCRS() == null) {
                resource.setNativeCRS(newRefSystem);
            }
            resource.setSRS(srs);
        }

    }
View Full Code Here

    }
   
    public <T extends ResourceInfo> T getResource(String id, Class<T> clazz) {
        List l = lookup(clazz, resources);
        for (Iterator i = l.iterator(); i.hasNext();) {
            ResourceInfo resource = (ResourceInfo) i.next();
            if (id.equals(resource.getId())) {
                return ModificationProxy.create((T) resource, clazz );
            }
        }

        return null;
View Full Code Here

       
        if (namespace == ANY_NAMESPACE) {
            //do an exhaustive lookup
            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 ) {
                return ModificationProxy.create( (T) matches.get( 0 ), clazz );
            }
        }
        else {
            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 );
                    }
                }
            }
View Full Code Here

        if ( namespace == null ) {
            namespace = getDefaultNamespace();
        }

        for (Iterator r = all.iterator(); r.hasNext();) {
            ResourceInfo resource = (ResourceInfo) r.next();
            if (namespace != null ) {
                if (namespace.equals(resource.getNamespace())) {
                    matches.add( resource );
                }
            }
            else if ( resource.getNamespace() == null ) {
                matches.add(resource);
            }
        }

        return ModificationProxy.createList( matches, clazz );
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.