Skip to content
Snippets Groups Projects
Commit ca6fe707 authored by srosse's avatar srosse
Browse files

OO-3175: make sure to reload the identity which was edited

parent 40d91cce
No related branches found
No related tags found
No related merge requests found
......@@ -216,13 +216,14 @@ public class UserAdminMainController extends MainLayoutBasicController implement
}
} else if (source == userAdminCtr) {
if (event == Event.BACK_EVENT) {
Identity editedIdentity = userAdminCtr.getEditedIdentity();
removeAsListenerAndDispose(userAdminCtr);
userAdminCtr = null;
// update data model of content controller when of type user search
// to display correct values of identity
if (contentCtr instanceof UsermanagerUserSearchController) {
UsermanagerUserSearchController userSearchCtr = (UsermanagerUserSearchController) contentCtr;
userSearchCtr.reloadFoundIdentity();
userSearchCtr.reloadFoundIdentity(editedIdentity);
addToHistory(ureq, userSearchCtr);
}
content.setContent(contentCtr.getInitialComponent());
......
......@@ -172,6 +172,10 @@ public class UserAdminController extends BasicController implements Activateable
putInitialPanel(new Panel("empty"));
}
}
public Identity getEditedIdentity() {
return myIdentity;
}
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
......
......@@ -38,7 +38,6 @@ import java.util.Set;
import org.olat.admin.user.bulkChange.UserBulkChangeManager;
import org.olat.admin.user.bulkChange.UserBulkChangeStep00;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityManager;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.basesecurity.Constants;
import org.olat.basesecurity.PermissionOnResourceable;
......@@ -46,7 +45,6 @@ import org.olat.basesecurity.SecurityGroup;
import org.olat.basesecurity.events.SingleIdentityChosenEvent;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.PersistenceHelper;
import org.olat.core.commons.services.webdav.WebDAVModule;
import org.olat.core.commons.services.webdav.manager.WebDAVAuthManager;
......@@ -87,7 +85,6 @@ import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.id.context.StateMapped;
import org.olat.core.logging.AssertException;
import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
import org.olat.core.util.StringHelper;
import org.olat.core.util.mail.ContactList;
......@@ -131,7 +128,6 @@ public class UsermanagerUserSearchController extends BasicController implements
private List<Identity> identitiesList, selectedIdentities;
private List<String> notUpdatedIdentities = new ArrayList<String>();
private ExtendedIdentitiesTableDataModel tdm;
private Identity foundIdentity = null;
private ContactFormController contactCtr;
private Link backFromMail;
private Link backFromList;
......@@ -330,7 +326,6 @@ public class UsermanagerUserSearchController extends BasicController implements
foundIdentites.add(found);
initUserListCtr(ureq, foundIdentites, 0);
}
foundIdentity = found;
fireEvent(ureq, new SingleIdentityChosenEvent(found));
}
}
......@@ -431,7 +426,6 @@ public class UsermanagerUserSearchController extends BasicController implements
* @return List of identities that match the criterias from the search form
*/
private List<Identity> findIdentitiesFromSearchForm() {
BaseSecurity secMgr = BaseSecurityManager.getInstance();
// get user attributes from form
String login = searchform.getStringValue("login");
// when searching for deleted users, add wildcard to match with backup prefix
......@@ -465,27 +459,27 @@ public class UsermanagerUserSearchController extends BasicController implements
// get group memberships from form
List<SecurityGroup> groupsList = new ArrayList<SecurityGroup>();
if (searchform.getRole("admin")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_ADMIN);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
groupsList.add(group);
}
if (searchform.getRole("author")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_AUTHORS);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
groupsList.add(group);
}
if (searchform.getRole("groupmanager")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("usermanager")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_USERMANAGERS);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("oresmanager")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER);
groupsList.add(group);
}
if (searchform.getRole("poolmanager")) {
SecurityGroup group = secMgr.findSecurityGroupByName(Constants.GROUP_POOL_MANAGER);
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_POOL_MANAGER);
groupsList.add(group);
}
......@@ -507,7 +501,7 @@ public class UsermanagerUserSearchController extends BasicController implements
Date userLoginAfter = searchform.getUserLoginAfter();
// now perform power search
List<Identity> myIdentities = secMgr.getIdentitiesByPowerSearch((login.equals("") ? null : login), userPropertiesSearch, true, groups,
List<Identity> myIdentities = securityManager.getIdentitiesByPowerSearch((login.equals("") ? null : login), userPropertiesSearch, true, groups,
permissionOnResources, authProviders, createdAfter, createdBefore, userLoginAfter, userLoginBefore, status);
return myIdentities;
......@@ -542,7 +536,7 @@ public class UsermanagerUserSearchController extends BasicController implements
String actionid = te.getActionId();
if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_SELECTUSER)) {
int rowid = te.getRowId();
foundIdentity = tdm.getObject(rowid);
Identity foundIdentity = tdm.getObject(rowid);
// Tell parentController that a subject has been found
fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
} else if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_VCARD)) {
......@@ -671,10 +665,9 @@ public class UsermanagerUserSearchController extends BasicController implements
*/
private void reloadDataModel(UserRequest ureq) {
if (identitiesList == null) return;
BaseSecurity secMgr = BaseSecurityManager.getInstance();
for (int i = 0; i < identitiesList.size(); i++) {
Identity ident = identitiesList.get(i);
Identity refrshed = secMgr.loadIdentityByKey(ident.getKey());
Identity refrshed = securityManager.loadIdentityByKey(ident.getKey());
identitiesList.set(i, refrshed);
}
initUserListCtr(ureq, identitiesList, null);
......@@ -686,20 +679,24 @@ public class UsermanagerUserSearchController extends BasicController implements
* activated user table list model. The identity will be reloaded from the
* database to have accurate values.
*/
public void reloadFoundIdentity() {
if (foundIdentity == null) throw new AssertException("reloadFoundIdentity called but foundIdentity is null");
// reload the found identity
foundIdentity = (Identity) DBFactory.getInstance().loadObject(foundIdentity);
// replace the found identity in the table list model to display changed
// values
List identities = tdm.getObjects();
PersistenceHelper.replaceObjectInListByKey(identities, foundIdentity);
public void reloadFoundIdentity(Identity editedIdentity) {
if(editedIdentity == null) return;//nothing to replace
List<Identity> identities = tdm.getObjects();
int index = identities.indexOf(editedIdentity);
if(index >= 0) {
// reload the found identity
Identity reloadedIdentity = securityManager.loadIdentityByKey(editedIdentity.getKey());
// replace the found identity in the table list model to display changed
identities.set(index, reloadedIdentity);
}
}
/**
*
* @see org.olat.core.gui.control.DefaultController#doDispose(boolean)
*/
@Override
protected void doDispose() {
//
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment