Allon Mureinik has uploaded a new change for review.

Change subject: core: Remove VdcActionParameterBase.httpSessionId
......................................................................

core: Remove VdcActionParameterBase.httpSessionId

httpSessionId in VdcActionParameterBase is a private field that isn't
initialized in the constructor and has no set method. I.e., it is always
null.

Since it's actually a constant, there is no reason to hold it. This
patch removes the field and all its references. That refactoring, in
turn allows cleaning up login and logout flows a bit, as they have code
that only fires when this member is not null.

Change-Id: I239d13175a511291def1eb31ce55be17f376bf42
Signed-off-by: Allon Mureinik <amure...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LoginBaseCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LogoutUserCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java
3 files changed, 4 insertions(+), 44 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/11732/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LoginBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LoginBaseCommand.java
index 1f201dd..e1ac856 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LoginBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LoginBaseCommand.java
@@ -1,7 +1,6 @@
 package org.ovirt.engine.core.bll;
 
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
@@ -14,8 +13,8 @@
 import org.ovirt.engine.core.bll.adbroker.LdapSearchByUserNameParameters;
 import org.ovirt.engine.core.bll.adbroker.UserAuthenticationResult;
 import org.ovirt.engine.core.bll.session.SessionDataContainer;
-import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.LoginResult;
 import org.ovirt.engine.core.common.action.LoginUserParameters;
@@ -27,7 +26,6 @@
 import org.ovirt.engine.core.common.users.VdcUser;
 import org.ovirt.engine.core.dal.VdcBllMessages;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
-import org.ovirt.engine.core.dal.dbbroker.user_sessions;
 import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
 
 public abstract class LoginBaseCommand<T extends LoginUserParameters> extends 
CommandBase<T> {
@@ -95,20 +93,6 @@
         log.errorFormat(getReturnValue().getCanDoActionMessages().get(0) + " : 
{0}", getParameters().getUserName());
     }
 
-    /**
-     * Handles the user session.
-     *
-     * @param ldapUser
-     *            The LDAP user.
-     */
-    protected void HandleUserSession(LdapUser ldapUser) {
-        if (!StringUtils.isEmpty(getParameters().getHttpSessionId())) {
-            user_sessions user_sessions = new user_sessions("", "", new 
Date(), "", getParameters()
-                    .getHttpSessionId(), ldapUser.getUserId());
-            DbFacade.getInstance().getDbUserDao().saveSession(user_sessions);
-        }
-    }
-
     public String getUserPassword() {
         return getParameters().getUserPassword();
     }
@@ -129,8 +113,6 @@
     @Override
     protected void executeCommand() {
         // add user session
-        // todo : insert correct values of all arguments, separate
-        HandleUserSession(ldapUser);
         setActionReturnValue(getCurrentUser());
         // Persist the most updated version of the user
         UserCommandBase.persistAuthenticatedUser(ldapUser);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LogoutUserCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LogoutUserCommand.java
index da82426..b0203cc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LogoutUserCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/LogoutUserCommand.java
@@ -9,7 +9,6 @@
 import org.ovirt.engine.core.common.action.LogoutUserParameters;
 import org.ovirt.engine.core.common.businessentities.DbUser;
 import org.ovirt.engine.core.common.users.VdcUser;
-import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 
 public class LogoutUserCommand<T extends LogoutUserParameters> extends 
CommandBase<T> {
@@ -28,12 +27,7 @@
 
     @Override
     protected void executeCommand() {
-        Guid userId = (getParameters()).getUserId();
-        String httpSessionId = getParameters().getHttpSessionId();
-        if (httpSessionId != null) {
-            
DbFacade.getInstance().getDbUserDao().removeUserSession(httpSessionId, userId);
-            SessionDataContainer.getInstance().removeSession(httpSessionId);
-        } else if (!"".equals(getParameters().getSessionId())) {
+        if (!"".equals(getParameters().getSessionId())) {
             
SessionDataContainer.getInstance().removeSession(getParameters().getSessionId());
         } else {
             SessionDataContainer.getInstance().removeSession();
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java
index c620478..e34f02c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java
@@ -12,7 +12,6 @@
 import org.ovirt.engine.core.common.utils.ValidationUtils;
 import org.ovirt.engine.core.common.validation.group.PreRun;
 import org.ovirt.engine.core.compat.Guid;
-import org.ovirt.engine.core.compat.StringHelper;
 import org.ovirt.engine.core.compat.TransactionScopeOption;
 
 public class VdcActionParametersBase implements java.io.Serializable {
@@ -21,7 +20,6 @@
     private Guid commandId;
     private transient String sessionid;
     private boolean shouldbelogged;
-    private String httpSessionId;
     private IVdcUser parametersCurrentUser;
     private TransactionScopeOption transctionOption;
 
@@ -77,22 +75,14 @@
     }
 
     public String getSessionId() {
-        if (StringHelper.isNullOrEmpty(sessionid)) {
-            if (getHttpSessionId() != null) {
-                sessionid = getHttpSessionId();
-            } else {
-                sessionid = "";
-            }
+        if (sessionid == null) {
+            sessionid = "";
         }
         return sessionid;
     }
 
     public void setSessionId(String value) {
         sessionid = value;
-    }
-
-    public String getHttpSessionId() {
-        return httpSessionId;
     }
 
     public IVdcUser getParametersCurrentUser() {
@@ -258,7 +248,6 @@
         result = prime * result + (shouldbelogged ? 1231 : 1237);
         result = prime * result + ((transctionOption == null) ? 0 : 
transctionOption.hashCode());
         result = prime * result + ((entityId == null) ? 0 : 
entityId.hashCode());
-        result = prime * result + ((httpSessionId == null) ? 0 : 
httpSessionId.hashCode());
         result = prime * result + (multipleAction ? 1231 : 1237);
         result = prime * result + ((parametersCurrentUser == null) ? 0 : 
parametersCurrentUser.hashCode());
         result = prime * result + ((parentCommand == null) ? 0 : 
parentCommand.hashCode());
@@ -290,11 +279,6 @@
             if (other.entityId != null)
                 return false;
         } else if (!entityId.equals(other.entityId))
-            return false;
-        if (httpSessionId == null) {
-            if (other.httpSessionId != null)
-                return false;
-        } else if (!httpSessionId.equals(other.httpSessionId))
             return false;
         if (multipleAction != other.multipleAction)
             return false;


--
To view, visit http://gerrit.ovirt.org/11732
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I239d13175a511291def1eb31ce55be17f376bf42
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amure...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to