[Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:

curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”

Actually, POST on coverages is supposed to create a new coverage:

···

/workspaces//coveragestores//coverages[.]

Controls all coverages in a given coverage store and workspace.



Method



Action



Status code



Formats



Default Format



GET



List all coverages in coverage store cs



200



HTML, XML, JSON



HTML



POST



Create a new coverage



201 with Locationheader



XML, JSON







PUT







405











DELETE







405

Once the coverage is created, then you can no longer POST to it, only PUT, which is shown in the table you pasted in your response.

The error I am getting trying to POST a new coverage (which should be allowed by the API) is:

500 Internal Server Error

“:Resource native name must not be null”

Thanks,
Scott

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Friday, October 21, 2016 11:35 AM
To: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:

curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”



GET



Return coveragec



200



HTML, XML, JSON



HTML



quietOnNotFound



POST







405















PUT



Modify coverage c



200



XML,JSON











DELETE



Delete coveragec



200











recurse

Scott,

Sorry yes. I got a bit mixed up between your step 1 and step 2. Let me look at it again.

Bryan

···

On 10/21/16 1:56 PM, Ellis, Scott wrote:

Actually, POST on coverages is supposed to create a new coverage:

From: http://docs.geoserver.org/stable/en/user/rest/api/coverages.html

/workspaces//coveragestores//coverages[.]

Controls all coverages in a given coverage store and workspace.



Method



Action



Status code



Formats



Default Format



GET



List all coverages in coverage store cs



200



HTML, XML, JSON



HTML



POST



Create a new coverage



201 with Locationheader



XML, JSON







PUT







405











DELETE







405



Once the coverage is created, then you can no longer POST to it, only PUT, which is shown in the table you pasted in your response.

The error I am getting trying to POST a new coverage (which should be allowed by the API) is:

500 Internal Server Error

“:Resource native name must not be null”

Thanks,
Scott

From: Bryan Moore [mailto:bryan@anonymised.com]
Sent: Friday, October 21, 2016 11:35 AM
To: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:

curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”



GET



Return coveragec



200



HTML, XML, JSON



HTML



quietOnNotFound



POST







405















PUT



Modify coverage c



200



XML,JSON











DELETE



Delete coveragec



200











recurse

Thanks a lot for taking a look. Can you reproduce the issue?

The problem is at: org.geoserver.catalog.CatalogBuilder.java:989

cinfo.setNativeCoverageName(coverageName);

Because coverageName is null in this case.

I found I can at least work around the 500 Server Error by changing the REST call to the following:

curl -X POST –u admin:geoserver -H “Content-Type: application/json” -d '{

“coverage”: {

“name”: “rest_test_01”,

“nativeCoverageName”: “sfdem”

}

}

’ “http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json

But this workaround has two problems. A REST client should not need to know the correct nativeCoverageName to make this request work. Also, GeoServer does not honor the supplied name for the new coverage/layer, instead it uses the nativeCoverageName, e.g. the new coverage/layer is called “test:sfdem” in this case.

It’s starting to seem like a bug in GeoServer to me but I could be wrong. Any help or insight is very much appreciated.

Thanks,

Scott

···

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Friday, October 21, 2016 12:04 PM
To: Ellis, Scott (U.S. Person); geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

Sorry yes. I got a bit mixed up between your step 1 and step 2. Let me look at it again.

Bryan

On 10/21/16 1:56 PM, Ellis, Scott wrote:

Actually, POST on coverages is supposed to create a new coverage:

From: http://docs.geoserver.org/stable/en/user/rest/api/coverages.html

/workspaces//coveragestores//coverages[.]

Controls all coverages in a given coverage store and workspace.



Method



Action



Status code



Formats



Default Format



GET



List all coverages in coverage store cs



200



HTML, XML, JSON



HTML



POST



Create a new coverage



201 with Locationheader



XML, JSON







PUT







405











DELETE







405

Once the coverage is created, then you can no longer POST to it, only PUT, which is shown in the table you pasted in your response.

The error I am getting trying to POST a new coverage (which should be allowed by the API) is:

500 Internal Server Error

“:Resource native name must not be null”

Thanks,
Scott

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Friday, October 21, 2016 11:35 AM
To: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:
 
curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”



GET



Return coveragec



200



HTML, XML, JSON



HTML



quietOnNotFound



POST







405















PUT



Modify coverage c



200



XML,JSON











DELETE



Delete coveragec



200











recurse

Scott,

Yes I was able to reproduce it using your example and several other methods, same error.

I also found this interesting:

From 2.8.0 documentation: http://docs.geoserver.org/2.8.0/user/rest/examples/curl.html
vs
From 2.9.0 documentation: http://docs.geoserver.org/2.9.0/user/rest/examples/curl.html

Compare the section: Creating an empty mosaic and harvest granules in each version.

2.8.0

Where coverageconfig.xml may look like this

<coverage>
  <name>NO2</name>
</coverage>

2.9.0

Where coverageconfig.xml may look like this

<coverage>
  <nativeCoverageName>NO2</nativeCoverageName>
  <name>NO2</name>
</coverage>
···

On 10/21/16 8:16 PM, Ellis, Scott wrote:

Thanks a lot for taking a look. Can you reproduce the issue?

The problem is at: org.geoserver.catalog.CatalogBuilder.java:989

cinfo.setNativeCoverageName(coverageName);

Because coverageName is null in this case.

I found I can at least work around the 500 Server Error by changing the REST call to the following:

curl -X POST –u admin:geoserver -H “Content-Type: application/json” -d '{

“coverage”: {

“name”: “rest_test_01”,

“nativeCoverageName”: “sfdem”

}

}

“http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json”

But this workaround has two problems. A REST client should not need to know the correct nativeCoverageName to make this request work. Also, GeoServer does not honor the supplied name for the new coverage/layer, instead it uses the nativeCoverageName, e.g. the new coverage/layer is called “test:sfdem” in this case.

It’s starting to seem like a bug in GeoServer to me but I could be wrong. Any help or insight is very much appreciated.

Thanks,

Scott

From: Bryan Moore [mailto:bryan@anonymised.com]
Sent: Friday, October 21, 2016 12:04 PM
To: Ellis, Scott (U.S. Person); geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

Sorry yes. I got a bit mixed up between your step 1 and step 2. Let me look at it again.

Bryan

On 10/21/16 1:56 PM, Ellis, Scott wrote:

Actually, POST on coverages is supposed to create a new coverage:

From: http://docs.geoserver.org/stable/en/user/rest/api/coverages.html

/workspaces//coveragestores//coverages[.]

Controls all coverages in a given coverage store and workspace.



Method



Action



Status code



Formats



Default Format



GET



List all coverages in coverage store cs



200



HTML, XML, JSON



HTML



POST



Create a new coverage



201 with Locationheader



XML, JSON







PUT







405











DELETE







405



Once the coverage is created, then you can no longer POST to it, only PUT, which is shown in the table you pasted in your response.

The error I am getting trying to POST a new coverage (which should be allowed by the API) is:

500 Internal Server Error

“:Resource native name must not be null”

Thanks,
Scott

From: Bryan Moore [mailto:bryan@anonymised.com]
Sent: Friday, October 21, 2016 11:35 AM
To: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:
 
curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”



GET



Return coveragec



200



HTML, XML, JSON



HTML



quietOnNotFound



POST







405















PUT



Modify coverage c



200



XML,JSON











DELETE



Delete coveragec



200











recurse

Interesting find, thanks.

I still don’t understand why the onus is on the client to know the nativeCoverageName in order to make the request work. The nativeCoverageName is computed by the Reader from the source file name. Why would a REST client be required to know the implementation details of how that name was computed?

In any case, publishing the coverage with a supplied name still does not work because of this bug:

https://osgeo-org.atlassian.net/browse/GEOS-7631

Andrea, do you have any insight on these issues?

Thanks,

Scott

···

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Monday, October 24, 2016 8:40 AM
To: Ellis, Scott (U.S. Person); geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

Yes I was able to reproduce it using your example and several other methods, same error.

I also found this interesting:

From 2.8.0 documentation: http://docs.geoserver.org/2.8.0/user/rest/examples/curl.html
vs
From 2.9.0 documentation: http://docs.geoserver.org/2.9.0/user/rest/examples/curl.html

Compare the section: Creating an empty mosaic and harvest granules in each version.

2.8.0

Where coverageconfig.xml may look like this

<coverage>
  <name>NO2</name>
</coverage>

2.9.0

Where coverageconfig.xml may look like this

**<coverage>**
  **<nativeCoverageName>**NO2**</nativeCoverageName>**
  **<name>**NO2**</name>**
**</coverage>**

On 10/21/16 8:16 PM, Ellis, Scott wrote:

Thanks a lot for taking a look. Can you reproduce the issue?

The problem is at: org.geoserver.catalog.CatalogBuilder.java:989

cinfo.setNativeCoverageName(coverageName);

Because coverageName is null in this case.

I found I can at least work around the 500 Server Error by changing the REST call to the following:

curl -X POST –u admin:geoserver -H “Content-Type: application/json” -d '{

“coverage”: {

“name”: “rest_test_01”,

“nativeCoverageName”: “sfdem”

}

}

“http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json”

