protected GML3(FeatureTypeInfo featureType, WFSInfo wfs, Catalog catalog) { super(featureType, wfs, catalog); builder = new FeatureTypeSchemaBuilder.GML3(wfs.getGeoServer()); } }
public GML2(FeatureTypeInfo featureType, WFSInfo wfs, Catalog catalog) { super(featureType, wfs, catalog); builder = new FeatureTypeSchemaBuilder.GML2(wfs.getGeoServer()); } }
protected void updateSequence(AttributesImpl attributes) { attributes.addAttribute( "", "updateSequence", "updateSequence", "", wfs.getGeoServer().getGlobal().getUpdateSequence() + ""); }
public static Object parseRequest(Parser parser, Reader reader, WFSInfo wfs) throws Exception { // set the input source with the correct encoding InputSource source = new InputSource(reader); source.setEncoding(wfs.getGeoServer().getSettings().getCharset()); return parser.parse(source); }
public void openTag(String prefix, String name, String[] attributes) throws IOException { boolean root = writer == null; if (root) { writer = new BufferedWriter( new OutputStreamWriter( output, wfs.getGeoServer().getSettings().getCharset())); // write the processing instruction writer.write("<?xml version=\"1.0\" encoding=\"" + charSetEncoding + "\"?>"); } // write the element if (prefix != null) { writer.write("<" + prefix + ":" + name); } else { writer.write("<" + name); } if (root) { init(); } if (attributes != null) { for (int i = 0; i < attributes.length; i += 2) { attribute(attributes[i], attributes[i + 1]); } } writer.write(">"); }
public WFS1_0(WFSInfo wfs, Catalog catalog) { super(wfs, WFSInfo.Version.V_10, catalog); this.skipMisconfigured = ResourceErrorHandling.SKIP_MISCONFIGURED_LAYERS.equals( wfs.getGeoServer().getGlobal().getResourceErrorHandling()); }
protected void write( FeatureTypeInfo[] featureTypeInfos, OutputStream output, Operation describeFeatureType) throws IOException { WFSInfo wfs = getInfo(); // generates response, using general function String xmlResponse = generateTypes( featureTypeInfos, (DescribeFeatureTypeType) describeFeatureType.getParameters()[0]); if (!wfs.getGeoServer().getSettings().isVerbose()) { // strip out the formatting. This is pretty much the only way we // can do this, as the user files are going to have newline // characters and whatnot, unless we can get rid of formatting // when we read the file, which could be worth looking into if // this slows things down. xmlResponse = xmlResponse.replaceAll(">\n[ \\t\\n]*", ">"); xmlResponse = xmlResponse.replaceAll("\n[ \\t\\n]*", " "); } Writer writer = new OutputStreamWriter(output, wfs.getGeoServer().getSettings().getCharset()); writer.write(xmlResponse); writer.flush(); }
public WFS1_1( WFSInfo wfs, WFSInfo.Version version, String baseUrl, Catalog catalog, Collection<WFSExtendedCapabilitiesProvider> extCapsProviders) { super(wfs, version, catalog); skipMisconfigured = ResourceErrorHandling.SKIP_MISCONFIGURED_LAYERS.equals( wfs.getGeoServer().getGlobal().getResourceErrorHandling()); this.extCapsProviders = extCapsProviders; this.baseUrl = baseUrl; }
private AttrFormatter[] getFormatters(FeatureType schema) { if (schema instanceof SimpleFeatureType) { // prepare the formatter for numbers NumberFormat coordFormatter = NumberFormat.getInstance(Locale.US); coordFormatter.setMaximumFractionDigits( getInfo().getGeoServer().getSettings().getNumDecimals()); coordFormatter.setGroupingUsed(false); SimpleFeatureType sft = (SimpleFeatureType) schema; AttrFormatter[] formatters = new AttrFormatter[sft.getAttributeCount()]; int i = 0; for (AttributeDescriptor attributeDescriptor : sft.getAttributeDescriptors()) { Class<?> binding = attributeDescriptor.getType().getBinding(); if (Number.class.isAssignableFrom(binding)) { formatters[i] = new NumberFormatter(coordFormatter); } else if (java.sql.Date.class.isAssignableFrom(binding)) { formatters[i] = sqlDateFormatter; } else if (java.sql.Time.class.isAssignableFrom(binding)) { formatters[i] = sqlTimeFormatter; } else if (java.util.Date.class.isAssignableFrom(binding)) { formatters[i] = juDateFormatter; } else { formatters[i] = defaultFormatter; } i++; } return formatters; } else { return null; } }
public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (handler instanceof Dispatcher) { Dispatcher dispatcher = (Dispatcher) handler; Integer xmlLogBufferSize = getInfo().getGeoServer().getGlobal().getXmlPostRequestLogBufferSize(); if (xmlLogBufferSize != null) { dispatcher.setXMLPostRequestLogBufferSize(xmlLogBufferSize); } } return true; }
void write1_1(LockFeatureResponseType lockResponse, OutputStream output, Operation operation) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); LockFeatureType req = (LockFeatureType) operation.getParameters()[0]; encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, buildSchemaURL(req.getBaseUrl(), "schemas/wfs/1.1.0/wfs.xsd")); encoder.encode(lockResponse, org.geoserver.wfs.xml.v1_1_0.WFS.LOCKFEATURERESPONSE, output); output.flush(); } }
public WfsXmlWriter(WFSInfo wfs, OutputStream output) { this.wfs = wfs; this.output = output; // default to wfs configured charset charSetEncoding = wfs.getGeoServer().getSettings().getCharset(); // schema locations schemaLocations = new HashMap(); // declare the namespaces ( wfs is default ) namespaceSupport = new NamespaceSupport(); namespaceSupport.declarePrefix("xs", XS.NAMESPACE); namespaceSupport.declarePrefix("ogc", OGC.NAMESPACE); namespaceSupport.declarePrefix("gml", GML.NAMESPACE); namespaceSupport.declarePrefix("wfs", org.geoserver.wfs.xml.v1_0_0.WFS.NAMESPACE); namespaceSupport.declarePrefix("", org.geoserver.wfs.xml.v1_0_0.WFS.NAMESPACE); }
public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { // get the feature SimpleFeature feature = (SimpleFeature) value; SimpleFeatureType featureType = feature.getType(); // grab the metadata FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName()); // create teh encoder Encoder encoder = new Encoder(configuration); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); encoder.encode(feature, new QName(meta.getNamespace().getURI(), meta.getName()), output); } }
@Override protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { hits.setNumberOfFeatures(BigInteger.valueOf(0)); Encoder e = new Encoder(new WFSConfiguration()); e.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); e.setSchemaLocation( WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd")); e.encode(hits.getAdaptee(), WFS.FeatureCollection, output); } }
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd")); encoder.encode( hits.getAdaptee(), org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output); } }
@Override public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { Encoder encoder = new Encoder(new WFSConfiguration()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); encoder.setOmitXMLDeclaration(Dispatcher.REQUEST.get().isSOAP()); String baseURL = (String) EMFUtils.get((EObject) operation.getParameters()[0], "baseUrl"); encoder.setSchemaLocation(WFS.NAMESPACE, buildSchemaURL(baseURL, "wfs/2.0/wfs.xsd")); encode(encoder, value, output, operation); }
long geoUS = wfs.getGeoServer().getGlobal().getUpdateSequence(); if (reqUS > geoUS) { throw new ServiceException(
public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { Encoder encoder = new Encoder(new GMLConfiguration()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); if (value instanceof Point) { encoder.encode(value, GML.Point, output); } else if (value instanceof MultiPoint) { encoder.encode(value, GML.MultiPoint, output); } else if (value instanceof LineString) { encoder.encode(value, GML.LineString, output); } else if (value instanceof MultiLineString) { encoder.encode(value, GML.MultiLineString, output); } else if (value instanceof Polygon) { encoder.encode(value, GML.Polygon, output); } else if (value instanceof MultiPolygon) { encoder.encode(value, GML.MultiPolygon, output); } else { throw new WFSException("Cannot encode geometry of type: " + value.getClass()); } } }
@Override protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { hits.setNumberOfFeatures(BigInteger.ZERO); // instantiate the XML encoder Encoder encoder = new Encoder(new WFSConfiguration()); encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); encoder.setSchemaLocation( WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd")); Document document; try { // encode the HITS result using FeatureCollection as the root XML element document = encoder.encodeAsDOM(hits.getAdaptee(), WFS.FeatureCollection); } catch (Exception exception) { throw new RuntimeException("Error encoding INDEX result.", exception); } // add the resultSetID attribute to the result addResultSetIdElement(document, resultSetId); // write the XML document to response output stream writeDocument(document, output); }
public void v_1_1(TransactionResponseType response, OutputStream output, Operation operation) throws IOException, ServiceException { if (!response.getTransactionResults().getAction().isEmpty()) { // since we do atomic transactions, an action failure means all we rolled back // spec says to throw exception ActionType action = (ActionType) response.getTransactionResults().getAction().iterator().next(); throw new WFSException(action.getMessage(), action.getCode(), action.getLocator()); } Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); TransactionType req = (TransactionType) operation.getParameters()[0]; encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, buildSchemaURL(req.getBaseUrl(), "wfs/1.1.0/wfs.xsd")); encoder.encode(response, org.geoserver.wfs.xml.v1_1_0.WFS.TRANSACTIONRESPONSE, output); } }