data factory filter method
Change-Id: I3e25fa4e6d39dca19c7725f0f56ba7200334d9ad
diff --git a/src/main/java/de/ids_mannheim/korap/user/DataFactory.java b/src/main/java/de/ids_mannheim/korap/user/DataFactory.java
index 354fcd6..0e59f53 100644
--- a/src/main/java/de/ids_mannheim/korap/user/DataFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/user/DataFactory.java
@@ -67,6 +67,7 @@
public abstract String toStringValue (Object data);
+ public abstract Object filter(Object data, String ... keys);
public boolean checkDataType (Object data) {
throw new RuntimeException("Wrong data type for factory setting!");
@@ -210,6 +211,15 @@
return data.toString();
}
+ @Override
+ public Object filter(Object data, String... keys) {
+ if (checkDataType(data) && ((JsonNode) data).isObject()) {
+ ObjectNode node = ((JsonNode) data).deepCopy();
+ return node.retain(keys);
+ }
+ return JsonUtils.createObjectNode();
+ }
+
@Override
public boolean checkDataType (Object data) {
diff --git a/src/main/java/de/ids_mannheim/korap/user/Userdata.java b/src/main/java/de/ids_mannheim/korap/user/Userdata.java
index bbfddfb..581ad28 100644
--- a/src/main/java/de/ids_mannheim/korap/user/Userdata.java
+++ b/src/main/java/de/ids_mannheim/korap/user/Userdata.java
@@ -46,6 +46,10 @@
return DataFactory.getFactory().getValue(this.data, key);
}
+ public Object filter(String ... keys) {
+ return DataFactory.getFactory().filter(this.data, keys);
+ }
+
/**
*
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
index 2d793b2..c998e31 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
@@ -355,7 +355,7 @@
@POST
@Path("queries")
@Consumes(MediaType.APPLICATION_JSON)
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthFilter.class,
PiwikFilter.class, BlockingFilter.class })
public Response updateQueries (@Context SecurityContext context, String json) {
TokenContext ctx = (TokenContext) context.getUserPrincipal();