userdata bean configuration
diff --git a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
index 2eb99bd..8702b28 100644
--- a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
@@ -26,6 +26,8 @@
public static final String KUSTVAKT_ENCRYPTION = "kustvakt_encryption";
public static final String KUSTVAKT_AUDITING = "kustvakt_auditing";
public static final String KUSTVAKT_CONFIG = "kustvakt_config";
+ public static final String KUSTVAKT_USERSETTINGS = "kustvakt_usersettings";
+ public static final String KUSTVAKT_USERDETAILS = "kustvakt_userdetails";
public static final String KUSTVAKT_AUTHENTICATION_MANAGER = "kustvakt_authenticationmanager";
public static final String KUSTVAKT_USERDB = "kustvakt_userdb";
@@ -148,13 +150,13 @@
return getBean(KUSTVAKT_DB);
}
- // public AuthenticationManagerIface getAuthenticationManager() {
- // throw new RuntimeException("!Stub");
- // }
+ public UserDataDbIface getUserDetailsDao() {
+ return getBean(KUSTVAKT_USERDETAILS);
+ }
- // public EntityHandlerIface getUserDBHandler() {
- // throw new RuntimeException("!Stub");
- // }
+ public UserDataDbIface getUserSettingsDao() {
+ return getBean(KUSTVAKT_USERSETTINGS);
+ }
public EncryptionIface getEncryption() {
return getBean(KUSTVAKT_ENCRYPTION);
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
index 3eb7f38..25bfd38 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
@@ -2,7 +2,7 @@
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.user.Attributes;
-import de.ids_mannheim.korap.user.UserSettings;
+import de.ids_mannheim.korap.user.Userdata;
/**
* @author hanl
@@ -10,10 +10,10 @@
*/
public class LayerMapper {
- private UserSettings settings;
+ private Userdata settings;
private KustvaktConfiguration config;
- public LayerMapper(KustvaktConfiguration config, UserSettings settings) {
+ public LayerMapper(KustvaktConfiguration config, Userdata settings) {
this.settings = settings;
this.config = config;
}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
index 56ff658..e7961f9 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
@@ -4,10 +4,9 @@
import de.ids_mannheim.korap.config.BeanConfiguration;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.UserSettingsDao;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.resource.LayerMapper;
import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettings;
/**
* @author hanl
@@ -19,12 +18,10 @@
public JsonNode preProcess(KoralNode node, KustvaktConfiguration config,
User user) throws KustvaktException {
LayerMapper mapper;
- // inject user settings from cache!
if (user != null && BeanConfiguration.hasContext()) {
- UserSettingsDao dao = new UserSettingsDao(
- BeanConfiguration.getBeans().getPersistenceClient());
- UserSettings settings = dao.get(user);
- mapper = new LayerMapper(config, settings);
+ UserDataDbIface dao = BeanConfiguration.getBeans()
+ .getUserSettingsDao();
+ mapper = new LayerMapper(config, dao.get(user));
}else
mapper = new LayerMapper(config);
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index 89f4bb9..86a5cba 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns="http://www.springframework.org/schema/beans"
- xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
- http://www.springframework.org/schema/cache
- http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
+
+
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
@@ -42,13 +40,13 @@
</bean>
<!--<bean id='cacheManager'-->
- <!--class='org.springframework.cache.ehcache.EhCacheCacheManager'-->
- <!--p:cacheManager-ref='ehcache'/>-->
+ <!--class='org.springframework.cache.ehcache.EhCacheCacheManager'-->
+ <!--p:cacheManager-ref='ehcache'/>-->
<!--<bean id='ehcache'-->
- <!--class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'-->
- <!--p:configLocation='classpath:ehcache.xml'-->
- <!--p:shared='true'/>-->
+ <!--class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'-->
+ <!--p:configLocation='classpath:ehcache.xml'-->
+ <!--p:shared='true'/>-->
<!-- props are injected from default-config.xml -->
<bean id="kustvakt_config"
@@ -89,6 +87,16 @@
<property name="database" value="${jdbc.database}"/>
</bean>
+ <bean id="kustvakt_userdetails"
+ class="de.ids_mannheim.korap.handlers.UserDetailsDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
+ <bean id="kustvakt_usersettings"
+ class="de.ids_mannheim.korap.handlers.UserSettingsDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
<bean id="kustvakt_auditing"
class="de.ids_mannheim.korap.handlers.JDBCAuditing">
<constructor-arg ref="kustvakt_db"/>
@@ -101,8 +109,8 @@
<!--fixme: change name according to convention -->
<!--<bean id="collectionProvider"-->
- <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
- <!--<constructor-arg ref="kustvakt_db"/>-->
+ <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
+ <!--<constructor-arg ref="kustvakt_db"/>-->
<!--</bean>-->
<!--fixme: change name according to convention -->
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index eff4638..059329c 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -6,6 +6,7 @@
import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -21,7 +22,7 @@
TestHelper.setupAccount();
}
- // @AfterClass
+ @AfterClass
public static void close() {
TestHelper.dropUser();
BeanConfiguration.closeApplication();
@@ -30,7 +31,7 @@
@Test
public void initHandler() {
RewriteHandler handler = new RewriteHandler(null);
- handler.add(FoundryInject.class);
+ assert handler.add(FoundryInject.class);
}
@Test
diff --git a/src/test/resources/default-config.xml b/src/test/resources/default-config.xml
index b325134..ce2dc35 100644
--- a/src/test/resources/default-config.xml
+++ b/src/test/resources/default-config.xml
@@ -93,6 +93,16 @@
<property name="database" value="${jdbc.database}"/>
</bean>
+ <bean id="kustvakt_userdetails"
+ class="de.ids_mannheim.korap.handlers.UserDetailsDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
+ <bean id="kustvakt_usersettings"
+ class="de.ids_mannheim.korap.handlers.UserSettingsDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
<bean id="kustvakt_auditing"
class="de.ids_mannheim.korap.handlers.JDBCAuditing">
<constructor-arg ref="kustvakt_db"/>