Hi Tom,
I believe methods 2 and 3 both depend on TransactionPlugin, last time I
played around it
I opened this ticket:
https://osgeo-org.atlassian.net/browse/GEOS-7403
Unless I'm wrong, since the introduction of WFS 2.0 support (and the
associated refactoring it
required) it is no longer possible to modify the transactions on the fly,
save one specific case of inserts.
About method 2, it relies on a module that is officially unsupported and
has seen its last actual
change over 3 years ago (the GEOS-6535 one):
https://github.com/geoserver/geoserver/commits/master/src/community/script/py/src
Among the various options I'd go for 3), but even that one requires some
non trivial fixes
in the WFS module to restore TransactionPlugin ability to modify the
transaction contents.
Going for 2) is also posssible of course, but TransactionPlugin needs
fixing first.
While I'm at it let me offer a method 5), which is, implementing a
DispatcherCallback
<https://github.com/geoserver/geoserver/blob/master/src/ows/src/main/java/org/geoserver/ows/DispatcherCallback.java>
modifying the transaction request as it gets in.
It is similar to 3), but requires you to implement modification code for
WFS 1.0/1.1 and
WFS 2.0 request objects separately (they are both called TransactionType,
but
live in two different packages).
About the fragily related to internal changes, you cannot eliminate it
fully, GeoServer
is managed as an application, not a library, so we care primarily about
backwards compatibility
for outside users, and then for extension point interfaces to some extent,
but the
rest is subject to change. That said, TransactionType did not change in a
long time,
so it's probably safe (but no promises! :-) ).
Cheers
Andrea
On Thu, Oct 12, 2017 at 1:46 PM, Tom Feist-Hassan <[email protected]
> wrote:
> Hi Folks,
>
> I'm in the process of evaluating geoserver as the WFS backend for a
> web-based mapping app with both view and modify capabilities.
> So far things are going pretty smoothly using GS 2.11 and the Boundless
> web-sdk/openlayers, but now I'm facing some interesting issues around
> integration with other systems.
>
> One requirement I have is that when modifications are made to layers via
> WFS-T, certain fields should be validated serverside, potentially in quite
> complex ways. Some examples are:
>
> * certain field values should match a regular expression
> * if field A is modified, B should also be modified (and valid) in the
> same transaction
> * for some fields, new values should be passed to an external web service
> that approves/rejects the value.
>
> It would also be useful (although a little less critical) if certain
> fields could be modified serverside, between receiving and updating the
> data-store.
>
> One simple example is to automatically populate an 'edited_by' field, if
> present, with the currently autheticated geoserver user. More complex would
> be passing the received value to an external service, and passing the
> result of that instead of the original value to the data-store.
>
> I've come up with a couple of different approaches, and am looking for
> advice on which would be easiest/best, or if there are alternatives I
> haven't thought of.
>
> 1) Validation as triggers/rules in PostGIS datastore
> + can handle regex constraints
> + before-update and before-insert triggers could do cross-field validation
> - no simple way to lookup/validate via an external service (maybe with
> pl/??? and libraries, or FDW, but probably not ideal)
> - could be tricky to deploy/keep updated rules with business requirements
> - can't operate on data it doesn't have (e.g. geoserver auth username -
> although maybe with the session scripts that would work)
>
> 2) Use Geoserver Scripting Extension with WFS TX hooks
> + doesn't require modifying/recompiling (bits of) geoserver
> + easier to develop/test/deploy than DB constraints
> + easy to call external services
> - community module => possible reliability/support concerns?
> - not much documentation (AFAICT) on the APIs & hook parameters, e.g.:
> http://docs.geoserver.org/stable/en/user/community/
> scripting/py/api/index.html
>
> 3) Write a custom Geoserver TransactionPlugin to intercept/validate/modify
> + quite easy to test/deploy new rule sets
> + should be easy to call external sources
> + working in java brings benefits of tooling / integration with existing
> geoserver code
> - need to understand the GS build process and initial plugin
> development/setup
> - also seems to be lacking docs in the manual, assuming
> http://docs.geoserver.org/stable/en/developer/programming-guide/extension-
> points/index.html is the right place to look.
>
> 4) HTTP Interception/rewrite Proxy in front of geoserver /wfs endpoint
> - This is probably a terrible idea :)
> + doesn't require plugins/changes to geoserver
> - potentially an absolute beast to debug and test
> - doesn't have access to geoserver internals which could be
> useful/essential for some tasks
>
> That's what I've come up with so far. I've spent a bit of time, mostly on
> (2) using the python-scripting extension
> and exploring what values are passed to the hooks, and how to extract and
> manipulate them. I very briefly looked into (3), but ran into some issues
> getting the dev environment running/building properly, so I've put that on
> hold for now.
>
> One downside to this is the plugin is using jython-2.5.2, which is
> Python2.5ish language support, which excludes a lot of
> language features I've come to rely on, and makes installing 3rd party
> modules somewhat tricky.
>
> Extracting and modifying the transaction parameters also involves quite a
> bit of guesswork and experimentation, and I'm a
> little concerned that it might be quite fragile to internal geoserver
> changes, or even request-data/structure dependent without a lot more
> testing.
>
> Has anyone else on the list faced similar requirements, and if so, how did
> you go about handling them?
>
> If it turns out I am on the right track with either (2) or (3), I can try
> to find time to contribute some improvements to the docs, if there's any
> interest.
>
> Thanks for reading,
>
> Tom
>
>
> --
> Tom Feist-Hassan <[email protected]>
>
> Senior Engineer, MHN Ltd.
> 1.5 Techcube, Summerhall
> Edinburgh, EH9 1PL
> Company Registered in Scotland number SC304505 | 6 ATHOLL CRESCENT PERTH
> PH1 5JN
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to
> this list:
> - Earning your support instead of buying it, but Ian Turton:
> http://www.ianturton.com/talks/foss4g.html#/
> - The GeoServer user list posting guidelines: http://geoserver.org/comm/
> userlist-guidelines.html
>
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
--
Regards,
Andrea Aime
==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this
list:
- Earning your support instead of buying it, but Ian Turton:
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines:
http://geoserver.org/comm/userlist-guidelines.html
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users