Package org.geoserver.catalog

Examples of org.geoserver.catalog.MetadataLinkInfo


   
    @Test
    public void testMetadataLinks() throws Exception {
        FeatureTypeInfo mpolys = getCatalog().getFeatureTypeByName(getLayerId(MockTestData.MPOLYGONS));
        // a valid link whose metadata type needs tweaking
        MetadataLinkInfo ml1 = getCatalog().getFactory().createMetadataLink();
        ml1.setMetadataType("ISO19115:2003");
        ml1.setType("text/html");
        ml1.setContent("http://www.geoserver.org");
        mpolys.getMetadataLinks().add(ml1);
        // a valid one
        MetadataLinkInfo ml2 = getCatalog().getFactory().createMetadataLink();
        ml2.setMetadataType("FGDC");
        ml2.setType("text/html");
        ml2.setContent("http://www.geoserver.org");
        mpolys.getMetadataLinks().add(ml2);
        // an invalid one, not a valid type
        MetadataLinkInfo ml3 = getCatalog().getFactory().createMetadataLink();
        ml3.setMetadataType("other");
        ml3.setType("text/html");
        ml3.setContent("http://www.geoserver.org");
        mpolys.getMetadataLinks().add(ml3);
        // an invalid one, not a valid format
        MetadataLinkInfo ml4 = getCatalog().getFactory().createMetadataLink();
        ml4.setMetadataType("FGDC");
        ml4.setType("application/zip");
        ml4.setContent("http://www.geoserver.org");
        mpolys.getMetadataLinks().add(ml4);
        getCatalog().save(mpolys);
       
        Document doc = getAsDOM("wfs?service=WFS&version=1.1.0&request=getCapabilities");
        // print(doc);
View Full Code Here


        service.setTitle( (String) properties.get( "title") );
        service.setAbstract( (String) properties.get( "abstract") );
       
        Map metadataLink = (Map) properties.get("metadataLink");
        if ( metadataLink != null ) {
            MetadataLinkInfo ml = gs.getCatalog().getFactory().createMetadataLink();
            ml.setAbout( (String) metadataLink.get( "about" ) );
            ml.setMetadataType( (String) metadataLink.get( "metadataType" ) );
            ml.setType( (String) metadataLink.get( "type" ) );
            service.setMetadataLink( ml );
        }
       
        List<String> keywords = (List<String>) properties.get( "keywords" );
        if ( keywords != null ) {
View Full Code Here

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

    @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=DescribeCoverage&service=WCS&version=1.1.1&identifiers="
                + TASMANIA_DEM.getLocalPart());
View Full Code Here

    }
   
    @Test
    public void testMetadataLinks() throws Exception {
        FeatureTypeInfo mpolys = getCatalog().getFeatureTypeByName(getLayerId(MockTestData.MPOLYGONS));
        MetadataLinkInfo ml = getCatalog().getFactory().createMetadataLink();
        ml.setMetadataType("FGDC");
        ml.setType("text/html");
        ml.setContent("http://www.geoserver.org");
        mpolys.getMetadataLinks().add(ml);
        getCatalog().save(mpolys);
       
        Document doc = getAsDOM("wfs?service=WFS&version=2.0.0&request=getCapabilities");
        // print(doc);
View Full Code Here

    }

    @Test
    public void testProxyMetadataURL() throws Exception {
        createAppContext("http://foo.org/geoserver");
        MetadataLinkInfo link = new MetadataLinkInfoImpl();
        link.setContent("http://bar.com/geoserver/metadata.xml?foo=bar");

        String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/gesoserver");
        assertEquals(link.getContent(), url);
    }
View Full Code Here

    }

    @Test
    public void testProxyMetadataURLBackReference() throws Exception {
        createAppContext("http://foo.org/geoserver");
        MetadataLinkInfo link = new MetadataLinkInfoImpl();
        link.setContent("/metadata.xml?foo=bar");

        String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/gesoserver");
        assertEquals("http://foo.org/geoserver/metadata.xml?foo=bar", url);
    }
View Full Code Here

    }

    @Test
    public void testProxyMetadataURLBackReferenceNoProxyBaseUrl() throws Exception {
        createAppContext(null);
        MetadataLinkInfo link = new MetadataLinkInfoImpl();
        link.setContent("/metadata.xml?foo=bar");

        String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/geoserver");
        assertEquals("http://localhost/geoserver/metadata.xml?foo=bar", url);
    }
View Full Code Here

    @Test
    public void testModifyMetadataLinks() {
        addFeatureType();
       
        FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName());
        MetadataLinkInfo ml = catalog.getFactory().createMetadataLink();
        ml.setContent("http://www.geoserver.org/meta");
        ml.setType("text/plain");
        ml.setMetadataType("iso");
        ft2.getMetadataLinks().clear();
        ft2.getMetadataLinks().add(ml);
        catalog.save(ft2);
       
        FeatureTypeInfo ft3 = catalog.getFeatureTypeByName(ft.getName());
        MetadataLinkInfo ml3 = ft3.getMetadataLinks().get(0);
        ml3.setType("application/json");
       
        // do not save and grab another, the metadata link must not have been modified
        FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ft.getName());
        MetadataLinkInfo ml4 = ft4.getMetadataLinks().get(0);
        assertEquals("text/plain", ml4.getType());
       
       
        // now save and grab yet another, the modification must have happened
        catalog.save(ft3);
        FeatureTypeInfo ft5 = catalog.getFeatureTypeByName(ft.getName());
        MetadataLinkInfo ml5 = ft5.getMetadataLinks().get(0);
        assertEquals("application/json", ml5.getType());
    }
View Full Code Here

    @org.junit.Test
    public void testMetadataLinks() throws Exception {
        String layerName = MockData.POINTS.getPrefix() + ":" + MockData.POINTS.getLocalPart();
       
        LayerInfo layer = getCatalog().getLayerByName(MockData.POINTS.getLocalPart());
        MetadataLinkInfo mdlink = getCatalog().getFactory().createMetadataLink();
        mdlink.setMetadataType("FGDC");
        mdlink.setContent("http://geoserver.org");
        mdlink.setType("text/xml");
        ResourceInfo resource = layer.getResource();
        resource.getMetadataLinks().add(mdlink);
        getCatalog().save(resource);
       
        Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
        String xpath = "//wms:Layer[wms:Name='" + layerName + "']/wms:MetadataURL/wms:Format";
        assertXpathEvaluatesTo("text/xml", xpath, doc);
       
        xpath = "//wms:Layer[wms:Name='" + layerName + "']/wms:MetadataURL/@type";
        assertXpathEvaluatesTo("FGDC", xpath, doc);
       
        xpath = "//wms:Layer[wms:Name='" + layerName + "']/wms:MetadataURL/wms:OnlineResource/@xlink:type";
        assertXpathEvaluatesTo("simple", xpath, doc);
       
        xpath = "//wms:Layer[wms:Name='" + layerName + "']/wms:MetadataURL/wms:OnlineResource/@xlink:href";
        assertXpathEvaluatesTo("http://geoserver.org", xpath, doc);
       
        // Test transforming localhost to proxyBaseUrl
        GeoServerInfo global = getGeoServer().getGlobal();
        String proxyBaseUrl = global.getSettings().getProxyBaseUrl();
        mdlink.setContent("/metadata");
        getCatalog().save(resource);
       
        doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
        assertXpathEvaluatesTo(proxyBaseUrl + "/metadata", xpath, doc);
       
        // Test KVP in URL
        String query = "key=value";
        mdlink.setContent("/metadata?" + query);
        getCatalog().save(resource);
       
        doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
        assertXpathEvaluatesTo(proxyBaseUrl + "/metadata?" + query, xpath, doc);

        mdlink.setContent("http://localhost/metadata?" + query);
        getCatalog().save(resource);
       
        doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
        assertXpathEvaluatesTo("http://localhost/metadata?" + query, xpath, doc);
       
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.MetadataLinkInfo

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.