/** @return NamespaceSupport from Catalog */ public NamespaceSupport getNamespaceSupport() { return new CatalogNamespaceSupport(catalog); }
@Override public Enumeration getPrefixes(String uri) { final String pre = getPrefix(uri); if (pre == null) { return new Enumeration() {
@Override public Enumeration getDeclaredPrefixes() { return getPrefixes(); }
@Test public void testGetDefaultPrefix() { NamespaceInfo ns = createMock(NamespaceInfo.class); expect(ns.getPrefix()).andReturn("foo"); Catalog cat = createMock(Catalog.class); expect(cat.getDefaultNamespace()).andReturn(ns); replay(ns, cat); CatalogNamespaceSupport nsSupport = new CatalogNamespaceSupport(cat); assertEquals("foo", nsSupport.getPrefix("")); verify(ns, cat); }
@Test public void testNulls() { Catalog cat = createMock(Catalog.class); expect(cat.getNamespaceByURI(null)).andReturn(null); expect(cat.getNamespaceByPrefix(null)).andReturn(null); replay(cat); CatalogNamespaceSupport nsSupport = new CatalogNamespaceSupport(cat); assertNull(nsSupport.getPrefix(null)); assertNull(nsSupport.getURI(null)); verify(cat); } }
@Test public void testGetDefaultURI() { NamespaceInfo ns = createMock(NamespaceInfo.class); expect(ns.getURI()).andReturn("http://foo.org"); Catalog cat = createMock(Catalog.class); expect(cat.getDefaultNamespace()).andReturn(ns); replay(ns, cat); CatalogNamespaceSupport nsSupport = new CatalogNamespaceSupport(cat); assertEquals("http://foo.org", nsSupport.getURI("")); verify(ns, cat); }
@Test public void testGetPrefix() { NamespaceInfo ns = createMock(NamespaceInfo.class); expect(ns.getPrefix()).andReturn("foo"); Catalog cat = createMock(Catalog.class); expect(cat.getNamespaceByURI("http://foo.org")).andReturn(ns); replay(ns, cat); CatalogNamespaceSupport nsSupport = new CatalogNamespaceSupport(cat); assertEquals("foo", nsSupport.getPrefix("http://foo.org")); verify(ns, cat); }
@Test public void testGetURI() { NamespaceInfo ns = createMock(NamespaceInfo.class); expect(ns.getURI()).andReturn("http://foo.org"); Catalog cat = createMock(Catalog.class); expect(cat.getNamespaceByPrefix("foo")).andReturn(ns); replay(ns, cat); CatalogNamespaceSupport nsSupport = new CatalogNamespaceSupport(cat); assertEquals("http://foo.org", nsSupport.getURI("foo")); verify(ns, cat); }
p.getNamespaces().add(new CatalogNamespaceSupport(catalog));
public static void initRequestParser(Parser parser, WFSInfo wfs, GeoServer geoServer, Map kvp) { // check the strict flag to determine if we should validate or not Boolean strict = (Boolean) kvp.get("strict"); if (strict == null) { strict = Boolean.FALSE; } // check for cite compliance, we always validate for cite if (wfs.isCiteCompliant()) { strict = Boolean.TRUE; } parser.setValidating(strict.booleanValue()); WFSURIHandler.addToParser(geoServer, parser); Catalog catalog = geoServer.getCatalog(); // "inject" namespace mappings parser.getNamespaces().add(new CatalogNamespaceSupport(catalog)); }
parser.getNamespaces().add(new CatalogNamespaceSupport(catalog));
@Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentInstance(new org.geoserver.wcs.xml.v1_1_1.WCSParserDelegate()); container.registerComponentInstance(new org.geoserver.wcs.xml.v1_0_0.WCSParserDelegate()); container.registerComponentInstance(new org.geoserver.wcs2_0.xml.WCSParserDelegate()); container.registerComponentInstance(container); // replace WFSParserDelegate from GeoTools with a new one using GeoServer // GetFeatureTypeBinding, // able to parse viewParams attribute and enable usage of SQL views Object wfs = container.getComponentInstanceOfType(WFSParserDelegate.class); container.unregisterComponentByInstance(wfs); // XSDParserDelegate with CatalogNamespaceSupport container.registerComponentInstance( new WPSInternalXSDParserDelegate( new WFSConfiguration() { @Override protected void configureBindings(MutablePicoContainer container) { super.configureBindings(container); container.registerComponentImplementation( WFS.GetFeatureType, GetFeatureTypeBinding.class); } }, new CatalogNamespaceSupport( GeoServerExtensions.bean(LocalWorkspaceCatalog.class)))); container.registerComponentImplementation(ComplexDataHandler.class); }