[Geoserver-users] Updating raster statistics using REST API

I am trying to update the raster statistics of a geotiff coverage using the REST API (as the statistics are not automatically filled by Geoserver AFAIK).

I get the .json description of the coverage [1], update the statistics values on it and send back the updated json [2] to Geoserver using a PUT request (to URL http://localhost:8080/geoserver/rest/workspaces/cesar/coveragestores/tmp_media_stats24/coverages/tmp_media_stats24.json).

However, I only get a HTTP 500 error code:
---- Debugging information ----
cause-exception : java.lang.RuntimeException
cause-message : null
class : org.geotools.coverage.grid.GridGeometry2D
required-type : org.geotools.coverage.grid.GridGeometry2D
converter-type : org.geoserver.config.util.XStreamPersister$GridGeometry2DConverter
line number : -1
class[1] : org.geoserver.catalog.impl.CoverageInfoImpl
converter-type[1] : org.geoserver.config.util.XStreamPersister$CoverageInfoConverter
version : 2.8.1

···

César Martínez Izquierdo
GIS developer


Blog: http://geotechnotes.wordpress.com/
ETC-SIA: http://sia.eionet.europa.eu/
Universitat Autònoma de Barcelona (SPAIN)


On Thu, Jan 28, 2016 at 9:58 AM, César Martínez Izquierdo <
cesar.izq@anonymised.com> wrote:

I've seen a similar problem on mailing lists [3] and tried the @class
workaround with no success (the error message looks different anyway).

@class? Not sure what you mean.
Do you have the full stack trace for your error?

Judging by the error, it _could_ be related to the XXE vulnerability fix,
and might require someone
to add the GridGeometry2D class to the de-serialization whilelist here:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/config/util/XStreamPersister.java#L467

Cheers
Andrea

--

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 Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
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.

-------------------------------------------------------

The @class workaround was suggested by Mike Grogan on a similar error [1], consiting on specifying the class of the dimension element: .

I am using JSON, so I translated this workaround as
{“dimensions”: {“coverageDimension” { “@class”: “org.geoserver.catalog.CoverageDimensionInfo”, … }}}

maybe it’s just non-sense.

The full strack trace is:

02 feb 09:54:38 ERROR [geoserver.rest] -
com.thoughtworks.xstream.converters.ConversionException: null : null
---- Debugging information ----
cause-exception : java.lang.RuntimeException
cause-message : null
class : org.geotools.coverage.grid.GridGeometry2D
required-type : org.geotools.coverage.grid.GridGeometry2D
converter-type : org.geoserver.config.util.XStreamPersister$GridGeometry2DConverter
line number : -1
class[1] : org.geoserver.catalog.impl.CoverageInfoImpl
converter-type[1] : org.geoserver.config.util.XStreamPersister$CoverageInfoConverter
version : 2.8.1

···

On 28 January 2016 at 10:51, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Thu, Jan 28, 2016 at 9:58 AM, César Martínez Izquierdo <cesar.izq@anonymised.com> wrote:

I’ve seen a similar problem on mailing lists [3] and tried the @class workaround with no success (the error message looks different anyway).

@class? Not sure what you mean.
Do you have the full stack trace for your error?

Judging by the error, it could be related to the XXE vulnerability fix, and might require someone
to add the GridGeometry2D class to the de-serialization whilelist here:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/config/util/XStreamPersister.java#L467

Cheers
Andrea

==
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 Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
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.



César Martínez Izquierdo
GIS developer


Blog: http://geotechnotes.wordpress.com/
ETC-SIA: http://sia.eionet.europa.eu/
Universitat Autònoma de Barcelona (SPAIN)