01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfs.xml.filter.v1_1;
06:
07: import org.geoserver.wfs.WFSException;
08: import org.geotools.filter.v1_0.OGCPropertyNameTypeBinding;
09: import org.geotools.gml3.bindings.GML;
10: import org.geotools.xml.ElementInstance;
11: import org.geotools.xml.Node;
12: import org.opengis.filter.FilterFactory;
13: import org.opengis.filter.expression.PropertyName;
14: import org.vfny.geoserver.global.Data;
15: import org.xml.sax.helpers.NamespaceSupport;
16:
17: /**
18: * A binding for ogc:PropertyName which does a special case check for an empty
19: * property name.
20: *
21: * @author Justin Deoliveira, The Open Planning Project
22: *
23: */
24: public class PropertyNameTypeBinding extends OGCPropertyNameTypeBinding {
25: /** the geoserver catalog */
26: Data catalog;
27:
28: /** parser namespace mappings */
29: NamespaceSupport namespaceSupport;
30:
31: public PropertyNameTypeBinding(FilterFactory filterFactory,
32: NamespaceSupport namespaceSupport, Data catalog) {
33: super (filterFactory);
34: this .namespaceSupport = namespaceSupport;
35: this .catalog = catalog;
36: }
37:
38: public Object parse(ElementInstance instance, Node node,
39: Object value) throws Exception {
40: PropertyName propertyName = (PropertyName) super .parse(
41: instance, node, value);
42:
43: //JD: temporary hack, this should be carried out at evaluation time
44: String name = propertyName.getPropertyName();
45:
46: if (name != null && name.matches("\\w+:\\w+")) {
47: //namespace qualified name, ensure the prefix is valid
48: String prefix = name.substring(0, name.indexOf(':'));
49: String namespaceURI = namespaceSupport.getURI(prefix);
50:
51: //only accept if its an application schema namespace, or gml
52: if (!GML.NAMESPACE.equals(namespaceURI)
53: && (catalog.getNameSpaceFromURI(namespaceURI) == null)) {
54: throw new WFSException("Illegal attribute namespace: "
55: + namespaceURI);
56: }
57: }
58:
59: return propertyName;
60: }
61: }
|