[Geoserver-devel] [JIRA] (GEOS-7562) CoverageResource small fix/tweak to correctly detect new coverage/layer

carl created an issue

GeoServer / BugGEOS-7562

CoverageResource small fix/tweak to correctly detect new coverage/layer

Issue Type:

BugBug

Affects Versions:

2.8.3

Assignee:

Unassigned

Components:

REST

Created:

29/May/16 2:26 AM

Priority:

MediumMedium

Reporter:

carl

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:

/**

  • This method returns {@code true}

    in case we have POSTed a Coverage object with the name only, as an instance when configuring a new coverage which has just been harvested.

  • @param coverage
    *
    */
    private boolean isNewCoverage(CoverageInfo coverage) { return coverage.getName() != null && (coverage.isAdvertised()) && (!coverage.isEnabled()) && (coverage.getAlias() == null) && (coverage.getCRS() == null) && (coverage.getDefaultInterpolationMethod() == null) && (coverage.getDescription() == null) && (coverage.getDimensions() == null) && (coverage.getGrid() == null) && (coverage.getInterpolationMethods() == null) && (coverage.getKeywords() == null) && (coverage.getLatLonBoundingBox() == null) && (coverage.getMetadata() == null) && (coverage.getNativeBoundingBox() == null) && (coverage.getNativeCRS() == null) && (coverage.getNativeFormat() == null) && (coverage.getProjectionPolicy() == null) && (coverage.getSRS() == null) && (coverage.getResponseSRS() == null) && (coverage.getRequestSRS() == null); }

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

Add Comment

Add Comment

This message was sent by Atlassian JIRA (v1000.5.2#72002-sha1:b4422fe)

Atlassian logo