candlepin/candlepin — pull request #797 by mstead (2014-12-12 18:02:15+00:00)
Title: 1156576: Fix NPE on hypervisor checkin

The NPE was occuring if a request was made with an empty body.

This was fixed by checking for a null host to guest mapping
and throwing a BadRequestException. I had considered
equating the null data as an empty mapping and allowing
the request to succeed, but IMO the request should be
made with at least an empty mapping.

**Testing Instructions**
Consider no mapping provided an bad request, but an empty set is Ok.

No mapping provided:
```bash
$ curl -X POST -H "Content-Type: application/json" -k -u admin:admin -d "" https://localhost:8443/candlepin/hypervisors?owner=admin
{
"displayMessage" : "Host to guest mapping was not provided for hypervisor checkin.",
"requestUuid" : "c16dadca-ef0a-44b8-aefe-fe449962e645"
}
```

Empty mapping:
```bash
$ curl -X POST -H "Content-Type: application/json" -k -u admin:admin -d "{}" https://localhost:8443/candlepin/hypervisors?owner=admin
{
"created" : [ ],
"updated" : [ ],
"unchanged" : [ ],
"failedUpdate" : [ ]
}
```