CoverageResource small fix/tweak to correctly detect new coverage/layer
Description
I think there is a small fix than can be done in the isNewCoverage method in org/geoserver/catalog/rest/CoverageResource.java. This is the current implementation:
I think that method should also check for empty (not null) metadata and keywords.
For example, geoserver manager send those elements as empty tags, so they are parse and created as empty list and not null lists in CoverageInfo object. So with the current implementation, if we try to create a new coverage/layer, only providing name / nativeCoverageName, it's not recognized as "new" because metadata and keywords are empty list, and not null values, so values of the coverage/layer are not properly set.
An easy way to check, if you use this will create and incomplete coverage/layer curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<coverage><metadata /><keywords /><metadataLinks /><supportedFormats /><name>test</name><nativeCoverageName>test</nativeCoverageName></coverage>" http://localhost:8080/geoserver/rest/workspaces/test/coveragestores/rasters/coverages.xml
I think there is a small fix than can be done in the isNewCoverage method in org/geoserver/catalog/rest/CoverageResource.java. This is the current implementation:
I think that method should also check for empty (not null) metadata and keywords.
For example, geoserver manager send those elements as empty tags, so they are parse and created as empty list and not null lists in CoverageInfo object. So with the current implementation, if we try to create a new coverage/layer, only providing name / nativeCoverageName, it's not recognized as "new" because metadata and keywords are empty list, and not null values, so values of the coverage/layer are not properly set.
An easy way to check, if you use this will create and incomplete coverage/layer
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<coverage><metadata /><keywords /><metadataLinks /><supportedFormats /><name>test</name><nativeCoverageName>test</nativeCoverageName></coverage>" http://localhost:8080/geoserver/rest/workspaces/test/coveragestores/rasters/coverages.xml
And this will create a coverage/layer with the values properly set
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<coverage><name>test</name><nativeCoverageName>test</nativeCoverageName></coverage>" http://localhost:8080/geoserver/rest/workspaces/test/coveragestores/rasters/coverages.xml