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

OO-1615: break circular dependency of ldap beans

parent 3d148321
No related branches found
No related tags found
No related merge requests found
...@@ -149,8 +149,6 @@ public class LDAPLoginModule extends AbstractSpringModule { ...@@ -149,8 +149,6 @@ public class LDAPLoginModule extends AbstractSpringModule {
private Scheduler scheduler; private Scheduler scheduler;
@Autowired @Autowired
private BaseSecurity securityManager; private BaseSecurity securityManager;
@Autowired
private LDAPLoginManager ldapManager;
@Autowired @Autowired
public LDAPLoginModule(CoordinatorManager coordinatorManager) { public LDAPLoginModule(CoordinatorManager coordinatorManager) {
...@@ -240,22 +238,6 @@ public class LDAPLoginModule extends AbstractSpringModule { ...@@ -240,22 +238,6 @@ public class LDAPLoginModule extends AbstractSpringModule {
log.warn("Server Certificate will expire in less than 30 days."); log.warn("Server Certificate will expire in less than 30 days.");
} }
} }
// Check ldap connection
if (ldapManager.bindSystem() == null) {
// don't disable ldap, maybe just a temporary problem, but still report
// problem in logfile
log.error("LDAP connection test failed during module initialization, edit config or contact network administrator");
} else {
log.info("LDAP login is enabled");
}
// Sync LDAP Users on Startup
if (isLdapSyncOnStartup()) {
initStartSyncJob();
} else {
log.info("LDAP start sync is disabled");
}
// Start LDAP cron sync job // Start LDAP cron sync job
if (isLdapSyncCronSync()) { if (isLdapSyncCronSync()) {
...@@ -273,19 +255,6 @@ public class LDAPLoginModule extends AbstractSpringModule { ...@@ -273,19 +255,6 @@ public class LDAPLoginModule extends AbstractSpringModule {
// //
} }
/**
* Internal helper to sync users right away
* @param ldapManager
*/
private void initStartSyncJob() {
LDAPError errors = new LDAPError();
if (ldapManager.doBatchSync(errors, true)) {
log.info("LDAP start sync: users synced");
} else {
log.warn("LDAP start sync error: " + errors.get());
}
}
/** /**
* Internal helper to initialize the cron syncer job * Internal helper to initialize the cron syncer job
*/ */
......
...@@ -65,6 +65,8 @@ import org.olat.core.util.StringHelper; ...@@ -65,6 +65,8 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.WorkThreadInformations; import org.olat.core.util.WorkThreadInformations;
import org.olat.core.util.coordinate.Coordinator; import org.olat.core.util.coordinate.Coordinator;
import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.CoordinatorManager;
import org.olat.core.util.event.FrameworkStartedEvent;
import org.olat.core.util.event.FrameworkStartupEventChannel;
import org.olat.core.util.event.GenericEventListener; import org.olat.core.util.event.GenericEventListener;
import org.olat.core.util.mail.MailHelper; import org.olat.core.util.mail.MailHelper;
import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroup;
...@@ -130,6 +132,7 @@ public class LDAPLoginManagerImpl implements LDAPLoginManager, GenericEventListe ...@@ -130,6 +132,7 @@ public class LDAPLoginManagerImpl implements LDAPLoginManager, GenericEventListe
this.coordinator = coordinatorManager.getCoordinator(); this.coordinator = coordinatorManager.getCoordinator();
this.taskExecutorManager = taskExecutorManager; this.taskExecutorManager = taskExecutorManager;
coordinator.getEventBus().registerFor(this, null, ldapSyncLockOres); coordinator.getEventBus().registerFor(this, null, ldapSyncLockOres);
FrameworkStartupEventChannel.registerForStartupEvent(this);
} }
@Override @Override
...@@ -145,6 +148,36 @@ public class LDAPLoginManagerImpl implements LDAPLoginManager, GenericEventListe ...@@ -145,6 +148,36 @@ public class LDAPLoginManagerImpl implements LDAPLoginManager, GenericEventListe
} else if(LDAPEvent.DO_FULL_SYNCHING.equals(event.getCommand())) { } else if(LDAPEvent.DO_FULL_SYNCHING.equals(event.getCommand())) {
doHandleBatchSync(true); doHandleBatchSync(true);
} }
} else if(event instanceof FrameworkStartedEvent) {
try {
init();
} catch (Exception e) {
log.error("", e);
}
}
}
private void init() {
if(ldapLoginModule.isLDAPEnabled()) {
if (bindSystem() == null) {
// don't disable ldap, maybe just a temporary problem, but still report
// problem in logfile
log.error("LDAP connection test failed during module initialization, edit config or contact network administrator");
} else {
log.info("LDAP login is enabled");
}
// Start LDAP cron sync job
if (ldapLoginModule.isLdapSyncCronSync()) {
LDAPError errors = new LDAPError();
if (doBatchSync(errors, true)) {
log.info("LDAP start sync: users synced");
} else {
log.warn("LDAP start sync error: " + errors.get());
}
} else {
log.info("LDAP cron sync is disabled");
}
} }
} }
......
...@@ -197,19 +197,19 @@ public class LDAPAdminController extends BasicController implements GenericEvent ...@@ -197,19 +197,19 @@ public class LDAPAdminController extends BasicController implements GenericEvent
* wizard finish callback called after "finish" is called * wizard finish callback called after "finish" is called
*/ */
StepRunnerCallback finishCallback = new StepRunnerCallback() { StepRunnerCallback finishCallback = new StepRunnerCallback() {
public Step execute(UserRequest ureq, WindowControl control, StepsRunContext runContext) { public Step execute(UserRequest uureq, WindowControl control, StepsRunContext runContext) {
hasIdentitiesToDeleteAfterRun = ((Boolean) runContext.get("hasIdentitiesToDelete")).booleanValue(); hasIdentitiesToDeleteAfterRun = ((Boolean) runContext.get("hasIdentitiesToDelete")).booleanValue();
if (hasIdentitiesToDeleteAfterRun) { if (hasIdentitiesToDeleteAfterRun) {
List<Identity> identitiesToDelete = (List<Identity>) runContext.get("identitiesToDelete"); List<Identity> idToDelete = (List<Identity>) runContext.get("identitiesToDelete");
amountUsersToDelete = identitiesToDelete.size(); amountUsersToDelete = idToDelete.size();
// Delete all identities now and tell everybody that // Delete all identities now and tell everybody that
// we are finished // we are finished
ldapLoginManager.deletIdentities(identitiesToDelete); ldapLoginManager.deletIdentities(idToDelete);
return StepsMainRunController.DONE_MODIFIED; return StepsMainRunController.DONE_MODIFIED;
} else { } else {
return StepsMainRunController.DONE_UNCHANGED; return StepsMainRunController.DONE_UNCHANGED;
} }
// otherwhise return without deleting anything // otherwise return without deleting anything
} }
}; };
......
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