private void writeActionResults200( XMLStreamWriter xmlWriter, String elName, ActionResults results ) throws XMLStreamException { if ( results.getTotal() > 0 ) { xmlWriter.writeStartElement( WFS_200_NS, elName ); for ( String handle : results.getHandles() ) { Collection<String> fids = results.getFids( handle ); for ( String fid : fids ) { xmlWriter.writeStartElement( WFS_200_NS, "Feature" ); xmlWriter.writeAttribute( "handle", handle ); xmlWriter.writeStartElement( FES_20_NS, "ResourceId" ); xmlWriter.writeAttribute( "rid", fid ); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); } } for ( String fid : results.getFidsWithoutHandle() ) { xmlWriter.writeStartElement( WFS_200_NS, "Feature" ); xmlWriter.writeStartElement( FES_20_NS, "ResourceId" ); xmlWriter.writeAttribute( "rid", fid ); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } }
private void doReplace( Replace replace, Lock lock ) throws OWSException { LOG.debug( "doReplace: " + replace ); XMLStreamReader xmlStream = replace.getReplacementFeatureStream(); QName ftName = xmlStream.getName(); FeatureStore fs = service.getStore( ftName ); if ( fs == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), INVALID_PARAMETER_VALUE ); } Feature replacementFeature = null; Filter filter = null; try { GMLStreamReader gmlReader = createGMLStreamReader( GML_32, xmlStream ); gmlReader.setApplicationSchema( fs.getSchema() ); replacementFeature = gmlReader.readFeature(); filter = replace.getFilter(); // superimpose default CRS Filters.setDefaultCRS( filter, master.getDefaultQueryCrs() ); } catch ( Exception e ) { throw new OWSException( e.getMessage(), INVALID_PARAMETER_VALUE ); } FeatureStoreTransaction ta = acquireTransaction( fs ); try { String newFid = ta.performReplace( replacementFeature, filter, lock, idGenMode ); replaced.add( newFid, replace.getHandle() ); } catch ( FeatureStoreException e ) { throw new OWSException( "Error performing replace: " + e.getMessage(), e, NO_APPLICABLE_CODE ); } }
private void sendResponse200( HttpResponseBuffer response ) throws XMLStreamException, IOException { String ns = WFS_200_NS; String schemaLocation = ns + " " + WFS_200_SCHEMA_URL; XMLStreamWriter xmlWriter = getXMLResponseWriter( response, "text/xml", schemaLocation ); xmlWriter.setPrefix( "wfs", WFS_200_NS ); xmlWriter.writeStartElement( WFS_200_NS, "TransactionResponse" ); xmlWriter.writeAttribute( "version", VERSION_200.toString() ); xmlWriter.writeNamespace( "wfs", WFS_200_NS ); xmlWriter.writeNamespace( "fes", FES_20_NS ); xmlWriter.writeStartElement( WFS_200_NS, "TransactionSummary" ); writeElement( xmlWriter, WFS_200_NS, "totalInserted", "" + inserted.getTotal() ); writeElement( xmlWriter, WFS_200_NS, "totalUpdated", "" + updated.getTotal() ); writeElement( xmlWriter, WFS_200_NS, "totalReplaced", "" + replaced.getTotal() ); writeElement( xmlWriter, WFS_200_NS, "totalDeleted", "" + deleted ); xmlWriter.writeEndElement(); writeActionResults200( xmlWriter, "InsertResults", inserted ); writeActionResults200( xmlWriter, "UpdateResults", updated ); writeActionResults200( xmlWriter, "ReplaceResults", replaced ); xmlWriter.writeEndElement(); xmlWriter.flush(); }
inserted.add( newFid, insert.getHandle() );
writeElement( xmlWriter, WFS_NS, "totalInserted", "" + inserted.getTotal() ); writeElement( xmlWriter, WFS_NS, "totalUpdated", "" + updated.getTotal() ); writeElement( xmlWriter, WFS_NS, "totalDeleted", "" + deleted ); xmlWriter.writeEndElement(); if ( inserted.getTotal() > 0 ) { xmlWriter.writeStartElement( WFS_NS, "InsertResults" ); for ( String handle : inserted.getHandles() ) { Collection<String> fids = inserted.getFids( handle ); for ( String fid : fids ) { LOG.debug( "Inserted fid: " + fid ); for ( String fid : inserted.getFidsWithoutHandle() ) { LOG.debug( "Inserted fid: " + fid ); xmlWriter.writeStartElement( WFS_NS, "Feature" );
private void doUpdate( Update update, Lock lock ) throws OWSException { LOG.debug( "doUpdate: " + update ); QName ftName = update.getTypeName(); FeatureType ft = service.lookupFeatureType( ftName ); FeatureStore fs = service.getStore( ftName ); if ( fs == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), INVALID_PARAMETER_VALUE ); } GMLVersion inputFormat = determineFormat( request.getVersion(), update.getInputFormat() ); FeatureStoreTransaction ta = acquireTransaction( fs ); List<ParsedPropertyReplacement> replacementProps = getReplacementProps( update, ft, inputFormat ); Filter filter = null; try { filter = update.getFilter(); // superimpose default query CRS Filters.setDefaultCRS( filter, master.getDefaultQueryCrs() ); } catch ( Exception e ) { throw new OWSException( e.getMessage(), INVALID_PARAMETER_VALUE ); } try { List<String> updatedFids = ta.performUpdate( ftName, replacementProps, filter, lock ); for ( String updatedFid : updatedFids ) { this.updated.add( updatedFid, update.getHandle() ); } } catch ( FeatureStoreException e ) { throw new OWSException( "Error performing update: " + e.getMessage(), e, NO_APPLICABLE_CODE ); } }
xmlWriter.writeAttribute( "version", VERSION_100.toString() ); if ( inserted.getTotal() > 0 ) { for ( String handle : inserted.getHandles() ) { xmlWriter.writeStartElement( "wfs", "InsertResult", WFS_NS ); writeHandle( xmlWriter, handle ); Collection<String> fids = inserted.getFids( handle ); for ( String fid : fids ) { LOG.debug( "Inserted fid: " + fid ); if ( !inserted.getFidsWithoutHandle().isEmpty() ) { xmlWriter.writeStartElement( "wfs", "InsertResult", WFS_NS ); for ( String fid : inserted.getFidsWithoutHandle() ) { LOG.debug( "Inserted fid: " + fid ); xmlWriter.writeStartElement( "ogc", "FeatureId", OGCNS );