diff --git a/src/main/java/de/bps/_spring/bpsContext.xml b/src/main/java/de/bps/_spring/bpsContext.xml index 87a9a8ae3ea86c6ef0f4798137d921e434fd2bf7..6955dc42123194074ae345f311aed52e11dd023e 100644 --- a/src/main/java/de/bps/_spring/bpsContext.xml +++ b/src/main/java/de/bps/_spring/bpsContext.xml @@ -1,9 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + <context:component-scan base-package="de.bps.onyx.plugin" /> <import resource="classpath:/de/bps/course/nodes/cl/_spring/buildingblockContext.xml"/> <import resource="classpath:/de/bps/course/nodes/den/_spring/buildingblockContext.xml"/> diff --git a/src/main/java/de/bps/onyx/plugin/OnyxModule.java b/src/main/java/de/bps/onyx/plugin/OnyxModule.java index f4ef0034160b360e6982b5068c2b5ab507c42141..af5ef3a7d164def770e095addecd41457b021337 100644 --- a/src/main/java/de/bps/onyx/plugin/OnyxModule.java +++ b/src/main/java/de/bps/onyx/plugin/OnyxModule.java @@ -37,9 +37,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.io.IOUtils; -import org.olat.core.configuration.AbstractOLATModule; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.configuration.ConfigOnOff; -import org.olat.core.configuration.PersistedProperties; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.OLATRuntimeException; @@ -47,6 +46,7 @@ import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.PathUtils; import org.olat.core.util.ZipUtil; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.course.nodes.QTICourseNode; import org.olat.course.run.scoring.ScoreEvaluation; import org.olat.fileresource.types.ResourceEvaluation; @@ -57,34 +57,43 @@ import org.olat.ims.qti.fileresource.TestFileResource; import org.olat.ims.qti.process.ImsRepositoryResolver; import org.olat.ims.qti.process.Resolver; import org.olat.modules.assessment.model.AssessmentEntryStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * @author Ingmar Kroll */ -public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { +@Service("onyxModule") +public class OnyxModule extends AbstractSpringModule implements ConfigOnOff { private static final OLog log = Tracing.createLoggerFor(OnyxModule.class); - private static String onyxPluginWSLocation; + @Value("${onyx.plugin.wslocation}") + private String onyxPluginWSLocation; public static ArrayList<PlayerTemplate> PLAYERTEMPLATES; /* * holds the local config name which is sent to the remote onyxplugin -> onyxplugin must have a config corresponding to this name */ - private static String configName; + @Value("${onyx.plugin.configname}") + private String configName; // <OLATCE-713> - private static String onyxUserViewLocation; - private static String onyxReporterUserViewLocation; + @Value("${onyx.plugin.userviewlocation}") + private String onyxUserViewLocation; + @Value("${onyx.reporter.userviewlocation}") + private String onyxReporterUserViewLocation; // </OLATCE-713> - private static String onyxExamModeLocation; + @Value("${onyx.plugin.exammodelocation}") + private String onyxExamModeLocation; + @Value("${assessmentplugin.activate}") private String assessmentPlugin; private static Map<Long,Boolean> onyxMap = new ConcurrentHashMap<Long,Boolean>(); - /** - * [used by spring] - */ - private OnyxModule() { - // + + @Autowired + public OnyxModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } @Override @@ -95,7 +104,7 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { /** * @return Returns the configName. */ - public static String getConfigName() { + public String getConfigName() { return configName; } @@ -103,14 +112,14 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { * @param configName The configName to set. */ public void setConfigName(final String configName) { - OnyxModule.configName = configName; + this.configName = configName; } /** * @param pluginWSLocation The pluginWSLocation to set. */ public void setOnyxPluginWSLocation(final String onyxPluginWSLocation) { - OnyxModule.onyxPluginWSLocation = onyxPluginWSLocation; + this.onyxPluginWSLocation = onyxPluginWSLocation; } /** @@ -118,13 +127,13 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { * The location of the onyx exam mode */ public void setOnyxExamModeLocation(String onyxExamModeLocation) { - OnyxModule.onyxExamModeLocation = onyxExamModeLocation; + this.onyxExamModeLocation = onyxExamModeLocation; } /** * @return Returns the userViewLocation. */ - public static String getUserViewLocation() { + public String getUserViewLocation() { // <OLATCE-713> return onyxUserViewLocation; // </OLATCE-713> @@ -133,14 +142,14 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { /** * @return Returns the pluginWSLocation. */ - public static String getPluginWSLocation() { + public String getPluginWSLocation() { return onyxPluginWSLocation + "/services"; } /** * @return The location of the Onyx Exam Mode */ - public static String getOnyxExamModeLocation() { + public String getOnyxExamModeLocation() { return onyxExamModeLocation; } @@ -161,21 +170,11 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { PLAYERTEMPLATES.add(pt); } - @Override - protected void initDefaultProperties() { - // - } - @Override protected void initFromChangedProperties() { // } - @Override - public void setPersistedProperties(final PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - public class PlayerTemplate { public String id; public String i18nkey; @@ -306,20 +305,20 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff { } // <OLATCE-713> - public static String getOnyxUserViewLocation() { + public String getOnyxUserViewLocation() { return onyxUserViewLocation; } public void setOnyxUserViewLocation(String onyxUserViewLocation) { - OnyxModule.onyxUserViewLocation = onyxUserViewLocation; + this.onyxUserViewLocation = onyxUserViewLocation; } - public static String getOnyxReporterUserViewLocation() { + public String getOnyxReporterUserViewLocation() { return onyxReporterUserViewLocation; } public void setOnyxReporterUserViewLocation(String onyxReporterUserViewLocation) { - OnyxModule.onyxReporterUserViewLocation = onyxReporterUserViewLocation; + this.onyxReporterUserViewLocation = onyxReporterUserViewLocation; } // </OLATCE-713> diff --git a/src/main/java/de/bps/onyx/plugin/_spring/onyxContext.xml b/src/main/java/de/bps/onyx/plugin/_spring/onyxContext.xml index 6e97636d725710d6674f5e9e8a099d1ce9aa9285..a2d626a2e08a3af500d76fa9b933e0b03641deb1 100644 --- a/src/main/java/de/bps/onyx/plugin/_spring/onyxContext.xml +++ b/src/main/java/de/bps/onyx/plugin/_spring/onyxContext.xml @@ -5,28 +5,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> -<bean id="onyxModule" class="de.bps.onyx.plugin.OnyxModule" depends-on="coordinatorManager"> - <property name="onyxPluginWSLocation" value="${onyx.plugin.wslocation}" /> - <!-- <OLATCE-713> --> - <property name="onyxUserViewLocation" value="${onyx.plugin.userviewlocation}" /> - <property name="onyxReporterUserViewLocation" value="${onyx.reporter.userviewlocation}" /> - <property name="onyxExamModeLocation" value="${onyx.plugin.exammodelocation}" /> - <property name="configName" value="${onyx.plugin.configname}" /> - <property name="assessmentPlugin" value="${assessmentplugin.activate}" /> - - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="onyxModule" /> - </bean> - </property> -</bean> - -<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="onyxModule" /> - <property name="targetMethod" value="init" /> -</bean> - <!-- update job for onyx results --> <bean id="updateQtiResultsTriggerOnyx" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="updateOnyxResults.${onyx.update.results.job}" /> diff --git a/src/main/java/de/bps/onyx/plugin/run/OnyxRunController.java b/src/main/java/de/bps/onyx/plugin/run/OnyxRunController.java index 9809d23b438bf54c05bcc57dc3bd580426b94108..8e03bf8b5f4b17f06efb17b6a375e688f48886f2 100644 --- a/src/main/java/de/bps/onyx/plugin/run/OnyxRunController.java +++ b/src/main/java/de/bps/onyx/plugin/run/OnyxRunController.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.WindowManager; import org.olat.core.gui.Windows; @@ -585,7 +586,7 @@ public class OnyxRunController extends BasicController { manager.controllExam(pool, identities, TestState.RESUME_REQUESTED); } - String onyxRunURL = OnyxModule.getUserViewLocation() + "?id=" + assessmentId; + String onyxRunURL = CoreSpringFactory.getImpl(OnyxModule.class).getUserViewLocation() + "?id=" + assessmentId; log.info(onyxRunURL); onyxPlugin.contextPut("urlonyxplugin", onyxRunURL); @@ -710,6 +711,8 @@ public class OnyxRunController extends BasicController { String tempalteId = "onyxdefault"; this.uniqueId = OnyxResultManager.getUniqueIdForShowOnly(ureq.getIdentity(), entry); + + OnyxModule onyxModule = CoreSpringFactory.getImpl(OnyxModule.class); java.io.FileInputStream inp = null; try { @@ -718,7 +721,7 @@ public class OnyxRunController extends BasicController { byte[] byteArray = new byte[fileLength.intValue()]; inp = new java.io.FileInputStream(cpFile); inp.read(byteArray); - onyxplugin.run(this.uniqueId, byteArray, language, "", tempalteId, OnyxModule.getConfigName(), true); + onyxplugin.run(this.uniqueId, byteArray, language, "", tempalteId, onyxModule.getConfigName(), true); } catch (FileNotFoundException e) { log.error("Cannot find CP of Onyx Test with assassmentId: " + uniqueId, e); } catch (IOException e) { @@ -733,7 +736,7 @@ public class OnyxRunController extends BasicController { } } - String urlonyxplugin = OnyxModule.getUserViewLocation() + "?id=" + this.uniqueId; + String urlonyxplugin = onyxModule.getUserViewLocation() + "?id=" + this.uniqueId; onyxPlugin = createVelocityContainer("onyxstart"); onyxPlugin.contextPut("isSurvey", Boolean.FALSE); diff --git a/src/main/java/de/bps/onyx/plugin/wsclient/OnyxExamMode.java b/src/main/java/de/bps/onyx/plugin/wsclient/OnyxExamMode.java index a88871b878f3db37bdccf341153aaa8a433a206a..3fcdc904849dae8a257fe4f6db3b3f387f410ed2 100644 --- a/src/main/java/de/bps/onyx/plugin/wsclient/OnyxExamMode.java +++ b/src/main/java/de/bps/onyx/plugin/wsclient/OnyxExamMode.java @@ -27,6 +27,8 @@ import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebEndpoint; +import org.olat.core.CoreSpringFactory; + import de.bps.onyx.plugin.OnyxModule; public class OnyxExamMode extends Service { @@ -36,12 +38,13 @@ public class OnyxExamMode extends Service { static { URL url = null; + String location = CoreSpringFactory.getImpl(OnyxModule.class).getOnyxExamModeLocation(); try { URL baseUrl; baseUrl = de.bps.onyx.plugin.wsclient.OnyxExamMode.class.getResource("."); - url = new URL(baseUrl, OnyxModule.getOnyxExamModeLocation() + "?wsdl"); + url = new URL(baseUrl, location + "?wsdl"); } catch (MalformedURLException e) { - logger.warning("Failed to create URL for the wsdl Location: '" + OnyxModule.getOnyxExamModeLocation() + "?wsdl', retrying as a local file"); + logger.warning("Failed to create URL for the wsdl Location: '" + location + "?wsdl', retrying as a local file"); logger.warning(e.getMessage()); } EXAM_SERVICE_WSDL_LOCATION = url; diff --git a/src/main/java/de/bps/onyx/plugin/wsclient/PluginService.java b/src/main/java/de/bps/onyx/plugin/wsclient/PluginService.java index 72d50a889b3452fc1648144017b4538207bf9e43..49d59e49d32f9a2db0fa726cc579f38462e18459 100644 --- a/src/main/java/de/bps/onyx/plugin/wsclient/PluginService.java +++ b/src/main/java/de/bps/onyx/plugin/wsclient/PluginService.java @@ -29,6 +29,8 @@ import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceFeature; +import org.olat.core.CoreSpringFactory; + import de.bps.onyx.plugin.OnyxModule; /** @@ -42,12 +44,13 @@ public class PluginService extends Service { static { URL url = null; + String location = CoreSpringFactory.getImpl(OnyxModule.class).getPluginWSLocation(); try { URL baseUrl; baseUrl = de.bps.onyx.plugin.wsclient.PluginService.class.getResource("."); - url = new URL(baseUrl, OnyxModule.getPluginWSLocation() + "?wsdl"); + url = new URL(baseUrl, location + "?wsdl"); } catch (final MalformedURLException e) { - logger.warning("Failed to create URL for the wsdl Location: '" + OnyxModule.getPluginWSLocation() + "?wsdl', retrying as a local file"); + logger.warning("Failed to create URL for the wsdl Location: '" + location + "?wsdl', retrying as a local file"); logger.warning(e.getMessage()); } PLUGINSERVICE_WSDL_LOCATION = url; diff --git a/src/main/java/de/bps/onyx/util/ExamPool.java b/src/main/java/de/bps/onyx/util/ExamPool.java index fa98e9335f7c6c2557045fe86e4d1228fc7ed978..1b50b09d6d20394f1fddf914d723b839034268fa 100644 --- a/src/main/java/de/bps/onyx/util/ExamPool.java +++ b/src/main/java/de/bps/onyx/util/ExamPool.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.io.IOUtils; +import org.olat.core.CoreSpringFactory; import org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; @@ -83,8 +84,6 @@ public class ExamPool implements Serializable { private final Long testSessionId; - private final static String providerId = OnyxModule.getConfigName(); - // private final Boolean sessionInitializied; private transient final OnyxExamModeService service; @@ -148,6 +147,7 @@ public class ExamPool implements Serializable { MapWrapper wrapper = new MapWrapper(); wrapper.setMap(parameterMap); + String providerId = CoreSpringFactory.getImpl(OnyxModule.class).getConfigName(); Long result = service.registerTest(testSessionId, providerId, contentPackage, wrapper); log.info("Init result : " + TestState.getState(result) + " for " + testSessionId + " , provider " + providerId + " and parameters " + parameterMap); } else { diff --git a/src/main/java/de/bps/webservices/clients/onyxreporter/OnyxReporterConnector.java b/src/main/java/de/bps/webservices/clients/onyxreporter/OnyxReporterConnector.java index 64ff6669cdc2678dac31c155b3d0ccf968fb50c3..529e9546442afdbfce64ba1a6e50b85637180cfd 100644 --- a/src/main/java/de/bps/webservices/clients/onyxreporter/OnyxReporterConnector.java +++ b/src/main/java/de/bps/webservices/clients/onyxreporter/OnyxReporterConnector.java @@ -39,6 +39,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import org.apache.commons.io.IOUtils; +import org.olat.core.CoreSpringFactory; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.id.UserConstants; @@ -219,7 +220,8 @@ public class OnyxReporterConnector { if (assessmentId != null) { underlyingMap.put("assessmentID", String.valueOf(assessmentId)); } - underlyingMap.put("providerID", OnyxModule.getConfigName()); + String providerID = CoreSpringFactory.getImpl(OnyxModule.class).getConfigName(); + underlyingMap.put("providerID", providerID); mapWrapper.setMap(underlyingMap); } diff --git a/src/main/java/org/olat/_spring/mainContext.xml b/src/main/java/org/olat/_spring/mainContext.xml index 4e81fe8d93421ea523c5c7106bcf94ea0c95c7ef..006d5322469901e64ec1b8a25dceb44e5b084aa4 100644 --- a/src/main/java/org/olat/_spring/mainContext.xml +++ b/src/main/java/org/olat/_spring/mainContext.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - <context:component-scan base-package="org.olat.note" /> + <context:component-scan base-package="org.olat.note,org.olat.social" /> <import resource="classpath:/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml"/> <import resource="classpath:/org/olat/core/_spring/mainCorecontext.xml"/> @@ -48,7 +48,6 @@ <import resource="classpath:/org/olat/restapi/_spring/restApiContext.xml"/> <import resource="classpath:/org/olat/search/_spring/searchContext.xml"/> <import resource="classpath:/org/olat/shibboleth/_spring/shibbolethContext.xml"/> - <import resource="classpath:/org/olat/social/_spring/socialContext.xml"/> <import resource="classpath:/org/olat/upgrade/_spring/databaseUpgradeContext.xml"/> <import resource="classpath:/org/olat/upgrade/_spring/upgradeContext.xml"/> diff --git a/src/main/java/org/olat/admin/_spring/adminContext.xml b/src/main/java/org/olat/admin/_spring/adminContext.xml index 19475c58e10269df0ae7214dbf7e1b68a9139caf..6914b8bcc292bb232a189692ffafe39ef9ba13ae 100644 --- a/src/main/java/org/olat/admin/_spring/adminContext.xml +++ b/src/main/java/org/olat/admin/_spring/adminContext.xml @@ -12,7 +12,6 @@ <import resource="classpath:/org/olat/admin/jmx/_spring/jmxContext.xml"/> <import resource="classpath:/org/olat/admin/landingpages/_spring/landingPagesContext.xml"/> - <import resource="classpath:/org/olat/admin/registration/_spring/registrationContext.xml"/> <import resource="classpath:/org/olat/admin/sysinfo/_spring/sysinfoContext.xml"/> <import resource="classpath:/org/olat/admin/user/tools/_spring/userToolsContext.xml"/> diff --git a/src/main/java/org/olat/admin/layout/LayoutAdminController.java b/src/main/java/org/olat/admin/layout/LayoutAdminController.java index 9dde82c70c8f7becba313237cbade0df886ac9ac..347fba5aa7f7d5ba596edf5284c5897cf4cc0195 100644 --- a/src/main/java/org/olat/admin/layout/LayoutAdminController.java +++ b/src/main/java/org/olat/admin/layout/LayoutAdminController.java @@ -43,6 +43,7 @@ import org.olat.core.gui.components.link.Link; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; +import org.olat.core.helpers.GUISettings; import org.olat.core.helpers.Settings; import org.olat.core.util.StringHelper; import org.olat.core.util.Util; @@ -76,6 +77,8 @@ public class LayoutAdminController extends FormBasicController { private static final String[] logoUrlTypeKeys = new String[]{ LogoURLType.landingpage.name(), LogoURLType.custom.name() }; + @Autowired + private GUISettings guiSettings; @Autowired private LayoutModule layoutModule; @Autowired @@ -102,7 +105,7 @@ public class LayoutAdminController extends FormBasicController { themeCont.setFormDescription(translate("layout.intro")); String[] keys = getThemes(); - String enabledTheme = Settings.getGuiThemeIdentifyer(); + String enabledTheme = guiSettings.getGuiThemeIdentifyer(); themeSelection = uifactory.addDropdownSingleselect("themeSelection", "form.theme", themeCont, keys, keys, null); // select current theme if available but don't break on unavailable theme for (String theme : keys) { @@ -238,7 +241,7 @@ public class LayoutAdminController extends FormBasicController { } else if(themeSelection == source) { // set new theme in Settings String newThemeIdentifyer = themeSelection.getSelectedKey(); - Settings.setGuiThemeIdentifyerGlobally(newThemeIdentifyer); + guiSettings.setGuiThemeIdentifyer(newThemeIdentifyer); // use new theme in current window getWindowControl().getWindowBackOffice().getWindow().getGuiTheme().init(newThemeIdentifyer); getWindowControl().getWindowBackOffice().getWindow().setDirty(true); diff --git a/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java b/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java index b1d317cde49f2b68e357b8ebab966c0ef3c5617d..6c9f9583256fa752b7a1dd65be5d267f27502ee7 100644 --- a/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java +++ b/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java @@ -50,11 +50,10 @@ import org.olat.basesecurity.PermissionOnResourceable; import org.olat.basesecurity.SecurityGroup; import org.olat.core.CoreSpringFactory; import org.olat.core.commons.persistence.DB; -import org.olat.core.configuration.Destroyable; -import org.olat.core.configuration.Initializable; import org.olat.core.helpers.Settings; import org.olat.core.id.Identity; -import org.olat.core.manager.BasicManager; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; import org.olat.core.util.httpclient.HttpClientFactory; import org.olat.core.util.i18n.I18nModule; @@ -68,6 +67,10 @@ import org.quartz.CronTrigger; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerException; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Description:<br> @@ -80,73 +83,42 @@ import org.quartz.SchedulerException; * @author gnaegi */ -public class SystemRegistrationManager extends BasicManager implements Initializable, Destroyable { +@Service +public class SystemRegistrationManager implements InitializingBean { + + private static final OLog log = Tracing.createLoggerFor(SystemRegistrationManager.class); private static final String SCHEDULER_NAME = "system.registration"; private static final String TRIGGER = "system_registration_trigger"; public static final String PRODUCT = "openolat"; - private final SystemRegistrationModule registrationModule; - private final Scheduler scheduler; - private final String clusterMode; - private final DB database; + @Value("${cluster.mode}") + private String clusterMode; + + @Autowired + private DB database; + @Autowired + private Scheduler scheduler; + @Autowired private RepositoryManager repositoryManager; + @Autowired private BaseSecurity securityManager; + @Autowired private BusinessGroupService businessGroupService; + @Autowired + private SystemRegistrationModule registrationModule; private static final String REGISTRATION_SERVER = "http://registration.openolat.org/registration/restapi/registration/openolat"; //private static final String REGISTRATION_SERVER = "http://localhost:8083/registration/restapi/registration/openolat"; - /** - * [used by spring] - * Use getInstance(), this is a singleton - */ - private SystemRegistrationManager(Scheduler scheduler, String clusterMode, DB database, SystemRegistrationModule registrationModule) { - this.scheduler = scheduler; - this.clusterMode = clusterMode; - this.database = database; - this.registrationModule = registrationModule; - } - /** * Initialize the configuration */ - public void init() { + @Override + public void afterPropertiesSet() throws Exception { setupRegistrationBackgroundThread(); } - /** - * Call this to shutdown the cron scheduler and remove cluster event listeners - * from the PersistedProperties infrastructure - */ - public void destroy() { - // - } - - /** - * [used by Spring] - * @param repositoryManager - */ - public void setRepositoryManager(RepositoryManager repositoryManager) { - this.repositoryManager = repositoryManager; - } - - /** - * [used by Spring] - * @param securityManager - */ - public void setSecurityManager(BaseSecurity securityManager) { - this.securityManager = securityManager; - } - - /** - * [used by Spring] - * @param businessGroupService - */ - public void setBusinessGroupService(BusinessGroupService businessGroupService) { - this.businessGroupService = businessGroupService; - } - /** * Helper method to create a cron trigger expression. The method makes sure * that not every olat installation submits at the same time @@ -201,7 +173,7 @@ public class SystemRegistrationManager extends BasicManager implements Initializ try { scheduler.triggerJob(SCHEDULER_NAME, Scheduler.DEFAULT_GROUP); } catch (SchedulerException e) { - logError("", e); + log.error("", e); } } @@ -240,20 +212,20 @@ public class SystemRegistrationManager extends BasicManager implements Initializ HttpResponse response = client.execute(method); int status = response.getStatusLine().getStatusCode(); if(status == HttpStatus.SC_CREATED) { - logInfo("Successfully registered OLAT installation on openolat.org server, thank you for your support!", null); + log.info("Successfully registered OLAT installation on openolat.org server, thank you for your support!", null); String registrationKey = EntityUtils.toString(response.getEntity()); registrationModule.setSecretKey(registrationKey); } else if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED) { - logInfo("Successfully registered OLAT installation on openolat.org server, thank you for your support!", null); + log.info("Successfully registered OLAT installation on openolat.org server, thank you for your support!", null); } else if (status == HttpStatus.SC_NOT_FOUND) { - logError("Registration server not found: " + response.getStatusLine().toString(), null); + log.error("Registration server not found: " + response.getStatusLine().toString(), null); } else if(status == HttpStatus.SC_NO_CONTENT){ - logInfo(EntityUtils.toString(response.getEntity()), response.getStatusLine().toString()); + log.info(EntityUtils.toString(response.getEntity()), response.getStatusLine().toString()); } else { - logError("Unexpected HTTP Status: " + response.getStatusLine().toString() + " during registration call", null); + log.error("Unexpected HTTP Status: " + response.getStatusLine().toString() + " during registration call", null); } } catch (Exception e) { - logError("Unexpected exception during registration call", e); + log.error("Unexpected exception during registration call", e); } finally { database.commitAndCloseSession(); if(method != null) { @@ -356,10 +328,10 @@ public class SystemRegistrationManager extends BasicManager implements Initializ // Schedule job now scheduler.scheduleJob(jobDetail, trigger); } catch (ParseException e) { - logError("Illegal cron expression for system registration", e); + log.error("Illegal cron expression for system registration", e); } catch (SchedulerException e) { - logError("Can not start system registration scheduler", e); + log.error("Can not start system registration scheduler", e); } - logInfo("Registration background job successfully started: "+cronExpression, null); + log.info("Registration background job successfully started: "+cronExpression, null); } } \ No newline at end of file diff --git a/src/main/java/org/olat/admin/registration/SystemRegistrationModule.java b/src/main/java/org/olat/admin/registration/SystemRegistrationModule.java index 2dfad593ac85cb56e317d8a62c4ec7f03234641a..523a9a5ee55e32ee9ad08aff2318dceb41c25837 100644 --- a/src/main/java/org/olat/admin/registration/SystemRegistrationModule.java +++ b/src/main/java/org/olat/admin/registration/SystemRegistrationModule.java @@ -21,9 +21,11 @@ package org.olat.admin.registration; import java.util.UUID; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * @@ -34,7 +36,8 @@ import org.olat.core.util.StringHelper; * * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com */ -public class SystemRegistrationModule extends AbstractOLATModule { +@Service +public class SystemRegistrationModule extends AbstractSpringModule { protected static final String CONF_KEY_PUBLISH_WEBSITE = "publishWebsite"; protected static final String CONF_KEY_WEBSITE_DESCRIPTION = "websiteDescription"; @@ -58,6 +61,11 @@ public class SystemRegistrationModule extends AbstractOLATModule { private String locationCoordinates; private String secretKey; private String instanceIdentifier; + + @Autowired + public SystemRegistrationModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + } @Override public void init() { @@ -97,25 +105,10 @@ public class SystemRegistrationModule extends AbstractOLATModule { instanceIdentifier = instanceIdentifierObj; } else { instanceIdentifier = UUID.randomUUID().toString(); - moduleConfigProperties.setStringProperty(CONF_KEY_IDENTIFYER, instanceIdentifier, true); + setStringProperty(CONF_KEY_IDENTIFYER, instanceIdentifier, true); } } - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - - @Override - protected void initDefaultProperties() { - publishWebsite = getBooleanConfigParameter(CONF_KEY_PUBLISH_WEBSITE, false); - websiteDescription = getStringConfigParameter(CONF_KEY_WEBSITE_DESCRIPTION, "", true); - notifyReleases = getBooleanConfigParameter(CONF_KEY_NOTIFY_RELEASES, false); - email = getStringConfigParameter(CONF_KEY_EMAIL, "", false); - location = getStringConfigParameter(CONF_KEY_LOCATION, "", false); - locationCoordinates = getStringConfigParameter(CONF_KEY_LOCATION_COORDS, "", false); - } - @Override protected void initFromChangedProperties() { init(); @@ -180,14 +173,4 @@ public class SystemRegistrationModule extends AbstractOLATModule { public void setLocationCoordinates(String locationCoordinates) { setStringProperty(CONF_KEY_LOCATION_COORDS, locationCoordinates, true); } - - - - - - - - - - } diff --git a/src/main/java/org/olat/admin/registration/_spring/registrationContext.xml b/src/main/java/org/olat/admin/registration/_spring/registrationContext.xml deleted file mode 100644 index 4a85d11eacfd5a91f7f36c947a3dc7e23125a974..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/admin/registration/_spring/registrationContext.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <bean id="systemRegistrationModule" class="org.olat.admin.registration.SystemRegistrationModule" - init-method="init" depends-on="coordinatorManager"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="systemRegistrationModule"/> - </bean> - </property> - </bean> - - <bean id="systemRegistrationManager" class="org.olat.admin.registration.SystemRegistrationManager" - init-method="init" destroy-method="destroy" depends-on="systemRegistrationModule"> - <constructor-arg index="0" ref="schedulerFactoryBean"/> - <constructor-arg index="1" value="${cluster.mode}"/> - <constructor-arg index="2" ref="database"/> - <constructor-arg index="3" ref="systemRegistrationModule"/> - <property name="securityManager" ref="baseSecurityManager" /> - <property name="repositoryManager" ref="repositoryManager" /> - <property name="businessGroupService" ref="businessGroupService" /> - </bean> -</beans> \ No newline at end of file diff --git a/src/main/java/org/olat/admin/setup/SetupModule.java b/src/main/java/org/olat/admin/setup/SetupModule.java new file mode 100644 index 0000000000000000000000000000000000000000..677d08ddf07c85bd8f2e6afa24c06c22307e5c8f --- /dev/null +++ b/src/main/java/org/olat/admin/setup/SetupModule.java @@ -0,0 +1,327 @@ +package org.olat.admin.setup; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.olat.basesecurity.BaseSecurity; +import org.olat.basesecurity.Constants; +import org.olat.basesecurity.SecurityGroup; +import org.olat.core.commons.persistence.DBFactory; +import org.olat.core.helpers.Settings; +import org.olat.core.id.Identity; +import org.olat.core.logging.OLATRuntimeException; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; +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.course.CourseFactory; +import org.olat.course.DeployableCourseExport; +import org.olat.properties.Property; +import org.olat.properties.PropertyManager; +import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryManager; +import org.olat.repository.RepositoryService; +import org.olat.resource.OLATResource; +import org.olat.resource.OLATResourceManager; +import org.olat.user.DefaultUser; +import org.olat.user.UserImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +/** + * + * Initial date: 14.07.2016<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +@Service +public class SetupModule implements GenericEventListener { + + private static final OLog log = Tracing.createLoggerFor(SetupModule.class); + + @Value("${deploy.course.exports}") + private boolean deployCoursesEnabled; + @Autowired @Qualifier("deployedCourseList") + private ArrayList<DeployableCourseExport> deployableCourseExports; + + @Value("${user.generateTestUsers}") + private boolean hasTestUsers; + @Value("${default.auth.provider.identifier}") + private String authenticationProviderConstant; + + @Autowired @Qualifier("defaultUsers") + private ArrayList<DefaultUser> defaultUsers; + @Autowired @Qualifier("testUsers") + private ArrayList<DefaultUser> testUsers; + + private Map<String, RepositoryEntry> deployedCourses; + + @Autowired + private CourseFactory courseFactory; + @Autowired + private PropertyManager propertyManager; + @Autowired + private RepositoryService repositoryService; + @Autowired + private OLATResourceManager olatResourceManager; + @Autowired + private BaseSecurity securityManager; + + + @Autowired + public SetupModule(CoordinatorManager coordinatorManager) { + coordinatorManager.getCoordinator().getEventBus().registerFor(this, null, FrameworkStartupEventChannel.getStartupEventChannel()); + } + + /** + * Courses are deployed after the startup has completed. + * + */ + @Override + public void event(org.olat.core.gui.control.Event event) { + if (!Settings.isJUnitTest() && deployCoursesEnabled + && event instanceof FrameworkStartedEvent + && ((FrameworkStartedEvent) event).isEventOnThisNode()) { + // Deploy demo courses + log.info("Received FrameworkStartedEvent and is on same node, will start deploying demo courses..."); + deployCoursesFromCourseExportFiles(); + //also in startup event processing intermediateCommit + DBFactory.getInstance().intermediateCommit(); + } + + createDefaultUsers(); + DBFactory.getInstance().intermediateCommit(); + } + + private void createDefaultUsers() { + // read user editable fields configuration + if (defaultUsers != null) { + for (DefaultUser user:defaultUsers) { + createUser(user); + } + } + if (hasTestUsers) { + // read user editable fields configuration + if (testUsers != null) { + for (DefaultUser user :testUsers) { + createUser(user); + } + } + } + // Cleanup, otherwhise this subjects will have problems in normal OLAT + // operation + DBFactory.getInstance().commitAndCloseSession(); + } + + private void deployCoursesFromCourseExportFiles( ) { + log.info("Deploying course exports."); + for (DeployableCourseExport export: deployableCourseExports) { + if (0 < export.getAccess() && export.getAccess() < 5) { + if (deployCoursesEnabled) { + try { + deployCourse(export, export.getAccess()); + } catch (Exception e) { + log.warn("Skipping deployment of course::" + export.getIdentifier(), e); + } + DBFactory.getInstance().intermediateCommit(); + continue; + } + } else { + log.info("Skipping deployment of course::" + export.getIdentifier() + " ; access attribute must be 1,2,3 or 4 but values is::"+ export.getAccess()); + } + log.info("Skipping deployment of course::" + export.getIdentifier()); + } + if (!deployCoursesEnabled) { + log.info("Skipping deployment of demo course exports. To deploy course exports, please enable in the configuration file. Help course will always be deployed!"); + } + } + + private RepositoryEntry deployCourse(DeployableCourseExport export, int access) { + // let's see if we previously deployed demo courses... + + RepositoryEntry re = getDeployedCourses().get(export.getIdentifier()); + if (re != null) { + log.info("Course '" + export.getIdentifier() + "' has been previousely deployed. Skipping."); + return re; + } + + File file = export.getDeployableCourseZipFile(); + if (file != null && file.exists()) { + log.info("deploying Course: " + file.getName()); + if (!file.exists()) { + //do not throw exception as users may upload bad file + log.warn("Cannot deploy course from file: " + file.getAbsolutePath(),null); + return null; + } + re = CourseFactory.deployCourseFromZIP(file, null, access); + if (re != null) markAsDeployed(export, re); + return re; + } + return null; + } + + /** + * Mark a course as deployed. Remember the key of the repository entry it was + * deployed. + * + * @param courseExportPath + * @param re + */ + private void markAsDeployed(DeployableCourseExport export, RepositoryEntry re) { + List<Property> props = propertyManager.findProperties(null, null, null, "_o3_", "deployedCourses"); + Property prop = null; + for (Property property : props) { + if (property.getLongValue() == re.getKey()){ + prop = property; + } + } + if (prop == null) { + prop = propertyManager.createPropertyInstance(null, null, null, "_o3_", "deployedCourses", export.getVersion(), re.getKey(), export.getIdentifier(), null); + } + prop.setFloatValue(export.getVersion()); + prop.setStringValue(export.getIdentifier()); + propertyManager.saveProperty(prop); + deployedCourses.put(export.getIdentifier(), re); + } + + /** + * Get the Map of deployed courses. Map contains repo entries by path keys. + * + * @return + */ + private Map<String, RepositoryEntry> getDeployedCourses() { + if (deployedCourses != null) return deployedCourses; + List<?> props = propertyManager.findProperties(null, null, null, "_o3_", "deployedCourses"); + deployedCourses = new HashMap<String, RepositoryEntry>(props.size()); + for (Iterator<?> iter = props.iterator(); iter.hasNext();) { + Property prop = (Property) iter.next(); + Long repoKey = prop.getLongValue(); + RepositoryEntry re = null; + re = RepositoryManager.getInstance().lookupRepositoryEntry(repoKey); + if (re != null) { + //props with floatValue null are old entries - delete them. + if (prop.getFloatValue() == null) { + //those are courses deployed with the old mechanism, check, if they exist and what should be done with them: + //fxdiff: no delete! + log.info("This course was already deployed and has old property values. course: "+prop.getStringValue()); + for (DeployableCourseExport export: deployableCourseExports) { + if (export.getIdentifier().equals(prop.getStringValue())) { + log.info("found this old course in the deployable courses list"); + if (export.isRedeploy()){ + // found in deployableCourses again and it should be redeployed, therefore delete: + log.info("marked as to be redeployed, therefore delete first!"); + deleteCourseAndProperty(prop, re); + re = null; //do not add to deployed courses + } else { + log.info("no redeploy! just update its version."); + markAsDeployed(export, re); + } + } + } + } else { + //check if latest version if course is installed + for (DeployableCourseExport export: deployableCourseExports) { + if (export.getIdentifier().equals(prop.getStringValue()) && export.getVersion() > prop.getFloatValue() && export.isRedeploy()) { + //we have a newer version - delete the old course + log.info("There is a new version for this course available. Deleting it and redeploy course: "+prop.getStringValue()); + deleteCourseAndProperty(prop, re); + re = null; //do not add to deployed courses + break; + } + } + } + } + if (re != null) deployedCourses.put(prop.getStringValue(), re); + } + return deployedCourses; + } + + private void deleteCourseAndProperty(Property prop, RepositoryEntry re) { + try { + propertyManager.deleteProperty(prop); + repositoryService.deleteRepositoryEntryAndBaseGroups(re); + CourseFactory.deleteCourse(re, re.getOlatResource()); + OLATResource ores = olatResourceManager.findResourceable(re.getOlatResource()); + olatResourceManager.deleteOLATResource(ores); + } catch (Exception e) { + log.warn("Could not delete course and property of demo course with name: "+prop.getStringValue(), e); + } + } + + /** + * Method to create a user with the given configuration + * + * @return Identity or null + */ + protected Identity createUser(DefaultUser user) { + Identity identity; + identity = securityManager.findIdentityByName(user.getUserName()); + if (identity == null) { + // Create new user and subject + UserImpl newUser = new UserImpl(); + newUser.setFirstName(user.getFirstName()); + newUser.setLastName(user.getLastName()); + newUser.setEmail(user.getEmail()); + + newUser.getPreferences().setLanguage(user.getLanguage()); + newUser.getPreferences().setInformSessionTimeout(true); + + if (!StringUtils.hasText(authenticationProviderConstant)){ + throw new OLATRuntimeException(this.getClass(), "Auth token not set! Please fix! " + authenticationProviderConstant, null); + } + + // Now finally create that user thing on the database with all + // credentials, person etc. in one transation context! + identity = securityManager.createAndPersistIdentityAndUser(user.getUserName(), null, newUser, authenticationProviderConstant, + user.getUserName(), user.getPassword()); + if (identity == null) { + throw new OLATRuntimeException(this.getClass(), "Error, could not create user and subject with name " + user.getUserName(), null); + } else { + + if (user.isGuest()) { + SecurityGroup anonymousGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS); + securityManager.addIdentityToSecurityGroup(identity, anonymousGroup); + log .info("Created anonymous user " + user.getUserName()); + } else { + SecurityGroup olatuserGroup = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS); + + if (user.isAdmin()) { + SecurityGroup adminGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN); + securityManager.addIdentityToSecurityGroup(identity, adminGroup); + securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); + log .info("Created admin user " + user.getUserName()); + } else if (user.isAuthor()) { + SecurityGroup authorGroup = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS); + securityManager.addIdentityToSecurityGroup(identity, authorGroup); + securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); + log.info("Created author user " + user.getUserName()); + } else if (user.isUserManager()) { + SecurityGroup usermanagerGroup = securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS); + securityManager.addIdentityToSecurityGroup(identity, usermanagerGroup); + securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); + log .info("Created userManager user " + user.getUserName()); + } else if (user.isGroupManager()) { + SecurityGroup groupmanagerGroup = securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS); + securityManager.addIdentityToSecurityGroup(identity, groupmanagerGroup); + securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); + log .info("Created groupManager user " + user.getUserName()); + } else { + securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); + log .info("Created user " + user.getUserName()); + } + } + } + } + return identity; + } +} + diff --git a/src/main/java/org/olat/admin/version/VersionMaintenanceForm.java b/src/main/java/org/olat/admin/version/VersionMaintenanceForm.java index 67cfd623ca72edda436e47490631b58b159b1b92..af67f3dac6064c0f2e07f1540da1232a6aba2fed 100644 --- a/src/main/java/org/olat/admin/version/VersionMaintenanceForm.java +++ b/src/main/java/org/olat/admin/version/VersionMaintenanceForm.java @@ -203,8 +203,8 @@ public class VersionMaintenanceForm extends FormBasicController implements Progr taskExecutorManager.execute(new Runnable() { public void run() { waitASecond(); - Long numOfVersions = getNumOfVersions(); - versionsManager.pruneHistory(numOfVersions.longValue(), VersionMaintenanceForm.this); + int numOfVersions = getNumOfVersions(); + versionsManager.pruneHistory(numOfVersions, VersionMaintenanceForm.this); } }); @@ -225,7 +225,7 @@ public class VersionMaintenanceForm extends FormBasicController implements Progr } } - public Long getNumOfVersions() { + public int getNumOfVersions() { SimpleVersionConfig config = (SimpleVersionConfig) CoreSpringFactory.getBean(SimpleVersionConfig.class); return config.getMaxNumberOfVersionsProperty(); } diff --git a/src/main/java/org/olat/admin/version/VersionSettingsForm.java b/src/main/java/org/olat/admin/version/VersionSettingsForm.java index 3661dbf25fc34358a8bf92b1bcacc317182cf4d3..69dac4b6af731196061717160b43e71c74ce8c38 100644 --- a/src/main/java/org/olat/admin/version/VersionSettingsForm.java +++ b/src/main/java/org/olat/admin/version/VersionSettingsForm.java @@ -76,15 +76,13 @@ public class VersionSettingsForm extends FormBasicController { numOfVersions = uifactory.addDropdownSingleselect("version.numOfVersions", formLayout, keys, values, null); numOfVersions.addActionListener(FormEvent.ONCHANGE); - Long maxNumber = getNumOfVersions(); - if(maxNumber == null) { - numOfVersions.select("0", true); - } else if (maxNumber.longValue() == 0l) { + int maxNumber = getNumOfVersions(); + if (maxNumber == 0l) { numOfVersions.select("0", true); // deactivated - } else if (maxNumber.longValue() == -1l) { + } else if (maxNumber == -1l) { numOfVersions.select("-1", true); // unlimited } else { - String str = maxNumber.toString(); + String str = Integer.toString(maxNumber); boolean found = false; for(String value:values) { if(value.equals(str)) { @@ -126,13 +124,13 @@ public class VersionSettingsForm extends FormBasicController { } } - public Long getNumOfVersions() { - SimpleVersionConfig config = (SimpleVersionConfig) CoreSpringFactory.getBean(SimpleVersionConfig.class); + public int getNumOfVersions() { + SimpleVersionConfig config = CoreSpringFactory.getImpl(SimpleVersionConfig.class); return config.getMaxNumberOfVersionsProperty(); } public void setNumOfVersions(int maxNumber) { SimpleVersionConfig config = (SimpleVersionConfig) CoreSpringFactory.getBean(SimpleVersionConfig.class); - config.setMaxNumberOfVersionsProperty(new Long(maxNumber)); + config.setMaxNumberOfVersionsProperty(maxNumber); } } diff --git a/src/main/java/org/olat/basesecurity/BaseSecurityModule.java b/src/main/java/org/olat/basesecurity/BaseSecurityModule.java index f146dc6dc89b21f7b05374051e5c72cc1556d31f..ac90495a1f7c34776f69bcc177e881827c184222 100644 --- a/src/main/java/org/olat/basesecurity/BaseSecurityModule.java +++ b/src/main/java/org/olat/basesecurity/BaseSecurityModule.java @@ -27,11 +27,16 @@ package org.olat.basesecurity; import org.olat.NewControllerFactory; import org.olat.admin.user.UserAdminContextEntryControllerCreator; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.id.Roles; import org.olat.core.id.User; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Initial Date: May 4, 2004 @@ -39,24 +44,10 @@ import org.olat.core.util.StringHelper; * @author guido * Comment: */ -public class BaseSecurityModule extends AbstractOLATModule { +@Service("baseSecurityModule") +public class BaseSecurityModule extends AbstractSpringModule { - private static final String CONFIG_USERMANAGER_CAN_CREATE_USER = "sysGroupUsermanager.canCreateUser"; - private static final String CONFIG_USERMANAGER_CAN_DELETE_USER = "sysGroupUsermanager.canDeleteUser"; - private static final String CONFIG_USERMANAGER_CAN_CREATE_PWD = "sysGroupUsermanager.canCreatePassword"; - private static final String CONFIG_USERMANAGER_CAN_MODIFY_PWD = "sysGroupUsermanager.canModifyPassword"; - private static final String CONFIG_USERMANAGER_CAN_START_GROUPS = "sysGroupUsermanager.canStartGroups"; - private static final String CONFIG_USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS = "sysGroupUsermanager.canModifySubscriptions"; - private static final String CONFIG_USERMANAGER_ACCESS_TO_QUOTA = "sysGroupUsermanager.accessToQuota"; - private static final String CONFIG_USERMANAGER_ACCESS_TO_PROP = "sysGroupUsermanager.accessToProperties"; - private static final String CONFIG_USERMANAGER_ACCESS_TO_AUTH = "sysGroupUsermanager.accessToAuthentications"; - private static final String CONFIG_USERMANAGER_CAN_MANAGE_POOLMANAGERS = "sysGroupUsermanager.canManagePoolmanagers"; - private static final String CONFIG_USERMANAGER_CAN_MANAGE_GROUPMANAGERS = "sysGroupUsermanager.canManageGroupmanagers"; - private static final String CONFIG_USERMANAGER_CAN_MANAGE_INSTITUTIONAL_RESOURCE_MANAGER = "sysGroupUsermanager.canManageInstitutionalResourceManager"; - private static final String CONFIG_USERMANAGER_CAN_MANAGE_AUTHORS = "sysGroupUsermanager.canManageAuthors"; - private static final String CONFIG_USERMANAGER_CAN_MANAGE_GUESTS = "sysGroupUsermanager.canManageGuests"; - private static final String CONFIG_USERMANAGER_CAN_BYPASS_EMAILVERIFICATION = "sysGroupUsermanager.canBypassEmailverification"; - private static final String CONFIG_USERMANAGER_CAN_EDIT_ALL_PROFILE_FIELDS = "sysGroupUsermanager.canEditAllProfileFields"; + private static final OLog log = Tracing.createLoggerFor(BaseSecurityModule.class); private static final String USERSEARCH_ADMINPROPS_USERS = "userSearchAdminPropsForUsers"; private static final String USERSEARCH_ADMINPROPS_AUTHORS = "userSearchAdminPropsForAuthors"; @@ -87,7 +78,7 @@ public class BaseSecurityModule extends AbstractOLATModule { * default values */ public static Boolean USERMANAGER_CAN_CREATE_USER = false; - public static Boolean USERMANAGER_CAN_DELETE_USER = true; + public static Boolean USERMANAGER_CAN_DELETE_USER = false; public static Boolean USERMANAGER_CAN_CREATE_PWD = true; public static Boolean USERMANAGER_CAN_MODIFY_PWD = true; public static Boolean USERMANAGER_CAN_START_GROUPS = true; @@ -102,35 +93,54 @@ public class BaseSecurityModule extends AbstractOLATModule { public static Boolean USERMANAGER_CAN_MANAGE_GUESTS = false; public static Boolean USERMANAGER_CAN_BYPASS_EMAILVERIFICATION = true; public static Boolean USERMANAGER_CAN_EDIT_ALL_PROFILE_FIELDS = true; + private static String defaultAuthProviderIdentifier; + @Value("${usersearch.adminProps.users:disabled}") private String userSearchAdminPropsForUsers; + @Value("${usersearch.adminProps.authors:enabled}") private String userSearchAdminPropsForAuthors; + @Value("${usersearch.adminProps.usermanagers:enabled}") private String userSearchAdminPropsForUsermanagers; + @Value("${usersearch.adminProps.groupmanagers:enabled}") private String userSearchAdminPropsForGroupmanagers; + @Value("${usersearch.adminProps.administrators:enabled}") private String userSearchAdminPropsForAdministrators; - + + @Value("${user.lastlogin.visible.users:disabled}") private String userLastLoginVisibleForUsers; + @Value("${user.lastlogin.visible.authors:enabled}") private String userLastLoginVisibleForAuthors; + @Value("${user.lastlogin.visible.usermanagers:enabled}") private String userLastLoginVisibleForUsermanagers; + @Value("${user.lastlogin.visible.groupmanagers:enabled}") private String userLastLoginVisibleForGroupmanagers; + @Value("${user.lastlogin.visible.administrators:enabled}") private String userLastLoginVisibleForAdministrators; + @Value("${usersearch.maxResults:-1}") private String userSearchMaxResults; + @Value("${usersearch.autocomplete.users:enabled}") private String userSearchAutocompleteForUsers; + @Value("${usersearch.autocomplete.authors:enabled}") private String userSearchAutocompleteForAuthors; + @Value("${usersearch.autocomplete.usermanagers:enabled}") private String userSearchAutocompleteForUsermanagers; + @Value("${usersearch.autocomplete.groupmanagers:enabled}") private String userSearchAutocompleteForGroupmanagers; + @Value("${usersearch.autocomplete.administrators:enabled}") private String userSearchAutocompleteForAdministrators; + @Value("${userinfos.tunnelcoursebuildingblock}") private String userInfosTunnelCourseBuildingBlock; - private String forceTopFrame; - private String wikiEnabled; + private String forceTopFrame = "disabled"; + private String wikiEnabled = "enabled"; - - private BaseSecurityModule(String defaultAuthProviderIdentifier) { - BaseSecurityModule.defaultAuthProviderIdentifier = defaultAuthProviderIdentifier; + @Autowired + public BaseSecurityModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + BaseSecurityModule.defaultAuthProviderIdentifier = "OLAT"; } /** @@ -143,59 +153,11 @@ public class BaseSecurityModule extends AbstractOLATModule { @Override public void init() { - // fxdiff: Add controller factory extension point to launch user admin site NewControllerFactory.getInstance().addContextEntryControllerCreator(User.class.getSimpleName(), new UserAdminContextEntryControllerCreator()); updateProperties(); } - @Override - protected void initDefaultProperties() { - USERMANAGER_CAN_CREATE_USER = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_CREATE_USER, USERMANAGER_CAN_CREATE_USER); - USERMANAGER_CAN_DELETE_USER = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_DELETE_USER, USERMANAGER_CAN_DELETE_USER); - USERMANAGER_CAN_CREATE_PWD = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_CREATE_PWD, USERMANAGER_CAN_CREATE_PWD); - USERMANAGER_CAN_MODIFY_PWD = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MODIFY_PWD, USERMANAGER_CAN_MODIFY_PWD); - USERMANAGER_CAN_START_GROUPS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_START_GROUPS, USERMANAGER_CAN_START_GROUPS); - USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS, USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS); - - USERMANAGER_ACCESS_TO_QUOTA = getBooleanConfigParameter(CONFIG_USERMANAGER_ACCESS_TO_QUOTA, USERMANAGER_ACCESS_TO_QUOTA); - USERMANAGER_ACCESS_TO_PROP = getBooleanConfigParameter(CONFIG_USERMANAGER_ACCESS_TO_PROP, USERMANAGER_ACCESS_TO_PROP); - USERMANAGER_ACCESS_TO_AUTH = getBooleanConfigParameter(CONFIG_USERMANAGER_ACCESS_TO_AUTH, USERMANAGER_ACCESS_TO_AUTH); - - USERMANAGER_CAN_MANAGE_GROUPMANAGERS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MANAGE_GROUPMANAGERS, USERMANAGER_CAN_MANAGE_GROUPMANAGERS); - USERMANAGER_CAN_MANAGE_POOLMANAGERS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MANAGE_POOLMANAGERS, USERMANAGER_CAN_MANAGE_POOLMANAGERS); - USERMANAGER_CAN_MANAGE_INSTITUTIONAL_RESOURCE_MANAGER = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MANAGE_INSTITUTIONAL_RESOURCE_MANAGER, USERMANAGER_CAN_MANAGE_INSTITUTIONAL_RESOURCE_MANAGER); - USERMANAGER_CAN_MANAGE_AUTHORS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MANAGE_AUTHORS, USERMANAGER_CAN_MANAGE_AUTHORS); - USERMANAGER_CAN_MANAGE_GUESTS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MANAGE_GUESTS, USERMANAGER_CAN_MANAGE_GUESTS); - - USERMANAGER_CAN_BYPASS_EMAILVERIFICATION = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_BYPASS_EMAILVERIFICATION, USERMANAGER_CAN_BYPASS_EMAILVERIFICATION); - USERMANAGER_CAN_EDIT_ALL_PROFILE_FIELDS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_EDIT_ALL_PROFILE_FIELDS, USERMANAGER_CAN_EDIT_ALL_PROFILE_FIELDS); - - userSearchAdminPropsForUsers = getStringConfigParameter(USERSEARCH_ADMINPROPS_USERS, "disabled", true); - userSearchAdminPropsForAuthors = getStringConfigParameter(USERSEARCH_ADMINPROPS_AUTHORS, "enabled", true); - userSearchAdminPropsForUsermanagers = getStringConfigParameter(USERSEARCH_ADMINPROPS_USERMANAGERS, "enabled", true); - userSearchAdminPropsForGroupmanagers = getStringConfigParameter(USERSEARCH_ADMINPROPS_GROUPMANAGERS, "enabled", true); - userSearchAdminPropsForAdministrators = getStringConfigParameter(USERSEARCH_ADMINPROPS_ADMINISTRATORS, "enabled", true); - - userLastLoginVisibleForUsers = getStringConfigParameter(USER_LASTLOGIN_VISIBLE_USERS, "disabled", true); - userLastLoginVisibleForAuthors = getStringConfigParameter(USER_LASTLOGIN_VISIBLE_AUTHORS, "enabled", true); - userLastLoginVisibleForUsermanagers = getStringConfigParameter(USER_LASTLOGIN_VISIBLE_USERMANAGERS, "enabled", true); - userLastLoginVisibleForGroupmanagers = getStringConfigParameter(USER_LASTLOGIN_VISIBLE_GROUPMANAGERS, "enabled", true); - userLastLoginVisibleForAdministrators = getStringConfigParameter(USER_LASTLOGIN_VISIBLE_ADMINISTRATORS, "enabled", true); - - userSearchAutocompleteForUsers = getStringConfigParameter(USERSEARCHAUTOCOMPLETE_USERS, "enabled", true); - userSearchAutocompleteForAuthors = getStringConfigParameter(USERSEARCHAUTOCOMPLETE_AUTHORS, "enabled", true); - userSearchAutocompleteForUsermanagers = getStringConfigParameter(USERSEARCHAUTOCOMPLETE_USERMANAGERS, "enabled", true); - userSearchAutocompleteForGroupmanagers = getStringConfigParameter(USERSEARCHAUTOCOMPLETE_GROUPMANAGERS, "enabled", true); - userSearchAutocompleteForAdministrators = getStringConfigParameter(USERSEARCHAUTOCOMPLETE_ADMINISTRATORS, "enabled", true); - userSearchMaxResults = getStringConfigParameter(USERSEARCH_MAXRESULTS, "-1", true); - - userInfosTunnelCourseBuildingBlock = getStringConfigParameter(USERINFOS_TUNNEL_CBB, "disabled", true); - - forceTopFrame = getStringConfigParameter(FORCE_TOP_FRAME, "disabled", true); - wikiEnabled = getStringConfigParameter(WIKI_ENABLED, "enabled", true); - } - @Override protected void initFromChangedProperties() { updateProperties(); @@ -284,11 +246,6 @@ public class BaseSecurityModule extends AbstractOLATModule { wikiEnabled = enabled; } } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } public boolean isUserAllowedAdminProps(Roles roles) { if(roles == null) return false; @@ -475,7 +432,7 @@ public class BaseSecurityModule extends AbstractOLATModule { try { return Integer.parseInt(userSearchMaxResults); } catch (NumberFormatException e) { - logError("userSearchMaxResults as the wrong format", e); + log.error("userSearchMaxResults as the wrong format", e); } } return -1; diff --git a/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml b/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml index 7072c9c37fbed068f6e8994f1bb1348b35582958..f2a10a370bb7b09b4c8dd555929af490154a8fbc 100644 --- a/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml +++ b/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - <context:component-scan base-package="org.olat.basesecurity.manager" /> + <context:component-scan base-package="org.olat.basesecurity" /> <!-- manager --> <bean id="baseSecurityManager" class="org.olat.basesecurity.BaseSecurityManager" init-method="init" @@ -20,116 +20,4 @@ <property name="dbVendor" value="${db.vendor}" /> </bean> - <!-- module --> - <bean id="baseSecurityModule" class="org.olat.basesecurity.BaseSecurityModule"> - <constructor-arg type="java.lang.String" value="${default.auth.provider.identifier}" /> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="baseSecurityModule" /> - </bean> - </property> - </bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="baseSecurityModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <!-- Important: Set tomcats policy to allow read/write access to Root and TmpDir --> - <value> - userSearchAdminPropsForUsers=${usersearch.adminProps.users} - userSearchAdminPropsForAuthors=${usersearch.adminProps.authors} - userSearchAdminPropsForUsermanagers=${usersearch.adminProps.usermanagers} - userSearchAdminPropsForGroupmanagers=${usersearch.adminProps.groupmanagers} - userSearchAdminPropsForAdministrators=${usersearch.adminProps.administrators} - - userLastLoginVisibleForUsers=${user.lastlogin.visible.users} - userLastLoginVisibleForAuthors=${user.lastlogin.visible.authors} - userLastLoginVisibleForUsermanagers=${user.lastlogin.visible.usermanagers} - userLastLoginVisibleForGroupmanagers=${user.lastlogin.visible.groupmanagers} - userLastLoginVisibleForAdministrators=${user.lastlogin.visible.administrators} - - userSearchAutocompleteForUsers=${usersearch.autocomplete.users} - userSearchAutocompleteForAuthors=${usersearch.autocomplete.authors} - userSearchAutocompleteForUsermanagers=${usersearch.autocomplete.usermanagers} - userSearchAutocompleteForGroupmanagers=${usersearch.autocomplete.groupmanagers} - userSearchAutocompleteForAdministrators=${usersearch.autocomplete.administrators} - userSearchMaxResults=${usersearch.maxResults} - - userInfosTunnelCourseBuildingBlock=${userinfos.tunnelcoursebuildingblock} - - sysGroupUsermanager.canCreateUser=true - sysGroupUsermanager.canDeleteUser=false - sysGroupUsermanager.canCreatePassword=true - sysGroupUsermanager.canModifyPassword=true - sysGroupUsermanager.canStartGroups=true - sysGroupUsermanager.canModifySubscriptions=true - sysGroupUsermanager.accessToQuota=true - sysGroupUsermanager.accessToProperties=false - sysGroupUsermanager.accessToPolicies=false - sysGroupUsermanager.accessToAuthentications=false - sysGroupUsermanager.canManagePoolmanagers=true - sysGroupUsermanager.canManageGroupmanagers=true - sysGroupUsermanager.canManageInstitutionalResourceManager=true - sysGroupUsermanager.canManageAuthors=true - sysGroupUsermanager.canManageGuests=false - sysGroupUsermanager.canBypassEmailverification=true - sysGroupUsermanager.canEditAllProfileFields=true - <!-- - User manager configuration - Users from the system group 'userManager' can be configured to have the following - rights within the user management. Currently the rights are applied to all members - of the user management. Individual rights on a per user base are not possible. The - configuration below does not apply to system administrators, those always have full - access to the user management. - - canCreateUser: Allows the user to create new system users. The users are automatically - put into the system group users. - - canDeleteUser: Allows the user to delete users. - - canCreatePassword: Allows the user to create new OLAT passwords when no such password - exists. If set to false, the usermanager has a limited user creation form that has no - option to add a password. In addition, the user import workflow does not feature - a password column. - - canModifyPassword: Allows the user to modify the password of all users that he has - the right to manage (see canManageXXX configuration below) - - canStartGroups: Allows the user to start every group a user is in. If disabled, the groups - are only listed and have no link to start. - - accessToQuota: Allows the user to modify the personal quota of users he can manage - - accessToProperties: Allows the user to see all properties of for users he can manage - including the course properties. This is usually not very interresting for user - managers, it is commonly used by system administrators for debugging. - - accessToPolicies: Allows the user to see system security policies for all users he - can manage. This is usually not very interresting for user managers. - - accessToAuthentications: Allows the user to see and delete authentication tokens for - user he can manage. This is used e.g. to reset the RSS or Jabber password or to remove - a shibboleth or OLAT authentication. In most cases this is a power feature used only - by system administrators. - - canManageGroupmanagers: Allows the user to add a user to the system group - groupmanagers. Groupmanagers can manage course comprehensive groups using the top - navigation site Groupmanagement. When set to false, the user manager is not allowed - to modify any profile information or password from a user that is within such a group. - - canModifySubscriptions: Allows the user to list all the subscriptions the users has, - launch the corresponding resource and allow the user to delete unwanted subscriptions. - This is e.g. usefull to delete subscriptions where the user has no more access or to - manage users that are inactive at the moment but you do not yet want to delete them. - - canManageAuthors: Allows the user to add a user to the system group authors. Authors - are allowed to create new learning resources in the learning resources repository. Note - that beeing added as a co-author to a learning resource grants also the right to create - new learning resources, however the user is not automatically put into the system group - authors! When set to false, the user manager is not allowed to modify any profile - information or password from a user that is within such a group. - - canManageGuests: Allows the user to add a user to the system group guests. Guests are - anonymous users that must not be in any other system group. Guests have limited access - to OLAT. When set to false, the user manager is not allowed to modify any profile - information or password from a user that is within such a group. Usually it is a good - idea to let only system administrators manage guests. - - canBypassEmailverification: True allows a user admin to bypass the email verification workflow, - i.e. change emails directly without having a user to do verification. - - canEditAllProfileFields: True allowes the user admin to edit all fields in user - profile form. Be careful when enabling this feature since the user admin will be able - to change fields which contain validated data from shibboleth login process. - --> - </value> - </property> -</bean> - </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/core/commons/modules/bc/FolderModule.java b/src/main/java/org/olat/core/commons/modules/bc/FolderModule.java index c92065da375a32a4536ce34ed009dcb2a8c56f82..2b1da86f23c6741c89c90d88c83d121da8bebfe3 100644 --- a/src/main/java/org/olat/core/commons/modules/bc/FolderModule.java +++ b/src/main/java/org/olat/core/commons/modules/bc/FolderModule.java @@ -28,45 +28,58 @@ package org.olat.core.commons.modules.bc; import java.io.File; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.helpers.Settings; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.vfs.version.FolderVersioningConfigurator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Initial Date: 13.11.2002 * * @author Mike Stock */ -public class FolderModule extends AbstractOLATModule { +@Service +public class FolderModule extends AbstractSpringModule { private static final OLog log = Tracing.createLoggerFor(FolderModule.class); - private static final String CONFIG_ROOT = "Root"; - private static final String CONFIG_LIMITULMB = "LimitULMB"; - private static final String CONFIG_EDITFILESIZELIMIT = "EditFileSizeLimit"; - private static final String CONFIG_QUOTAMB = "QuotaMB"; - private static final String CONFIG_SENDDOCLINKONLY = "SendDocLinkOnly"; - private static final String CONFIG_SENDDOCTOEXTERN = "SendDocToExtern"; + private static final String CONFIG_FORCE_DOWNLOAD = "forceDownload"; - private FolderVersioningConfigurator versioning; + @Value("${folder.root}") + private String homesRoot; + @Value("${folder.editFileSizeLimitBytes:524288}") + private int maxEditSizeLimit; + @Value("${folder.maxulmb}") + private int maxULMB; + @Value("${folder.quotamb}") + private int quotaMB; + @Value("${folder.sendDocumentLinkOnly:true}") + private boolean sendDocLinkyOnly; + @Value("${folder.sendDocumentToExtern:false}") + private boolean sendDocToExtern; + @Value("${folder.force.download:true}") private String forceDownload; - /** - * [used by spring] - */ - private FolderModule() { - // + @Autowired + private FolderVersioningConfigurator versioning; + + @Autowired + public FolderModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } @Override protected void initDefaultProperties() { // Set folder root - File defaultHome = new File(System.getProperty("java.io.tmpdir"), "olatdata/bcroot"); - String homesRoot = getStringConfigParameter(CONFIG_ROOT, defaultHome.getAbsolutePath() , false); + if(!StringHelper.containsNonWhitespace(homesRoot)) { + homesRoot = new File(System.getProperty("java.io.tmpdir"), "olatdata/bcroot").getAbsolutePath(); + } if (Settings.isJUnitTest()) { // use dummy directory for junit testcases to not conflict with actual data // on current server. someone may start junit test and not realize that this @@ -75,36 +88,22 @@ public class FolderModule extends AbstractOLATModule { } else { FolderConfig.setFolderRoot(homesRoot); } - log.info("Folder root set to '" + FolderConfig.getCanonicalRoot() + "'."); - int maxEditSizeLimit = getIntConfigParameter(CONFIG_EDITFILESIZELIMIT, 524288); FolderConfig.setMaxEditSizeLimit(maxEditSizeLimit); - // Set maximum upload filesize - int maxULMB =getIntConfigParameter(CONFIG_LIMITULMB, 100); FolderConfig.setLimitULKB(maxULMB * 1024); - log.info("Maximum file upload size set to " + FolderConfig.getLimitULKB() + " KB."); - // Set default quotas - int quotaMB = getIntConfigParameter(CONFIG_QUOTAMB, 100); FolderConfig.setDefaultQuotaKB(quotaMB * 1024); log.info("Default user quota set to " + FolderConfig.getDefaultQuotaKB() + " KB."); - //set default - boolean sendDocLinkyOnly = getBooleanConfigParameter(CONFIG_SENDDOCLINKONLY, true); FolderConfig.setSendDocumentLinkOnly(sendDocLinkyOnly); - //set default - boolean sendDocToExtern = getBooleanConfigParameter(CONFIG_SENDDOCTOEXTERN, false); FolderConfig.setSendDocumentToExtern(sendDocToExtern); // create tmp directory - File fTmp = new File(FolderConfig.getCanonicalTmpDir()); - fTmp.mkdirs(); - - forceDownload = getStringConfigParameter(CONFIG_FORCE_DOWNLOAD, "true", true); + new File(FolderConfig.getCanonicalTmpDir()).mkdirs(); } @Override @@ -133,11 +132,6 @@ public class FolderModule extends AbstractOLATModule { this.versioning = versioning; } - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - public boolean isForceDownload() { return "true".equals(forceDownload); } @@ -146,4 +140,8 @@ public class FolderModule extends AbstractOLATModule { String enabled = enable ? "true" : "false"; setStringProperty(CONFIG_FORCE_DOWNLOAD, enabled, true); } + + public String getCanonicalTmpDir() { + return FolderConfig.getCanonicalTmpDir(); + } } \ No newline at end of file diff --git a/src/main/java/org/olat/core/commons/modules/bc/_spring/folderModuleCorecontext.xml b/src/main/java/org/olat/core/commons/modules/bc/_spring/folderModuleCorecontext.xml index 65f2f9d44aac1ff216362c68fef1756f74914e88..f4b67e20235268f4ee61cdf91b427e618212c188 100644 --- a/src/main/java/org/olat/core/commons/modules/bc/_spring/folderModuleCorecontext.xml +++ b/src/main/java/org/olat/core/commons/modules/bc/_spring/folderModuleCorecontext.xml @@ -1,42 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + <context:component-scan base-package="org.olat.core.commons.modules.bc" /> -<bean id="folderModule" class="org.olat.core.commons.modules.bc.FolderModule"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="folderModule" /> - </bean> - </property> - - <property name="versioning" ref="versioningConfigurator"/> -</bean> - -<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="folderModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <!-- Important: Set tomcats policy to allow read/write access to Root and TmpDir --> - <value> - LimitULMB=${folder.maxulmb} - <!-- Default folder quota for all folders within OLAT. --> - QuotaMB=${folder.quotamb} - <!-- The personal folder's root relative to the user data root. --> - Root=${folder.root} - <!-- Allow to send document to extern people --> - SendDocToExtern=${folder.sendDocumentToExtern} - <!-- Restrict sending document to links to enforce authentication --> - SendDocLinkOnly=${folder.sendDocumentLinkOnly} - <!-- max edit filesize for online-editing in Bytes --> - EditFileSizeLimit=${folder.editFileSizeLimitBytes} - forceDownload=${folder.force.download} - </value> - </property> -</bean> <bean id="org.olat.core.commons.modules.bc.FilesInfoMBean" class="org.olat.core.commons.modules.bc.FilesInfoMBean" /> diff --git a/src/main/java/org/olat/core/gui/components/Window.java b/src/main/java/org/olat/core/gui/components/Window.java index f0728adc270f6585bcc1941c2a680b9bfb383ced..26ffcbb1d8843142ae6baafe0b82af0be6506718 100644 --- a/src/main/java/org/olat/core/gui/components/Window.java +++ b/src/main/java/org/olat/core/gui/components/Window.java @@ -76,6 +76,7 @@ import org.olat.core.gui.render.ValidationResult; import org.olat.core.gui.render.intercept.InterceptHandler; import org.olat.core.gui.render.intercept.InterceptHandlerInstance; import org.olat.core.gui.themes.Theme; +import org.olat.core.helpers.GUISettings; import org.olat.core.helpers.Settings; import org.olat.core.id.context.BusinessControl; import org.olat.core.id.context.BusinessControlFactory; @@ -183,7 +184,7 @@ public class Window extends AbstractComponent { this.wbackofficeImpl = wbackoffice; jsAndCssAdder = wbackoffice.createJSAndCSSAdder(); // set default theme - Theme myTheme = new Theme(Settings.getGuiThemeIdentifyer()); + Theme myTheme = new Theme(CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer()); setGuiTheme(myTheme); } diff --git a/src/main/java/org/olat/core/gui/themes/Theme.java b/src/main/java/org/olat/core/gui/themes/Theme.java index 0a8a1acfc5d0aa4a3d385275099ac804460536a1..8c5a3ac63d007138135bd8f3afc04da3ffb9e0ab 100644 --- a/src/main/java/org/olat/core/gui/themes/Theme.java +++ b/src/main/java/org/olat/core/gui/themes/Theme.java @@ -21,8 +21,10 @@ package org.olat.core.gui.themes; import java.io.File; +import org.olat.core.CoreSpringFactory; import org.olat.core.dispatcher.impl.StaticMediaDispatcher; import org.olat.core.gui.render.StringOutput; +import org.olat.core.helpers.GUISettings; import org.olat.core.helpers.Settings; import org.olat.core.util.WebappHelper; @@ -79,11 +81,12 @@ public class Theme { if(staticThemesPath == null) { staticThemesPath = WebappHelper.getContextRoot() + "/static/themes/"; } - - File themeFolder = new File(staticThemesPath, Settings.getGuiThemeIdentifyer()); + + String guiThemIdentifyer = CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer(); + File themeFolder = new File(staticThemesPath, guiThemIdentifyer); if (!themeFolder.exists() && Settings.getGuiCustomThemePath() != null) { // fallback to custom themes folder - themeFolder = new File(Settings.getGuiCustomThemePath(), Settings.getGuiThemeIdentifyer()); + themeFolder = new File(Settings.getGuiCustomThemePath(), guiThemIdentifyer); } return new File(themeFolder, CUSTOMFILENAME); } diff --git a/src/main/java/org/olat/core/helpers/GUISettings.java b/src/main/java/org/olat/core/helpers/GUISettings.java new file mode 100644 index 0000000000000000000000000000000000000000..c4da1d5fc90a27c63148acf34f0b4da9c59397de --- /dev/null +++ b/src/main/java/org/olat/core/helpers/GUISettings.java @@ -0,0 +1,65 @@ +package org.olat.core.helpers; + +import org.olat.core.configuration.AbstractSpringModule; +import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +/** + * + * Initial date: 18.07.2016<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +@Service +public class GUISettings extends AbstractSpringModule { + + private static final String KEY_GUI_THEME_IDENTIFYER = "layout.theme"; + + /** + * Set the system theme here. Make sure the directory webapp/WEB-INF/static/themes/YOURTHEME exists. + * This is only the default value in case no user configuration is found. Use the administration GUI to + * Set a specific theme. + */ + @Value("${layout.theme:light}") + private String guiThemeIdentifyer; + + @Autowired + public GUISettings(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + } + + @Override + public void init() { + //module enabled/disabled + String guiThemeIdentifyerObj = getStringPropertyValue(KEY_GUI_THEME_IDENTIFYER, true); + if(StringHelper.containsNonWhitespace(guiThemeIdentifyerObj)) { + guiThemeIdentifyer = guiThemeIdentifyerObj; + } + } + + @Override + protected void initFromChangedProperties() { + init(); + } + + /** + * @return the CSS theme used for this webapp + */ + public String getGuiThemeIdentifyer() { + return guiThemeIdentifyer; + } + + /** + * Set the CSS theme used for this webapp. Only used by spring. Use static + * method to change the theme at runtime! + * + * @param guiTheme + */ + public void setGuiThemeIdentifyer(String guiThemeIdentifyer) { + this.guiThemeIdentifyer = guiThemeIdentifyer; + setStringProperty(KEY_GUI_THEME_IDENTIFYER, guiThemeIdentifyer, true); + } +} diff --git a/src/main/java/org/olat/core/helpers/Settings.java b/src/main/java/org/olat/core/helpers/Settings.java index 617599bce207b24f9d4786c361b2be9dc409a362..667d7aa6bc7b71cf30de6fc679dfc02910589438 100644 --- a/src/main/java/org/olat/core/helpers/Settings.java +++ b/src/main/java/org/olat/core/helpers/Settings.java @@ -37,17 +37,11 @@ import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import org.olat.core.configuration.Destroyable; -import org.olat.core.configuration.Initializable; -import org.olat.core.configuration.PersistedProperties; -import org.olat.core.configuration.PersistedPropertiesChangedEvent; import org.olat.core.gui.UserRequest; -import org.olat.core.gui.control.Event; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; import org.olat.core.util.WebappHelper; -import org.olat.core.util.event.GenericEventListener; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -60,23 +54,17 @@ import org.springframework.core.io.Resource; * * @author Felix Jost */ -public class Settings implements Initializable, Destroyable, GenericEventListener { +public class Settings { private static boolean debug = false; - private static String guiThemeIdentifyer = "light"; private static String htmlEditorContentCssClassPrefixes; private static List<Pattern> ajaxBlacklistPatterns = new ArrayList<Pattern>(); private static boolean jUnitTest; - // the persited properties contain user configurable config data (overrides - // default values from spring config) - private static PersistedProperties persistedProperties; private static String applicationName; private static String version; private static String buildIdentifier; private static OLog log = Tracing.createLoggerFor(Settings.class); - - private static final String KEY_GUI_THEME_IDENTIFYER = "layout.theme"; private static int nodeId; private static String clusterMode; private static Date buildDate; @@ -151,10 +139,6 @@ public class Settings implements Initializable, Destroyable, GenericEventListene return buildDate; } - public void setPersistedProperties(PersistedProperties persistedProperties) { - Settings.persistedProperties = persistedProperties; - } - /** * @return */ @@ -282,49 +266,8 @@ public class Settings implements Initializable, Destroyable, GenericEventListene public void setDebug(boolean debug) { Settings.debug = debug; } - - /** - * @see org.olat.core.configuration.ServiceLifeCycle#init() - */ - @Override - public void init() { - // Initialize the user configuration and the spring default configuration - // - // Set the default theme configured in the spring configuration - persistedProperties.setStringPropertyDefault(KEY_GUI_THEME_IDENTIFYER, guiThemeIdentifyer); - // Override gui theme with value from properties configuration - guiThemeIdentifyer = persistedProperties.getStringPropertyValue(KEY_GUI_THEME_IDENTIFYER, false); - } - - /** - * @see org.olat.core.configuration.ServiceLifeCycle#destroy() - */ - @Override - public void destroy() { - if (persistedProperties != null) { - persistedProperties.destroy(); - persistedProperties = null; - } - } - /** - * @return the CSS theme used for this webapp - */ - public static String getGuiThemeIdentifyer() { - return guiThemeIdentifyer; - } - - /** - * Set the CSS theme used for this webapp. Only used by spring. Use static - * method to change the theme at runtime! - * - * @param guiTheme - */ - public void setGuiThemeIdentifyer(String guiThemeIdentifyer) { - Settings.guiThemeIdentifyer = guiThemeIdentifyer; - } - /** * @return A regexp that matches for css class name prefixes that should be * used in the HTML editor to limit css names that are available in @@ -371,27 +314,6 @@ public class Settings implements Initializable, Destroyable, GenericEventListene + guiCustomThemePath + " invalid. Configure property layout.custom.themes.dir if you want to use a custom themes directory."); } - } - - /** - * Set the CSS theme used for this webapp. The configuration is stored in - * the olatdata/system/configuration properties file and overrides the - * spring default configuration. - * - * @param newGuiThemeIdentifyer - */ - public static void setGuiThemeIdentifyerGlobally(String newGuiThemeIdentifyer) { - if (!guiThemeIdentifyer.equals(newGuiThemeIdentifyer)) { - // store new configuration and notify other nodes - persistedProperties.setStringProperty(KEY_GUI_THEME_IDENTIFYER, newGuiThemeIdentifyer, true); - } - } - - public void event(Event event) { - if (event instanceof PersistedPropertiesChangedEvent) { - // Override gui theme with value from properties configuration - guiThemeIdentifyer = persistedProperties.getStringPropertyValue(KEY_GUI_THEME_IDENTIFYER, false); - } } public static String getURIScheme() { @@ -406,7 +328,6 @@ public class Settings implements Initializable, Destroyable, GenericEventListene return getServerInsecurePort() > 0; } - public static String createServerURI() { String uri; if (isSecurePortAvailable()) { diff --git a/src/main/java/org/olat/core/util/WebappHelper.java b/src/main/java/org/olat/core/util/WebappHelper.java index 367597508b7e56fa79d4a462228e849d867dbf71..7fe810e3be566c02b04549d68785d0286cecc7b1 100644 --- a/src/main/java/org/olat/core/util/WebappHelper.java +++ b/src/main/java/org/olat/core/util/WebappHelper.java @@ -46,7 +46,6 @@ import org.olat.core.helpers.Settings; import org.olat.core.logging.OLog; import org.olat.core.logging.StartupException; import org.olat.core.logging.Tracing; -import org.olat.core.util.i18n.I18nModule; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -239,12 +238,10 @@ public class WebappHelper implements Initializable, Destroyable, ServletContextA File fil = new File(fullPathToSrc); if(fil.exists()){ log.debug("Path to source set to: " + fullPathToSrc); - }else{ - if (Settings.isDebuging() || I18nModule.isTransToolEnabled()) { - log.error("Path to source wrong, debugging may not work as expected: " + fullPathToSrc, new Exception("getSourcePath")); - } else { - log.info("Path to source not valid: " + fullPathToSrc); - } + } else if (Settings.isDebuging()) { + log.error("Path to source wrong, debugging may not work as expected: " + fullPathToSrc, new Exception("getSourcePath")); + } else { + log.info("Path to source not valid: " + fullPathToSrc); } return fullPathToSrc; diff --git a/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml b/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml index 04807209ced1448ff50f1d4c47235871938cc0f2..e48bab4999532f3ce0e2ca94b0b5a42dd3f2af5d 100644 --- a/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml +++ b/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - <context:component-scan base-package="org.olat.core.util.session" /> + <context:component-scan base-package="org.olat.core.util.session,org.olat.core.util.vfs.version,org.olat.core.helpers" /> <bean id="codeHelper" class="org.olat.core.util.CodeHelper" > <constructor-arg value="${node.id}" /> @@ -50,13 +50,7 @@ <property name="mathJaxCdn" value="${mathjax.cdn}"/> </bean> - <bean id="org.olat.core.helpers.Settings" class="org.olat.core.helpers.Settings" depends-on="org.olat.core.util.WebappHelper" init-method="init" destroy-method="destroy"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="org.olat.core.helpers.Settings" /> - </bean> - </property> + <bean id="org.olat.core.helpers.Settings" class="org.olat.core.helpers.Settings" depends-on="org.olat.core.util.WebappHelper"> <!-- OLAT Tomcat server configuration parameters. This is used e.g. to assemble absolute URIS where needed. --> <property name="serverDomainName" value="${server.domainname}" /> <property name="serverSecurePort" value="${server.port.ssl}" /> @@ -79,13 +73,7 @@ <value>.*Lynx.*</value> <!-- Lynx console browser (no js) --> </list> </property> - <property name="crossOriginFilter" value="${allow.cross.origin.domain}"/> - <!-- - Set the system theme here. Make sure the directory webapp/WEB-INF/static/themes/YOURTHEME exists. - This is only the default value in case no user configuration is found. Use the administration GUI to - Set a specific theme. - --> - <property name="guiThemeIdentifyer" value="${layout.theme}" /> + <property name="crossOriginFilter" value="${allow.cross.origin.domain}"/> <!-- Optional path to a directory which contains custom themes. This is an alternative to placing the theme into the webapp, default is to have your custom themes in olatdata/customizing/themes @@ -130,27 +118,6 @@ <bean id="core.preferences.PreferencesStorage" class="org.olat.core.util.prefs.db.DbStorage" /> - <!-- Definition of the providers --> - <bean id="userSessionModule" class="org.olat.core.util.session.UserSessionModule"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="coordinatorManager,org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="userSessionModule" /> - </bean> - </property> - </bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="userSessionModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - session.timeout=${session.timeout} - session.timeout.authenticated=${session.timeout.authenticated} - </value> - </property> - </bean> <!-- Cache --> <bean id="infinispanCacheManager" class="org.olat.core.util.cache.infinispan.InfinispanCacheManager" destroy-method="stop"> diff --git a/src/main/java/org/olat/core/util/i18n/I18nModule.java b/src/main/java/org/olat/core/util/i18n/I18nModule.java index 7ee785005dfdd20d39c4316dc8f9d6d80c53ea84..e893d0520696b67e2f5e30222148c1eab1ffc8dc 100644 --- a/src/main/java/org/olat/core/util/i18n/I18nModule.java +++ b/src/main/java/org/olat/core/util/i18n/I18nModule.java @@ -37,6 +37,8 @@ import org.olat.core.gui.control.Event; import org.olat.core.helpers.Settings; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.OLATRuntimeException; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.ArrayHelper; import org.olat.core.util.StringHelper; import org.olat.core.util.WebappHelper; @@ -54,6 +56,9 @@ import org.olat.core.util.resource.OresHelper; */ public class I18nModule extends AbstractOLATModule implements Destroyable { + + private static final OLog log = Tracing.createLoggerFor(I18nModule.class); + // Some general variables public static final String LOCAL_STRINGS_FILE_PREFIX = "LocalStrings_"; public static final String LOCAL_STRINGS_FILE_POSTFIX = ".properties"; @@ -166,6 +171,13 @@ public class I18nModule extends AbstractOLATModule implements Destroyable { // Register on the event channel to get cache flushes of other nodes I18N_CACHE_FLUSHED_EVENT_CHANNEL = OresHelper.createOLATResourceableType(this.getClass().getSimpleName() + "I18N_CACHE_FLUSHED_EVENT_CHANNEL"); coordinatorManager.getCoordinator().getEventBus().registerFor(this, null, I18N_CACHE_FLUSHED_EVENT_CHANNEL); + + if(isTransToolEnabled()) { + String sourcePath = WebappHelper.getSourcePath(); + if(!StringHelper.containsNonWhitespace(sourcePath) || !(new File(sourcePath).exists())) { + log.error("Path to source wrong, translation tool may not work as expected: " + sourcePath, null); + } + } } private void doInit() { diff --git a/src/main/java/org/olat/core/util/session/UserSessionModule.java b/src/main/java/org/olat/core/util/session/UserSessionModule.java index 6294d0e6c604614db73eb0a3fe8482eed3720e0f..5bd76611eb95471ea492dda5e1d12ffc37c5a9a6 100644 --- a/src/main/java/org/olat/core/util/session/UserSessionModule.java +++ b/src/main/java/org/olat/core/util/session/UserSessionModule.java @@ -19,9 +19,12 @@ */ package org.olat.core.util.session; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * @@ -29,14 +32,22 @@ import org.olat.core.util.StringHelper; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class UserSessionModule extends AbstractOLATModule { +@Service +public class UserSessionModule extends AbstractSpringModule { private static final String SESSION_TIMEOUT = "session.timeout"; private static final String SESSION_TIMEOUT_AUTH = "session.timeout.authenticated"; + @Value("${session.timeout}") private int sessionTimeout; + @Value("${session.timeout.authenticated}") private int sessionTimeoutAuthenticated; + + @Autowired + public UserSessionModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + } @Override public void init() { @@ -50,23 +61,12 @@ public class UserSessionModule extends AbstractOLATModule { sessionTimeoutAuthenticated = Integer.parseInt(timeoutAuthObj); } } - - @Override - protected void initDefaultProperties() { - sessionTimeout = getIntConfigParameter(SESSION_TIMEOUT, 7200); - sessionTimeoutAuthenticated = getIntConfigParameter(SESSION_TIMEOUT_AUTH, 300); - } @Override protected void initFromChangedProperties() { init(); } - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - public int getSessionTimeout() { return sessionTimeout; } diff --git a/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml b/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml index 2fff927309dfa2bb5fb74900494385d964c60c08..cb04b76d81d1a348734a277325bef2fa1f957ccc 100644 --- a/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml +++ b/src/main/java/org/olat/core/util/threadlog/_spring/threadlogCorecontext.xml @@ -4,9 +4,9 @@ xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd + http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.1.xsd"> + http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:serviceconfig/olat.properties, classpath:olat.local.properties" system-properties-mode="OVERRIDE"/> <context:annotation-config /> diff --git a/src/main/java/org/olat/core/util/vfs/version/SimpleVersionConfig.java b/src/main/java/org/olat/core/util/vfs/version/SimpleVersionConfig.java index 3b9deab164038161509af11f2c8faa65824517fd..8bcbd9c39e3158b27844f5e7d105e5fcebf33640 100644 --- a/src/main/java/org/olat/core/util/vfs/version/SimpleVersionConfig.java +++ b/src/main/java/org/olat/core/util/vfs/version/SimpleVersionConfig.java @@ -24,9 +24,7 @@ import java.util.ArrayList; import java.util.List; import org.olat.core.commons.modules.bc.FolderConfig; -import org.olat.core.configuration.PersistedProperties; -import org.olat.core.configuration.PersistedPropertiesChangedEvent; -import org.olat.core.gui.control.Event; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.util.StringHelper; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.GenericEventListener; @@ -34,6 +32,9 @@ import org.olat.core.util.vfs.LocalFolderImpl; import org.olat.core.util.vfs.MergeSource; import org.olat.core.util.vfs.NamedContainerImpl; import org.olat.core.util.vfs.VFSContainer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * @@ -47,7 +48,8 @@ import org.olat.core.util.vfs.VFSContainer; * * @author srosse */ -public class SimpleVersionConfig implements GenericEventListener, FolderVersioningConfigurator { +@Service("versioningConfigurator") +public class SimpleVersionConfig extends AbstractSpringModule implements GenericEventListener, FolderVersioningConfigurator { private static final String MAX_NUMBER_OF_VERSIONS = "maxnumber.versions"; private static final String COURSE_PATH = "/course/"; @@ -58,9 +60,8 @@ public class SimpleVersionConfig implements GenericEventListener, FolderVersioni private static final String[] EXCLUSIONS_IN_COURSE_PATH = {SOLUTIONS_PATH, RETURNBOXES_PATH, DROPBOXES, TASKFOLDERS}; - private Long maxNumOfVersions; - private int maxNumberOfVersionsConfig = -1; - private PersistedProperties persistedProperties; + @Value("${maxnumber.versions:0}") + private int maxNumberOfVersions; private String courseRoot; private List<String> excludedRoots; @@ -68,65 +69,34 @@ public class SimpleVersionConfig implements GenericEventListener, FolderVersioni /** * [used by spring] */ - private SimpleVersionConfig() { + @Autowired + public SimpleVersionConfig(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } - public void event(Event event) { - if (event instanceof PersistedPropertiesChangedEvent) { - // Reload the properties - if (!((PersistedPropertiesChangedEvent)event).isEventOnThisNode()) { - persistedProperties.loadPropertiesFromFile(); - } - maxNumOfVersions = null; + @Override + public void init() { + String maxNumberOfVersionsObj = getStringPropertyValue(MAX_NUMBER_OF_VERSIONS, true); + if(StringHelper.containsNonWhitespace(maxNumberOfVersionsObj)) { + maxNumberOfVersions = Integer.parseInt(maxNumberOfVersionsObj); } } - - public void setCoordinator(CoordinatorManager coordinatorManager) { - //nothing to do - } - - /** - * [used by spirng] - * @param persistedProperties - */ - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.persistedProperties = persistedProperties; - } - - /** - * @return default maximum number of versions, defined in xml file - */ - public Integer getDefaultMaxNumberOfVersions() { - return maxNumberOfVersionsConfig; - } - public void setDefaultMaxNumberOfVersions(Integer maxNumberOfVersionsConfig) { - this.maxNumberOfVersionsConfig = maxNumberOfVersionsConfig; + @Override + protected void initFromChangedProperties() { + init(); } /** * @return maximum number of revisions, defined in admin. of Olat */ - public Long getMaxNumberOfVersionsProperty() { - if(maxNumOfVersions != null) { - return maxNumOfVersions; - } - - if (getPersistedProperties() == null) { - return null; - } - String maxNumOfVersionsStr = getPersistedProperties().getStringPropertyValue(MAX_NUMBER_OF_VERSIONS, true); - if (maxNumOfVersionsStr == null || maxNumOfVersionsStr.length() == 0) { - return null; - } - maxNumOfVersions = Long.parseLong(maxNumOfVersionsStr); - return maxNumOfVersions; + public int getMaxNumberOfVersionsProperty() { + return maxNumberOfVersions; } - public void setMaxNumberOfVersionsProperty(Long maxNumber) { - if (getPersistedProperties() != null) { - getPersistedProperties().setStringProperty(MAX_NUMBER_OF_VERSIONS, maxNumber.toString(), true); - } + public void setMaxNumberOfVersionsProperty(int maxNumber) { + this.maxNumberOfVersions = maxNumber; + setStringProperty(MAX_NUMBER_OF_VERSIONS, Integer.toString(maxNumber), true); } @Override @@ -188,23 +158,8 @@ public class SimpleVersionConfig implements GenericEventListener, FolderVersioni } private int getVersionAllowed() { - Long max = getMaxNumberOfVersionsProperty(); - if (max != null) { - return max.intValue(); - } - Integer configMax = getDefaultMaxNumberOfVersions(); - if (configMax != null) { - return configMax.intValue(); - } - return 0; - } - - /** - * - * @return the persisted properties - */ - private PersistedProperties getPersistedProperties() { - return persistedProperties; + int max = getMaxNumberOfVersionsProperty(); + return max; } private String getCourseRoot() { diff --git a/src/main/java/org/olat/core/util/vfs/version/_spring/versioningCorecontext.xml b/src/main/java/org/olat/core/util/vfs/version/_spring/versioningCorecontext.xml index 1bc1f9892ada5a798dd382b82c05c31d8b766528..4d15c9e51f95d80b086ea28574ab5167773407a3 100644 --- a/src/main/java/org/olat/core/util/vfs/version/_spring/versioningCorecontext.xml +++ b/src/main/java/org/olat/core/util/vfs/version/_spring/versioningCorecontext.xml @@ -3,26 +3,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="versionsManager" class="org.olat.core.util.vfs.version.VersionsFileManager" init-method="init"> <property name="versioningConfigurator" ref="versioningConfigurator" /> </bean> - <bean id="versioningConfigurator" class="org.olat.core.util.vfs.version.SimpleVersionConfig" - depends-on="coordinatorManager,org.olat.core.util.WebappHelper,folderModule"> - <property name="coordinator" ref="coordinatorManager" /> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="versioningConfigurator" /> - <!-- Max versions: -1 is unlimited, 0 is no versioning, 1 - n is the exact max. number of versions allowed --> - <property name="defaultProperties"> - <value>maxnumber.versions=0</value> - </property> - </bean> - </property> - </bean> + </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java index a5eec4fd52f27cba527c8be97fb207267397dffb..8f0d815b48cb804eb90e34a84b2bb8513836bf0e 100644 --- a/src/main/java/org/olat/course/CourseFactory.java +++ b/src/main/java/org/olat/course/CourseFactory.java @@ -653,7 +653,7 @@ public class CourseFactory { */ public static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl) { // Find repository entry for this course - String helpCourseSoftKey = CourseModule.getHelpCourseSoftKey(); + String helpCourseSoftKey = CoreSpringFactory.getImpl(CourseModule.class).getHelpCourseSoftKey(); RepositoryManager rm = RepositoryManager.getInstance(); RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class); RepositoryEntry entry = null; diff --git a/src/main/java/org/olat/course/CourseModule.java b/src/main/java/org/olat/course/CourseModule.java index f19be1fb86e52e9a054695440e4f063913d29681..791d7ca7f0509aab64a4b699db3de2d9e11d8091 100644 --- a/src/main/java/org/olat/course/CourseModule.java +++ b/src/main/java/org/olat/course/CourseModule.java @@ -25,34 +25,22 @@ package org.olat.course; -import java.io.File; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.commons.services.notifications.SubscriptionContext; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; -import org.olat.core.helpers.Settings; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; 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.resource.OresHelper; import org.olat.course.assessment.AssessmentManager; import org.olat.course.nodes.CourseNode; import org.olat.course.run.environment.CourseEnvironment; -import org.olat.properties.Property; -import org.olat.properties.PropertyManager; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.repository.RepositoryService; -import org.olat.resource.OLATResource; -import org.olat.resource.OLATResourceManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Initial Date: 02.09.2005 <br> @@ -61,224 +49,38 @@ import org.olat.resource.OLATResourceManager; * @author guido * @author Florian Gnägi */ -public class CourseModule extends AbstractOLATModule { - - private static boolean courseChatEnabled; - private static boolean displayParticipantsCount; +@Service +public class CourseModule extends AbstractSpringModule { + + @Value("${course.display.participants.count}") + private boolean displayParticipantsCount; + @Value("${help.course.softkey}") + private String helpCourseSoftkey; + @Autowired @Qualifier("logVisibilityForCourseAuthor") + private HashMap<String, String> logVisibilities; + // Repository types public static String ORES_TYPE_COURSE = OresHelper.calculateTypeName(CourseModule.class); public static OLATResourceable ORESOURCEABLE_TYPE_COURSE = OresHelper.lookupType(CourseModule.class); public static final String ORES_COURSE_ASSESSMENT = OresHelper.calculateTypeName(AssessmentManager.class); - private static String helpCourseSoftkey; - private static CoordinatorManager coordinatorManager; - private Map<String, RepositoryEntry> deployedCourses; - private boolean deployCoursesEnabled; - private PropertyManager propertyManager; - private CourseFactory courseFactory; - private Map<String, String> logVisibilities; - private List<DeployableCourseExport> deployableCourseExports; - private RepositoryService repositoryService; - private OLATResourceManager olatResourceManager; + private static CoordinatorManager coordinatorManager; - - /** - * [used by spring] - */ - private CourseModule(CoordinatorManager coordinatorManager, PropertyManager propertyManager, CourseFactory courseFactory, RepositoryService repositoryService, OLATResourceManager olatResourceManager) { + @Autowired + public CourseModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); CourseModule.coordinatorManager = coordinatorManager; - this.propertyManager = propertyManager; - this.courseFactory = courseFactory; - this.repositoryService = repositoryService; - this.olatResourceManager = olatResourceManager; - coordinatorManager.getCoordinator().getEventBus().registerFor(this, null, FrameworkStartupEventChannel.getStartupEventChannel()); } - - /** - * Courses are deployed after the startup has completed. - * - */ - @Override - public void event(org.olat.core.gui.control.Event event) { - //do not deploy courses/help course if in JUnit Mode. - if (Settings.isJUnitTest()) return; - - if (event instanceof FrameworkStartedEvent && ((FrameworkStartedEvent) event).isEventOnThisNode()) { - // Deploy demo courses - logInfo("Received FrameworkStartedEvent and is on same node, will start deploying demo courses..."); - deployCoursesFromCourseExportFiles(); - } - //also in startup event processing intermediateCommit - DBFactory.getInstance().intermediateCommit(); - } - - /** - * [used by spring] - */ - public void setCourseExportFiles(List<DeployableCourseExport> deployableCourseExports) { - this.deployableCourseExports = deployableCourseExports; - } - - /** - * [used by spring] - */ - public void setLogVisibilityForCourseAuthor(Map<String, String> logVisibilities) { - this.logVisibilities = logVisibilities; - } - @Override - protected void initDefaultProperties() { - courseChatEnabled = getBooleanConfigParameter("enableCourseChat", true); - deployCoursesEnabled = getBooleanConfigParameter("deployCourseExportsEnabled", true); - displayParticipantsCount = getBooleanConfigParameter("displayParticipantsCount", true); - helpCourseSoftkey = getStringConfigParameter("helpCourseSoftKey", "", true); + protected void initFromChangedProperties() { + // } - /** - * @see org.olat.core.configuration.OLATModule#init(com.anthonyeden.lib.config.Configuration) - */ @Override public void init() { // } - - private void deployCoursesFromCourseExportFiles( ) { - logInfo("Deploying course exports."); - for (DeployableCourseExport export: deployableCourseExports) { - if (0 < export.getAccess() && export.getAccess() < 5) { - if (deployCoursesEnabled) { - try { - deployCourse(export, export.getAccess()); - } catch (Exception e) { - logWarn("Skipping deployment of course::" + export.getIdentifier(), e); - } - DBFactory.getInstance().intermediateCommit(); - continue; - } - } else { - logInfo("Skipping deployment of course::" + export.getIdentifier() + " ; access attribute must be 1,2,3 or 4 but values is::"+ export.getAccess()); - } - logInfo("Skipping deployment of course::" + export.getIdentifier()); - } - if (!deployCoursesEnabled) { - logInfo("Skipping deployment of demo course exports. To deploy course exports, please enable in the configuration file. Help course will always be deployed!"); - } - } - - private RepositoryEntry deployCourse(DeployableCourseExport export, int access) { - // let's see if we previously deployed demo courses... - - RepositoryEntry re = getDeployedCourses().get(export.getIdentifier()); - if (re != null) { - logInfo("Course '" + export.getIdentifier() + "' has been previousely deployed. Skipping."); - return re; - } - - File file = export.getDeployableCourseZipFile(); - if (file != null && file.exists()) { - logInfo("deploying Course: " + file.getName()); - if (!file.exists()) { - //do not throw exception as users may upload bad file - logWarn("Cannot deploy course from file: " + file.getAbsolutePath(),null); - return null; - } - re = CourseFactory.deployCourseFromZIP(file, null, access); - if (re != null) markAsDeployed(export, re); - return re; - } - return null; - } - - /** - * Mark a course as deployed. Remember the key of the repository entry it was - * deployed. - * - * @param courseExportPath - * @param re - */ - private void markAsDeployed(DeployableCourseExport export, RepositoryEntry re) { - List<Property> props = propertyManager.findProperties(null, null, null, "_o3_", "deployedCourses"); - Property prop = null; - for (Property property : props) { - if (property.getLongValue() == re.getKey()){ - prop = property; - } - } - if (prop == null) { - prop = propertyManager.createPropertyInstance(null, null, null, "_o3_", "deployedCourses", export.getVersion(), re.getKey(), export.getIdentifier(), null); - } - prop.setFloatValue(export.getVersion()); - prop.setStringValue(export.getIdentifier()); - propertyManager.saveProperty(prop); - deployedCourses.put(export.getIdentifier(), re); - } - - /** - * Get the Map of deployed courses. Map contains repo entries by path keys. - * - * @return - */ - private Map<String, RepositoryEntry> getDeployedCourses() { - if (deployedCourses != null) return deployedCourses; - List<?> props = propertyManager.findProperties(null, null, null, "_o3_", "deployedCourses"); - deployedCourses = new HashMap<String, RepositoryEntry>(props.size()); - for (Iterator<?> iter = props.iterator(); iter.hasNext();) { - Property prop = (Property) iter.next(); - Long repoKey = prop.getLongValue(); - RepositoryEntry re = null; - re = RepositoryManager.getInstance().lookupRepositoryEntry(repoKey); - if (re != null) { - //props with floatValue null are old entries - delete them. - if (prop.getFloatValue() == null) { - //those are courses deployed with the old mechanism, check, if they exist and what should be done with them: - //fxdiff: no delete! - logInfo("This course was already deployed and has old property values. course: "+prop.getStringValue()); - for (DeployableCourseExport export: deployableCourseExports) { - if (export.getIdentifier().equals(prop.getStringValue())) { - logInfo("found this old course in the deployable courses list"); - if (export.isRedeploy()){ - // found in deployableCourses again and it should be redeployed, therefore delete: - logInfo("marked as to be redeployed, therefore delete first!"); - deleteCourseAndProperty(prop, re); - re = null; //do not add to deployed courses - } else { - logInfo("no redeploy! just update its version."); - markAsDeployed(export, re); - } - } - } - } else { - //check if latest version if course is installed - for (DeployableCourseExport export: deployableCourseExports) { - if (export.getIdentifier().equals(prop.getStringValue()) && export.getVersion() > prop.getFloatValue() && export.isRedeploy()) { - //we have a newer version - delete the old course - logInfo("There is a new version for this course available. Deleting it and redeploy course: "+prop.getStringValue()); - deleteCourseAndProperty(prop, re); - re = null; //do not add to deployed courses - break; - } - } - } - } - if (re != null) deployedCourses.put(prop.getStringValue(), re); - } - return deployedCourses; - } - - private void deleteCourseAndProperty(Property prop, RepositoryEntry re) { - try { - propertyManager.deleteProperty(prop); - repositoryService.deleteRepositoryEntryAndBaseGroups(re); - CourseFactory.deleteCourse(re, re.getOlatResource()); - OLATResource ores = olatResourceManager.findResourceable(re.getOlatResource()); - olatResourceManager.deleteOLATResource(ores); - } catch (Exception e) { - logWarn("Could not delete course and property of demo course with name: "+prop.getStringValue(), e); - } - } - - /** * @return true if the course author can see/download/modify the admin log @@ -306,7 +108,7 @@ public class CourseModule extends AbstractOLATModule { * * @return The filename of the zipped help course */ - public static String getHelpCourseSoftKey() { + public String getHelpCourseSoftKey() { return helpCourseSoftkey; } @@ -352,15 +154,6 @@ public class CourseModule extends AbstractOLATModule { SubscriptionContext sc = new SubscriptionContext(getCourseTypeName(), ce.getCourseResourceableId(), cn.getIdent() + ":" + subsubId); return sc; } - - /** - * whether course chat is enabled or not - depends on Instant Messaging enabled! you should check first for - * IM Enabled @see {@link org.olat.instantMessaging.InstantMessagingModule} - * @return - */ - public static boolean isCourseChatEnabled(){ - return courseChatEnabled; - } public static void registerForCourseType(GenericEventListener gel, Identity identity) { coordinatorManager.getCoordinator().getEventBus().registerFor(gel, identity, ORESOURCEABLE_TYPE_COURSE); @@ -378,17 +171,7 @@ public class CourseModule extends AbstractOLATModule { return 499; } - @Override - protected void initFromChangedProperties() { - // - } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - - public static boolean displayParticipantsCount() { - return CourseModule.displayParticipantsCount; + public boolean displayParticipantsCount() { + return displayParticipantsCount; } } diff --git a/src/main/java/org/olat/course/_spring/courseContext.xml b/src/main/java/org/olat/course/_spring/courseContext.xml index aea0913520a9d272dabbf43aeb6bfb4617aaa942..100fa16fc6ff7c0cf11b854e5fe4dd0dabb23ab7 100644 --- a/src/main/java/org/olat/course/_spring/courseContext.xml +++ b/src/main/java/org/olat/course/_spring/courseContext.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - <context:component-scan base-package="org.olat.course.certificate.manager,org.olat.course.reminder" /> + <context:component-scan base-package="org.olat.course" /> <import resource="classpath:/org/olat/course/assessment/_spring/assessmentContext.xml"/> <import resource="classpath:/org/olat/course/certificate/_spring/certificateContext.xml"/> @@ -23,40 +23,16 @@ <import resource="classpath:/org/olat/course/nodes/vitero/_spring/buildingblockContext.xml"/> <import resource="classpath:/org/olat/course/statistic/_spring/statisticContext.xml"/> <import resource="classpath:/org/olat/course/statistic/_spring/statisticsJobContext.xml"/> - - - <bean id="courseModule" class="org.olat.course.CourseModule" - depends-on="userModule, triggerUserModuleInit, org.olat.core.util.WebappHelper, metaInfoFactory, fileresourceManager"> - + + <bean id="courseFactory" class="org.olat.course.CourseFactory" + depends-on="businessGroupService,resourceManager,baseSecurityManager,glossaryManager"> <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="propertyManager" /> - <constructor-arg index="2" ref="courseFactory" /> - <constructor-arg index="3" ref="repositoryService" /> - <constructor-arg index="4" ref="resourceManager" /> - - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="courseModule" /> - </bean> - </property> - - <!-- Select exported courses to be deployed automatically. See property (DeployCourseExportsEnabled) below. - Default access is 4: - value=1 : Access only for owners (B) - value=2 : Access only for owners and authors (BA) - value=3 : Access for all registered users (BAR) - value=4 : Access for all registered users and anonymous guests - - Be increasing the version with the same identifier, the repo entry gets deleted and the new version gets deployed - If you changing the identifier there will be a new course deployed and the old one will stay. - --> - <property name="courseExportFiles"> - <ref bean="deployedCourseList"/> - </property> - + <constructor-arg index="1" ref="repositoryManager" /> + <constructor-arg index="2" ref="repositoryService" /> + <constructor-arg index="3" ref="referenceManager" /> + </bean> - <!-- Three Logs are available within a course: + <!-- Three Logs are available within a course: - Adminlog, logs administrative activity in the course - Userlog, logs the course user activity, where the user is identifiable - Statisticlog, logs the course user activity, where the user is anonymized @@ -70,41 +46,14 @@ In the case of absent configuration values default to INVISIBLE. --> - <property name="logVisibilityForCourseAuthor"> - <map > + <bean id="logVisibilityForCourseAuthor" class="java.util.HashMap"> + <constructor-arg> + <map > <entry key="AdminLog" value="VISIBLE" /> <entry key="UserLog" value="INVISIBLE" /> <entry key="StatisticLog" value="VISIBLE" /> </map> - </property> - </bean> - - <bean id="courseFactory" class="org.olat.course.CourseFactory" - depends-on="businessGroupService,resourceManager,baseSecurityManager,glossaryManager"> - <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="repositoryManager" /> - <constructor-arg index="2" ref="repositoryService" /> - <constructor-arg index="3" ref="referenceManager" /> - </bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="courseModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - <!-- - If the Instant Messaging is enabled you can switch here the availability of the course chat. - So chatting can be used generally and in groups but disabled in the course. - --> - enableCourseChat=true - <!-- Select exported demo courses to be deployed automatically. --> - deployCourseExportsEnabled=${deploy.course.exports} - <!-- whether the toolbox should display the current participant count or not --> - displayParticipantsCount=${course.display.participants.count} - <!-- The soft-key of the repository entry of the help course, empty to disable help course --> - helpCourseSoftKey = ${help.course.softkey} - </value> - </property> + </constructor-arg> </bean> <bean id="deployedCourseList" class="java.util.ArrayList"> diff --git a/src/main/java/org/olat/course/config/ui/courselayout/CourseLayoutHelper.java b/src/main/java/org/olat/course/config/ui/courselayout/CourseLayoutHelper.java index 1660fe6ce5929e3be8c5a6b6ae99c48cfb592b64..2a8a76c27d30b80a4b522ddb2953a557ee504c87 100644 --- a/src/main/java/org/olat/course/config/ui/courselayout/CourseLayoutHelper.java +++ b/src/main/java/org/olat/course/config/ui/courselayout/CourseLayoutHelper.java @@ -24,8 +24,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.olat.core.CoreSpringFactory; import org.olat.core.commons.services.image.ImageService; import org.olat.core.gui.components.htmlheader.jscss.CustomCSS; +import org.olat.core.helpers.GUISettings; import org.olat.core.helpers.Settings; import org.olat.core.util.StringHelper; import org.olat.core.util.UserSession; @@ -196,7 +198,7 @@ public class CourseLayoutHelper { File themeDir = null; // first attempt is to use custom theme path if (Settings.getGuiCustomThemePath() != null) { - themeDir = new File(Settings.getGuiCustomThemePath(), Settings.getGuiThemeIdentifyer()); + themeDir = new File(Settings.getGuiCustomThemePath(), CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer()); if (themeDir.exists() && themeDir.isDirectory()) { VFSContainer themeContainer = new LocalFolderImpl(themeDir); courseLayoutFolder = (VFSContainer) themeContainer.resolve("/courselayouts"); @@ -205,7 +207,7 @@ public class CourseLayoutHelper { // fallback is to use the standards themes directory in the web app if (themeDir == null || !themeDir.exists() || !themeDir.isDirectory()) { File themesDir = new File(WebappHelper.getContextRealPath("/static/themes/")); - themeDir = new File(themesDir, Settings.getGuiThemeIdentifyer()); + themeDir = new File(themesDir, CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer()); } // resolve now if (themeDir != null && themeDir.exists() && themeDir.isDirectory()) { diff --git a/src/main/java/org/olat/course/db/_spring/coursedbContext.xml b/src/main/java/org/olat/course/db/_spring/coursedbContext.xml index 4de68141a6b2c361d935e95db6b5060214682dab..6733896f7440456af9f6a1811e5cfa94cd582326 100644 --- a/src/main/java/org/olat/course/db/_spring/coursedbContext.xml +++ b/src/main/java/org/olat/course/db/_spring/coursedbContext.xml @@ -12,7 +12,7 @@ <bean id="courseDbWebService" class="org.olat.course.db.restapi.CourseDbWebService" /> - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> + <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject" ref="org.olat.restapi.support.RestRegistrationService" /> <property name="targetMethod" value="addSingleton" /> <property name="arguments" ref="courseDbWebService"/> diff --git a/src/main/java/org/olat/course/run/CourseRuntimeController.java b/src/main/java/org/olat/course/run/CourseRuntimeController.java index 7e9b5dff8dab66a772cbcd71202e112175fe9a35..0ee3ca10d5537fd371262f3078f46b66a2455726 100644 --- a/src/main/java/org/olat/course/run/CourseRuntimeController.java +++ b/src/main/java/org/olat/course/run/CourseRuntimeController.java @@ -177,6 +177,8 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im private int currentUserCount; private Map<String, Boolean> courseRightsCache; + @Autowired + private CourseModule courseModule; @Autowired private ReminderModule reminderModule; @Autowired @@ -203,7 +205,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im // - group modification events coordinatorManager.getCoordinator().getEventBus().registerFor(this, getIdentity(), getRepositoryEntry()); - if (CourseModule.displayParticipantsCount()) { + if (courseModule.displayParticipantsCount()) { coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new MultiUserEvent(JOINED), getOlatResourceable()); updateCurrentUserCount(); } @@ -701,7 +703,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im && imModule.isCourseEnabled() && reSecurity.canLaunch(); if(chatIsEnabled && getUserCourseEnvironment() != null) { chatLink = LinkFactory.createToolLink("chat",translate("command.coursechat"), this, "o_icon_chat"); - chatLink.setVisible(CourseModule.isCourseChatEnabled() && cc.isChatEnabled()); + chatLink.setVisible(imModule.isCourseEnabled() && cc.isChatEnabled()); toolbarPanel.addTool(chatLink); } } @@ -718,7 +720,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im protected void doDispose() { super.doDispose(); - if (CourseModule.displayParticipantsCount()) { + if (courseModule.displayParticipantsCount()) { coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new MultiUserEvent(LEFT), getOlatResourceable()); } } diff --git a/src/main/java/org/olat/ims/_spring/imsContext.xml b/src/main/java/org/olat/ims/_spring/imsContext.xml index 09311f8f0fb1fb3bd912490e37397ef0d27fe367..4b38e52504ff3eab5db131cbe02ea54118d6ca69 100644 --- a/src/main/java/org/olat/ims/_spring/imsContext.xml +++ b/src/main/java/org/olat/ims/_spring/imsContext.xml @@ -10,7 +10,6 @@ <context:component-scan base-package="org.olat.ims.lti.manager,org.olat.ims.qti,org.olat.ims.qti21,uk.ac.ed.ph.jqtiplus" /> - <import resource="classpath:/org/olat/ims/qti/_spring/qtiContext.xml"/> <bean id="org.olat.ims.cp.CPManager" class="org.olat.ims.cp.CPManagerImpl"/> diff --git a/src/main/java/org/olat/ims/qti/QTIModule.java b/src/main/java/org/olat/ims/qti/QTIModule.java index b3896f8e5da9fe79f8e8b408ea09358863689c32..4949bb2bf9516d0065a8011d4a657e7d7f52675e 100644 --- a/src/main/java/org/olat/ims/qti/QTIModule.java +++ b/src/main/java/org/olat/ims/qti/QTIModule.java @@ -25,65 +25,36 @@ package org.olat.ims.qti; -import java.util.List; - -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; -import org.olat.repository.handlers.RepositoryHandler; +import org.olat.core.configuration.AbstractSpringModule; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.olat.ims.qti.repository.handlers.QTISurveyHandler; +import org.olat.ims.qti.repository.handlers.QTITestHandler; import org.olat.repository.handlers.RepositoryHandlerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * Initial Date: 13.11.2002 * * @author Mike Stock */ -public class QTIModule extends AbstractOLATModule { - private static boolean isValidating = false; - private static final String CONFIG_VALIDATING = "validating"; - private List<RepositoryHandler> qtiRepositoryHandlers; - - /** - * @return true if qti xml files should be validated - */ - public static boolean isValidating() { return isValidating; } +@Service("") +public class QTIModule extends AbstractSpringModule { - - /** - * [used by spring] - */ - private QTIModule() { - // + @Autowired + public QTIModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } @Override public void init() { - for (RepositoryHandler qtiRepositoryHandler : qtiRepositoryHandlers) { - RepositoryHandlerFactory.registerHandler(qtiRepositoryHandler, 10); - } + RepositoryHandlerFactory.registerHandler(new QTISurveyHandler(), 10); + RepositoryHandlerFactory.registerHandler(new QTITestHandler(), 10); } - @Override - protected void initDefaultProperties() { - isValidating = getBooleanConfigParameter(CONFIG_VALIDATING, false); - - } @Override protected void initFromChangedProperties() { // } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - - /** - * [SPRING] - * @param qtiFileHandlers - */ - public void setQtiRepositoryHandlers(List<RepositoryHandler> qtiRepositoryHandlers) { - this.qtiRepositoryHandlers = qtiRepositoryHandlers; - } - } diff --git a/src/main/java/org/olat/ims/qti/QTIResultManager.java b/src/main/java/org/olat/ims/qti/QTIResultManager.java index e7217678bb868aec9d84489e9bbf356378153f1c..0ad0aba96f0aa679cd584b702bf4be0db3c680dd 100644 --- a/src/main/java/org/olat/ims/qti/QTIResultManager.java +++ b/src/main/java/org/olat/ims/qti/QTIResultManager.java @@ -40,18 +40,22 @@ import org.olat.core.id.Identity; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.user.UserDataDeletable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * Description: Useful functions for download * * @author Alexander Schneider */ +@Service("qtiResultManager") public class QTIResultManager implements UserDataDeletable { private static final OLog log = Tracing.createLoggerFor(QTIResultManager.class); private static QTIResultManager instance; + @Autowired private DB dbInstance; /** diff --git a/src/main/java/org/olat/ims/qti/_spring/qtiContext.xml b/src/main/java/org/olat/ims/qti/_spring/qtiContext.xml deleted file mode 100644 index a9d3775a7f90b2d4802591b4dc3af7eb66161ccc..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/ims/qti/_spring/qtiContext.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <bean id="qtiModule" class="org.olat.ims.qti.QTIModule" depends-on="database" > - <property name="qtiRepositoryHandlers"> - <list> - <ref bean="QTITestHandler" /> - <ref bean="QTISurveyHandler" /> - </list> - </property> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="qtiModule" /> - </bean> - </property> - </bean> - - <!-- The Handlers which are registered by the QTIMOdule at the repository --> - <bean id="QTITestHandler" class="org.olat.ims.qti.repository.handlers.QTITestHandler"></bean> - <bean id="QTISurveyHandler" class="org.olat.ims.qti.repository.handlers.QTISurveyHandler"></bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="qtiModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - <!-- Whether to validate QTI XML files or not. --> - validating=false - </value> - </property> - </bean> - - <bean id="qtiResultManager" class="org.olat.ims.qti.QTIResultManager"> - <property name="dbInstance" ref="database"/> - </bean> - -</beans> \ No newline at end of file diff --git a/src/main/java/org/olat/instantMessaging/InstantMessagingModule.java b/src/main/java/org/olat/instantMessaging/InstantMessagingModule.java index 9325cc6e92eb656616bad5d51ce836f31fc26431..9f16577460c063e2a911ccacfebec4a16a092b5d 100644 --- a/src/main/java/org/olat/instantMessaging/InstantMessagingModule.java +++ b/src/main/java/org/olat/instantMessaging/InstantMessagingModule.java @@ -62,7 +62,8 @@ public class InstantMessagingModule extends AbstractSpringModule implements Conf private boolean enabled; private boolean groupEnabled = true; private boolean groupAnonymEnabled = true; - private boolean groupAnonymDefaultEnabled = false; + private boolean groupAnonymDefaultEnabled = false; + @Value("${course.chat.enabled:true}") private boolean courseEnabled = true; private boolean courseAnonymEnabled = true; private boolean courseAnonymDefaultEnabled = true; diff --git a/src/main/java/org/olat/ldap/ui/LDAPAuthenticationController.java b/src/main/java/org/olat/ldap/ui/LDAPAuthenticationController.java index c678d603ed9745d9cfd038f695f720e5ee9d6ac8..62523ac42dc6af5bbcf0733541d3bebf0590c555 100644 --- a/src/main/java/org/olat/ldap/ui/LDAPAuthenticationController.java +++ b/src/main/java/org/olat/ldap/ui/LDAPAuthenticationController.java @@ -84,6 +84,8 @@ public class LDAPAuthenticationController extends AuthenticationController imple private final OLATAuthManager olatAuthenticationSpi; + @Autowired + private UserModule userModule; @Autowired private LoginModule loginModule; @Autowired @@ -99,7 +101,7 @@ public class LDAPAuthenticationController extends AuthenticationController imple loginComp = createVelocityContainer("ldaplogin"); - if(UserModule.isPwdchangeallowed(null) && ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) { + if(userModule.isPwdChangeAllowed(null) && ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) { pwLink = LinkFactory.createLink("_olat_login_change_pwd", "menu.pw", loginComp, this); pwLink.setElementCssClass("o_login_pwd"); } @@ -128,7 +130,7 @@ public class LDAPAuthenticationController extends AuthenticationController imple protected void openChangePassword(UserRequest ureq, String initialEmail) { // double-check if allowed first - if (!UserModule.isPwdchangeallowed(ureq.getIdentity()) || !ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) { + if (!userModule.isPwdChangeAllowed(ureq.getIdentity()) || !ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) { showError("error.password.change.not.allow"); } else { removeAsListenerAndDispose(cmc); diff --git a/src/main/java/org/olat/login/OLATAuthenticationController.java b/src/main/java/org/olat/login/OLATAuthenticationController.java index 7064ef7db6729874a597ca4b5f8a18288c8a6378..791540b223287c6261b6f5f77c0ff30b985598e7 100644 --- a/src/main/java/org/olat/login/OLATAuthenticationController.java +++ b/src/main/java/org/olat/login/OLATAuthenticationController.java @@ -79,6 +79,8 @@ public class OLATAuthenticationController extends AuthenticationController imple private Link pwLink; private Link registerLink; + @Autowired + private UserModule userModule; @Autowired private LoginModule loginModule; @Autowired @@ -95,7 +97,7 @@ public class OLATAuthenticationController extends AuthenticationController imple loginComp = createVelocityContainer("olat_log", "olatlogin"); - if(UserModule.isPwdchangeallowed(null)) { + if(userModule.isPwdChangeAllowed(null)) { pwLink = LinkFactory.createLink("_olat_login_change_pwd", "menu.pw", loginComp, this); pwLink.setElementCssClass("o_login_pwd"); } @@ -154,7 +156,7 @@ public class OLATAuthenticationController extends AuthenticationController imple protected void openChangePassword(UserRequest ureq, String initialEmail) { // double-check if allowed first - if (!UserModule.isPwdchangeallowed(ureq.getIdentity())) { + if (!userModule.isPwdChangeAllowed(ureq.getIdentity())) { throw new OLATSecurityException("chose password to be changed, but disallowed by config"); } diff --git a/src/main/java/org/olat/login/oauth/ui/OAuthRegistrationController.java b/src/main/java/org/olat/login/oauth/ui/OAuthRegistrationController.java index e4b7210b7f0827051a8c84621a7e6bbfb6b44600..1759ab1e2d8e84efb389a528949739a37602ab05 100644 --- a/src/main/java/org/olat/login/oauth/ui/OAuthRegistrationController.java +++ b/src/main/java/org/olat/login/oauth/ui/OAuthRegistrationController.java @@ -77,6 +77,8 @@ public class OAuthRegistrationController extends FormBasicController { private Identity authenticatedIdentity; + @Autowired + private UserModule userModule; @Autowired private UserManager userManager; @Autowired @@ -179,7 +181,7 @@ public class OAuthRegistrationController extends FormBasicController { if (!userManager.syntaxCheckOlatLogin(login)) { usernameEl.setErrorKey("form.check3", null); allOk &= false; - } else if (UserModule.isLoginOnBlacklist(login)) { + } else if (userModule.isLoginOnBlacklist(login)) { usernameEl.setErrorKey("form.check6", null); allOk &= false; } else { diff --git a/src/main/java/org/olat/modules/openmeetings/OpenMeetingsModule.java b/src/main/java/org/olat/modules/openmeetings/OpenMeetingsModule.java index a5f0235b204eb9dcf0d58650730468dee952f8e7..4286ca9241c0ecc6f98ab315d80c1d86588d5f03 100644 --- a/src/main/java/org/olat/modules/openmeetings/OpenMeetingsModule.java +++ b/src/main/java/org/olat/modules/openmeetings/OpenMeetingsModule.java @@ -23,16 +23,20 @@ import java.net.URI; import javax.ws.rs.core.UriBuilder; -import org.olat.core.configuration.AbstractOLATModule; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.configuration.ConfigOnOff; -import org.olat.core.configuration.PersistedProperties; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com */ -public class OpenMeetingsModule extends AbstractOLATModule implements ConfigOnOff { +@Service("openmeetingsModule") +public class OpenMeetingsModule extends AbstractSpringModule implements ConfigOnOff { private static final String ENABLED = "vc.openmeetings.enabled"; private static final String PROTOCOL = "protocol"; @@ -42,15 +46,28 @@ public class OpenMeetingsModule extends AbstractOLATModule implements ConfigOnO private static final String ADMIN_LOGIN = "adminLogin"; private static final String ADMIN_PASSWORD = "adminPassword"; + @Value("${vc.openmeetings.enabled}") private boolean enabled; private String displayName; + @Value("${vc.openmeetings.protocol}") private String protocol; + @Value("${vc.openmeetings.port}") private int port; + @Value("${vc.openmeetings.baseurl}") private String baseUrl; + @Value("${vc.openmeetings.contextPath}") private String contextPath; + @Value("${vc.openmeetings.adminlogin}") private String adminLogin; + @Value("${vc.openmeetings.adminpassword}") private String adminPassword; + + @Autowired + public OpenMeetingsModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + } + @Override public void init() { String enabledObj = getStringPropertyValue(ENABLED, true); @@ -84,27 +101,10 @@ public class OpenMeetingsModule extends AbstractOLATModule implements ConfigOnO } } - @Override - protected void initDefaultProperties() { - enabled = getBooleanConfigParameter(ENABLED, true); - protocol = getStringConfigParameter(PROTOCOL, "http", false); - port = getIntConfigParameter(PORT, 5080); - baseUrl = getStringConfigParameter(BASE_URL, "localhost", false); - contextPath = getStringConfigParameter(CONTEXT_PATH, "openmeetings", false); - adminLogin = getStringConfigParameter(ADMIN_LOGIN, "admin", false); - adminPassword = getStringConfigParameter(ADMIN_PASSWORD, "0007", false); - } - @Override protected void initFromChangedProperties() { init(); } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - public URI getOpenMeetingsURI() { UriBuilder builder = UriBuilder.fromUri(getProtocol() + "://" + getBaseUrl()); @@ -120,8 +120,8 @@ public class OpenMeetingsModule extends AbstractOLATModule implements ConfigOnO public void setOpenMeetingsURI(URI uri) { String host = uri.getHost(); setBaseUrl(host); - int port = uri.getPort(); - setPort(port); + int omPort = uri.getPort(); + setPort(omPort); String path = uri.getPath(); if(StringHelper.containsNonWhitespace(path) && path.startsWith("/")) { path = path.substring(1, path.length()); diff --git a/src/main/java/org/olat/modules/openmeetings/_spring/openmeetingsContext.xml b/src/main/java/org/olat/modules/openmeetings/_spring/openmeetingsContext.xml index cb321e6f7589661d57b7346d04c9606ed1709d38..d53ed9339a8c5edfab4fe1ca210b4cd89094ddde 100644 --- a/src/main/java/org/olat/modules/openmeetings/_spring/openmeetingsContext.xml +++ b/src/main/java/org/olat/modules/openmeetings/_spring/openmeetingsContext.xml @@ -4,41 +4,12 @@ xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="org.olat.modules.openmeetings" /> - <!-- Definition of the providers --> - <bean id="openmeetingsModule" class="org.olat.modules.openmeetings.OpenMeetingsModule"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="coordinatorManager,org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="openmeetingsModule" /> - </bean> - </property> - </bean> - - <!-- default configuration --> - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="openmeetingsModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - vc.openmeetings.enabled=${vc.openmeetings.enabled} - protocol=${vc.openmeetings.protocol} - port=${vc.openmeetings.port} - baseUrl=${vc.openmeetings.baseurl} - contextPath=${vc.openmeetings.contextPath} - adminLogin=${vc.openmeetings.adminlogin} - adminPassword=${vc.openmeetings.adminpassword} - customerId=${vc.openmeetings.customerid} - </value> - </property> - </bean> - <!-- OpenMeetings admin. panel --> <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> <property name="order" value="7210" /> diff --git a/src/main/java/org/olat/modules/vitero/ViteroModule.java b/src/main/java/org/olat/modules/vitero/ViteroModule.java index 9ff23a18cd4fafbdc8ba22c992a85967088aa58b..4b53ac19524560281f433526a9d538a55d3734c6 100644 --- a/src/main/java/org/olat/modules/vitero/ViteroModule.java +++ b/src/main/java/org/olat/modules/vitero/ViteroModule.java @@ -25,15 +25,20 @@ import java.util.Calendar; import javax.ws.rs.core.UriBuilder; -import org.olat.core.configuration.AbstractOLATModule; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.configuration.ConfigOnOff; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.modules.vitero.manager.ViteroZombieSlayerJob; import org.quartz.CronTrigger; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * @@ -44,7 +49,10 @@ import org.quartz.SchedulerException; * * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com */ -public class ViteroModule extends AbstractOLATModule implements ConfigOnOff { +@Service +public class ViteroModule extends AbstractSpringModule implements ConfigOnOff { + + private static final OLog log = Tracing.createLoggerFor(ViteroModule.class); private static final String ENABLED = "vc.vitero.enabled"; private static final String PROTOCOL = "protocol"; @@ -56,22 +64,35 @@ public class ViteroModule extends AbstractOLATModule implements ConfigOnOff { private static final String CUSTOMER_ID = "customerId"; private static final String OLAT_TIMEZONE_ID = "olatTimeZoneId"; + @Value("${vc.vitero.enabled}") private boolean enabled; private String displayName; + @Value("${vc.vitero.protocol}") private String protocol; + @Value("${vc.vitero.port}") private int port; + @Value("${vc.vitero.baseurl}") private String baseUrl; + @Value("${vc.vitero.contextPath}") private String contextPath; + @Value("${vc.vitero.adminlogin}") private String adminLogin; + @Value("${vc.vitero.adminpassword}") private String adminPassword; + @Value("${vc.vitero.customerid}") private int customerId; + @Value("${vc.vitero.olatTimeZoneId}") private String olatTimeZoneId; - + @Value("${vc.vitero.cron:0 15 */12 * * ?}") private String cronExpression; - private final Scheduler scheduler; + @Value("${vc.vitero.deleteVmsUserOnUserDelete}") private boolean deleteVmsUserOnUserDelete; - public ViteroModule(Scheduler scheduler) { + private final Scheduler scheduler; + + @Autowired + public ViteroModule(CoordinatorManager coordinatorManager, Scheduler scheduler) { + super(coordinatorManager); this.scheduler = scheduler; } @@ -118,19 +139,6 @@ public class ViteroModule extends AbstractOLATModule implements ConfigOnOff { initCronJob(); } - @Override - protected void initDefaultProperties() { - enabled = getBooleanConfigParameter(ENABLED, true); - protocol = getStringConfigParameter(PROTOCOL, "http", false); - port = getIntConfigParameter(PORT, 8080); - baseUrl = getStringConfigParameter(BASE_URL, "localhost", false); - contextPath = getStringConfigParameter(CONTEXT_PATH, "vitero", false); - adminLogin = getStringConfigParameter(ADMIN_LOGIN, "admin", false); - adminPassword = getStringConfigParameter(ADMIN_PASSWORD, "007", false); - customerId = Integer.parseInt(getStringConfigParameter(CUSTOMER_ID, "1", false)); - olatTimeZoneId = getStringConfigParameter(OLAT_TIMEZONE_ID, "Africa/Ceuta", false); - } - @Override protected void initFromChangedProperties() { init(); @@ -150,16 +158,11 @@ public class ViteroModule extends AbstractOLATModule implements ConfigOnOff { scheduler.scheduleJob(jobDetail, trigger); } } catch (ParseException e) { - logError("Cannot start the Quartz Job which clean the Vitero rooms", e); + log.error("Cannot start the Quartz Job which clean the Vitero rooms", e); } catch (SchedulerException e) { - logError("Cannot start the Quartz Job which clean the Vitero rooms", e); + log.error("Cannot start the Quartz Job which clean the Vitero rooms", e); } } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } public boolean isDeleteVmsUserOnUserDelete() { return deleteVmsUserOnUserDelete; diff --git a/src/main/java/org/olat/modules/vitero/_spring/viteroContext.xml b/src/main/java/org/olat/modules/vitero/_spring/viteroContext.xml index 893dd4508b19b5c625ed3af18fe0b8299d5bc650..e770b7fd4ddf0a588b18b62877bee29172af41d9 100644 --- a/src/main/java/org/olat/modules/vitero/_spring/viteroContext.xml +++ b/src/main/java/org/olat/modules/vitero/_spring/viteroContext.xml @@ -4,46 +4,11 @@ xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="org.olat.modules.vitero" /> - - <!-- Definition of the providers --> - <bean id="viteroModule" class="org.olat.modules.vitero.ViteroModule"> - <constructor-arg index="0" ref="schedulerFactoryBean"/> - <property name="cronExpression" value="0 15 */12 * * ?" /> - <property name="deleteVmsUserOnUserDelete" value="${vc.vitero.deleteVmsUserOnUserDelete}" /> - - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="coordinatorManager,org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="viteroModule" /> - </bean> - </property> - - </bean> - - <!-- default configuration --> - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="viteroModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - vc.vitero.enabled=${vc.vitero.enabled} - protocol=${vc.vitero.protocol} - port=${vc.vitero.port} - baseUrl=${vc.vitero.baseurl} - contextPath=${vc.vitero.contextPath} - adminLogin=${vc.vitero.adminlogin} - adminPassword=${vc.vitero.adminpassword} - customerId=${vc.vitero.customerid} - olatTimeZoneId=${vc.vitero.olatTimeZoneId} - </value> - </property> - </bean> <!-- vitero admin. panel --> <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> diff --git a/src/main/java/org/olat/registration/PwChangeController.java b/src/main/java/org/olat/registration/PwChangeController.java index 14b47e9fb96a35434585a1ef67f94864beba28c1..d15a9a5e0a5c114f3de1a6ad6cf657bcdda1aec4 100644 --- a/src/main/java/org/olat/registration/PwChangeController.java +++ b/src/main/java/org/olat/registration/PwChangeController.java @@ -83,6 +83,8 @@ public class PwChangeController extends BasicController { private EmailOrUsernameFormController emailOrUsernameCtr; private Link pwchangeHomelink; + @Autowired + private UserModule userModule; @Autowired private RegistrationManager rm; @Autowired @@ -232,7 +234,7 @@ public class PwChangeController extends BasicController { if (identity != null) { // check if user has an OLAT provider token, otherwhise a pwd change makes no sense Authentication auth = BaseSecurityManager.getInstance().findAuthentication(identity, BaseSecurityModule.getDefaultAuthProviderIdentifier()); - if (auth == null || !UserModule.isPwdchangeallowed(identity)) { + if (auth == null || !userModule.isPwdChangeAllowed(identity)) { getWindowControl().setWarning(translate("password.cantchange")); return; } diff --git a/src/main/java/org/olat/registration/RegistrationController.java b/src/main/java/org/olat/registration/RegistrationController.java index 5c1af935791254ed7b5669dc42532904ecb8905c..db4cc5c3b4d84082ec37cb437de08260134b2691 100644 --- a/src/main/java/org/olat/registration/RegistrationController.java +++ b/src/main/java/org/olat/registration/RegistrationController.java @@ -185,8 +185,8 @@ public class RegistrationController extends BasicController implements Activatea Map<String,String> userAttrs = new HashMap<String,String>(); userAttrs.put("email", tempKey.getEmailAddress()); - if(RegistrationModule.getUsernamePresetBean() != null) { - UserNameCreationInterceptor interceptor = RegistrationModule.getUsernamePresetBean(); + if(registrationModule.getUsernamePresetBean() != null) { + UserNameCreationInterceptor interceptor = registrationModule.getUsernamePresetBean(); String proposedUsername = interceptor.getUsernameFor(userAttrs); if(proposedUsername == null) { if(interceptor.allowChangeOfUsername()) { @@ -468,7 +468,6 @@ public class RegistrationController extends BasicController implements Activatea //add eventually static value UserPropertiesConfig userPropertiesConfig = CoreSpringFactory.getImpl(UserPropertiesConfig.class); - RegistrationModule registrationModule = CoreSpringFactory.getImpl(RegistrationModule.class); if(registrationModule.isStaticPropertyMappingEnabled()) { String propertyName = registrationModule.getStaticPropertyMappingName(); String propertyValue = registrationModule.getStaticPropertyMappingValue(); diff --git a/src/main/java/org/olat/registration/RegistrationForm2.java b/src/main/java/org/olat/registration/RegistrationForm2.java index 974010892d61e160df4c7ede6532ed023283f9d5..c317c2fd5d7810093356dae1c97c7a11896d1cb3 100644 --- a/src/main/java/org/olat/registration/RegistrationForm2.java +++ b/src/main/java/org/olat/registration/RegistrationForm2.java @@ -50,6 +50,7 @@ import org.olat.user.ChangePasswordForm; import org.olat.user.UserManager; import org.olat.user.UserModule; import org.olat.user.propertyhandlers.UserPropertyHandler; +import org.springframework.beans.factory.annotation.Autowired; /** * Description: @@ -74,6 +75,9 @@ public class RegistrationForm2 extends FormBasicController { private FormLayoutContainer buttonLayout; + @Autowired + private UserModule userModule; + /** * @param name * @param languageKey @@ -222,7 +226,7 @@ public class RegistrationForm2 extends FormBasicController { } Identity s = BaseSecurityManager.getInstance().findIdentityByName(getLogin()); - if (s != null || UserModule.isLoginOnBlacklist(getLogin())) { + if (s != null || userModule.isLoginOnBlacklist(getLogin())) { setLoginErrorKey("form.check6"); return false; } diff --git a/src/main/java/org/olat/registration/RegistrationModule.java b/src/main/java/org/olat/registration/RegistrationModule.java index cf69988ea09eca15cd9bf220c07379dbc4261584..d4569e8a72d71990e749ac753bd75d454290b721 100644 --- a/src/main/java/org/olat/registration/RegistrationModule.java +++ b/src/main/java/org/olat/registration/RegistrationModule.java @@ -29,10 +29,16 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.mail.EmailAddressValidator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Initial Date: May 4, 2004 @@ -47,49 +53,48 @@ import org.olat.core.util.mail.EmailAddressValidator; * disclaimer that has to be accepted by users when entering the system * the first time. */ -public class RegistrationModule extends AbstractOLATModule { - // registration config - private static final String CONFIG_SELFREGISTRATION = "enableSelfregistration"; - private static final String CONFIG_STATIC_PROPERTY_MAPPING = "enableStaticPropertyMapping"; - private static final String CONFIG_STATIC_PROPERTY_MAPPING_KEY = "staticPropertyMapping"; - private static final String CONFIG_STATIC_PROPERTY_MAPPING_VAL = "staticPropertyMappingValue"; - private static final String CONFIG_SELFREGISTRATION_LINK = "enableSelfregistrationLink"; - private static final String CONFIG_SELFREGISTRATION_LOGIN = "enableSelfregistrationLogin"; - private static final String CONFIG_REGISTRATION_NOTIFICATION ="registrationNotificationEnabled"; - private static final String CONFIG_REGISTRATION_NOTIFICATION_EMAIL ="registrationNotificationEmail"; +@Service("registrationModule") +public class RegistrationModule extends AbstractSpringModule { + private static final OLog log = Tracing.createLoggerFor(RegistrationModule.class); + + @Value("${registration.enableSelfRegistration}") private boolean selfRegistrationEnabled; + @Value("${registration.enableSelfRegistration.link}") private boolean selfRegistrationLinkEnabled; + @Value("${registration.enableSelfRegistration.login}") private boolean selfRegistrationLoginEnabled; - private boolean staticPropertyMappingEnabled; + + @Value("${registration.enableNotificationEmail}") + private boolean registrationNotificationEmailEnabled; + @Value("${registration.notificationEmail}") private String registrationNotificationEmail; + + @Value("${registration.staticPropertyMapping:false}") + private boolean staticPropertyMappingEnabled; + @Value("${registration.domainList}") private String domainList; private String staticPropertyMappingName; private String staticPropertyMappingValue; - // disclaimer config - private static final String CONFIG_DISCLAIMER = "disclaimerEnabled"; - private static final String CONFIG_ADDITIONAL_CHECKBOX ="disclaimerAdditionalCheckbox"; - private static final String CONFIG_ADDITIONAL_LINK ="disclaimerAdditionaLinkText"; - private static boolean disclaimerEnabled; - private static boolean additionalCheckbox; - private static boolean additionaLinkText; + @Value("${registration.enableDisclaimer}") + private boolean disclaimerEnabled; + @Value("${registration.disclaimerAdditionalCheckbox}") + private boolean additionalCheckbox; + @Value("${registration.disclaimerAdditionaLinkText} ") + private boolean additionaLinkText; - private static UserNameCreationInterceptor usernamePresetBean; + @Autowired @Qualifier("usernamePresetBean") + private UserNameCreationInterceptor usernamePresetBean; - /** - * [used by spring] - */ - private RegistrationModule() { - // + @Autowired + public RegistrationModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } - public static UserNameCreationInterceptor getUsernamePresetBean() { - return RegistrationModule.usernamePresetBean; + public UserNameCreationInterceptor getUsernamePresetBean() { + return usernamePresetBean; } - public void setUsernamePresetBean(UserNameCreationInterceptor usernamePresetBean) { - RegistrationModule.usernamePresetBean = usernamePresetBean; - } /** * @return true if self registration is turned on, false otherwhise @@ -261,49 +266,32 @@ public class RegistrationModule extends AbstractOLATModule { @Override protected void initDefaultProperties() { - selfRegistrationEnabled = getBooleanConfigParameter(CONFIG_SELFREGISTRATION, false); + super.initDefaultProperties(); + if (selfRegistrationEnabled) { - logInfo("Selfregistration is turned ON"); + log.info("Selfregistration is turned ON"); } else { - logInfo("Selfregistration is turned OFF"); + log.info("Selfregistration is turned OFF"); } - - selfRegistrationLinkEnabled = getBooleanConfigParameter(CONFIG_SELFREGISTRATION_LINK, false); - selfRegistrationLoginEnabled = getBooleanConfigParameter(CONFIG_SELFREGISTRATION_LOGIN, false); // Check for registration email notification configuration - Boolean regNoti = getBooleanConfigParameter(CONFIG_REGISTRATION_NOTIFICATION, true); - registrationNotificationEmail = getStringConfigParameter(CONFIG_REGISTRATION_NOTIFICATION_EMAIL, "", true); - if (EmailAddressValidator.isValidEmailAddress(registrationNotificationEmail) || !regNoti) { - logInfo("Registration notification email is turned OFF by configuration or because given email::" + registrationNotificationEmail + " is not valid."); + if (EmailAddressValidator.isValidEmailAddress(registrationNotificationEmail) || !registrationNotificationEmailEnabled) { + log.info("Registration notification email is turned OFF by configuration or because given email::" + registrationNotificationEmail + " is not valid."); registrationNotificationEmail = null; } else { - logInfo("Registration notification email is turned ON, email used is '" + registrationNotificationEmail + "'"); + log.info("Registration notification email is turned ON, email used is '" + registrationNotificationEmail + "'"); } // disclaimer configuration - disclaimerEnabled = getBooleanConfigParameter(CONFIG_DISCLAIMER, false); if (disclaimerEnabled) { - logInfo("Disclaimer is turned ON"); + log.info("Disclaimer is turned ON"); } else { - logInfo("Disclaimer is turned OFF"); + log.info("Disclaimer is turned OFF"); } - // optional disclaimer elements - additionalCheckbox = getBooleanConfigParameter(CONFIG_ADDITIONAL_CHECKBOX, false); - additionaLinkText = getBooleanConfigParameter(CONFIG_ADDITIONAL_LINK, false); - - staticPropertyMappingEnabled = getBooleanConfigParameter(CONFIG_STATIC_PROPERTY_MAPPING, false); - staticPropertyMappingName = getStringConfigParameter(CONFIG_STATIC_PROPERTY_MAPPING_KEY, "", true); - staticPropertyMappingValue = getStringConfigParameter(CONFIG_STATIC_PROPERTY_MAPPING_VAL, "", true); } @Override protected void initFromChangedProperties() { init(); } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } } \ No newline at end of file diff --git a/src/main/java/org/olat/registration/_spring/registrationContext.xml b/src/main/java/org/olat/registration/_spring/registrationContext.xml index a3de55b653e39feeed619355fae50cc12269bb03..89ed47e292b39acb0afb580100b75207da454ed2 100644 --- a/src/main/java/org/olat/registration/_spring/registrationContext.xml +++ b/src/main/java/org/olat/registration/_spring/registrationContext.xml @@ -10,40 +10,7 @@ <context:component-scan base-package="org.olat.registration" /> - <!-- Registration module --> - <bean id="registrationModule" class="org.olat.registration.RegistrationModule" depends-on="i18nModule" > - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="registrationModule" /> - </bean> - </property> - <property name="usernamePresetBean" ref="registrationPresetUsername.${registration.preset.username}"/> - </bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="registrationModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - <!-- Should users be able to register themselfe? If disabled, users can not create --> - <!-- local user accounts themself. This has no effect on the registration mechanism --> - <!-- used in the Shibboleth registration process, its only about local user accounts --> - enableSelfregistration=${registration.enableSelfRegistration} - enableSelfregistrationLink=${registration.enableSelfRegistration.link} - enableSelfregistrationLogin=${registration.enableSelfRegistration.login} - registrationDomainList=${registration.domainList} - - <!-- Send an email to the given address every time a new user registers in the system. --> - <!-- This is usefull to monitor who is registering and maybe block unwanted users. --> - registrationNotificationEnabled=${registration.enableNotificationEmail} - registrationNotificationEmail=${registration.notificationEmail} - disclaimerEnabled=${registration.enableDisclaimer} - disclaimerAdditionalCheckbox=${registration.disclaimerAdditionalCheckbox} - disclaimerAdditionaLinkText=${registration.disclaimerAdditionaLinkText} - </value> - </property> - </bean> + <alias alias="usernamePresetBean" name="registrationPresetUsername.${registration.preset.username}"/> <bean id="registrationPresetUsername.byEmail" class="org.olat.registration.SelfRegistrationUserNameFromEmailUserNameCreationInterceptor" lazy-init="true"> diff --git a/src/main/java/org/olat/registration/restapi/ChangePasswordWebService.java b/src/main/java/org/olat/registration/restapi/ChangePasswordWebService.java index f825bf7cf6f29a7088f29abe7f4c726e53e3f9df..87931af41db289d613b65b080df9743b33226835 100644 --- a/src/main/java/org/olat/registration/restapi/ChangePasswordWebService.java +++ b/src/main/java/org/olat/registration/restapi/ChangePasswordWebService.java @@ -68,7 +68,7 @@ public class ChangePasswordWebService { Identity identity = securityManager.loadIdentityByKey(identityKey); if(identity == null) { return Response.serverError().status(Status.NOT_FOUND).build(); - } else if(!UserModule.isPwdchangeallowed(identity)) { + } else if(!CoreSpringFactory.getImpl(UserModule.class).isPwdChangeAllowed(identity)) { return Response.serverError().status(Status.FORBIDDEN).build(); } diff --git a/src/main/java/org/olat/resource/accesscontrol/provider/paypal/PaypalModule.java b/src/main/java/org/olat/resource/accesscontrol/provider/paypal/PaypalModule.java index d389ba73de12221ac375646fae60ffb0eef1ba4f..e80cb3a39cd372eab121b2911ca53979d4ea5759 100644 --- a/src/main/java/org/olat/resource/accesscontrol/provider/paypal/PaypalModule.java +++ b/src/main/java/org/olat/resource/accesscontrol/provider/paypal/PaypalModule.java @@ -23,11 +23,14 @@ package org.olat.resource.accesscontrol.provider.paypal; import java.net.InetAddress; import java.net.UnknownHostException; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.helpers.Settings; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.GenericEventListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * @@ -39,7 +42,8 @@ import org.olat.core.util.event.GenericEventListener; * Initial Date: 25 mai 2011 <br> * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com */ -public class PaypalModule extends AbstractOLATModule implements GenericEventListener { +@Service +public class PaypalModule extends AbstractSpringModule implements GenericEventListener { private static final String X_PAYPAL_SECURITY_USERID = "paypal.security.user.id"; private static final String X_PAYPAL_SECURITY_PASSWORD = "paypal.security.password"; @@ -54,21 +58,39 @@ public class PaypalModule extends AbstractOLATModule implements GenericEventList private static final String PAYPAL_CURRENCY = "paypal.currency"; private static final String DEFAULT_PAYPAL_DATA_FORMAT = "XML"; - private boolean sandbox = true; + // API USERNAME, Replace RHS with your API user name you obtained from sandbox/live server. + @Value("${paypal.security.user.id}") private String paypalSecurityUserId; + // API PASSWORD, Replace RHS with your API password you obtained from sandbox/live server. + @Value("${paypal.security.password}") private String paypalSecurityPassword; + // API SIGNATURE ,If you are using the 3 token credential then you should uncomment the following + // line and specify/change the signature on the RHS of the = sign. The module only implements the + // 3 token credential. + @Value("${paypal.security.signature}") private String paypalSecuritySignature; + // APPLICATION ID, Replace RHS with your application id + @Value("${paypal.application.id}") private String paypalApplicationId; + // Replace the RHS with the email address you used to signup at http://developer.paypal.com + @Value("${paypal.sandbox:false}") + private boolean sandbox; + @Value("${paypal.sandbox.email}") private String paypalSandboxEmailAddress; + // Email fo the first receiver/merchant + @Value("${paypal.first.receiver.email} ") private String paypalFirstReceiverEmailAddress; private String deviceIpAddress; private String paypalCurrency; + // change only if you know what you do + @Value("${paypal.data.format}") private String paypalDataFormat; - - public PaypalModule() { - // + + @Autowired + public PaypalModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } @Override @@ -119,23 +141,6 @@ public class PaypalModule extends AbstractOLATModule implements GenericEventList } } - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - - @Override - protected void initDefaultProperties() { - paypalSecurityUserId = getStringConfigParameter(X_PAYPAL_SECURITY_USERID, "", true); - paypalSecurityPassword = getStringConfigParameter(X_PAYPAL_SECURITY_PASSWORD, "", true); - paypalSecuritySignature = getStringConfigParameter(X_PAYPAL_SECURITY_SIGNATURE, "", true); - paypalApplicationId = getStringConfigParameter(X_PAYPAL_APPLICATION_ID, "", true); - paypalSandboxEmailAddress = getStringConfigParameter(X_PAYPAL_SANDBOX_EMAIL_ADDRESS, "", true); - paypalDataFormat = getStringConfigParameter(DATA_FORMAT_XML, DEFAULT_PAYPAL_DATA_FORMAT, true); - paypalFirstReceiverEmailAddress = getStringConfigParameter(FIRST_RECEIVER_EMAIL_ADDRESS, "", true); - sandbox = getBooleanConfigParameter(SANDBOX, false); - } - @Override protected void initFromChangedProperties() { init(); diff --git a/src/main/java/org/olat/resource/accesscontrol/provider/paypal/_spring/paypalContext.xml b/src/main/java/org/olat/resource/accesscontrol/provider/paypal/_spring/paypalContext.xml index 81515b2ff7021f576d82e726bbdc76e1db1edbf2..13ff50afb968e2195ea1f6683736d20a678af743 100644 --- a/src/main/java/org/olat/resource/accesscontrol/provider/paypal/_spring/paypalContext.xml +++ b/src/main/java/org/olat/resource/accesscontrol/provider/paypal/_spring/paypalContext.xml @@ -2,51 +2,10 @@ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="paypalModule" class="org.olat.resource.accesscontrol.provider.paypal.PaypalModule" init-method="init"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="paypalModule" /> - <constructor-arg index="2" value="com.frentix.olat.accesscontrol.paypal.PaypalModule" /> - <constructor-arg index="3" value="true" /> - </bean> - </property> - </bean> - - <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="paypalModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - - <!-- API USERNAME, Replace RHS with your API user name you obtained from sandbox/live server. --> - paypal.security.user.id=${paypal.security.user.id} - <!-- API PASSWORD, Replace RHS with your API password you obtained from sandbox/live server. --> - paypal.security.password=${paypal.security.password} - <!-- API SIGNATURE ,If you are using the 3 token credential then you should uncomment the following - line and specify/change the signature on the RHS of the = sign. The module only implements the - 3 token credential. --> - paypal.security.signature=${paypal.security.signature} - <!-- APPLICATION ID, Replace RHS with your application id --> - paypal.application.id=${paypal.application.id} - <!-- Replace the RHS with the email address you used to signup at http://developer.paypal.com --> - paypal.sandbox.email=${paypal.sandbox.email} - <!-- Use the sandbox server --> - paypal.sandbox=${paypal.sandbox} - <!-- change only if you know what you do --> - paypal.data.format=${paypal.data.format} - <!-- Email fo the first receiver/merchant --> - paypal.first.receiver.email=${paypal.first.receiver.email} - </value> - </property> - </bean> - <bean id="paypalAccessHandler" class="org.olat.resource.accesscontrol.provider.paypal.PaypalAccessHandler"/> - <!-- Paypal admin panel --> <bean class="org.olat.core.extensions.action.GenericActionExtension" id="sysadmin.menupoint.paypal" init-method="initExtensionPoints"> <property name="actionController"> diff --git a/src/main/java/org/olat/search/SearchModule.java b/src/main/java/org/olat/search/SearchModule.java index 41ffc0bcbb8a693d31e6d4085cf9c9584352565e..67ff87bdfd2d707c20294e0ee0aa83634affca8c 100644 --- a/src/main/java/org/olat/search/SearchModule.java +++ b/src/main/java/org/olat/search/SearchModule.java @@ -33,12 +33,16 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -import org.olat.core.commons.modules.bc.FolderConfig; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.commons.modules.bc.FolderModule; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Description:<br> @@ -46,7 +50,8 @@ import org.olat.core.util.StringHelper; * Initial Date: 15.06.200g <br> * @author Christian Guretzki */ -public class SearchModule extends AbstractOLATModule { +@Service("searchModule") +public class SearchModule extends AbstractSpringModule { private static final OLog log = Tracing.createLoggerFor(SearchModule.class); // Definitions config parameter names in module-config @@ -56,102 +61,76 @@ public class SearchModule extends AbstractOLATModule { public final static String CONF_TEMP_INDEX_PATH = "tempIndexPath"; public final static String CONF_TEMP_SPELL_CHECK_PATH = "tempSpellCheckPath"; public final static String CONF_GENERATE_AT_STARTUP = "generateIndexAtStartup"; - private static final String CONF_INDEX_INTERVAL = "indexInterval"; - private static final String CONF_MAX_HITS = "maxHits"; - private static final String CONF_MAX_RESULTS = "maxResults"; - private static final String CONF_FOLDER_POOL_SIZE = "folderPoolSize"; - private static final String CONF_RESTART_WINDOW_START = "restartWindowStart"; - private static final String CONF_RESTART_WINDOW_END = "restartWindowEnd"; - private static final String CONF_UPDATE_INTERVAL = "updateInterval"; - private static final String CONF_DOCUMENTS_PER_INTERVAL = "documentsPerInterval"; - private static final String CONF_RESTART_DAY_OF_WEEK = "restartDayOfWeek"; private static final String CONF_PPT_FILE_ENABLED = "pptFileEnabled"; private static final String CONF_EXCEL_FILE_ENABLED = "excelFileEnabled"; private static final String CONF_PDF_FILE_ENABLED = "pdfFileEnabled"; - private static final String CONF_PDF_TEXT_BUFFERING = "pdfTextBuffering"; - private static final String CONF_PDF_EXTERNAL_INDEXER = "pdfExternalIndexer"; - private static final String CONF_PDF_EXTERNAL_INDEXER_CMD = "pdfExternExtractorCommand"; - private static final String CONF_SPELL_CHECK_ENABLED = "spellCheckEnabled"; - private static final String CONF_TEMP_PDF_TEXT_BUF_PATH = "pdfTextBufferPath"; - private static final String CONF_MAX_FILE_SIZE = "maxFileSize"; - private static final String CONF_RAM_BUFFER_SIZE_MB = "ramBufferSizeMb"; - private static final String CONF_USE_COMPOUND_FILE = "useCompoundFile"; private static final String CONF_FILE_BLACK_LIST = "fileBlackList"; + - // Default values - private static final int DEFAULT_INDEX_INTERVAL = 0; - private static final int DEFAULT_MAX_HITS = 1000; - private static final int DEFAULT_MAX_RESULTS = 100; - private static final int DEFAULT_FOLDER_POOL_SIZE = 0; - private static final int DEFAULT_RESTART_WINDOW_START = 0; - private static final int DEFAULT_RESTART_WINDOW_END = 24; - private static final int DEFAULT_UPDATE_INTERVAL = 0; - private static final int DEFAULT_DOCUMENTS_PER_INTERVAL = 4; - private static final int DEFAULT_RESTART_DAY_OF_WEEK = 8; - private static final String DEFAULT_RAM_BUFFER_SIZE_MB = "48"; - + @Value("${search.service:enabled}") private String searchService; + + @Value("${search.index.tempIndex:/tmp}") + private String tempIndexPath; + @Value("${search.index.tempSpellcheck:/tmp}") + private String tempSpellCheckPath; + @Value("${search.index.pdfBuffer:/tmp}") + private String tempPdfTextBufferPath; + + @Value("${search.index.path:/tmp}") + private String indexPath; + @Value("${search.permanent.index.path:/sidx}") + private String permanentIndexPath; + private String fullIndexPath; private String fullPermanentIndexPath; private String fullTempIndexPath; private String fullTempSpellCheckPath; - private long indexInterval; + + private long indexInterval = 0; + @Value("${generate.index.at.startup:true}") private boolean generateAtStartup; - private int maxHits; - private int maxResults; - private List<String> fileBlackList; - private List<String> customFileBlackList; + private int maxHits = 1000; + private int maxResults = 100; + @Value("${search.folder.pool.size:3}") private int folderPoolSize; + @Value("${restart.window.start}") private int restartWindowStart; + @Value("${restart.window.end}") private int restartWindowEnd; - private long updateInterval; - private int documentsPerInterval; - private int restartDayOfWeek; - private boolean pptFileEnabled; - private boolean excelFileEnabled; - private boolean pdfFileEnabled; - private boolean pdfTextBuffering; + private long updateInterval = 0; + private int documentsPerInterval = 4; + private int restartDayOfWeek = 0; + private boolean pptFileEnabled = true; + private boolean excelFileEnabled = true; + private boolean pdfFileEnabled = true; + private boolean pdfTextBuffering = true; + @Value("${search.pdf.external:false}") private boolean pdfExternalIndexer; + @Value("${search.pdf.external.command:convertpdf.sh}") private String pdfExternalIndexerCmd; - private boolean isSpellCheckEnabled; + private boolean isSpellCheckEnabled = true; private String fullPdfTextBufferPath; - private List<String> fileSizeSuffixes; - private long maxFileSize; - private List<Long> repositoryBlackList; - - private double ramBufferSizeMB; - private boolean useCompoundFile; + private long maxFileSize = 10485760; + private double ramBufferSizeMB = 16; + private boolean useCompoundFile = false; + @Autowired @Qualifier("fileSizeSuffixes") + private ArrayList<String> fileSizeSuffixes; + @Autowired @Qualifier("fileBlackList") + private ArrayList<String> fileBlackList; + private ArrayList<String> customFileBlackList; + @Autowired @Qualifier("repositoryBlackList") + private ArrayList<Long> repositoryBlackList; - /** - * [used by spring] - */ - private SearchModule() { - } - - /** - * [used by spring] - * @param fileSizeSuffixes - */ - public void setFileSizeSuffixes(List<String> fileSizeSuffixes) { - this.fileSizeSuffixes = fileSizeSuffixes; - } - /** - * [used by spring] - * @param fileBlackList - */ - public void setFileBlackList(List<String> fileBlackList) { - this.fileBlackList = fileBlackList; - } + @Autowired + private FolderModule folderModule; - /** - * [used by spring] - * @param fileBlackList - */ - public void setRepositoryBlackList(List<Long> repositoryBlackList) { - this.repositoryBlackList = repositoryBlackList; + @Autowired + public SearchModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } /** @@ -160,45 +139,15 @@ public class SearchModule extends AbstractOLATModule { @Override public void initDefaultProperties() { log.debug("init start..."); - - searchService = getStringConfigParameter(CONF_SEARCH_SERVICE, "enabled", false); + super.initDefaultProperties(); - String indexPath = getStringConfigParameter(CONF_INDEX_PATH, "/tmp", false); - String permanentIndexPath = getStringConfigParameter(CONF_PERMANENT_INDEX_PATH, "/sidx", false); - log.debug("init indexPath=" + indexPath); - String tempIndexPath = getStringConfigParameter(CONF_TEMP_INDEX_PATH, "/tmp", false); - String tempSpellCheckPath = getStringConfigParameter(CONF_TEMP_SPELL_CHECK_PATH, "/tmp",false); - String tempPdfTextBufferPath = getStringConfigParameter(CONF_TEMP_PDF_TEXT_BUF_PATH, "/tmp", false); - fullIndexPath = buildPath(indexPath); fullPermanentIndexPath = buildPath(permanentIndexPath); - fullTempIndexPath = buildPath(tempIndexPath); - fullTempSpellCheckPath = buildPath(tempSpellCheckPath); - fullPdfTextBufferPath = buildPath(tempPdfTextBufferPath); - - generateAtStartup = getBooleanConfigParameter(CONF_GENERATE_AT_STARTUP, true); - indexInterval = getIntConfigParameter(CONF_INDEX_INTERVAL, DEFAULT_INDEX_INTERVAL); - maxHits = getIntConfigParameter(CONF_MAX_HITS, DEFAULT_MAX_HITS); - maxResults = getIntConfigParameter(CONF_MAX_RESULTS, DEFAULT_MAX_RESULTS); - folderPoolSize = getIntConfigParameter(CONF_FOLDER_POOL_SIZE, DEFAULT_FOLDER_POOL_SIZE); - restartWindowStart = getIntConfigParameter(CONF_RESTART_WINDOW_START, DEFAULT_RESTART_WINDOW_START); - restartWindowEnd = getIntConfigParameter(CONF_RESTART_WINDOW_END, DEFAULT_RESTART_WINDOW_END); - updateInterval = getIntConfigParameter(CONF_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL); - documentsPerInterval = getIntConfigParameter(CONF_DOCUMENTS_PER_INTERVAL, DEFAULT_DOCUMENTS_PER_INTERVAL); - restartDayOfWeek = getIntConfigParameter(CONF_RESTART_DAY_OF_WEEK, DEFAULT_RESTART_DAY_OF_WEEK); - pptFileEnabled = getBooleanConfigParameter(CONF_PPT_FILE_ENABLED, true); - excelFileEnabled = getBooleanConfigParameter(CONF_EXCEL_FILE_ENABLED, true); - pdfFileEnabled = getBooleanConfigParameter(CONF_PDF_FILE_ENABLED, true); - pdfTextBuffering = getBooleanConfigParameter(CONF_PDF_TEXT_BUFFERING, true); - pdfExternalIndexer = getBooleanConfigParameter(CONF_PDF_EXTERNAL_INDEXER, false); - pdfExternalIndexerCmd = getStringConfigParameter(CONF_PDF_EXTERNAL_INDEXER_CMD, "convertpdf.sh", false); - - isSpellCheckEnabled = getBooleanConfigParameter(CONF_SPELL_CHECK_ENABLED, true); - maxFileSize = Integer.parseInt(getStringConfigParameter(CONF_MAX_FILE_SIZE, "0", false)); - ramBufferSizeMB = Double.parseDouble(getStringConfigParameter(CONF_RAM_BUFFER_SIZE_MB, DEFAULT_RAM_BUFFER_SIZE_MB, false)); - useCompoundFile = getBooleanConfigParameter(CONF_USE_COMPOUND_FILE, false); + fullTempIndexPath = buildPath(tempIndexPath); + fullTempSpellCheckPath = buildPath(tempSpellCheckPath); + fullPdfTextBufferPath = buildPath(tempPdfTextBufferPath); } private String buildPath(String path) { @@ -206,7 +155,7 @@ public class SearchModule extends AbstractOLATModule { if(f.isAbsolute() && (f.exists() || f.mkdirs())) { return path; } - return FolderConfig.getCanonicalTmpDir() + File.separator + path; + return folderModule.getCanonicalTmpDir() + File.separator + path; } @Override @@ -457,11 +406,6 @@ public class SearchModule extends AbstractOLATModule { return repositoryBlackList; } - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - public double getRAMBufferSizeMB() { return ramBufferSizeMB; } @@ -469,5 +413,4 @@ public class SearchModule extends AbstractOLATModule { public boolean getUseCompoundFile() { return useCompoundFile; } - } diff --git a/src/main/java/org/olat/search/_spring/searchContext.xml b/src/main/java/org/olat/search/_spring/searchContext.xml index e4adf9ccadbfd1cde2958cf8f1124f26e29214f9..14736634f9f1ee7d35985eb0bfd9e12b7f8877b5 100644 --- a/src/main/java/org/olat/search/_spring/searchContext.xml +++ b/src/main/java/org/olat/search/_spring/searchContext.xml @@ -1,8 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + <context:component-scan base-package="org.olat.search" /> <!-- Search components --> <bean id="org.olat.admin.user.UserSearchUIService" @@ -30,7 +36,7 @@ </bean> <bean id="org.olat.search.service.enabled" class="org.olat.search.service.SearchServiceImpl" - init-method="init" destroy-method="stop" depends-on="searchModuleInit" lazy-init="true"> + init-method="init" destroy-method="stop" lazy-init="true"> <constructor-arg index="0" ref="searchModule" /> <constructor-arg index="1" ref="mainIndexer" /> <constructor-arg index="2" ref="searchProvider" /> @@ -69,31 +75,31 @@ </property> </bean> - <bean id="searchModule" class="org.olat.search.SearchModule" lazy-init="true"> - <property name="fileBlackList"> + <bean id="fileSizeSuffixes" class="java.util.ArrayList"> + <constructor-arg index="0"> + <list> + <!-- list of files which will not be indexed --> + <value>ppt</value> + </list> + </constructor-arg> + </bean> + + <bean id="fileBlackList" class="java.util.ArrayList"> + <constructor-arg index="0"> <list> <!-- list of files which will not be indexed --> <value>imsmanifest.xml</value> </list> - </property> - <property name="repositoryBlackList"> + </constructor-arg> + </bean> + + <bean id="repositoryBlackList" class="java.util.ArrayList"> + <constructor-arg index="0"> <list> <!-- list of repository-entry ResourceableId which will not be indexed --> <value></value> </list> - </property> - <property name="fileSizeSuffixes"> - <!-- list of file-suffixes for which will be checked the file size by 'maxFileSize'-parameter --> - <value>ppt</value> - - </property> - - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="searchModule" /> - </bean> - </property> + </constructor-arg> </bean> <bean id="searchProvider" class="org.olat.search.service.searcher.JmsSearchProvider" init-method="springInit" destroy-method="stop" lazy-init="true"> @@ -110,44 +116,6 @@ <!-- The metadata fields that are supported in the search engine --> <bean id="SearchMetadataFieldsProvider" class="org.olat.search.service.SimpleDublinCoreMetadataFieldsProvider" /> - <bean id="searchModuleInit" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" lazy-init="true"> - <property name="targetObject" ref="searchModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - searchService=${search.service} - - generateIndexAtStartup=${generate.index.at.startup} - tempIndexPath=${search.index.tempIndex} - tempSpellCheckPath=${search.index.tempSpellcheck} - pdfTextBufferPath=${search.index.pdfBuffer} - indexPath=${search.index.path} - permanentIndexPath=${search.permanent.index.path} - <!-- indexInterval in ms (0=no delay) --> - indexInterval=0 - documentsPerInterval=4 - - <!-- Files bigger than maxFileSize (and on fileSizeSuffixes-list) will be excluded from index --> - maxFileSize=10485760 - <!-- Control indexer prozess --> - folderPoolSize=${search.folder.pool.size} - <!-- Define automatic restart time window e.g. 01:00-02:59 restartWindowStart=1 restartWindowEnd=3 --> - restartWindowStart=${restart.window.start} - restartWindowEnd=${restart.window.end} - <!-- Restart only at this day 1=Sunday,2=Monday...7=Saturday (0=restart every day) --> - restartDayOfWeek=0 - <!-- Enable text-buffering of extracted PDF text --> - pdfTextBuffering=true - pdfExternalIndexer=${search.pdf.external} - pdfExternExtractorCommand=${search.pdf.external.command} - <!-- updater runs every xx ms (0=stopped) --> - <!-- The updater is NOT implemented for all index elements, do not use it for now! --> - updateInterval=0 - ramBufferSizeMb=16 - </value> - </property> - </bean> - <!-- Indexer factory --> <bean id="mainIndexer" class="org.olat.search.service.indexer.MainIndexer" lazy-init="true"> <property name="indexerList"> diff --git a/src/main/java/org/olat/shibboleth/ShibbolethRegistrationController.java b/src/main/java/org/olat/shibboleth/ShibbolethRegistrationController.java index 73873144cf26fe3a8323e541253b3306d3cb1b1b..388ba45ecddf26412db04b86235c7a4360596619 100644 --- a/src/main/java/org/olat/shibboleth/ShibbolethRegistrationController.java +++ b/src/main/java/org/olat/shibboleth/ShibbolethRegistrationController.java @@ -114,6 +114,8 @@ public class ShibbolethRegistrationController extends DefaultController implemen @Autowired private ShibbolethModule shibbolethModule; + @Autowired + private RegistrationModule registrationModule; /** * Implements the shibboleth registration workflow. @@ -163,8 +165,8 @@ public class ShibbolethRegistrationController extends DefaultController implemen mainContainer.put("select.language", languageChooserController.getInitialComponent()); mainContainer.contextPut("languageCode", locale.getLanguage()); - if(RegistrationModule.getUsernamePresetBean() != null) { - UserNameCreationInterceptor interceptor = RegistrationModule.getUsernamePresetBean(); + if(registrationModule.getUsernamePresetBean() != null) { + UserNameCreationInterceptor interceptor = registrationModule.getUsernamePresetBean(); proposedUsername = interceptor.getUsernameFor(shibbolethAttributesMap); if(proposedUsername == null) { if(interceptor.allowChangeOfUsername()) { diff --git a/src/main/java/org/olat/shibboleth/ShibbolethRegistrationForm.java b/src/main/java/org/olat/shibboleth/ShibbolethRegistrationForm.java index fb82af7b5c8951c44413493063aae43e8a446500..7a5ed0b8b9a49093d0f22e69839b6d27c541999e 100644 --- a/src/main/java/org/olat/shibboleth/ShibbolethRegistrationForm.java +++ b/src/main/java/org/olat/shibboleth/ShibbolethRegistrationForm.java @@ -32,9 +32,9 @@ import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; - import org.olat.user.UserManager; import org.olat.user.UserModule; +import org.springframework.beans.factory.annotation.Autowired; /** * Initial Date: 09.08.2004 @@ -50,6 +50,10 @@ public class ShibbolethRegistrationForm extends FormBasicController { private TextElement login; private String proposedUsername; + @Autowired + private UserModule userModule; + @Autowired + private UserManager userManager; /** * @param name * @param translator @@ -64,11 +68,11 @@ public class ShibbolethRegistrationForm extends FormBasicController { @Override protected boolean validateFormLogic(UserRequest ureq) { if (login.isEmpty("srf.error.loginempty")) return false; - if (!UserManager.getInstance().syntaxCheckOlatLogin(getLogin())) { + if (!userManager.syntaxCheckOlatLogin(getLogin())) { login.setErrorKey("srf.error.loginregexp", null); return false; } - if (UserModule.isLoginOnBlacklist(getLogin())) { + if (userModule.isLoginOnBlacklist(getLogin())) { login.setErrorKey("srf.error.blacklist", null); return false; } diff --git a/src/main/java/org/olat/social/SocialModule.java b/src/main/java/org/olat/social/SocialModule.java index ae77d4b24cc9ab5c6df430a3e2db6eb7bdb18003..cf25ff11853bc4c1254e13aa435bef7f896ea9a1 100644 --- a/src/main/java/org/olat/social/SocialModule.java +++ b/src/main/java/org/olat/social/SocialModule.java @@ -25,9 +25,12 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.util.StringHelper; +import org.olat.core.util.coordinate.CoordinatorManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * <h3>Description:</h3> @@ -40,15 +43,17 @@ import org.olat.core.util.StringHelper; * * @author Florian Gnaegi, frentix GmbH, http://www.frentix.com */ - -public class SocialModule extends AbstractOLATModule { +@Service("socialModule") +public class SocialModule extends AbstractSpringModule { private static final String SHARE_ENABLED = "social.share.enabled"; private static final String SHARE_LINK_BUTTONS = "social.share.link.buttons"; private static final String SHARE_LINK_BUTTONS_AVAILABLE = "twitter,facebook,google,delicious,digg,mail,link"; // the share enabled config saved in the persisted properties + @Value("${social.share.enabled:false}") private boolean shareEnabled; // the share links enabled config separated by comma saved in the persisted properties + @Value("${social.share.link.buttons}") private String shareLinkButtonsEnabled; // the list of all configurable share links @@ -56,6 +61,11 @@ public class SocialModule extends AbstractOLATModule { // the list of enabled link buttons for your convenience as list object private List<String> shareLinkButtonsEnabledList; + @Autowired + public SocialModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); + } + /* (non-Javadoc) * @see org.olat.core.configuration.AbstractOLATModule#init() */ @@ -89,25 +99,6 @@ public class SocialModule extends AbstractOLATModule { } } - /** - * [Spring] Setter - * @see org.olat.core.configuration.AbstractOLATModule#setPersistedProperties(org.olat.core.configuration.PersistedProperties) - */ - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - - /* (non-Javadoc) - * @see org.olat.core.configuration.AbstractOLATModule#initDefaultProperties() - */ - @Override - protected void initDefaultProperties() { - // init default configuration from spring configuration. Might be overriden in init() by persisted properties - shareEnabled = getBooleanConfigParameter(SHARE_ENABLED, true); - shareLinkButtonsEnabled = getStringConfigParameter(SHARE_LINK_BUTTONS, SHARE_LINK_BUTTONS_AVAILABLE, true); - } - /* (non-Javadoc) * @see org.olat.core.configuration.AbstractOLATModule#initFromChangedProperties() */ @@ -116,13 +107,6 @@ public class SocialModule extends AbstractOLATModule { init(); } - /** - * [Spring] Destroy method - */ - public void destroy() { - // nothing to do so far - } - /** * @return true: sharing with social networks is enabled; false: sharing * with social networks is disabled @@ -173,6 +157,4 @@ public class SocialModule extends AbstractOLATModule { public List<String> getEnabledShareLinkButtons() { return shareLinkButtonsEnabledList; } - - } diff --git a/src/main/java/org/olat/social/_spring/socialContext.xml b/src/main/java/org/olat/social/_spring/socialContext.xml deleted file mode 100644 index d38a64721fe2ad110d6b44aa1496dbbf5c348128..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/social/_spring/socialContext.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - <bean id="socialModule" class="org.olat.social.SocialModule" destroy-method="destroy"> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" - depends-on="org.olat.core.util.WebappHelper"> - <constructor-arg index="0" ref="coordinatorManager" /> - <constructor-arg index="1" ref="socialModule" /> - </bean> - </property> - </bean> - - <bean name="socialModuleInitializer" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="socialModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - social.share.enabled=${social.share.enabled} - social.share.link.buttons=${social.share.link.buttons} - </value> - </property> - </bean> - -</beans> \ No newline at end of file diff --git a/src/main/java/org/olat/user/ChangePasswordController.java b/src/main/java/org/olat/user/ChangePasswordController.java index f9675c46b9db94667937a1c122fe2a801943c9ec..a4848b6f6e00c4d0f4cff8c954f892fc92e031ea 100644 --- a/src/main/java/org/olat/user/ChangePasswordController.java +++ b/src/main/java/org/olat/user/ChangePasswordController.java @@ -72,7 +72,8 @@ public class ChangePasswordController extends BasicController implements Support private VelocityContainer myContent; private ChangePasswordForm chPwdForm; - + @Autowired + private UserModule userModule; @Autowired private LDAPLoginModule ldapLoginModule; @Autowired @@ -88,7 +89,7 @@ public class ChangePasswordController extends BasicController implements Support super(ureq, wControl); // if a user is not allowed to change his/her own password, say it here - if (!UserModule.isPwdchangeallowed(ureq.getIdentity())) { + if (!userModule.isPwdChangeAllowed(ureq.getIdentity())) { String text = translate("notallowedtochangepwd", new String[] { WebappHelper.getMailConfig("mailSupport") }); Controller simpleMsg = new SimpleMessageController(ureq, wControl, text, "o_warning"); listenTo(simpleMsg); //register controller to be disposed automatically on dispose of Change password controller diff --git a/src/main/java/org/olat/user/HomePageDisplayController.java b/src/main/java/org/olat/user/HomePageDisplayController.java index 4fc702248e41a825e4e1e21db83ca0d71916d7c9..0ce83055282a51295e6d120ad69ef0282509833b 100644 --- a/src/main/java/org/olat/user/HomePageDisplayController.java +++ b/src/main/java/org/olat/user/HomePageDisplayController.java @@ -66,6 +66,8 @@ public class HomePageDisplayController extends BasicController { private Link imLink; + @Autowired + private UserModule userModule; @Autowired private UserManager userManager; @Autowired @@ -123,7 +125,7 @@ public class HomePageDisplayController extends BasicController { listenTo(dpc); // auto dispose mainVC.put("image", dpc.getInitialComponent()); - if(UserModule.isLogoByProfileEnabled()) { + if(userModule.isLogoByProfileEnabled()) { File logo = DisplayPortraitManager.getInstance().getBigLogo(homeIdentity.getName()); if (logo != null) { ImageComponent logoCmp = new ImageComponent(ureq.getUserSession(), "logo"); diff --git a/src/main/java/org/olat/user/ProfileFormController.java b/src/main/java/org/olat/user/ProfileFormController.java index c1f641d76e5ff4df128463b9886b96855c951cc1..0dae8bb84a9bdcb3101c5fa0f92cef75f12ced8e 100644 --- a/src/main/java/org/olat/user/ProfileFormController.java +++ b/src/main/java/org/olat/user/ProfileFormController.java @@ -103,6 +103,8 @@ public class ProfileFormController extends FormBasicController { private String changedEmail; private String currentEmail; + @Autowired + private UserModule userModule; @Autowired private UserManager userManager; @Autowired @@ -144,7 +146,7 @@ public class ProfileFormController extends FormBasicController { this.identityToModify = identityToModify; this.isAdministrativeUser = isAdministrativeUser; - this.logoEnabled = UserModule.isLogoByProfileEnabled(); + this.logoEnabled = userModule.isLogoByProfileEnabled(); userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifier, isAdministrativeUser); initForm(ureq); diff --git a/src/main/java/org/olat/user/TestUserAdder.java b/src/main/java/org/olat/user/TestUserAdder.java deleted file mode 100644 index 4999aea854a6f3f79fcaa67f8b2663661be69c1c..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/user/TestUserAdder.java +++ /dev/null @@ -1,70 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ - -package org.olat.user; - -import java.util.Iterator; -import java.util.List; - -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; - -/** - * - * @author Christian Guretzki - */ -public class TestUserAdder { - private UserModule userModule; - private static OLog log = Tracing.createLoggerFor(TestUserAdder.class); - - - /** - * [used by spring] - * @param authenticationProviderConstant - */ - private TestUserAdder(UserModule userModule) { - log.info("Constructor TestUserAdder"); - this.userModule = userModule; - } - - - /** - * [used by Spring] - * @param addionalTestUsers - */ - public void setAdditionalTestUsers(List<DefaultUser> additionalTestUsers) { - createAdditionalTestUsers(additionalTestUsers); - } - - private void createAdditionalTestUsers(List<DefaultUser> additionalTestUsers) { - if (additionalTestUsers != null) { - for (Iterator<DefaultUser> iter = additionalTestUsers.iterator(); iter.hasNext();) { - DefaultUser user = iter.next(); - userModule.createUser(user); - log.info("created additional test-user username=" + user.getUserName()); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/user/UserModule.java b/src/main/java/org/olat/user/UserModule.java index 65aa726ccf64271a4a9fc0367669908cacf34afe..1228670b26308d0a31009843370e23412e57aa13 100644 --- a/src/main/java/org/olat/user/UserModule.java +++ b/src/main/java/org/olat/user/UserModule.java @@ -33,26 +33,21 @@ import java.util.regex.PatternSyntaxException; import org.olat.NewControllerFactory; import org.olat.admin.site.UserAdminSite; import org.olat.admin.user.UserAdminContextEntryControllerCreator; -import org.olat.basesecurity.BaseSecurity; -import org.olat.basesecurity.BaseSecurityManager; -import org.olat.basesecurity.Constants; -import org.olat.basesecurity.SecurityGroup; import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.configuration.AbstractOLATModule; -import org.olat.core.configuration.PersistedProperties; +import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.id.Identity; import org.olat.core.id.User; import org.olat.core.id.UserConstants; -import org.olat.core.logging.OLATRuntimeException; import org.olat.core.logging.OLog; import org.olat.core.logging.StartupException; import org.olat.core.logging.Tracing; +import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.ldap.LDAPLoginManager; -import org.olat.login.AfterLoginConfig; -import org.olat.login.AfterLoginInterceptionManager; import org.olat.user.propertyhandlers.UserPropertyHandler; -import org.springframework.util.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; /** * Desciption: The user module represents an implementation of @@ -60,75 +55,33 @@ import org.springframework.util.StringUtils; * * @author Florian Gnägi */ -public class UserModule extends AbstractOLATModule { - private List<String> loginBlacklist; - private static List<String> loginBlacklistChecked = new ArrayList<String>(); - private static boolean hasTestUsers; - private BaseSecurity securityManager; - private SecurityGroup adminGroup, authorGroup, olatuserGroup, anonymousGroup, groupmanagerGroup, usermanagerGroup; - private static boolean pwdchangeallowed; - private static boolean pwdchangeallowedLDAP; - private static String adminUserName; - private static boolean enabledLogoByProfile; - private List<DefaultUser> defaultUsers; - private List<DefaultUser> testUsers; +@Service +public class UserModule extends AbstractSpringModule { + private static OLog log = Tracing.createLoggerFor(UserModule.class); - private String authenticationProviderConstant; + + @Autowired @Qualifier("loginBlacklist") + private ArrayList<String> loginBlacklist; + private List<String> loginBlacklistChecked = new ArrayList<String>(); + + @Value("${password.change.allowed}") + private boolean pwdchangeallowed; + @Value("${ldap.propagatePasswordChangedOnLdapServer}") + private boolean pwdchangeallowedLDAP; + private String adminUserName = "administrator"; + @Value("${user.logoByProfile:disabled}") + private String enabledLogoByProfile; + + @Autowired private UserManager userManger; - private AfterLoginConfig afterLoginConfig; - private AfterLoginInterceptionManager afterLoginInterceptionManager; - - /** - * [used by spring] - * @param authenticationProviderConstant - */ - private UserModule(String authenticationProviderConstant, UserManager userManager, AfterLoginInterceptionManager afterLoginInterceptionManager) { - this.authenticationProviderConstant = authenticationProviderConstant; - this.userManger = userManager; - this.afterLoginInterceptionManager = afterLoginInterceptionManager; - } - - /** - * [used by spring] - * @param afterLoginConfig - */ - public void setAfterLoginConfig(AfterLoginConfig afterLoginConfig) { - this.afterLoginConfig = afterLoginConfig; + @Autowired + public UserModule(CoordinatorManager coordinatorManager) { + super(coordinatorManager); } - /** - * [used by spring] - * @param loginBlacklist - */ - public void setLoginBlacklist(List<String> loginBlacklist) { - this.loginBlacklist = loginBlacklist; - } - - /** - * Check wether a login is on the blacklist. - * - * @param login - * @return True if login is in blacklist - */ - public static boolean isLoginOnBlacklist(String login) { - login = login.toLowerCase(); - for (String regexp: getLoginBlacklist()) { - if (login.matches(regexp)) { - log.audit("Blacklist entry match for login '" + login + "' with regexp '" + regexp + "'."); - return true; - } - } - return false; - } - - /** - * @see org.olat.core.configuration.OLATModule#init(com.anthonyeden.lib.config.Configuration) - */ + @Override public void init() { - pwdchangeallowed = getBooleanConfigParameter("passwordChangeAllowed", true); - pwdchangeallowedLDAP = getBooleanConfigParameter("passwordChangeAllowedLDAP", false); - int count = 0; for (String regexp : loginBlacklist) { try { @@ -140,41 +93,7 @@ public class UserModule extends AbstractOLATModule { count ++; } - logInfo("Successfully added " + count + " entries to login blacklist."); - - - // Autogeneration of test users - hasTestUsers = getBooleanConfigParameter("generateTestUsers", true); - enabledLogoByProfile = "enabled".equals(getStringConfigParameter("logoByProfileEnabled", "disabled", true)); - - // Check if default users exists, if not create them - securityManager = BaseSecurityManager.getInstance(); - adminGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN); - authorGroup = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS); - olatuserGroup = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS); - anonymousGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS); - groupmanagerGroup = securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS); - usermanagerGroup = securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS); - - // read user editable fields configuration - if (defaultUsers != null) { - for (DefaultUser user:defaultUsers) { - createUser(user); - } - } - if (hasTestUsers) { - // read user editable fields configuration - if (testUsers != null) { - for (DefaultUser user :testUsers) { - createUser(user); - } - } - } - // Cleanup, otherwhise this subjects will have problems in normal OLAT - // operation - DBFactory.getInstance().commitAndCloseSession(); - - adminUserName = getStringConfigParameter("adminUserName", "administrator", false); + log.info("Successfully added " + count + " entries to login blacklist."); // Check if user manager is configured properly and has user property // handlers for the mandatory user properties used in OLAT @@ -193,17 +112,6 @@ public class UserModule extends AbstractOLATModule { new UserAdminContextEntryControllerCreator()); NewControllerFactory.getInstance().addContextEntryControllerCreator(UserAdminSite.class.getSimpleName(), new UserAdminContextEntryControllerCreator()); - - - // Append AfterLoginControllers if any configured - if (afterLoginConfig != null) { - afterLoginInterceptionManager.addAfterLoginControllerConfig(afterLoginConfig); - } - } - - @Override - protected void initDefaultProperties() { - // } @Override @@ -227,70 +135,27 @@ public class UserModule extends AbstractOLATModule { } /** - * Method to create a user with the given configuration - * - * @return Identity or null + * @return List of logins on blacklist. */ - protected Identity createUser(DefaultUser user) { - Identity identity; - identity = securityManager.findIdentityByName(user.getUserName()); - if (identity == null) { - // Create new user and subject - UserImpl newUser = new UserImpl(); - newUser.setFirstName(user.getFirstName()); - newUser.setLastName(user.getLastName()); - newUser.setEmail(user.getEmail()); - - newUser.getPreferences().setLanguage(user.getLanguage()); - newUser.getPreferences().setInformSessionTimeout(true); - - if (!StringUtils.hasText(authenticationProviderConstant)){ - throw new OLATRuntimeException(this.getClass(), "Auth token not set! Please fix! " + authenticationProviderConstant, null); - } - - // Now finally create that user thing on the database with all - // credentials, person etc. in one transation context! - identity = BaseSecurityManager.getInstance().createAndPersistIdentityAndUser(user.getUserName(), null, newUser, authenticationProviderConstant, - user.getUserName(), user.getPassword()); - if (identity == null) { - throw new OLATRuntimeException(this.getClass(), "Error, could not create user and subject with name " + user.getUserName(), null); - } else { - - if (user.isGuest()) { - securityManager.addIdentityToSecurityGroup(identity, anonymousGroup); - log .info("Created anonymous user " + user.getUserName()); - } else { - if (user.isAdmin()) { - securityManager.addIdentityToSecurityGroup(identity, adminGroup); - securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); - log .info("Created admin user " + user.getUserName()); - } else if (user.isAuthor()) { - securityManager.addIdentityToSecurityGroup(identity, authorGroup); - securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); - log.info("Created author user " + user.getUserName()); - } else if (user.isUserManager()) { - securityManager.addIdentityToSecurityGroup(identity, usermanagerGroup); - securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); - log .info("Created userManager user " + user.getUserName()); - } else if (user.isGroupManager()) { - securityManager.addIdentityToSecurityGroup(identity, groupmanagerGroup); - securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); - log .info("Created groupManager user " + user.getUserName()); - } else { - securityManager.addIdentityToSecurityGroup(identity, olatuserGroup); - log .info("Created user " + user.getUserName()); - } - } - } - } - return identity; + public List<String> getLoginBlacklist() { + return loginBlacklistChecked; } - + /** - * @return List of logins on blacklist. + * Check wether a login is on the blacklist. + * + * @param login + * @return True if login is in blacklist */ - public static List<String> getLoginBlacklist() { - return loginBlacklistChecked; + public boolean isLoginOnBlacklist(String login) { + login = login.toLowerCase(); + for (String regexp: getLoginBlacklist()) { + if (login.matches(regexp)) { + log.audit("Blacklist entry match for login '" + login + "' with regexp '" + regexp + "'."); + return true; + } + } + return false; } /** @@ -304,14 +169,16 @@ public class UserModule extends AbstractOLATModule { * @param id * @return */ - public static boolean isPwdchangeallowed(Identity id) { - - if(id == null) return isAnyPwdchangeallowed(); + public boolean isPwdChangeAllowed(Identity id) { + if(id == null) { + return isAnyPwdchangeallowed(); + } // if this is set to false, noone can change their pw - if (!pwdchangeallowed) + if (!pwdchangeallowed) { return false; - LDAPLoginManager ldapLoginManager = (LDAPLoginManager) CoreSpringFactory.getBean("org.olat.ldap.LDAPLoginManager"); + } + LDAPLoginManager ldapLoginManager = CoreSpringFactory.getImpl(LDAPLoginManager.class); if (ldapLoginManager.isIdentityInLDAPSecGroup(id)) { // it's an ldap-user return pwdchangeallowedLDAP; @@ -325,29 +192,15 @@ public class UserModule extends AbstractOLATModule { * * @return */ - private static boolean isAnyPwdchangeallowed() { + private boolean isAnyPwdchangeallowed() { return pwdchangeallowed; } - public static boolean isLogoByProfileEnabled() { - return enabledLogoByProfile; + public boolean isLogoByProfileEnabled() { + return "enabled".equals(enabledLogoByProfile); } - public static String getAdminUserName() { + public String getAdminUserName() { return adminUserName; } - - public void setDefaultUsers(List<DefaultUser> defaultUsers) { - this.defaultUsers = defaultUsers; - } - - public void setTestUsers(List<DefaultUser> testUsers) { - this.testUsers = testUsers; - } - - @Override - public void setPersistedProperties(PersistedProperties persistedProperties) { - this.moduleConfigProperties = persistedProperties; - } - } \ No newline at end of file diff --git a/src/main/java/org/olat/user/_spring/userContext.xml b/src/main/java/org/olat/user/_spring/userContext.xml index a7a988492a3fff73885bf0112682b1885e808bab..5360d93f80b513117af075eb3a8449f969dd10ab 100644 --- a/src/main/java/org/olat/user/_spring/userContext.xml +++ b/src/main/java/org/olat/user/_spring/userContext.xml @@ -13,22 +13,9 @@ <import resource="classpath:/org/olat/user/propertyhandlers/_spring/userPropertiesContext.xml"/> <import resource="classpath:/org/olat/user/propertyhandlers/_spring/userPropertriesHandlersContext.xml"/> -<bean id="userModule" class="org.olat.user.UserModule" - depends-on="notificationsManager, database, baseSecurityManager, triggerI18nModuleInit"> - <!-- default auth string --> - <constructor-arg index="0" value="${default.auth.provider.identifier}" /> - <constructor-arg index="1" ref="userManager" /> - <constructor-arg index="2" ref="afterLoginInterceptionManager" /> - <property name="persistedProperties"> - <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy"> - <constructor-arg index="0" ref="coordinatorManager"/> - <constructor-arg index="1" ref="userModule" /> - </bean> - </property> - - <!-- provide an admin user--> - <property name="defaultUsers"> - <list> + <bean id="defaultUsers" class="java.util.ArrayList"> + <constructor-arg index="0"> + <list> <bean class="org.olat.user.DefaultUser"> <!-- constructor arg is userName --> <constructor-arg type="java.lang.String" value="administrator" /> @@ -39,12 +26,14 @@ <property name="language" value="${defaultlang}" /> <property name="admin" value="true" /> </bean> - </list> - </property> + </list> + </constructor-arg> + </bean> <!-- provide some test users --> - <property name="testUsers"> - <list> + <bean id="testUsers" class="java.util.ArrayList"> + <constructor-arg index="0"> + <list> <bean class="org.olat.user.DefaultUser"> <!-- constructor arg is userName --> <constructor-arg type="java.lang.String" value="author" /> @@ -133,8 +122,11 @@ <property name="admin" value="false" /> </bean> </list> - </property> - <property name="loginBlacklist"> + </constructor-arg> + </bean> + + <bean id="loginBlacklist" class="java.util.ArrayList"> + <constructor-arg index="0"> <list> <!-- Use regexp to define logins which are not allowed. @@ -175,16 +167,22 @@ <value>[\.\-_].*</value> <value>[\.\-_]*</value> </list> - </property> - <property name="afterLoginConfig"> - <ref bean="org.olat.user.AfterLoginConfig"/> - </property> -</bean> + </constructor-arg> + </bean> + + <!-- + <bean id="org.olat.user.AfterLogin.Injection" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> + <property name="targetObject" ref="afterLoginInterceptionManager" /> + <property name="targetMethod" value="addAfterLoginControllerConfig" /> + <property name="arguments"> + <ref bean="org.olat.user.AfterLoginConfig"/> + </property> + </bean> <bean id="org.olat.user.AfterLoginConfig" class="org.olat.login.AfterLoginConfig" scope="prototype"> <property name="afterLoginControllerList"> <list> - <!-- Configuration to force users to regularly check and update the user profile, redoTimeout sets the interval (seconds) + // Configuration to force users to regularly check and update the user profile, redoTimeout sets the interval (seconds) <map> <entry key="controller"> <bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype"> @@ -195,8 +193,7 @@ <entry key="redoTimeout"><value>10</value></entry> <entry key="i18nIntro"><value>org.olat.user:runonce.profile.intro</value></entry> </map> - --> - <!-- Alternative configuration to force users to fill out profile if a mandatory user property is missing (no syntax checks done, only checks if property exists) + // Alternative configuration to force users to fill out profile if a mandatory user property is missing (no syntax checks done, only checks if property exists) <map> <entry key="controller"> <bean class="org.olat.user.ProfileAndHomePageEditIfMissingMandatoryControllerCreator" scope="prototype" /> @@ -205,9 +202,8 @@ <entry key="redoTimeout"><value>31536000</value></entry> <entry key="i18nIntro"><value>org.olat.user:runonce.profile.intro</value></entry> <entry key="size"><value>800x600</value></entry> - </map> - --> - <!-- Configuration to force users to change their password after the configured redoTimeout (seconds) + </map> + // Configuration to force users to change their password after the configured redoTimeout (seconds) <map> <entry key="controller"> <bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype"> @@ -237,24 +233,11 @@ ## specify in the form of "package:i18nKey" <entry key="i18nIntro"><value>org.olat.user:runonce.intro</value></entry> </map> - --> + </list> </property> </bean> - - <bean id="triggerUserModuleInit" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject" ref="userModule" /> - <property name="targetMethod" value="init" /> - <property name="arguments"> - <value> - generateTestUsers=${user.generateTestUsers} - passwordChangeAllowed=${password.change.allowed} - passwordChangeAllowedLDAP=${ldap.propagatePasswordChangedOnLdapServer} - adminUserName=administrator - logoByProfileEnabled=${user.logoByProfile} - </value> - </property> - </bean> + --> <!-- Implementation to display "firstname lastname" --> <bean id="userDisplayName_firstname_lastname" class="org.olat.user.UserDisplayNameCreator" /> diff --git a/src/test/java/org/olat/core/helpers/SettingsTest.java b/src/test/java/org/olat/core/helpers/SettingsTest.java index f75469f297b12e2bc015b2ed0babbd761dc40876..e2eb55dfd7d08bd67d8c2be71c041543880bac87 100644 --- a/src/test/java/org/olat/core/helpers/SettingsTest.java +++ b/src/test/java/org/olat/core/helpers/SettingsTest.java @@ -166,7 +166,6 @@ public class SettingsTest { Properties defaultPropertiesHttp = new Properties(); defaultPropertiesHttp.setProperty("dummykey", "dummyvalue"); persistedPropertiesHttp.setDefaultProperties(defaultPropertiesHttp); - settings.setPersistedProperties(persistedPropertiesHttp); settings.setServerSecurePort(securePort); settings.setServerInsecurePort(insecurePort); settings.setServerDomainName(SettingsTest.serverFqnd);//${server.domainname} diff --git a/src/test/java/org/olat/core/util/vfs/version/VersionManagerTest.java b/src/test/java/org/olat/core/util/vfs/version/VersionManagerTest.java index c11c7711f0960727a00754b3d05101679885a745..f3aaa2d37cc3953b71b60c4746e420ae67e3ba91 100644 --- a/src/test/java/org/olat/core/util/vfs/version/VersionManagerTest.java +++ b/src/test/java/org/olat/core/util/vfs/version/VersionManagerTest.java @@ -81,16 +81,16 @@ public class VersionManagerTest extends OlatTestCase { id2 = JunitTestHelper.createAndPersistIdentityAsUser("vm-two" + getRandomName()); SimpleVersionConfig versionConfig = (SimpleVersionConfig)CoreSpringFactory.getBean("versioningConfigurator"); - versionConfig.setMaxNumberOfVersionsProperty(new Long(10)); + versionConfig.setMaxNumberOfVersionsProperty(10); waitForCondition(new SetMaxNumberOfVersions(versionConfig, 10l), 2000); setuped = true; } @After public void resetMaxVersions() { - Long maxNumberOfVersions = versioningConfigurator.getMaxNumberOfVersionsProperty(); - if(maxNumberOfVersions == null || maxNumberOfVersions.longValue() != 10) { - versioningConfigurator.setMaxNumberOfVersionsProperty(new Long(10)); + int maxNumberOfVersions = versioningConfigurator.getMaxNumberOfVersionsProperty(); + if(maxNumberOfVersions != 10) { + versioningConfigurator.setMaxNumberOfVersionsProperty(10); waitForCondition(new SetMaxNumberOfVersions(versioningConfigurator, 10l), 2000); } } @@ -107,8 +107,8 @@ public class VersionManagerTest extends OlatTestCase { @Override public Boolean call() throws Exception { - Long currentValue = versioningConfig.getMaxNumberOfVersionsProperty(); - return currentValue != null && currentValue.longValue() == maxNumOfVersions.longValue(); + int currentValue = versioningConfig.getMaxNumberOfVersionsProperty(); + return currentValue == maxNumOfVersions.longValue(); } } @@ -168,7 +168,7 @@ public class VersionManagerTest extends OlatTestCase { @Test public void testOverflow_lowLevel() throws IOException { - versioningConfigurator.setMaxNumberOfVersionsProperty(new Long(3)); + versioningConfigurator.setMaxNumberOfVersionsProperty(3); waitForCondition(new SetMaxNumberOfVersions(versioningConfigurator, 3l), 2000); //create a file @@ -205,7 +205,7 @@ public class VersionManagerTest extends OlatTestCase { @Test public void testOverflow_lowLevel_deactivated() throws IOException { - versioningConfigurator.setMaxNumberOfVersionsProperty(new Long(0)); + versioningConfigurator.setMaxNumberOfVersionsProperty(0); waitForCondition(new SetMaxNumberOfVersions(versioningConfigurator, 0l), 2000); //create a file