But this workaround has two problems. A REST client should not need to know the correct nativeCoverageName to make this request work. Also, GeoServer does not honor the supplied name for the new coverage/layer, instead it uses the nativeCoverageName, e.g. the new coverage/layer is called “test:sfdem” in this case.

It’s starting to seem like a bug in GeoServer to me but I could be wrong. Any help or insight is very much appreciated.

Thanks,

Scott

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Friday, October 21, 2016 12:04 PM
To: Ellis, Scott (U.S. Person); geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

Sorry yes. I got a bit mixed up between your step 1 and step 2. Let me look at it again.

Bryan

On 10/21/16 1:56 PM, Ellis, Scott wrote:

Actually, POST on coverages is supposed to create a new coverage:

From: http://docs.geoserver.org/stable/en/user/rest/api/coverages.html

/workspaces//coveragestores//coverages[.]

Controls all coverages in a given coverage store and workspace.



Method



Action



Status code



Formats



Default Format



GET



List all coverages in coverage store cs



200



HTML, XML, JSON



HTML



POST



Create a new coverage



201 with Locationheader



XML, JSON







PUT







405











DELETE







405

Once the coverage is created, then you can no longer POST to it, only PUT, which is shown in the table you pasted in your response.

The error I am getting trying to POST a new coverage (which should be allowed by the API) is:

500 Internal Server Error

“:Resource native name must not be null”

Thanks,
Scott

From: Bryan Moore [mailto:bryan@…4527…]
Sent: Friday, October 21, 2016 11:35 AM
To: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] Trouble adding coverage through REST

Scott,

However, the second step of adding the coverage, e.g.:
 
curl -X POST -u admin:geoserver -H "Content-Type: application/json" -d '{
  "coverage": {
    "name": "rest_test_01"
  }
}
' "[http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json"](http://myhost:8080/geoserver/rest/workspaces/test/coveragestores/rest_test_01/coverages.json%22);

The problem is that POST on coverages as shown in http://docs.geoserver.org/stable/en/user/rest/api/coverages.html returns a 405 which is “Method not allowed”



GET



Return coveragec



200



HTML, XML, JSON



HTML



quietOnNotFound



POST







405















PUT



Modify coverage c



200



XML,JSON











DELETE



Delete coveragec



200











recurse

On Mon, Oct 24, 2016 at 6:36 PM, Ellis, Scott <SELLIS06@anonymised.com> wrote:

Andrea, do you have any insight on these issues?

Meh, I don't like very much being called out directly given that I had no
involvement in this (the thread, the
particular REST code in question, the documentation about it), if any core
developer wants to participate to the thread
they can, we all see the mails going on the list and can (and should) be
able to decide if we want to participate.

Probably no one bothered to look into this because a discussion on devel is
supposed to be about
the software development, not the usage, and there was no clear offer to
fix the code so far (a developer
here is someone that contributes to GeoServer, not someone that, while
being a developer on his own, uses it).
Not saying the issue is not valid, it certainly looks like it is, but
someone just looking for confirmation
of a bug can ask on the users list.

If you believe this is a harsh response, consider we're up to our eyeballs
of work, way too many users,
not enough active devs, and there is a lot of people trying to get direct
attention without contributing back squat, so, while I cannot
speak about others, I've become exceptionally sensitive to attempts of
pulling me by the jacket.

In any case, I have checked the history of CoverageResource and there is a
commit that seems
to relate to the topic of discussion:. History here:
https://github.com/geoserver/geoserver/commits/master/src/restconfig/src/main/java/org/geoserver/catalog/rest/CoverageResource.java
In particular, "GEOS-6874 Resolve conflation of catalog and native coverage
names."

Now, Kevin might want to chime in here (or not!) :-p

Regards
Andrea

PS: the one commit of mine in that history is there due to our shallow
github history, it just happens
to be the first one in the part of history migrated from svn to github.
The rest of the history of that class is here:
https://github.com/geoserver/geoserver-history/commits/master/src/restconfig/src/main/java/org/geoserver/catalog/rest/CoverageResource.java

--

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.

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

On Mon, Oct 24, 2016 at 7:18 PM, Andrea Aime <andrea.aime@anonymised.com>
wrote:

Probably no one bothered to look into this because a discussion on devel
is supposed to be about
the software development, not the usage, and there was no clear offer to
fix the code so far (a developer
here is someone that contributes to GeoServer, not someone that, while
being a developer on his own, uses it).
Not saying the issue is not valid, it certainly looks like it is, but
someone just looking for confirmation
of a bug can ask on the users list.

Mind, if you don't have plans to provide a fix for it you might still want
to open a ticket, we have a bug fix
sprint once a month, eventually it might get picked up (the sooner if you
can show it's a regression, e.g.,
used to work with an older version of GeoServer).

Regards
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 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.

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