Fixed Mapping Update API returned status 409 with duplicate project
* add receive Duplication exception in Mapping Update API and Threshold Update API. Change-Id: I722a81f9c090e3366cab4f07efa2fecc3c430fe1 Closes-bug: #1717487
This commit is contained in:
parent
b3ae81dc92
commit
aa0c15ea2b
@ -158,6 +158,8 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
group_id=mapping.group_id,
|
||||
tenant_id=mapping.tenant_id)
|
||||
pecan.response.headers['Location'] = pecan.request.path
|
||||
except db_api.MappingAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
except db_api.ClientHashMapError as e:
|
||||
|
@ -158,6 +158,8 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
group_id=threshold.group_id,
|
||||
tenant_id=threshold.tenant_id)
|
||||
pecan.response.headers['Location'] = pecan.request.path
|
||||
except db_api.ThresholdAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
except db_api.NoSuchThreshold as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
except db_api.ClientHashMapError as e:
|
||||
|
@ -432,6 +432,14 @@ class HashMap(api.HashMap):
|
||||
else:
|
||||
raise api.ClientHashMapError('No attribute to update.')
|
||||
return mapping_db
|
||||
except exception.DBDuplicateEntry:
|
||||
puuid = uuid
|
||||
ptype = 'Mapping_id'
|
||||
raise api.MappingAlreadyExists(
|
||||
value,
|
||||
puuid,
|
||||
ptype,
|
||||
tenant_id=kwargs.get('tenant_id'))
|
||||
except sqlalchemy.orm.exc.NoResultFound:
|
||||
raise api.NoSuchMapping(uuid)
|
||||
|
||||
@ -465,6 +473,14 @@ class HashMap(api.HashMap):
|
||||
else:
|
||||
raise api.ClientHashMapError('No attribute to update.')
|
||||
return threshold_db
|
||||
except exception.DBDuplicateEntry:
|
||||
puuid = uuid
|
||||
ptype = 'Threshold_id'
|
||||
raise api.ThresholdAlreadyExists(
|
||||
value,
|
||||
puuid,
|
||||
ptype,
|
||||
tenant_id=kwargs.get('tenant_id'))
|
||||
except sqlalchemy.orm.exc.NoResultFound:
|
||||
raise api.NoSuchThreshold(uuid)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user