REST API implementation for setting defaults violates Catalog API

Description

The REST API implementation of handleObjectPut for NamespaceResource and WorkspaceResource has an odd implementation for case of setting the default value.
It passes a partial (name / prefix set, everything else null, including Id) Info object to catalog.setDefault[Workspace/Namespace]:

https://github.com/geoserver/geoserver/blob/master/src/restconfig/src/main/java/org/geoserver/catalog/rest/NamespaceResource.java#L88
https://github.com/geoserver/geoserver/blob/master/src/restconfig/src/main/java/org/geoserver/catalog/rest/WorkspaceResource.java#L121

Just looking at the CatalogInfo / CatalogFacade interfaces, the behaviour for this is undefined, but the implication is that you should be passing valid Catalig objects to the CatalogFacade method.

Looking at the implementation, it appears this only works because there is a special case hardcoded in to handle it:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/DefaultCatalogFacade.java#L645
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/DefaultCatalogFacade.java#L744

The REST API implementation should be fixed.

Environment

None

Status

Assignee

Torben Barsballe

Reporter

Torben Barsballe

Triage

Fix versions

Affects versions

None

Components

Priority

Medium
Configure