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

OO-1192: don't revalidate already validated import text, add commit and close...

OO-1192: don't revalidate already validated import text, add commit and close session in different place of the bulk import
parent 1c337921
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.olat.basesecurity.BaseSecurityManager;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.dispatcher.mapper.Mapper;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.ValidationError;
......@@ -129,6 +130,8 @@ class ImportStep00 extends BasicStep {
@Override
protected void formOK(UserRequest ureq) {
String inp = textAreaElement.getValue();
addToRunContext("inp", inp);
addToRunContext("idents", idents);
addToRunContext("newIdents", newIdents);
addToRunContext("updateIdents", updateIdents);
......@@ -144,7 +147,13 @@ class ImportStep00 extends BasicStep {
@Override
protected boolean validateFormLogic(UserRequest ureq) {
Object validatedInp = getFromRunContext("inp");
String inp = textAreaElement.getValue();
if(validatedInp != null && validatedInp.equals(inp)) {
//already validated
return true;
}
String defaultlang = I18nModule.getDefaultLocale().toString();
List<String> importedEmails = new ArrayList<String>();
......@@ -167,6 +176,11 @@ class ImportStep00 extends BasicStep {
Set<String> languages = I18nModule.getEnabledLanguageKeys();
String[] lines = inp.split("\r?\n");
for (int i = 0; i < lines.length; i++) {
if(i % 25 == 0) {
DBFactory.getInstance().commitAndCloseSession();
}
String line = lines[i];
if (line.equals("")) continue;
......@@ -441,5 +455,4 @@ class ImportStep00 extends BasicStep {
}
}
}
}
\ No newline at end of file
......@@ -36,6 +36,7 @@ import org.olat.basesecurity.AuthHelper;
import org.olat.basesecurity.Authentication;
import org.olat.basesecurity.BaseSecurity;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
......@@ -87,7 +88,8 @@ public class UserImportController extends BasicController {
private final BaseSecurity securityManager;
private final OLATAuthManager olatAuthManager;
private final BusinessGroupService businessGroupService;
private final UserManager um ;
private final UserManager um;
private final DB dbInstance;
/**
* @param ureq
......@@ -98,6 +100,7 @@ public class UserImportController extends BasicController {
public UserImportController(UserRequest ureq, WindowControl wControl, boolean canCreateOLATPassword) {
super(ureq, wControl);
um = UserManager.getInstance();
dbInstance = CoreSpringFactory.getImpl(DB.class);
securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
olatAuthManager = CoreSpringFactory.getImpl(OLATAuthManager.class);
businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
......@@ -241,11 +244,17 @@ public class UserImportController extends BasicController {
try {
if (runContext.containsKey("validImport") && ((Boolean) runContext.get("validImport")).booleanValue()) {
// create new users and persist
int count = 0;
@SuppressWarnings("unchecked")
List<TransientIdentity> newIdents = (List<TransientIdentity>) runContext.get("newIdents");
for (TransientIdentity newIdent:newIdents) {
doCreateAndPersistIdentity(newIdent, report);
if(++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commitAndCloseSession();
Boolean updateUsers = (Boolean)runContext.get("updateUsers");
Boolean updatePasswords = (Boolean)runContext.get("updatePasswords");
......@@ -253,7 +262,11 @@ public class UserImportController extends BasicController {
List<UpdateIdentity> updateIdents = (List<UpdateIdentity>) runContext.get("updateIdents");
for (UpdateIdentity updateIdent:updateIdents) {
doUpdateIdentity(updateIdent, updateUsers, updatePasswords, report);
if(++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commitAndCloseSession();
@SuppressWarnings("unchecked")
List<Long> ownGroups = (List<Long>) runContext.get("ownerGroups");
......
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