Skip to content

Conversation

@Sanket-Shelar
Copy link
Contributor

…' and 'updated by' fields

What changes were proposed in this pull request?

When grant policy is created created by and updated by is empty as it is trying to get the details from ContextUtil.getCurrentUserId() method which in case of non kerbores environment is giving null.
Update the condition to fetch user from database.

How was this patch tested?

Local build.
Ran grant command for a table and policy is created with created by and updated by field populated.

}

protected T populateEntityBeanForCreate(T entityObj, V vObj) {
XXPortalUser createdByUser = daoMgr.getXXPortalUser().findByLoginId(vObj.getCreatedBy());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
    ...
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants