Description of problem: When attempting to create an activation key using a name that has already been used, we get the following error: Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598 This seems like a common enough user error to warrant an error message that is easier to understand. Version-Release number of selected component (if applicable): [root@jsefler-onprem-62candlepin candlepin]# git show-ref | grep master 895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/heads/master 895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/remotes/origin/master How reproducible: Steps to Reproduce: [jsefler@jseflerT510 ~]$ curl -k --request POST --user testuser1:password --data '{"name":"DUPLICATE-KEY"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 108 272 100 272 0 24 586 51 --:--:-- --:--:-- --:--:-- 774 { "created": "2011-08-05T21:13:32.095+0000", "id": "8a90f8c63196bb2001319bcb38bf3a28", "name": "DUPLICATE-KEY", "owner": { "displayName": "Admin Owner", "href": "/owners/admin", "id": "8a90f8c63196bb20013196bb9e210006", "key": "admin" }, "pools": [], "updated": "2011-08-05T21:13:32.095+0000" } [jsefler@jseflerT510 ~]$ curl -k --request POST --user testuser1:password --data '{"name":"DUPLICATE-KEY"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 111 208 100 208 0 24 462 53 --:--:-- --:--:-- --:--:-- 611 { "displayMessage": "Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598" } [jsefler@jseflerT510 ~]$ Actual results: Expected results: Additional info:
Looks like it works now: [jmolet@jmolet ~]$ curl -k --request POST --user testuser1:password --data '{"name":"dupkey"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 282 100 265 100 17 560 35 --:--:-- --:--:-- --:--:-- 676 { "created": "2011-08-19T14:26:34.182+0000", "id": "8a90f8c631c3a8100131e26faa461187", "name": "dupkey", "owner": { "displayName": "Admin Owner", "href": "/owners/admin", "id": "8a90f8c631c3a8100131c3a899e90006", "key": "admin" }, "pools": [], "updated": "2011-08-19T14:26:34.182+0000" } [jmolet@jmolet ~]$ curl -k --request POST --user testuser1:password --data '{"name":"dupkey"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 102 100 85 100 17 242 48 --:--:-- --:--:-- --:--:-- 302 { "displayMessage": "Activation key name [dupkey] is already in use for owner [admin]" } [jmolet@jmolet ~]$ curl -k --request GET --user testuser1:password https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/status | python -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 48 100 48 0 0 142 0 --:--:-- --:--:-- --:--:-- 187 { "release": "1", "result": true, "version": "0.4.10" } marking VERIFIED