Package org.geoserver.catalog

Examples of org.geoserver.catalog.NamespaceInfo


        saved(map);
    }

    // Namespace methods
    public NamespaceInfo getNamespace(String id) {
        final NamespaceInfo namespace = catalogDAO.getNamespace(id);
        if (namespace != null) {
            resolve(namespace);
            return createProxy(namespace, NamespaceInfo.class);
        } else
            return null;
View Full Code Here


            return null;

    }

    public NamespaceInfo getNamespaceByPrefix(String prefix) {
        NamespaceInfo namespace = catalogDAO.getNamespaceByPrefix(prefix);
        if (namespace != null) {
            resolve(namespace);
            return createProxy(namespace, NamespaceInfo.class);
        } else
            return null;
View Full Code Here

        } else
            return null;
    }

    public NamespaceInfo getNamespaceByURI(String uri) {
        NamespaceInfo namespace = catalogDAO.getNamespaceByURI(uri);
        if (namespace != null) {
            resolve(namespace);
            return createProxy(namespace, NamespaceInfo.class);
        } else
            return null;
View Full Code Here

    void validate(NamespaceInfo namespace, boolean isNew) {
        if (isNull(namespace.getPrefix())) {
            throw new NullPointerException("Namespace prefix must not be null");
        }

        NamespaceInfo existing = catalogDAO.getNamespaceByPrefix(namespace.getPrefix());
        if (existing != null && !existing.getId().equals(namespace.getId())) {
            throw new IllegalArgumentException("Namespace with prefix '" + namespace.getPrefix()
                    + "' already exists.");
        }

        if (namespace.getURI() == null) {
View Full Code Here

        return createProxy(defaultNamespace, NamespaceInfo.class);

    }

    public void setDefaultNamespace(NamespaceInfo defaultNamespace) {
        NamespaceInfo nsold = catalogDAO.getDefaultNamespace();
        NamespaceInfo nsnew = catalogDAO.getNamespaceByPrefix(defaultNamespace.getPrefix());
        if (nsnew == null) {
            throw new IllegalArgumentException("No such namespace: '"
                    + defaultNamespace.getPrefix() + "'");
        }

        if (nsold != null && nsold.getPrefix().equals(nsnew.getPrefix())) // setting existing
                                                                          // default
            return;

        ((NamespaceInfoImpl) nsnew).setDefault(true);
        catalogDAO.update(nsnew);
View Full Code Here

    }

    public static void createDefaultXXXXspace(GeoServer geoServer) {
        Catalog resourceCatalog = geoServer.getCatalog();

        NamespaceInfo ns = resourceCatalog.getFactory().createNamespace();
        ns.setPrefix("topp");
        ns.setURI("http://www.opengeo.org");
        resourceCatalog.add(ns);
        resourceCatalog.setDefaultNamespace(ns);

        ns = resourceCatalog.getFactory().createNamespace();
        ns.setPrefix("it.geosolutions");
        ns.setURI("http://www.geo-solutions.it");
        resourceCatalog.add(ns);

        WorkspaceInfoImpl ws = (WorkspaceInfoImpl) resourceCatalog.getFactory()
                .createWorkspace();
        ws.setName("topp");
View Full Code Here

        return geoserver;
    }

    public NamespaceInfo createDefaultNamespace() {
        NamespaceInfo ns = resourceCatalog.getFactory().createNamespace();
        ns.setPrefix("nurc");
        ns.setURI("http://www.nurc.nato.int");
        resourceCatalog.add(ns);
        resourceCatalog.setDefaultNamespace(ns);
        return ns;
    }
View Full Code Here

        System.out.println("========== testNamespace()");
        // ensure no stores
        clearCatalog();
        removeExistingNS();

        NamespaceInfo namespace = catalog.getFactory().createNamespace();
        namespace.setPrefix("topp");
        namespace.setURI("http://topp.openplans.org");
        catalog.add(namespace);

        namespace = catalog.getFactory().createNamespace();
        namespace.setPrefix("gs");
        namespace.setURI("http://geoserver.org");
        catalog.add(namespace);

        endTransaction();
        startNewTransaction();

        Iterator<NamespaceInfo> namespaces = catalog.getNamespaces().iterator();

        assertTrue(namespaces.hasNext());
        NamespaceInfo ns1 = namespaces.next();
        ns1 = ModificationProxy.unwrap(ns1);

        assertTrue(namespaces.hasNext());
        NamespaceInfo ns2 = namespaces.next();
        ns2 = ModificationProxy.unwrap(ns2);

        if ("gs".equals(ns1.getPrefix())) {
            NamespaceInfo t = ns1;
            ns1 = ns2;
            ns2 = t;
        }

        assertEquals("topp", ns1.getPrefix());
View Full Code Here

        System.out.println("========== testDefaultNamespace()");
        // ensure no stores
        clearCatalog();
        removeExistingNS();

        NamespaceInfo toppNamespace = catalog.getFactory().createNamespace();
        toppNamespace.setPrefix("topp2");
        toppNamespace.setURI("http://topp.openplans.org/default");

        catalog.add(toppNamespace);
        catalog.setDefaultNamespace(toppNamespace);

        NamespaceInfo gsNamespace = catalog.getFactory().createNamespace();
        gsNamespace.setPrefix("gs2");
        gsNamespace.setURI("http://geoserver.org/default");
        catalog.add(gsNamespace);

        endTransaction();
        startNewTransaction();

        NamespaceInfo defaultNs = catalog.getDefaultNamespace();
        assertEquals(toppNamespace, defaultNs);

        catalog.setDefaultNamespace(gsNamespace);

        endTransaction();
View Full Code Here

        // ensure no stores
        clearCatalog();
        removeExistingNS();

        NamespaceInfo namespace = catalog.getFactory().createNamespace();
        namespace.setPrefix(getName());
        namespace.setURI("http://" + getName() + ".openplans.org");
        catalog.add(namespace);

        // store needs a workspace...
        WorkspaceInfo ws = catalog.getFactory().createWorkspace();
        ws.setName("testFeatureTypeWorkspace");
        catalog.add(ws);

        StyleInfo style = catalog.getFactory().createStyle();
        style.setName("style_testFeatureType");
        style.setFilename("style_testFeatureType");
        catalog.add(style);

        DataStoreInfo dataStore = catalog.getFactory().createDataStore();
        dataStore.setName("dataStore2");
        dataStore.setDescription("store description");
        dataStore.setEnabled(true);
        dataStore.setWorkspace(ws);
        catalog.add(dataStore);

        FeatureTypeInfo refFeatureType = catalog.getFactory().createFeatureType();
        refFeatureType.setName("featureType");
        refFeatureType.setNativeName("nativefeatureType");
        refFeatureType.setTitle("featureType title");
        refFeatureType.setDescription("featureType description");
        refFeatureType.setAbstract("featureType abstract");
        refFeatureType.setSRS("EPSG:4326");
        refFeatureType.setNamespace(namespace);

        FilterFactory factory = CommonFactoryFinder.getFilterFactory(null);
        Filter filter = factory.id(Collections.EMPTY_SET);
        refFeatureType.setFilter(filter);

        CoordinateReferenceSystem crsNative = CRS
                .parseWKT("PROJCS[\"NAD83 / BC Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4269\"]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"standard_parallel_1\",50],PARAMETER[\"standard_parallel_2\",58.5],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-126],PARAMETER[\"false_easting\",1000000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"3005\"]]");
        BoundingBox nativeBoundingBox = new ReferencedEnvelope(0, 0, 0, 0, crsNative);
        BoundingBox latLonBoundingBox = new ReferencedEnvelope(-180, 180, -90, 90,
                DefaultGeographicCRS.WGS84);

        refFeatureType.setNativeBoundingBox((ReferencedEnvelope) nativeBoundingBox);
        refFeatureType.setLatLonBoundingBox((ReferencedEnvelope) latLonBoundingBox);

        refFeatureType.setStore(dataStore);

        catalog.add(refFeatureType);

        endTransaction();

        startNewTransaction();

        FeatureTypeInfo loadedFeatureType = catalog.getFeatureType(refFeatureType.getId());
        assertNotNull(loadedFeatureType);

        assertFalse(refFeatureType == loadedFeatureType);
        refFeatureType = loadedFeatureType;

        assertEquals("featureType", refFeatureType.getName());
        assertEquals("featureType title", refFeatureType.getTitle());
        assertEquals("featureType description", refFeatureType.getDescription());
        assertEquals("featureType abstract", refFeatureType.getAbstract());
        assertEquals("EPSG:4326", refFeatureType.getSRS());

        BoundingBox box = refFeatureType.getNativeBoundingBox();
        assertNotNull("Native BBox is null", box);
        assertEquals(0d, box.getMinX(), 0d);
        assertEquals(0d, box.getMinY(), 0d);
        assertEquals(0d, box.getMaxX(), 0d);
        assertEquals(0d, box.getMaxY(), 0d);
        assertTrue(CRS.equalsIgnoreMetadata(crsNative, box.getCoordinateReferenceSystem()));

        box = refFeatureType.getLatLonBoundingBox();
        assertNotNull(box);
        assertEquals(-180d, box.getMinX(), 0d);
        assertEquals(-90d, box.getMinY(), 0d);
        assertEquals(180d, box.getMaxX(), 0d);
        assertEquals(90d, box.getMaxY(), 0d);
        assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, box
                .getCoordinateReferenceSystem()));

        assertNotNull(refFeatureType.getNamespace());
        assertEquals(getName(), refFeatureType.getNamespace().getPrefix());

        assertNotNull(refFeatureType.getStore());
        assertEquals("dataStore2", refFeatureType.getStore().getName());
        endTransaction();

        startNewTransaction();
        loadedFeatureType = catalog.getFeatureTypeByName(namespace.getPrefix(), refFeatureType
                .getName());
        assertNotNull(loadedFeatureType);

        loadedFeatureType = catalog.getFeatureTypeByName(namespace.getURI(), refFeatureType
                .getName());
        assertNotNull(loadedFeatureType);
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.NamespaceInfo

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.