tests and bean loader hot fix
diff --git a/src/main/java/de/ids_mannheim/korap/config/AdminSetup.java b/src/main/java/de/ids_mannheim/korap/config/AdminSetup.java
index 5c0a276..378e015 100644
--- a/src/main/java/de/ids_mannheim/korap/config/AdminSetup.java
+++ b/src/main/java/de/ids_mannheim/korap/config/AdminSetup.java
@@ -49,12 +49,14 @@
store.setReadable(true, true);
store.setWritable(true, true);
store.setExecutable(false);
+ System.out.println();
System.out
.println("_______________________________________________");
System.out.println("Token created. Please make note of it!");
System.out.println("Token: " + token);
System.out
.println("_______________________________________________");
+ System.out.println();
return setup;
}
catch (Exception e) {
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 b09140e..8081e5d 100644
--- a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
@@ -51,27 +51,6 @@
}
- @Deprecated
- public static void loadAuthenticationProviders () {
- Set<Class<? extends AuthenticationIface>> set = KustvaktClassLoader
- .loadSubTypes(AuthenticationIface.class);
- Set<AuthenticationIface> set2 = new HashSet<>();
- for (Class<? extends AuthenticationIface> i : set) {
- try {
- set2.add(i.newInstance());
- }
- catch (InstantiationException | IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- try {
- getBeans().getAuthenticationManager().setProviders(set2);
- }
- catch (RuntimeException e) {
- // do nothing
- }
- }
-
public static boolean hasContext () {
return beans != null && beans.context != null;
diff --git a/src/main/java/de/ids_mannheim/korap/config/BeansFactory.java b/src/main/java/de/ids_mannheim/korap/config/BeansFactory.java
index 6e79890..84fcde1 100644
--- a/src/main/java/de/ids_mannheim/korap/config/BeansFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/config/BeansFactory.java
@@ -1,8 +1,6 @@
package de.ids_mannheim.korap.config;
-import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
-import de.ids_mannheim.korap.resources.KustvaktResource;
import de.ids_mannheim.korap.user.Userdata;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
import org.springframework.context.ApplicationContext;
@@ -11,6 +9,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.Arrays;
import java.util.Collection;
/**
@@ -43,7 +42,7 @@
public static synchronized TypeBeanFactory getTypeFactory () {
- return new TypeBeanFactory(beanHolder);
+ return new TypeBeanFactory();
}
@@ -107,21 +106,11 @@
public static class TypeBeanFactory {
- private ContextHolder holder;
-
-
- private TypeBeanFactory (ContextHolder holder) {
- this.holder = holder;
- }
-
-
- public <T> T getTypedBean (Collection objs, Class type) {
+ public <T> T getTypeInterfaceBean (Collection objs, Class type) {
for (Object o : objs) {
- Type gtype = o.getClass().getGenericInterfaces()[0];
- if (gtype instanceof ParameterizedType) {
- ParameterizedType ptype = (ParameterizedType) gtype;
- Object ctype = ptype.getActualTypeArguments()[0];
- if (ctype.equals(type))
+ if (o instanceof KustvaktTypeInterface) {
+ Class t = ((KustvaktTypeInterface) o).type();
+ if (type.equals(t))
return (T) o;
}
}
@@ -132,9 +121,19 @@
@Deprecated
- public UserDataDbIface getUserDaoInstance (
- Class<? extends Userdata> type) {
- return getTypedBean(this.holder.getUserDataDaos(), type);
+ public <T> T getTypedBean (Collection objs, Class type) {
+ for (Object o : objs) {
+ Type gtype = o.getClass().getGenericSuperclass();
+ if (gtype instanceof ParameterizedType) {
+ ParameterizedType ptype = (ParameterizedType) gtype;
+ Object ctype = ptype.getActualTypeArguments()[0];
+ if (ctype.equals(type))
+ return (T) o;
+ }
+ }
+ throw new RuntimeException(
+ "Could not find typed bean in context for class '" + type
+ + "'");
}
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java b/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
index b652a19..f3f256c 100644
--- a/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
+++ b/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
@@ -84,7 +84,7 @@
}
- public Collection<UserDataDbIface> getUserDataDaos () {
+ public Collection<UserDataDbIface> getUserDataProviders () {
return getBean(KUSTVAKT_USERDATA);
}
@@ -115,9 +115,7 @@
}
- // todo: !!!!!!!!!!!!!!!!!!!!!!!!!!
- // todo: more specific --> collection provider, document provider, etc.
- public Collection<ResourceOperationIface> getResourceProvider () {
+ public Collection<ResourceOperationIface> getResourceProviders () {
return getBean(KUSTVAKT_RESOURCES);
}
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/StatusCodes.java b/src/main/java/de/ids_mannheim/korap/exceptions/StatusCodes.java
index 49b204e..abc4d22 100644
--- a/src/main/java/de/ids_mannheim/korap/exceptions/StatusCodes.java
+++ b/src/main/java/de/ids_mannheim/korap/exceptions/StatusCodes.java
@@ -47,10 +47,8 @@
public static final int CLIENT_REMOVAL_FAILURE = 215;
public static final int CLIENT_AUTHORIZATION_FAILURE = 216;
- /**
- * 500 status codes for access control related components (also
- * policy rewrite)
- */
+
+
public static final int PERMISSION_DENIED = 401;
public static final int UNSUPPORTED_RESOURCE = 402;
public static final int UNSUPPORTED_FOUNDRY = 403;
@@ -67,7 +65,13 @@
public static final int MISSING_POLICY_CONDITIONS = 413;
public static final int MISSING_POLICY_PERMISSION = 414;
public static final int RESOURCE_NOT_FOUND = 415;
+ public static final int ACCESS_DENIED_NO_RESOURCES = 416;
+
+ /**
+ * 500 status codes for access control related components (also
+ * policy rewrite)
+ */
// todo: extend according to policy rewrite possible!
// policy errors
public static final int POLICY_ERROR_DEFAULT = 500;
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java b/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
index 3de9412..5520ffc 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
@@ -16,6 +16,7 @@
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import javax.print.Doc;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
@@ -290,4 +291,5 @@
public Class<Document> type () {
return Document.class;
}
+
}
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
index 41b1c72..cf5701b 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
@@ -245,4 +245,5 @@
return -1;
}
}
+
}
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
index 4714ca8..74a6f4a 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
@@ -157,4 +157,10 @@
return -1;
}
}
+
+
+ @Override
+ public Class<UserDetails> type () {
+ return UserDetails.class;
+ }
}
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
index 2dfebdf..7d02a60 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
@@ -164,4 +164,10 @@
return -1;
}
}
+
+
+ @Override
+ public Class<UserSettings> type () {
+ return UserSettings.class;
+ }
}
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
index 43124a0..565ceec 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
@@ -8,7 +8,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Set;
// todo: for transaction to work this should go into core module!?!
// todo: user instance only required for auditing pointcut operations
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
index 5b0cf0e..a475dae 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
@@ -1,5 +1,6 @@
package de.ids_mannheim.korap.interfaces.db;
+import de.ids_mannheim.korap.config.KustvaktTypeInterface;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.user.Userdata;
@@ -8,7 +9,8 @@
* @author hanl
* @date 27/01/2016
*/
-public interface UserDataDbIface<T extends Userdata> {
+public interface UserDataDbIface<T extends Userdata> extends
+ KustvaktTypeInterface<T> {
public int store (T data) throws KustvaktException;
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
index 649f58d..5c8e568 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
@@ -4,12 +4,12 @@
import de.ids_mannheim.korap.config.*;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.handlers.DocumentDao;
+import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
import de.ids_mannheim.korap.resources.Document;
import de.ids_mannheim.korap.user.User;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
-import org.w3c.dom.Attr;
/**
* @author hanl
@@ -19,7 +19,7 @@
public class DocMatchRewrite implements RewriteTask.IterableRewritePath,
BeanInjectable {
- private DocumentDao docDao;
+ private ResourceOperationIface<Document> docDao;
private Cache cache;
@@ -30,8 +30,8 @@
@Override
public void insertBeans (ContextHolder beans) {
- this.docDao = BeansFactory.getTypeFactory().getTypedBean(
- beans.getResourceProvider(), Document.class);
+ this.docDao = BeansFactory.getTypeFactory().getTypeInterfaceBean(
+ beans.getResourceProviders(), Document.class);
}
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 9c3762b..923e7a2 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
@@ -35,8 +35,8 @@
LayerMapper mapper;
if (user != null && !userdaos.isEmpty()) {
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- userdaos, UserSettings.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(userdaos, UserSettings.class);
mapper = new LayerMapper(config, dao.get(user));
}
else
@@ -69,6 +69,6 @@
@Override
public <T extends ContextHolder> void insertBeans (T beans) {
- this.userdaos = beans.getUserDataDaos();
+ this.userdaos = beans.getUserDataProviders();
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
index 6bd59a5..d7e32ee 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
@@ -29,7 +29,7 @@
@Override
public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
- User user) {
+ User user) throws KustvaktException {
JsonNode subnode = node.rawNode();
if (!subnode.at("/collection").findValuesAsText("key")
@@ -38,32 +38,28 @@
if (subnode.has("collection"))
b.setBaseQuery(JsonUtils.toJSON(subnode));
- try {
- Set resources = ResourceFinder.search(user, Corpus.class);
- ArrayList<KustvaktResource> list = new ArrayList(resources);
+ Set resources = ResourceFinder.search(user, Corpus.class);
+ ArrayList<KustvaktResource> list = new ArrayList(resources);
- if (list.isEmpty())
- throw new KustvaktException(StatusCodes.PERMISSION_DENIED,
- "No resources found for user", user.getUsername());
+ if (list.isEmpty())
+ throw new KustvaktException(
+ StatusCodes.ACCESS_DENIED_NO_RESOURCES,
+ "Resources could not be loaded for user ",
+ user.getUsername());
- Set ids = new HashSet(resources.size());
- for (int i = 0; i < list.size(); i++) {
- if (i > 0)
- b.or();
- b.with(Attributes.CORPUS_SIGLE + "="
- + list.get(i).getPersistentID());
- ids.add(list.get(i).getPersistentID());
- }
- JsonNode rewritten = JsonUtils.readTree(b.toJSON());
- node.set("collection", rewritten.at("/collection"),
- new KoralNode.RewriteIdentifier(
- Attributes.CORPUS_SIGLE, ids));
- node.at("/collection");
+ Set ids = new HashSet(resources.size());
+ for (int i = 0; i < list.size(); i++) {
+ if (i > 0)
+ b.or();
+ b.with(Attributes.CORPUS_SIGLE + "="
+ + list.get(i).getPersistentID());
+ ids.add(list.get(i).getPersistentID());
}
- catch (KustvaktException e) {
- e.printStackTrace();
- // todo:
- }
+ JsonNode rewritten = JsonUtils.readTree(b.toJSON());
+ node.set("collection", rewritten.at("/collection"),
+ new KoralNode.RewriteIdentifier(Attributes.CORPUS_SIGLE,
+ ids));
+ node.at("/collection");
}
return node.rawNode();
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
index 468fa9e..94875f4 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
@@ -115,24 +115,28 @@
- public String processQuery (JsonNode root, User user) {
+ public String processQuery (JsonNode root, User user)
+ throws KustvaktException {
RewriteProcess process = new RewriteProcess(root, user);
JsonNode pre = process.start(false);
return JsonUtils.toJSON(pre);
}
- public String processQuery (String json, User user) {
+ public String processQuery (String json, User user)
+ throws KustvaktException {
return processQuery(JsonUtils.readTree(json), user);
}
- public String processResult (String json, User user) {
+ public String processResult (String json, User user)
+ throws KustvaktException {
return processResult(JsonUtils.readTree(json), user);
}
- public String processResult (JsonNode node, User user) {
+ public String processResult (JsonNode node, User user)
+ throws KustvaktException {
RewriteProcess process = new RewriteProcess(node, user);
JsonNode pre = process.start(true);
return JsonUtils.toJSON(pre);
@@ -167,7 +171,7 @@
private KoralNode processNode (String key, JsonNode value,
- boolean result) {
+ boolean result) throws KustvaktException {
KoralNode kroot = KoralNode.wrapNode(value);
if (value.isObject()) {
if (value.has("operands")) {
@@ -204,7 +208,7 @@
}
- private JsonNode start (boolean result) {
+ private JsonNode start (boolean result) throws KustvaktException {
jlog.debug("Running rewrite process on query {}", root);
if (root != null) {
Iterator<Map.Entry<String, JsonNode>> it = root.fields();
@@ -227,7 +231,8 @@
* applies if parent is an array node
*/
private KoralNode rewrite (String rootNode, KoralNode node,
- Collection<? extends RewriteTask> tasks, boolean result) {
+ Collection<? extends RewriteTask> tasks, boolean result)
+ throws KustvaktException {
if (RewriteHandler.this.config == null)
throw new RuntimeException("KustvaktConfiguration must be set!");
@@ -247,21 +252,14 @@
continue;
}
}
- try {
- if (!result && task instanceof RewriteTask.RewriteQuery) {
- ((RewriteTask.RewriteQuery) task).rewriteQuery(node,
- RewriteHandler.this.config, this.user);
- }
- else if (task instanceof RewriteTask.RewriteResult) {
- ((RewriteTask.RewriteResult) task).rewriteResult(node);
- }
+ if (!result && task instanceof RewriteTask.RewriteQuery) {
+ ((RewriteTask.RewriteQuery) task).rewriteQuery(node,
+ RewriteHandler.this.config, this.user);
}
- catch (KustvaktException e) {
- jlog.error("Error in rewrite processor {} for node {}",
- task.getClass().getSimpleName(), node.rawNode()
- .toString());
- e.printStackTrace();
+ else if (task instanceof RewriteTask.RewriteResult) {
+ ((RewriteTask.RewriteResult) task).rewriteResult(node);
}
+
if (node.isRemove()) {
node.buildRewrites(this.root.at("/" + rootNode));
break;
@@ -275,7 +273,8 @@
// fixme: merge with processNode!
private void processFixedNode (JsonNode node,
- Collection<RewriteTask> tasks, boolean post) {
+ Collection<RewriteTask> tasks, boolean post)
+ throws KustvaktException {
for (RewriteTask task : tasks) {
KoralNode next = KoralNode.wrapNode(node);
if (task instanceof RewriteTask.RewriteNodeAt) {
@@ -284,19 +283,13 @@
next = next.at(rwa.at());
}
- try {
- if (!post & task instanceof RewriteTask.RewriteQuery)
- ((RewriteTask.RewriteQuery) task).rewriteQuery(next,
- RewriteHandler.this.config, user);
- else if (task instanceof RewriteTask.RewriteResult)
- ((RewriteTask.RewriteResult) task).rewriteResult(next);
- next.buildRewrites();
- }
- catch (KustvaktException e) {
- jlog.error("Error in rewrite processor {} for node {}",
- task.getClass().getSimpleName(), next.toString());
- e.printStackTrace();
- }
+ if (!post & task instanceof RewriteTask.RewriteQuery)
+ ((RewriteTask.RewriteQuery) task).rewriteQuery(next,
+ RewriteHandler.this.config, user);
+ else if (task instanceof RewriteTask.RewriteResult)
+ ((RewriteTask.RewriteResult) task).rewriteResult(next);
+ next.buildRewrites();
+
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java b/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
index d31a2f7..33cde6d 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
@@ -51,7 +51,7 @@
beans = BeansFactory.getKustvaktContext();
if (policydao == null | resourcedaos == null) {
ResourceFinder.policydao = beans.getPolicyDbProvider();
- for (ResourceOperationIface iface : beans.getResourceProvider())
+ for (ResourceOperationIface iface : beans.getResourceProviders())
resourcedaos.put(iface.type(), iface);
}
if (policydao == null | resourcedaos.isEmpty())
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java b/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
index 0bf367c..059d33b 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
@@ -70,7 +70,7 @@
SecurityManager.crypto = beans.getEncryption();
SecurityManager.handlers = new HashMap<>();
Collection<ResourceOperationIface> providers = beans
- .getResourceProvider();
+ .getResourceProviders();
for (ResourceOperationIface op : providers)
SecurityManager.handlers.put(op.type(), op);
}
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index f7387c4..918650a 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -13,7 +13,6 @@
import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.*;
-import de.ids_mannheim.korap.utils.NamingUtils;
import de.ids_mannheim.korap.utils.StringUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
import net.sf.ehcache.Cache;
@@ -546,12 +545,12 @@
settings.readDefaults(safeMap);
settings.checkRequired();
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- userdatadaos, UserDetails.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(userdatadaos, UserDetails.class);
assert dao != null;
dao.store(details);
- dao = BeansFactory.getTypeFactory().getTypedBean(userdatadaos,
- UserSettings.class);
+ dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(
+ userdatadaos, UserSettings.class);
assert dao != null;
dao.store(settings);
}
@@ -586,8 +585,8 @@
d.readDefaults(attributes);
d.checkRequired();
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- userdatadaos, UserDetails.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(userdatadaos, UserDetails.class);
assert dao != null;
dao.store(d);
@@ -595,7 +594,7 @@
s.readDefaults(attributes);
s.checkRequired();
- dao = BeansFactory.getTypeFactory().getTypedBean(userdatadaos,
+ dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(userdatadaos,
UserSettings.class);
assert dao != null;
dao.store(d);
@@ -747,11 +746,10 @@
throws WrappedException {
try {
- UserDataDbIface<T> dao = BeansFactory
- .getTypeFactory()
- .getTypedBean(
- BeansFactory.getKustvaktContext().getUserDataDaos(),
- clazz);
+ UserDataDbIface<T> dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ BeansFactory.getKustvaktContext()
+ .getUserDataProviders(), clazz);
T data = null;
if (dao != null)
data = dao.get(user);
@@ -775,9 +773,10 @@
try {
data.validate(this.crypto);
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- BeansFactory.getKustvaktContext().getUserDataDaos(),
- data.getClass());
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ BeansFactory.getKustvaktContext()
+ .getUserDataProviders(), data.getClass());
if (dao != null)
dao.update(data);
}
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java b/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
index cae83af..c2768b4 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
@@ -32,7 +32,7 @@
public static UserDataDbIface getDaoInstanceFromBean (
Class<? extends Userdata> type) {
Collection<UserDataDbIface> daos = BeansFactory.getKustvaktContext()
- .getUserDataDaos();
+ .getUserDataProviders();
for (UserDataDbIface o : daos) {
Type gtype = o.getClass().getGenericInterfaces()[0];
if (gtype instanceof ParameterizedType) {
diff --git a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
index 70207fe..8c94ee9 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
@@ -115,13 +115,14 @@
set.readDefaults(vals);
set.validate(crypto);
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- BeansFactory.getKustvaktContext().getUserDataDaos(),
- UserDetails.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ BeansFactory.getKustvaktContext()
+ .getUserDataProviders(), UserDetails.class);
dao.store(det);
- dao = BeansFactory.getTypeFactory().getTypedBean(
- BeansFactory.getKustvaktContext().getUserDataDaos(),
+ dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(
+ BeansFactory.getKustvaktContext().getUserDataProviders(),
UserSettings.class);
dao.store(set);
}
diff --git a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 7b3ec6a..03f051a 100644
--- a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -17,6 +17,7 @@
import org.eclipse.jetty.util.ssl.SslContextFactory;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -48,9 +49,6 @@
KustvaktArgs kargs = new KustvaktArgs();
for (int i = 0; i < args.length; i++) {
switch ((args[i])) {
- case "--debug":
- kargs.setDebug(true);
- break;
case "--config":
kargs.setConfig(args[i + 1]);
break;
@@ -93,32 +91,36 @@
}
}
System.out.println("Found boot loading interfaces: " + list);
+
while (!list.isEmpty()) {
- for (BootableBeanInterface iface : new ArrayList<>(list)) {
+ loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
try {
+ for (Class dep : iface.getDependencies()) {
+ if (set.contains(dep))
+ continue loop;
+ }
iface.load(BeansFactory.getKustvaktContext());
+ list.remove(iface);
+ set.remove(iface.getClass());
+ System.out.println("Done with interface "
+ + iface.getClass().getSimpleName());
}
catch (KustvaktException e) {
// don't do anything!
System.out.println("An error occurred in class "
- + iface.getClass().getSimpleName() + "!\n" + e);
- continue;
+ + iface.getClass().getSimpleName() + "!\n");
+ System.exit(-1);
}
- list.remove(iface);
- }
- if (!list.isEmpty()) {
- System.out.println("Following bootup classes raised errors: "
- + list);
- break;
}
}
- AdminSetup.getInstance();
}
protected void startServer (KustvaktArgs kargs) {
- if (kargs.init)
+ if (kargs.init) {
runPreStart();
+ AdminSetup.getInstance();
+ }
if (kargs.port == -1)
kargs.setPort(BeansFactory.getKustvaktContext().getConfiguration()
@@ -162,6 +164,7 @@
}
catch (Exception e) {
e.printStackTrace();
+ System.exit(-1);
}
}
@@ -169,7 +172,6 @@
@Setter
public static class KustvaktArgs {
- private boolean debug;
@Getter
private String config;
private int port;
@@ -181,7 +183,6 @@
public KustvaktArgs () {
this.port = -1;
this.sslContext = null;
- this.debug = false;
this.config = null;
this.init = false;
}
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
index dd29b09..e1a5278 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
@@ -462,8 +462,13 @@
// fixme: should only apply to CQL queries per default!
// meta.addEntry("itemsPerResource", 1);
serializer.setMeta(meta.raw());
-
- String query = this.processor.processQuery(serializer.toJSON(), user);
+ String query;
+ try {
+ query = this.processor.processQuery(serializer.toJSON(), user);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
jlog.info("the serialized query {}", query);
@@ -696,7 +701,13 @@
VirtualCollection tmp = resourceHandler.getCache(cache.getId(),
VirtualCollection.class);
if (tmp == null) {
- String query = this.processor.processQuery(cache.getData(), user);
+ String query;
+ try {
+ query = this.processor.processQuery(cache.getData(), user);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
String stats = searchKrill.getStatistics(query);
cache.setStats(JsonUtils.readSimple(stats, Map.class));
resourceHandler.cache(cache);
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java b/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
index 7c3b346..8bd7c88 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
@@ -101,14 +101,27 @@
ss.setMeta(meta.raw());
if (cq != null)
ss.setCollection(cq);
- return Response.ok(processor.processQuery(ss.toJSON(), null)).build();
+
+ String query;
+ try {
+ query = this.processor.processQuery(ss.toJSON(), null);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
+ return Response.ok(query).build();
}
@POST
@Path("search")
public Response queryRaw (@QueryParam("engine") String engine, String jsonld) {
- jsonld = processor.processQuery(jsonld, null);
+ try {
+ jsonld = processor.processQuery(jsonld, null);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
// todo: should be possible to add the meta part to the query serialization
jlog.info("Serialized search: {}", jsonld);
@@ -142,7 +155,13 @@
if (cq != null)
serializer.setCollection(cq);
- String query = processor.processQuery(serializer.toJSON(), null);
+ String query;
+ try {
+ query = this.processor.processQuery(serializer.toJSON(), null);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
jlog.info("the serialized query {}", query);
// This may not work with the the KoralQuery
@@ -213,7 +232,12 @@
// meta.addEntry("itemsPerResource", 1);
QuerySerializer s = new QuerySerializer().setQuery(query, ql, v)
.setMeta(meta.raw());
- query = processor.processQuery(s.toJSON(), null);
+ try {
+ query = this.processor.processQuery(s.toJSON(), null);
+ }
+ catch (KustvaktException e) {
+ throw KustvaktResponseHandler.throwit(e);
+ }
}
String result;
try {
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index 1b0c72c..62d5997 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -1,9 +1,11 @@
<?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
@@ -15,8 +17,6 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
- <!--<cache:annotation-driven/>-->
-
<bean id="props"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
@@ -39,14 +39,14 @@
</property>
</bean>
- <!--<bean id='cacheManager'-->
- <!--class='org.springframework.cache.ehcache.EhCacheCacheManager'-->
- <!--p:cacheManager-ref='ehcache'/>-->
+ <bean id='cacheManager'
+ 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'/>-->
+ <bean id='ehcache'
+ 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"
@@ -87,16 +87,6 @@
<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"/>
@@ -107,18 +97,16 @@
<constructor-arg ref="kustvakt_db"/>
</bean>
- <!--fixme: change name according to convention -->
- <!--<bean id="collectionProvider"-->
- <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
- <!--<constructor-arg ref="kustvakt_db"/>-->
- <!--</bean>-->
-
- <!--fixme: change name according to convention -->
- <bean id="resourceProvider"
+ <bean id="resource_provider"
class="de.ids_mannheim.korap.handlers.ResourceDao">
<constructor-arg ref="kustvakt_db"/>
</bean>
+ <bean id="document_provider"
+ class="de.ids_mannheim.korap.handlers.DocumentDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
<bean id="kustvakt_policies"
class="de.ids_mannheim.korap.security.ac.PolicyDao">
<constructor-arg ref="kustvakt_db"/>
@@ -173,13 +161,12 @@
<bean id="userdata_details"
class="de.ids_mannheim.korap.handlers.UserDetailsDao">
<constructor-arg
- type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
ref="kustvakt_db"/>
</bean>
+
<bean id="userdata_settings"
- class="de.ids_mannheim.korap.handlers.UserDetailsDao">
+ class="de.ids_mannheim.korap.handlers.UserSettingsDao">
<constructor-arg
- type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
ref="kustvakt_db"/>
</bean>
@@ -189,6 +176,13 @@
<ref bean="userdata_settings"/>
</util:list>
+
+ <util:list id="kustvakt_resources"
+ value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
+ <ref bean="document_provider"/>
+ <ref bean="resource_provider"/>
+ </util:list>
+
<!-- specify type for constructor argument -->
<bean id="kustvakt_authenticationmanager"
class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
diff --git a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
index 266b784..5ddb6dd 100644
--- a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
@@ -2,6 +2,7 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import net.jcip.annotations.NotThreadSafe;
+import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -28,13 +29,16 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public abstract class BeanConfigTest {
+
+ private static Logger jlog = Logger.getLogger(BeanConfigTest.class);
+
@Autowired
private ApplicationContext context;
public void init () throws Exception {
assertNotNull("Application context must not be null!", this.context);
- System.out.println("running one-time before init for class "
+ jlog.debug("running one-time before init for class "
+ this.getClass().getSimpleName() + " ...");
initMethod();
BeansFactory.setKustvaktContext(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java b/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
index ce4de02..192c561 100644
--- a/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
@@ -61,12 +61,12 @@
while (!set.isEmpty()) {
out_loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
try {
- System.out.println("Running boot instructions from class "
- + iface.getClass().getSimpleName());
for (Class cl : iface.getDependencies()) {
if (set.contains(cl))
continue out_loop;
}
+ System.out.println("Running boot instructions from class "
+ + iface.getClass().getSimpleName());
set.remove(iface.getClass());
list.remove(iface);
iface.load(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java b/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
index d3bdc84..32e53d1 100644
--- a/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
+++ b/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
@@ -10,6 +10,7 @@
import de.ids_mannheim.korap.user.UserDetails;
import de.ids_mannheim.korap.user.UserSettings;
import de.ids_mannheim.korap.user.Userdata;
+import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -46,26 +47,32 @@
}
- // @Test
+ @Test
+ @Ignore
public void testUserdetailsGetNonExistent () throws KustvaktException {
helper().setupSimpleAccount("userdbtest", "userdbTest");
User user = helper().getContext().getUserDBHandler()
.getAccount("userdbtest");
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserDetails.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserDetails.class);
Userdata data = dao.get(user);
assertNull(data);
helper().dropUser("userdbtest");
}
- // @Test
+ @Test
+ @Ignore
public void testUserSettingsGetNonExistent () throws KustvaktException {
helper().setupSimpleAccount("userdbtest", "userdbTest");
User user = helper().getContext().getUserDBHandler()
.getAccount("userdbtest");
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserSettings.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserSettings.class);
Userdata data = dao.get(user);
assertNull(data);
helper().dropUser("userdbtest");
@@ -74,7 +81,8 @@
// username cannot currently be changed
- // @Test
+ @Test
+ @Ignore
public void updateUsername () throws KustvaktException {
User user1 = helper().getContext().getUserDBHandler()
.getAccount(TestHelper.getUserCredentials()[0]);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
index 227be22..90e37eb 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
@@ -46,7 +46,8 @@
@Test
- public void testCollectionNodeRemoveCorpusIdNoErrors () {
+ public void testCollectionNodeRemoveCorpusIdNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -68,7 +69,8 @@
@Test
- public void testCollectionNodeRemoveAllCorpusIdNoErrors () {
+ public void testCollectionNodeRemoveAllCorpusIdNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -88,7 +90,8 @@
@Test
- public void testCollectionNodeRemoveGroupedCorpusIdNoErrors () {
+ public void testCollectionNodeRemoveGroupedCorpusIdNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -111,7 +114,8 @@
//fixme: will probably fail when one doc groups are being refactored
@Test
- public void testCollectionCleanEmptyDocGroupNoErrors () {
+ public void testCollectionCleanEmptyDocGroupNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -139,7 +143,8 @@
@Test
- public void testCollectionCleanMoveOneDocFromGroupUpNoErrors () {
+ public void testCollectionCleanMoveOneDocFromGroupUpNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -160,7 +165,8 @@
@Test
- public void testCollectionCleanEmptyGroupAndMoveOneFromGroupUpNoErrors () {
+ public void testCollectionCleanEmptyGroupAndMoveOneFromGroupUpNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -181,7 +187,8 @@
@Test
- public void testCollectionRemoveAndMoveOneFromGroupUpNoErrors () {
+ public void testCollectionRemoveAndMoveOneFromGroupUpNoErrors ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -251,7 +258,7 @@
@Test
- public void testRemoveCorpusFromDifferentGroups () {
+ public void testRemoveCorpusFromDifferentGroups () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
@@ -276,7 +283,8 @@
@Test
- public void testRemoveOneCorpusAndMoveDocFromTwoGroups () {
+ public void testRemoveOneCorpusAndMoveDocFromTwoGroups ()
+ throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
handler.add(CollectionConstraint.class);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
index 8c0f1f0..b667796 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
@@ -53,7 +53,8 @@
@Test
- public void testDefaultFoundryInjectLemmaThrowsNoError () {
+ public void testDefaultFoundryInjectLemmaThrowsNoError ()
+ throws KustvaktException {
KustvaktConfiguration c = helper().getBean(
ContextHolder.KUSTVAKT_CONFIG);
@@ -77,7 +78,7 @@
@Test
- public void testDefaultFoundryInjectPOSNoErrors () {
+ public void testDefaultFoundryInjectPOSNoErrors () throws KustvaktException {
KustvaktConfiguration c = helper().getBean(
ContextHolder.KUSTVAKT_CONFIG);
@@ -115,8 +116,10 @@
String result = handler.processQuery(s.toJSON(), user);
JsonNode node = JsonUtils.readTree(result);
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserSettings.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserSettings.class);
UserSettings settings = (UserSettings) dao.get(user);
assertTrue(settings.isValid());
String pos = (String) settings.get(Attributes.DEFAULT_POS_FOUNDRY);
@@ -145,8 +148,10 @@
String result = handler.processQuery(s.toJSON(), user);
JsonNode node = JsonUtils.readTree(result);
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserSettings.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserSettings.class);
UserSettings settings = (UserSettings) dao.get(user);
assertTrue(settings.isValid());
String lemma = (String) settings.get(Attributes.DEFAULT_LEMMA_FOUNDRY);
@@ -161,7 +166,8 @@
@Test
- public void testFoundryInjectJoinedQueryNoErrors () {
+ public void testFoundryInjectJoinedQueryNoErrors ()
+ throws KustvaktException {
KustvaktConfiguration c = helper().getBean(
ContextHolder.KUSTVAKT_CONFIG);
@@ -183,7 +189,8 @@
@Test
- public void testFoundryInjectGroupedQueryNoErrors () {
+ public void testFoundryInjectGroupedQueryNoErrors ()
+ throws KustvaktException {
QuerySerializer s = new QuerySerializer();
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
index 69e8ea7..b112b61 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
@@ -16,7 +16,7 @@
public class IdRewriteTest extends BeanConfigTest {
@Test
- public void insertTokenId () {
+ public void insertTokenId () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
assertTrue(handler.add(IdWriter.class));
@@ -34,7 +34,7 @@
@Test
- public void testIdWriterTest () {
+ public void testIdWriterTest () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
assertTrue(handler.add(IdWriter.class));
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 3cb528d..9458b0c 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
@@ -33,7 +33,7 @@
// throws exception cause of missing configuration
@Test(expected = RuntimeException.class)
- public void testRewriteConfigThrowsException () {
+ public void testRewriteConfigThrowsException () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
QuerySerializer s = new QuerySerializer();
s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
@@ -43,7 +43,7 @@
@Test
- public void testRewriteNoBeanInject () {
+ public void testRewriteNoBeanInject () throws KustvaktException {
RewriteHandler handler = new RewriteHandler(helper().getContext()
.getConfiguration());
QuerySerializer s = new QuerySerializer();
@@ -55,7 +55,7 @@
@Test
- public void testRewriteBeanInject () {
+ public void testRewriteBeanInject () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
QuerySerializer s = new QuerySerializer();
@@ -74,7 +74,7 @@
@Test
- public void testRewriteUserSpecific () {
+ public void testRewriteUserSpecific () throws KustvaktException {
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
QuerySerializer s = new QuerySerializer();
@@ -96,7 +96,8 @@
public void initMethod () throws KustvaktException {
helper().setupAccount();
UserDataDbIface settingsdao = BeansFactory.getTypeFactory()
- .getTypedBean(helper().getContext().getUserDataDaos(),
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
UserSettings.class);
assertNotNull(settingsdao);
UserSettings s = (UserSettings) settingsdao.get(helper().getUser());
diff --git a/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java
deleted file mode 100644
index fdd328d..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import de.ids_mannheim.korap.handlers.ResourceDaoTest;
-import de.ids_mannheim.korap.handlers.UserDaoTest;
-import de.ids_mannheim.korap.security.PolicyDaoTest;
-import de.ids_mannheim.korap.user.UserdataTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 26/02/2016
- */
-
-@Deprecated
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PolicyDaoTest.class, UserdataTest.class,
- UserDaoTest.class, ResourceDaoTest.class })
-public class DaoTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java
deleted file mode 100644
index 9f3a05e..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-
-import de.ids_mannheim.korap.config.CollectionLoaderTest;
-import de.ids_mannheim.korap.config.PolicyLoaderTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PolicyLoaderTest.class, CollectionLoaderTest.class })
-public class LoaderTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java
deleted file mode 100644
index c3cceda..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import de.ids_mannheim.korap.security.PermissionBufferTest;
-import de.ids_mannheim.korap.security.PolicyBuilderTest;
-import de.ids_mannheim.korap.security.SecurityPolicyTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-// test object serialization and I/O buffers
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PermissionBufferTest.class, PolicyBuilderTest.class,
- SecurityPolicyTest.class })
-public class SecurityEntityTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java
deleted file mode 100644
index 45116b5..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({})
-public class SecurityTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java
deleted file mode 100644
index e83e232..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({})
-public class ServiceTestSuite {
-
-}
diff --git a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
index 9295cf3..d7a3bf4 100644
--- a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
+++ b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
@@ -92,13 +92,16 @@
@Test
public void testUserdatafactory () throws KustvaktException {
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserDetails.class);
+ UserDataDbIface dao = BeansFactory.getTypeFactory()
+ .getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserDetails.class);
assertNotNull(dao);
assertEquals(UserDetailsDao.class, dao.getClass());
- dao = BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), UserSettings.class);
+ dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(),
+ UserSettings.class);
assertNotNull(dao);
assertEquals(UserSettingsDao.class, dao.getClass());
@@ -107,8 +110,8 @@
@Test(expected = RuntimeException.class)
public void testUserdatafactoryError () throws KustvaktException {
- BeansFactory.getTypeFactory().getTypedBean(
- helper().getContext().getUserDataDaos(), new Userdata(1) {
+ BeansFactory.getTypeFactory().getTypeInterfaceBean(
+ helper().getContext().getUserDataProviders(), new Userdata(1) {
@Override
public String[] requiredFields () {
return new String[0];
diff --git a/src/test/resources/default-config.xml b/src/test/resources/default-config.xml
index f669953..3ad0aeb 100644
--- a/src/test/resources/default-config.xml
+++ b/src/test/resources/default-config.xml
@@ -21,8 +21,6 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
- <cache:annotation-driven/>
-
<bean id="props"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
@@ -67,7 +65,7 @@
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
lazy-init="false">
<property name="driverClassName" value="org.sqlite.JDBC"/>
- <property name="url" value="jdbc:sqlite:tmp_new.sqlite"/>
+ <property name="url" value="jdbc:sqlite::memory:"/>
<!--<property name="initialSize" value="1" />-->
<!--<property name="maxTotal" value="1" />-->
<!--<property name="maxIdle" value="1" />-->
@@ -116,17 +114,16 @@
<constructor-arg ref="kustvakt_db"/>
</bean>
- <!--<bean id="collectionProvider"-->
- <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
- <!--<constructor-arg ref="kustvakt_db"/>-->
- <!--</bean>-->
-
- <!--fixme: change name according to convention -->
- <bean id="resourceProvider"
+ <bean id="resource_provider"
class="de.ids_mannheim.korap.handlers.ResourceDao">
<constructor-arg ref="kustvakt_db"/>
</bean>
+ <bean id="document_provider"
+ class="de.ids_mannheim.korap.handlers.DocumentDao">
+ <constructor-arg ref="kustvakt_db"/>
+ </bean>
+
<bean id="kustvakt_policies"
class="de.ids_mannheim.korap.security.ac.PolicyDao">
<constructor-arg ref="kustvakt_db"/>
@@ -184,7 +181,7 @@
ref="kustvakt_db"/>
</bean>
<bean id="userdata_settings"
- class="de.ids_mannheim.korap.handlers.UserDetailsDao">
+ class="de.ids_mannheim.korap.handlers.UserSettingsDao">
<constructor-arg
type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
ref="kustvakt_db"/>
@@ -196,6 +193,12 @@
<ref bean="userdata_settings"/>
</util:list>
+ <util:list id="kustvakt_resources"
+ value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
+ <ref bean="document_provider"/>
+ <ref bean="resource_provider"/>
+ </util:list>
+
<!-- specify type for constructor argument -->
<bean id="kustvakt_authenticationmanager"