Gilad Chaplik has uploaded a new change for review. Change subject: frontend: login: split user@domain ......................................................................
frontend: login: split user@domain Split will occur iff second part of split of last occurance of '@' will outcome in a string that exists in domain list. Change-Id: Ie74a9b0d74b081c4966a26a5d9de1598c91fac51 Bug-Url: https://bugzilla.redhat.com/1112252 Signed-off-by: Gilad Chaplik <gchap...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/LoginModel.java 1 file changed, 33 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/29613/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/LoginModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/LoginModel.java index 9658255..81753d5 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/LoginModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/LoginModel.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models; +import java.util.Collection; import java.util.List; import org.ovirt.engine.core.common.action.VdcReturnValueBase; @@ -213,28 +214,43 @@ if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition) && sender == getUserName()) { - userName_EntityChanged(); + userNameChanged(); } } - private void userName_EntityChanged() - { - getDomain().setIsChangable(getDomainAvailability()); + private void userNameChanged() { + String typedDomain = getTypedDomain(); + if (typedDomain == null) { + getDomain().setIsChangable(true); + } else { + getDomain().setSelectedItem(typedDomain); + getDomain().setIsChangable(false); + } } - private boolean getDomainAvailability() - { - // Check whether the user name contains domain part. - boolean hasDomain = getUserNameParts(getUserName().getEntity())[1] != null; - - return !hasDomain; + /** + * @return domain part iff it contains in available domains + */ + private String getTypedDomain() { + String typedDomain = getUserNameParts(getUserName().getEntity())[1]; + if (typedDomain != null) { + Collection<String> domains = getDomain().getItems(); + if (domains != null) { + for (String domain : domains) { + if (domain.equals(typedDomain)) { + return domain; + } + } + } + } + return null; } private String[] getUserNameParts(String value) { if (!StringHelper.isNullOrEmpty(value)) { - int index = value.indexOf('@'); + int index = value.lastIndexOf('@'); // Always return array of two elements representing user name and domain.) return new String[] { index > -1 ? value.substring(0, index) : value, @@ -256,8 +272,11 @@ disableLoginScreen(); String fullUserName = getUserName().getEntity(); - String[] parts = getUserNameParts(fullUserName); - String domain = parts[1]; + String user = fullUserName; + String domain = getTypedDomain(); + if (domain != null) { + user = getUserNameParts(fullUserName)[0]; + } AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { @@ -292,7 +311,7 @@ } } }; - Frontend.getInstance().loginAsync(fullUserName, getPassword().getEntity(), + Frontend.getInstance().loginAsync(user, getPassword().getEntity(), StringHelper.isNullOrEmpty(domain) ? getDomain().getSelectedItem() : domain, true, _asyncQuery); } -- To view, visit http://gerrit.ovirt.org/29613 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie74a9b0d74b081c4966a26a5d9de1598c91fac51 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches