unittests and resource register table
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 4f27617..7c24af2 100644
--- a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
@@ -80,10 +80,10 @@
             context = new ClassPathXmlApplicationContext(files);
 
         BeanConfiguration.beans = new BeanHolderHelper(context);
-        setManualBeans();
 
     }
 
+    @Deprecated
     private static void setManualBeans() {
         if (getBeans().getPolicyDbProvider() != null
                 && getBeans().getEncryption() != null
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
index 5377998..c175824 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
@@ -38,6 +38,7 @@
         return reflections.getTypesAnnotatedWith(annotation);
     }
 
+    @Deprecated
     public static void registerResourceClasses() {
         PersistenceClient cl = BeanConfiguration.getBeans()
                 .getPersistenceClient();
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java b/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
index 3b078ff..dc00049 100644
--- a/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
+++ b/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
@@ -5,6 +5,7 @@
 import lombok.Setter;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -24,6 +25,11 @@
         this.statusCode = status;
     }
 
+    public KustvaktException(int status, String... args) {
+        this.statusCode = status;
+        this.entity = Arrays.asList(args).toString();
+    }
+
     public KustvaktException(Object userid, int status) {
         this(status);
         this.userid = String.valueOf(userid);
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java b/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
index b2fa818..4317bb5 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
@@ -22,6 +22,7 @@
  * @date 11/01/2014
  */
 
+@Deprecated
 //todo?! cache with ehcache and put token/sentence/paragraph numbers into cache
 public class CollectionDao
         implements ResourceOperationIface<VirtualCollection> {
@@ -76,7 +77,7 @@
             throws KustvaktException {
         MapSqlParameterSource np = new MapSqlParameterSource();
         np.addValue("id", resource.getPersistentID());
-        np.addValue("qy", resource.getQuery());
+        np.addValue("qy", resource.getData());
         np.addValue("name", resource.getName());
         np.addValue("desc", resource.getDescription());
         final String sql = "UPDATE coll_store SET query=:qy, name=:name, description=:desc WHERE persistent_id=:id;";
@@ -98,7 +99,7 @@
         for (VirtualCollection c : resources) {
             MapSqlParameterSource np = new MapSqlParameterSource();
             np.addValue("id", c.getPersistentID());
-            np.addValue("qy", c.getQuery());
+            np.addValue("qy", c.getData());
             np.addValue("name", c.getName());
             np.addValue("desc", c.getDescription());
             sources[i++] = np;
@@ -114,9 +115,9 @@
     @Override
     public int storeResource(VirtualCollection resource, User user)
             throws KustvaktException {
-        if (resource.getQuery().length() > 3) {
+        if (resource.getData() != null) {
             MapSqlParameterSource np = new MapSqlParameterSource();
-            np.addValue("query", resource.getQuery());
+            np.addValue("query", resource.getData());
             np.addValue("pid", resource.getPersistentID());
             np.addValue("name", resource.getName());
             np.addValue("desc", resource.getDescription());
@@ -135,7 +136,7 @@
             }
         }else
             throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
-                    "invalid query parameter", resource.getQuery());
+                    "invalid query parameter", (String) resource.getData());
     }
 
     public int deleteResource(String id, User user) throws KustvaktException {
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 53f3a3b..06c952f 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
@@ -54,7 +54,8 @@
         source.addValue("id", resource.getPersistentID());
         source.addValue("name", resource.getName());
         source.addValue("desc", resource.getDescription());
-        final String sql = "UPDATE resource_store set name=:name, description=:desc where persistent_id=:id;";
+        source.addValue("data", resource.getData());
+        final String sql = "UPDATE resource_store set name=:name, data=:data, description=:desc where persistent_id=:id;";
         try {
             return this.jdbcTemplate.update(sql, source);
         }catch (DataAccessException e) {
@@ -115,6 +116,7 @@
             return (T) this.jdbcTemplate.queryForObject(sql, source,
                     new RowMapperFactory.ResourceMapper());
         }catch (DataAccessException e) {
+            e.printStackTrace();
             return null;
         }
     }
@@ -129,16 +131,17 @@
         b.insert(Attributes.NAME, Attributes.PARENT_ID,
                 Attributes.PERSISTENT_ID, Attributes.DESCRIPTION,
                 Attributes.CREATOR, Attributes.TYPE, Attributes.CREATED);
-        b.params(":name, :parent, :pid, :desc, :ow, :type, :created");
+        b.params(
+                ":name, :parent, :pid, :desc, :ow, :type, :created, :dtype, :data");
 
         if (resource.getParentID() == null) {
-            sql = "INSERT INTO resource_store (name, parent_id, persistent_id, description, creator, type, created) "
-                    + "VALUES (:name, :parent, :pid, :desc, :ow, :type, :created);";
+            sql = "INSERT INTO resource_store (name, parent_id, persistent_id, description, creator, type, created, data) "
+                    + "VALUES (:name, :parent, :pid, :desc, :ow, :type, :created, :data);";
             parid = null;
         }else {
             // fixme: use trigger for consistency check!
-            sql = "INSERT INTO resource_store (name, parent_id, persistent_id, description, creator, type, created) "
-                    + "select :name, id, :pid, :desc, :ow, :type, :created from resource_store where persistent_id=:parent;";
+            sql = "INSERT INTO resource_store (name, parent_id, persistent_id, description, creator, type, created, data) "
+                    + "select :name, id, :pid, :desc, :ow, :type, :created, :data from resource_store where persistent_id=:parent;";
             parid = resource.getParentID();
         }
 
@@ -150,6 +153,8 @@
         source.addValue("type",
                 ResourceFactory.getResourceMapping(resource.getClass()));
         source.addValue("created", System.currentTimeMillis());
+        source.addValue("data", resource.getData());
+
         try {
             this.jdbcTemplate
                     .update(sql, source, holder, new String[] { "id" });
@@ -188,6 +193,13 @@
 
     @Override
     public int size() throws KustvaktException {
-        return -1;
+        final String sql = "SELECT COUNT(*) FROM resource_store;";
+        try {
+            return this.jdbcTemplate
+                    .queryForObject(sql, new HashMap<String, Object>(),
+                            Integer.class);
+        }catch (DataAccessException e) {
+            return -1;
+        }
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/RowMapperFactory.java b/src/main/java/de/ids_mannheim/korap/handlers/RowMapperFactory.java
index b30d1bf..060578c 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/RowMapperFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/RowMapperFactory.java
@@ -108,6 +108,8 @@
                 r.setId(rs.getInt("id"));
                 r.setOwner(rs.getInt("creator"));
                 r.setName(rs.getString("name"));
+
+                r.setFields(rs.getString("data"));
                 r.setDescription(rs.getString("description"));
                 r.setCreated(rs.getTimestamp("created").getTime());
                 r.setPath(rs.getString("name_path"));
@@ -115,6 +117,7 @@
             }
             return r;
         }
+
     }
 
     // todo: ??!
@@ -131,7 +134,7 @@
             c.setName(rs.getString("name"));
             c.setDescription(rs.getString("description"));
             c.setOwner(rs.getInt("user_id"));
-            c.setQuery(rs.getString("query"));
+            c.setFields(rs.getString("data"));
             c.checkNull();
             return c;
         }
diff --git a/src/main/java/de/ids_mannheim/korap/resources/Corpus.java b/src/main/java/de/ids_mannheim/korap/resources/Corpus.java
index 7266646..8dd64e6 100755
--- a/src/main/java/de/ids_mannheim/korap/resources/Corpus.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/Corpus.java
@@ -14,16 +14,14 @@
 @Setter
 public class Corpus extends KustvaktResource {
 
+    // todo: can be deprecated since resource offers data field here!
+    @Deprecated
     private Map stats;
 
     public Corpus() {
         super();
     }
 
-    public Corpus(Integer id, long created, int creator) {
-        super(id, creator, created);
-    }
-
     public Corpus(Integer id, int creator) {
         super(id, creator);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/resources/Foundry.java b/src/main/java/de/ids_mannheim/korap/resources/Foundry.java
index b86874d..51e14f0 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/Foundry.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/Foundry.java
@@ -10,21 +10,11 @@
         super();
     }
 
-    public Foundry(Integer id, int creator, long created) {
-        super(id, creator, created);
-    }
-
     public Foundry(Integer id, int creator) {
         super(id, creator);
     }
 
-    public Foundry(Integer id, String persistentID, int creator) {
-        super(id, creator);
-        this.setName(persistentID);
-        this.setPersistentID(persistentID);
-    }
-
-    public Foundry(String persistentID,int creator) {
+    public Foundry(String persistentID, int creator) {
         super(persistentID, creator);
         this.setName(persistentID);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java b/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
index 0c99e36..259b033 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
@@ -1,7 +1,9 @@
 package de.ids_mannheim.korap.resources;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.utils.TimeUtils;
+import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.Setter;
 import org.joda.time.DateTime;
@@ -21,6 +23,7 @@
     private String persistentID;
     private String name;
     private String description;
+    // todo: manage creator over policies!
     @JsonIgnore
     private Integer owner;
     protected long created;
@@ -32,19 +35,15 @@
     // parents persistentid
     private String parentID;
 
-    //    private static RandomStringUtils utils = new RandomStringUtils();
+    @Getter(AccessLevel.PROTECTED)
+    private Map<String, Object> fields;
 
+    // todo: redo constructors
     protected KustvaktResource() {
         this.created = TimeUtils.getNow().getMillis();
         this.id = -1;
         this.parentID = null;
-    }
-
-    public KustvaktResource(Integer id, int creator, long created) {
-        this.created = created;
-        this.owner = creator;
-        this.id = id;
-        this.parentID = null;
+        this.fields = new HashMap<>();
     }
 
     public KustvaktResource(Integer id, int creator) {
@@ -52,6 +51,7 @@
         this.id = id;
         this.owner = creator;
         this.parentID = null;
+        this.fields = new HashMap<>();
     }
 
     // todo: move creator to builder instance for policies
@@ -61,6 +61,41 @@
         this.persistentID = persistentID;
     }
 
+    //    public void setData(int type, Object data) {
+    //        this.data = new Object[2];
+    //        this.data[0] = type;
+    //        this.data[1] = data;
+    //    }
+
+    //    public int getDataType() {
+    //        return this.data != null ? (int) this.data[0] : -1;
+    //    }
+
+    public void addField(String key, Object value) {
+        this.fields.put(key, value);
+    }
+
+    public void setFields(Map<String, Object> fields) {
+        this.fields = fields;
+    }
+
+    public void setFields(String fields) {
+        Map s = JsonUtils.readSimple(fields, Map.class);
+        if (s == null)
+            throw new RuntimeException(
+                    "Fields could not be read for resource '" + persistentID
+                            + "'!");
+        this.fields = s;
+    }
+
+    public Object getField(String key) {
+        return this.fields.get(key);
+    }
+
+    public String getData() {
+        return JsonUtils.toJSON(this.fields);
+    }
+
     @Override
     public boolean equals(Object other) {
         return other instanceof KustvaktResource && this.id
@@ -137,12 +172,13 @@
         m.put("id", persistentID);
         m.put("name", name);
         //todo: fix!
-//        m.put("path", path);
+        //        m.put("path", path);
         m.put("description", description);
         m.put("created", TimeUtils.format(new DateTime(created)));
+        m.put("data", getData());
         // deprecated
-//        m.put("managed", managed);
-//        m.put("shared", shared);
+        //        m.put("managed", managed);
+        //        m.put("shared", shared);
         return m;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resources/Layer.java b/src/main/java/de/ids_mannheim/korap/resources/Layer.java
index df464c0..7203216 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/Layer.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/Layer.java
@@ -10,9 +10,6 @@
         super();
     }
 
-    public Layer(Integer id, int creator, long created) {
-        super(id, creator, created);
-    }
 
     public Layer(Integer id, int creator) {
         super(id, creator);
diff --git a/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java b/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
index ac9f9d2..e854b49 100755
--- a/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
@@ -18,7 +18,7 @@
         subTypes.add(FOUNDRY, Foundry.class);
         subTypes.add(LAYER, Layer.class);
         subTypes.add(VIRTUALCOLLECTION, VirtualCollection.class);
-//        subTypes.add(USERQUERY, UserQuery.class);
+        //        subTypes.add(USERQUERY, UserQuery.class);
     }
 
     public static KustvaktResource getResource(
@@ -54,16 +54,15 @@
         return null;
     }
 
-
     public static <T extends KustvaktResource> Class<T> getResourceClass(
             String type) {
         for (Class value : subTypes) {
             if (value == VirtualCollection.class && type
                     .equalsIgnoreCase("collection"))
                 return (Class<T>) VirtualCollection.class;
-                    //todo
-//            else if (value == UserQuery.class && type.equalsIgnoreCase("query"))
-//                return (Class<T>) UserQuery.class;
+                //todo
+                //            else if (value == UserQuery.class && type.equalsIgnoreCase("query"))
+                //                return (Class<T>) UserQuery.class;
             else if (value.getSimpleName().equalsIgnoreCase(type.trim())) {
                 return value;
             }
@@ -73,11 +72,9 @@
     // all deprecated!
 
     public static VirtualCollection getCachedCollection(String query) {
-        VirtualCollection v = new VirtualCollection();
-        v.setQuery(query);
+        VirtualCollection v = new VirtualCollection(query);
         v.setName("");
         v.setDescription("");
-        v.setPersistentID(v.createID());
         return v;
     }
 
@@ -101,11 +98,11 @@
         return v;
     }
 
-    public static VirtualCollection createCollection(String name, String query,
-            long time, Integer owner) {
-        VirtualCollection v = new VirtualCollection(0, owner, time);
+    public static VirtualCollection createCollection(String name,
+            Integer owner) {
+        VirtualCollection v = new VirtualCollection();
+        v.setOwner(owner);
         v.setName(name);
-        v.setQuery(query);
         return v;
     }
 
@@ -120,13 +117,11 @@
 
     public static VirtualCollection createContainer(String name,
             String description, String query, Integer owner) {
-        VirtualCollection v = new VirtualCollection();
+        VirtualCollection v = new VirtualCollection(query);
         v.setName(name);
         v.setDescription(description);
-        v.setQuery(query);
         v.setOwner(owner);
         v.setManaged(true);
-        v.setPersistentID(v.createID());
         return v;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java b/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java
index e48ee50..5ffbb13 100755
--- a/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java
@@ -1,6 +1,5 @@
 package de.ids_mannheim.korap.resources;
 
-import de.ids_mannheim.korap.utils.JsonUtils;
 import lombok.Getter;
 import lombok.Setter;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -11,10 +10,11 @@
 @Setter
 public class VirtualCollection extends KustvaktResource {
 
-    private String query;
+    //    private String query;
     // use ehcache instead and only save persisted values in the database
     //    @Deprecated
     //    private boolean cache = false;
+    @Deprecated
     private Map stats;
 
     protected VirtualCollection() {
@@ -22,10 +22,6 @@
         this.setPersistentID(this.createID());
     }
 
-    protected VirtualCollection(Integer id, int creator, long created) {
-        super(id, creator, created);
-    }
-
     public VirtualCollection(Integer id, int creator) {
         super(id, creator);
     }
@@ -36,14 +32,15 @@
 
     public VirtualCollection(String query) {
         this();
-        this.setQuery(query);
+        this.setFields(query);
         this.setPersistentID(this.createID());
     }
 
+    // todo: redo!
     @Override
     protected String createID() {
-        if (this.query != null) {
-            String s = this.getQuery();
+        if (this.getData() != null) {
+            String s = this.getData();
             return DigestUtils.sha1Hex(s);
         }
         return super.createID();
@@ -55,10 +52,9 @@
         if (resource == null | !(resource instanceof VirtualCollection))
             return;
         VirtualCollection other = (VirtualCollection) resource;
-        this.setStats(
-                this.getStats() == null ? other.getStats() : this.getStats());
-        this.setQuery(
-                this.getQuery() == null ? other.getQuery() : this.getQuery());
+        this.setFields(this.getFields() == null ?
+                other.getFields() :
+                this.getFields());
     }
 
     @Override
@@ -67,7 +63,6 @@
         super.checkNull();
         this.setDescription(
                 this.getDescription() == null ? "" : this.getDescription());
-        this.setQuery(this.query == null ? "" : this.getQuery());
     }
 
     @Override
@@ -79,18 +74,17 @@
                 ", path=" + this.getPath() +
                 ", owner=" + this.getOwner() +
                 ", name='" + this.getName() + '\'' +
-                ", query='" + query + '\'' +
-                ", stats='" + stats + '\'' +
+                ", data='" + this.getData() + '\'' +
                 '}';
     }
 
-    @Override
-    public Map toMap() {
-        Map res = super.toMap();
-        res.put("query", JsonUtils.readTree(query));
-        if (stats != null && !stats.isEmpty())
-            res.put("statistics", stats);
-        return res;
-    }
+    //    @Override
+    //    public Map toMap() {
+    //        Map res = super.toMap();
+    //        res.put("query", JsonUtils.readTree());
+    //        if (stats != null && !stats.isEmpty())
+    //            res.put("statistics", stats);
+    //        return res;
+    //    }
 
 }
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 53e1706..fcdca03 100755
--- a/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
@@ -1,5 +1,6 @@
 package de.ids_mannheim.korap.security.ac;
 
+import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
 import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
@@ -32,10 +33,15 @@
     }
 
     private static void checkProviders() {
+        if (BeanConfiguration.hasContext() && policydao == null) {
+            ResourceFinder.policydao = BeanConfiguration.getBeans()
+                    .getPolicyDbProvider();
+        }
         if (policydao == null)
             throw new RuntimeException("provider not set!");
     }
 
+    @Deprecated
     public static void setProviders(PolicyHandlerIface policyHandler) {
         ResourceFinder.policydao = policyHandler;
     }
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 f3226ec..4321def 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
@@ -1,5 +1,6 @@
 package de.ids_mannheim.korap.security.ac;
 
+import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.exceptions.EmptyResultException;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.NotAuthorizedException;
@@ -31,13 +32,11 @@
 @SuppressWarnings("all")
 public class SecurityManager<T extends KustvaktResource> {
 
-    //    private static final Logger errorLogger = LoggerFactory
-    //            .getLogger(LoggerFactory.ERROR_LOG);
-
     private static final Logger jlog = LoggerFactory
             .getLogger(SecurityManager.class);
 
     private static PolicyHandlerIface policydao;
+    @Deprecated
     private static Map<Class<? extends KustvaktResource>, ResourceOperationIface> handlers;
     private static EncryptionIface crypto;
 
@@ -58,11 +57,23 @@
     }
 
     private static void checkProviders() {
-        if (policydao == null && crypto == null && handlers == null)
+        if (BeanConfiguration.hasContext() && (policydao == null
+                | crypto == null)) {
+            SecurityManager.policydao = BeanConfiguration.getBeans()
+                    .getPolicyDbProvider();
+            SecurityManager.crypto = BeanConfiguration.getBeans()
+                    .getEncryption();
+            SecurityManager.handlers = new HashMap<>();
+            ResourceOperationIface rprovider = BeanConfiguration.getBeans()
+                    .getResourceProvider();
+            SecurityManager.handlers.put(rprovider.getType(), rprovider);
+        }
+        if (policydao == null && crypto == null)
             throw new RuntimeException("providers not set!");
     }
 
-    public static final void setProviders(PolicyHandlerIface policyHandler,
+    @Deprecated
+    public static final void setProvgiders(PolicyHandlerIface policyHandler,
             EncryptionIface crypto, Collection<ResourceOperationIface> ifaces) {
         SecurityManager.policydao = policyHandler;
         SecurityManager.crypto = crypto;
@@ -72,6 +83,7 @@
             handlers.put(iface.getType(), iface);
     }
 
+    @Deprecated
     public static Map<Class<? extends KustvaktResource>, ResourceOperationIface> getHandlers() {
         return handlers;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
index 82f3c36..0548cc6 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
@@ -3,7 +3,6 @@
 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.CollectionDao;
 import de.ids_mannheim.korap.resources.Permissions;
 import de.ids_mannheim.korap.resources.ResourceFactory;
 import de.ids_mannheim.korap.resources.VirtualCollection;
@@ -21,9 +20,6 @@
     @Override
     public void load() throws KustvaktException {
         if (BeanConfiguration.hasContext()) {
-            CollectionDao dao = new CollectionDao(
-                    BeanConfiguration.getBeans().getPersistenceClient());
-
             int uid = (Integer) KustvaktConfiguration.KUSTVAKT_USER
                     .get(Attributes.ID);
 
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
index 2a76686..3ad501c 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
@@ -3,21 +3,11 @@
 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.CollectionDao;
-import de.ids_mannheim.korap.handlers.ResourceDao;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
 import de.ids_mannheim.korap.resources.Corpus;
 import de.ids_mannheim.korap.resources.Permissions;
 import de.ids_mannheim.korap.security.ac.PolicyBuilder;
-import de.ids_mannheim.korap.security.ac.PolicyDao;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
-import de.ids_mannheim.korap.security.ac.SecurityManager;
 import de.ids_mannheim.korap.user.User;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * @author hanl
  * @date 15/01/2016
@@ -27,16 +17,6 @@
     @Override
     public void load() throws KustvaktException {
         if (BeanConfiguration.hasContext()) {
-            PersistenceClient cl = BeanConfiguration.getBeans()
-                    .getPersistenceClient();
-            Set<ResourceOperationIface> ifaces = new HashSet<>();
-            ifaces.add(new ResourceDao(cl));
-            ifaces.add(new CollectionDao(cl));
-
-            SecurityManager.setProviders(new PolicyDao(cl),
-                    BeanConfiguration.getBeans().getEncryption(), ifaces);
-            ResourceFinder.setProviders(new PolicyDao(cl));
-
             User user = User.UserFactory
                     .toUser(KustvaktConfiguration.KUSTVAKT_USER);
             PolicyBuilder builder = new PolicyBuilder(user);
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 93a3d9d..7bb87e7 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
@@ -163,7 +163,7 @@
         CollectionQueryBuilder3 query = new CollectionQueryBuilder3();
         if (cl_type.equals(VirtualCollection.class)) {
             VirtualCollection c = (VirtualCollection) resource;
-            query.setBaseQuery(c.getQuery());
+            query.setBaseQuery((String) c.getData());
         }else if (cl_type.equals(Corpus.class)) {
             Corpus c = (Corpus) resource;
             query.addQuery("corpusID=" + c.getPersistentID());
@@ -379,7 +379,7 @@
                         ResourceFactory.getResourceClass(type));
 
             if (resource instanceof VirtualCollection)
-                cquery.addQuery(((VirtualCollection) resource).getQuery());
+                cquery.addQuery((String) resource.getData());
             else if (resource instanceof Corpus)
                 cquery.addQuery("corpusID=" + resource.getPersistentID());
 
@@ -557,7 +557,7 @@
                             ResourceFactory.getResourceClass(type));
 
                 if (resource instanceof VirtualCollection)
-                    builder.addQuery(((VirtualCollection) resource).getQuery());
+                    builder.setBaseQuery((String) resource.getData());
                 else if (resource instanceof Corpus)
                     builder.addQuery("corpusID=" + resource.getPersistentID());
                 else
@@ -669,7 +669,7 @@
             //todo ?!
             CollectionQueryBuilder3 query = new CollectionQueryBuilder3();
             if (resource instanceof VirtualCollection) {
-                query.setBaseQuery(((VirtualCollection) resource).getQuery());
+                query.setBaseQuery((String) resource.getData());
             }else if (resource instanceof Corpus) {
                 query.addQuery("corpusID=" + resource.getName());
             }
@@ -706,8 +706,9 @@
                 .getCache(cache.getId(), VirtualCollection.class);
         if (tmp == null) {
             CollectionQueryBuilder3 cquery = new CollectionQueryBuilder3()
-                    .setBaseQuery(cache.getQuery());
-            String query = this.processor.preProcess(cache.getQuery(), user);
+                    .setBaseQuery((String) cache.getData());
+            String query = this.processor
+                    .preProcess((String) cache.getData(), user);
             String stats = searchKrill.getStatistics(query);
             cache.setStats(JsonUtils.readSimple(stats, Map.class));
             resourceHandler.cache(cache);
@@ -783,8 +784,8 @@
             String base;
             if (reference != null && !reference.equals("null")) {
                 try {
-                    base = resourceHandler.findbyStrId(reference, user,
-                            VirtualCollection.class).getQuery();
+                    base = (String) resourceHandler.findbyStrId(reference, user,
+                            VirtualCollection.class).getData();
                 }catch (KustvaktException e) {
                     throw KustvaktResponseHandler.throwit(e);
                 }
@@ -863,12 +864,14 @@
                 .equals(ResourceFactory.getResourceClass(type))) {
 
             VirtualCollection cachetmp, collection;
+            // todo: ??
             Object read = JsonUtils.readTree(query);
             CollectionQueryBuilder3 cquery = new CollectionQueryBuilder3();
             if (reference != null && !reference.equals("null")) {
                 try {
-                    cquery.addQuery(resourceHandler.findbyStrId(reference, user,
-                            VirtualCollection.class).getQuery());
+                    cquery.addQuery(
+                            (String) resourceHandler.findbyStrId(reference, user,
+                                    VirtualCollection.class).getData());
                 }catch (KustvaktException e) {
                     throw KustvaktResponseHandler.throwit(e);
                 }
diff --git a/src/main/resources/db/sqlite/V1__Initial_version.sql b/src/main/resources/db/sqlite/V1__Initial_version.sql
index 44f64de..edbf4ee 100644
--- a/src/main/resources/db/sqlite/V1__Initial_version.sql
+++ b/src/main/resources/db/sqlite/V1__Initial_version.sql
@@ -192,8 +192,9 @@
 persistent_id VARCHAR(100) NOT NULL UNIQUE,
 name VARCHAR(100),
 description VARCHAR(300),
-parent_id Integer unsigned null,
-created timestamp default current_timestamp,
+parent_id INTEGER unsigned null,
+created TIMESTAMP default current_timestamp,
+data BLOB,
 type INTEGER NOT NULL,
 creator INTEGER NOT NULL
 );
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index a756340..cb62910 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -104,10 +104,10 @@
     </bean>
 
     <!--fixme: change name according to convention -->
-    <bean id="collectionProvider"
-          class="de.ids_mannheim.korap.handlers.CollectionDao">
-        <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"
diff --git a/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
index 6d23ed1..d4f2ad5 100644
--- a/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
@@ -1,7 +1,7 @@
 package de.ids_mannheim.korap.config;
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.CollectionDao;
+import de.ids_mannheim.korap.handlers.ResourceDao;
 import de.ids_mannheim.korap.resources.VirtualCollection;
 import de.ids_mannheim.korap.security.ac.ResourceFinder;
 import de.ids_mannheim.korap.user.Attributes;
@@ -29,25 +29,15 @@
     @Before
     public void create() {
         BeanConfiguration.loadClasspathContext("default-config.xml");
-        //        PersistenceClient cl = BeanConfiguration.getBeans()
-        //                .getPersistenceClient();
-        //        Set<ResourceOperationIface> ifaces = new HashSet<>();
-        //        ifaces.add(new ResourceDao(cl));
-        //        ifaces.add(new CollectionDao(cl));
-        //
-        //        SecurityManager.setProviders(new PolicyDao(cl),
-        //                BeanConfiguration.getBeans().getEncryption(), ifaces);
-        //        ResourceFinder.setProviders(new PolicyDao(cl));
-        TestHelper.runBootInterfaces();
     }
 
     @Test
     public void testCollectionLoader() throws KustvaktException {
-        CollectionDao dao = new CollectionDao(
+        TestHelper.runBootInterfaces();
+        ResourceDao dao = new ResourceDao(
                 BeanConfiguration.getBeans().getPersistenceClient());
         int size = dao.size();
-        Assert.assertNotEquals("Is not supposed to be zero", size, 0);
-        Assert.assertEquals("wrong size", size, 3);
+        Assert.assertNotEquals("Is not supposed to be zero", 0, size);
 
         Set<VirtualCollection> set = ResourceFinder.search(User.UserFactory
                         .toUser(KustvaktConfiguration.KUSTVAKT_USER),
diff --git a/src/test/resources/default-config.xml b/src/test/resources/default-config.xml
index a756340..b325134 100644
--- a/src/test/resources/default-config.xml
+++ b/src/test/resources/default-config.xml
@@ -103,11 +103,10 @@
         <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>
+    <!--<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"