You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "Qiang Zhang (JIRA)" <ji...@apache.org> on 2017/03/08 03:32:38 UTC

[jira] [Created] (RANGER-1432) Do some code improvement in UserMgr.java

Qiang Zhang created RANGER-1432:
-----------------------------------

             Summary: Do some code improvement in UserMgr.java
                 Key: RANGER-1432
                 URL: https://issues.apache.org/jira/browse/RANGER-1432
             Project: Ranger
          Issue Type: Bug
          Components: admin
    Affects Versions: 1.0.0
            Reporter: Qiang Zhang
            Assignee: Qiang Zhang
             Fix For: 1.0.0


In UserMgr.java, there are some duplicate logic.
1. At the beginning of method gjUserToUserProfile, we have already checked if sess is null, so we don't need to check it again in below codes.
{code}
UserSessionBase sess = ContextUtil.getCurrentUserSession();
if (sess == null) {
	return;
}
if (sess != null) {
	userProfile.setUserSource(sess.getAuthProvider());
} 
{code}
2. In method setUserRoles, it should be 'vStringRolesList' instead of 'vString' in comment.
{code}
/**
	 * @param userId
	 * @param vStrings
	 */
	public void setUserRoles(Long userId, List<VXString> vStringRolesList)
{code}
3. In method deactivateUser, it should be 'gjUser' instead of 'userId' in comment.
{code}
/**
	 * @param userId
	 */
	public VXPortalUser deactivateUser(XXPortalUser gjUser)
{code}
4. In method gjUserToUserProfile, below validation appears twice. 
{code}
if (sess.isUserAdmin() || sess.isKeyAdmin()
				|| sess.getXXPortalUser().getId().equals(user.getId())) {
			userProfile.setLoginId(user.getLoginId());
}
if (sess.isUserAdmin() || sess.isKeyAdmin()
				|| sess.getXXPortalUser().getId().equals(user.getId())) {
			userProfile.setId(user.getId());

}
{code}
IMO, we can put them together.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)