mneethiraj commented on code in PR #726:
URL: https://github.com/apache/ranger/pull/726#discussion_r2487677632
##########
security-admin/src/main/java/org/apache/ranger/service/RangerBaseModelService.java:
##########
@@ -313,15 +313,15 @@ protected V populateViewBean(T entityObj) {
}
protected T populateEntityBeanForCreate(T entityObj, V vObj) {
+ XXPortalUser createdByUser =
daoMgr.getXXPortalUser().findByLoginId(vObj.getCreatedBy());
Review Comment:
`ContextUtil.getCurrentUserId()` would not be null in Kerberos environments;
in this case, avoid unnecessary calls to DB to retrieve `XPortalUser`. Consider
the following:
```
if (!populateExistingBaseFields) {
Long addedByUserId = ContextUtil.getCurrentUserId();
if (addedByUserId == null) {
XXPortalUser createdByUser =
daoMgr.getXXPortalUser().findByLoginId(vObj.getCreatedBy());
if (createdByUser != null) {
addedByUserId = createdByUser.getId();
}
}
entityObj.setCreateTime(DateUtil.getUTCDate());
entityObj.setUpdateTime(entityObj.getCreateTime());
entityObj.setAddedByUserId(addedByUserId);
entityObj.setUpdatedByUserId(entityObj.getAddedByUserId());
} else {
...
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]