foundry mapper and rewrite service
diff --git a/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java b/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java
new file mode 100644
index 0000000..4daf76c
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 17/06/2015
+ */
+public class AuditingHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java b/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java
new file mode 100644
index 0000000..74a3a11
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 17/06/2015
+ */
+public class AuthenticationHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java b/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java
new file mode 100644
index 0000000..cab7f6d
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 18/06/2015
+ */
+public class EncryptionHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java b/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java
new file mode 100644
index 0000000..b0c473b
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 17/06/2015
+ */
+public class PluginHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java b/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java
new file mode 100644
index 0000000..d93e4f0
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 18/06/2015
+ */
+public class ProtectedResource {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java b/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java
new file mode 100644
index 0000000..c354a01
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 18/06/2015
+ */
+public class ResourceHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java b/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java
new file mode 100644
index 0000000..73fcc56
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ * @author hanl
+ * @date 17/06/2015
+ */
+public class UserDbHandler {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/Message.java b/src/main/java/de/ids_mannheim/korap/exceptions/Message.java
deleted file mode 100644
index f9021b4..0000000
--- a/src/main/java/de/ids_mannheim/korap/exceptions/Message.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package de.ids_mannheim.korap.exceptions;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-/**
- * @author hanl
- * @date 03/12/2014
- */
-public class Message implements Cloneable {
-
- ObjectMapper mapper = new ObjectMapper();
- private String msg;
- private int code = 0;
- private LinkedList<String> parameters;
-
- public Message(int code, String msg) {
- this.code = code;
- this.msg = msg;
- }
-
- public Message() {
- }
-
- @JsonIgnore
- public Message setMessage(String msg) {
- this.msg = msg;
- return this;
- }
-
- @JsonIgnore
- public String getMessage() {
- return this.msg;
- }
-
- @JsonIgnore
- public Message setCode(int code) {
- this.code = code;
- return this;
- }
-
- @JsonIgnore
- public int getCode() {
- return this.code;
- }
-
- public Message addParameter(String param) {
- if (this.parameters == null) {
- this.parameters = new LinkedList();
- }
-
- this.parameters.add(param);
- return this;
- }
-
- public Object clone() throws CloneNotSupportedException {
- Message clone = new Message();
- if (this.msg != null) {
- clone.msg = this.msg;
- }
-
- clone.code = this.code;
- if (this.parameters != null) {
- Iterator i$ = this.parameters.iterator();
-
- while (i$.hasNext()) {
- String p = (String) i$.next();
- clone.addParameter(p);
- }
- }
-
- return clone;
- }
-
- public JsonNode toJSONnode() {
- ArrayNode message = this.mapper.createArrayNode();
- if (this.code != 0) {
- message.add(this.getCode());
- }
-
- message.add(this.getMessage());
- if (this.parameters != null) {
- Iterator i$ = this.parameters.iterator();
-
- while (i$.hasNext()) {
- String p = (String) i$.next();
- message.add(p);
- }
- }
-
- return message;
- }
-
- public String toJSON() {
- String msg = "";
-
- try {
- return this.mapper.writeValueAsString(this.toJSONnode());
- } catch (Exception var3) {
- msg = ", \"" + var3.getLocalizedMessage() + "\"";
- return "[620, \"Unable to generate JSON\"" + msg + "]";
- }
- }
-}
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/Messages.java b/src/main/java/de/ids_mannheim/korap/exceptions/Messages.java
deleted file mode 100644
index 0729448..0000000
--- a/src/main/java/de/ids_mannheim/korap/exceptions/Messages.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package de.ids_mannheim.korap.exceptions;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import de.ids_mannheim.korap.utils.JsonUtils;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author hanl
- * @date 03/12/2014
- */
-public class Messages implements Cloneable, Iterable<Message> {
-
- private ArrayList<Message> messages = new ArrayList(3);
-
- public Messages() {
- }
-
- public Iterator<Message> iterator() {
- return new Messages.MessageIterator();
- }
-
- public Message add(int code, String message, String... terms) {
- Message newMsg = new Message(code, message);
- this.messages.add(newMsg);
- if (terms != null) {
- String[] arr$ = terms;
- int len$ = terms.length;
-
- for (int i$ = 0; i$ < len$; ++i$) {
- String t = arr$[i$];
- newMsg.addParameter(t);
- }
- }
-
- return newMsg;
- }
-
- public Message add(Message msg) {
- try {
- Message e = (Message) msg.clone();
- this.messages.add(e);
- return e;
- } catch (CloneNotSupportedException var3) {
- return (Message) null;
- }
- }
-
- public Message add(JsonNode msg) throws KorAPException {
- if (msg.isArray() && msg.has(0)) {
- Message newMsg = new Message();
- short i = 1;
- if (msg.get(0).isNumber()) {
- newMsg.setCode(msg.get(0).asInt());
- if (!msg.has(1)) {
- throw new KorAPException(750, "Passed notifications are not well formed", null);
- }
-
- newMsg.setMessage(msg.get(1).asText());
- ++i;
- } else {
- newMsg.setMessage(msg.get(0).asText());
- }
-
- while (msg.has(i)) {
- newMsg.addParameter(msg.get(i++).asText());
- }
-
- this.add((Message) newMsg);
- return newMsg;
- } else {
- throw new KorAPException(750, "Passed notifications are not well formed", null);
- }
- }
-
- public Messages add(Messages msgs) {
- try {
- Iterator e = msgs.getMessages().iterator();
-
- while (e.hasNext()) {
- Message msg = (Message) e.next();
- this.add((Message) ((Message) msg.clone()));
- }
- } catch (CloneNotSupportedException var4) {
- ;
- }
-
- return this;
- }
-
- public Messages clear() {
- this.messages.clear();
- return this;
- }
-
- public int size() {
- return this.messages.size();
- }
-
- @JsonIgnore
- public Message get(int index) {
- return index >= this.size() ? (Message) null : (Message) this.messages.get(index);
- }
-
- @JsonIgnore
- public List<Message> getMessages() {
- return this.messages;
- }
-
- public Object clone() throws CloneNotSupportedException {
- Messages clone = new Messages();
- Iterator i$ = this.messages.iterator();
-
- while (i$.hasNext()) {
- Message m = (Message) i$.next();
- clone.add((Message) ((Message) m.clone()));
- }
-
- return clone;
- }
-
- public JsonNode toJSONnode() {
- ArrayNode messageArray = JsonUtils.createArrayNode();
- Iterator i$ = this.messages.iterator();
-
- while (i$.hasNext()) {
- Message msg = (Message) i$.next();
- messageArray.add(msg.toJSONnode());
- }
-
- return messageArray;
- }
-
- public String toJSON() {
- String msg = "";
-
- try {
- return JsonUtils.toJSON(this.toJSONnode());
- } catch (Exception var3) {
- msg = ", \"" + var3.getLocalizedMessage() + "\"";
- return "[620, \"Unable to generate JSON\"" + msg + "]";
- }
- }
-
- private class MessageIterator implements Iterator<Message> {
- int index = 0;
-
- public MessageIterator() {
- }
-
- public boolean hasNext() {
- return this.index < Messages.this.messages.size();
- }
-
- public Message next() {
- return (Message) Messages.this.messages.get(this.index++);
- }
-
- public void remove() {
- Messages.this.messages.remove(this.index);
- }
- }
-}
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/UserControllerIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
similarity index 92%
rename from src/main/java/de/ids_mannheim/korap/interfaces/UserControllerIface.java
rename to src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
index 67d6545..a3fb44a 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/UserControllerIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
@@ -11,12 +11,13 @@
* @author hanl
* @date 15/06/2015
*/
-public abstract class UserControllerIface {
+public abstract class AuthenticationManagerIface {
private Map<String, AuthenticationIface> providers;
//todo: test if constr actually called
- public UserControllerIface() {
+ public AuthenticationManagerIface() {
+ System.out.println("TEST CONSTRUCTOR CALL");
this.providers = new HashMap<>();
}
diff --git a/src/main/java/de/ids_mannheim/korap/plugins/PluginManager.java b/src/main/java/de/ids_mannheim/korap/plugins/PluginManager.java
deleted file mode 100644
index 262985f..0000000
--- a/src/main/java/de/ids_mannheim/korap/plugins/PluginManager.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package de.ids_mannheim.korap.plugins;
-
-import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
-import de.ids_mannheim.korap.interfaces.UserControllerIface;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author hanl
- * @date 15/06/2015
- */
-// via spring a list of implementations is inserted, for which there will be default constructors loaded
-public class PluginManager {
-
- private Map<String, Class> plugins;
-
- public PluginManager() {
- plugins = new HashMap<>();
- }
-
- public void loadPluginInterfaces() {
- plugins.put("userdb", EntityHandlerIface.class);
- plugins.put("usercontroller", UserControllerIface.class);
- plugins.put("encrytion", EntityHandlerIface.class);
- }
-
- public void register(String key, Class cl) {
- plugins.put(key, cl);
- }
-}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
new file mode 100644
index 0000000..4b31330
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
@@ -0,0 +1,91 @@
+package de.ids_mannheim.korap.resource;
+
+import de.ids_mannheim.korap.user.UserSettings;
+
+/**
+ * @author hanl
+ * @date 14/10/2014
+ */
+public class LayerMapper {
+
+ private UserSettings settings;
+ private ExtConfiguration config;
+
+ public LayerMapper(UserSettings settings) {
+ this.settings = settings;
+ this.config = ExtensionBeans.getConfiguration();
+ }
+
+ /**
+ * find foundry entry in settings specific settings. Includes a call to #translateLayer to get the
+ * correct mapping for the layer denomination!
+ *
+ * @param layer
+ * @return
+ */
+
+ //todo: make mapping configurable!
+ public String findFoundry(String layer) {
+ if (settings != null) {
+ switch (translateLayer(layer.toLowerCase().trim())) {
+ case "d":
+ return settings.getDefaultRelfoundry();
+ case "c":
+ return settings.getDefaultConstfoundry();
+ case "pos":
+ return settings.getDefaultPOSfoundry();
+ case "lemma":
+ return settings.getDefaultLemmafoundry();
+ case "surface":
+ return "opennlp";
+ default:
+ // if the layer is not in this specific listing, assume a default layer
+ // like orth or other tokenization layers
+ return "opennlp";
+ }
+ }else {
+ switch (translateLayer(layer.toLowerCase().trim())) {
+ case "d":
+ return config.getDefault_dep();
+ case "c":
+ return config.getDefault_const();
+ case "pos":
+ return config.getDefault_pos();
+ case "lemma":
+ return config.getDefault_lemma();
+ case "surface":
+ return config.getDefault_surface();
+ default:
+ // if the layer is not in this specific listing, assume a default layer
+ // like orth or other tokenization layers
+ return "opennlp";
+ }
+ }
+ }
+
+ // relevance: map to access control id references. p is usually mapped to pos, l to lemma, etc.
+ public String translateLayer(String layer) {
+ switch (layer.toLowerCase().trim()) {
+ // case "pos":
+ // return "p";
+ // case "lemma":
+ // return "l";
+ case "m":
+ return "msd";
+ //todo the orth layer does not need a foundry entry
+ case "orth":
+ return "surface";
+ case "t":
+ return "surface";
+ case "const":
+ return "c";
+ case "p":
+ return "pos";
+ case "l":
+ return "lemma";
+ default:
+ return layer;
+ }
+ }
+
+}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java
new file mode 100644
index 0000000..78fd005
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.resource;
+
+/**
+ * @author hanl
+ * @date 19/06/2015
+ */
+public class LayerProcessor {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java
new file mode 100644
index 0000000..4f27347
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.resource;
+
+/**
+ * @author hanl
+ * @date 19/06/2015
+ */
+public class NodeProcessor {
+}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java
new file mode 100644
index 0000000..9950266
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java
@@ -0,0 +1,8 @@
+package de.ids_mannheim.korap.resource;
+
+/**
+ * @author hanl
+ * @date 19/06/2015
+ */
+public class RewriteProcessor {
+}
diff --git a/src/test/java/RewriteTest.java b/src/test/java/RewriteTest.java
new file mode 100644
index 0000000..70bf72a
--- /dev/null
+++ b/src/test/java/RewriteTest.java
@@ -0,0 +1,6 @@
+/**
+ * @author hanl
+ * @date 18/06/2015
+ */
+public class RewriteTest {
+}