Move copyright notice to configuration file and fix reference to 'Leibniz-Institut'

Change-Id: I8cf746e0b4e98e584d4ca63f8d7f20d4899f4d19
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
index 10c9030..333ed60 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
@@ -11,6 +11,7 @@
 import java.io.*;
 import java.lang.String;
 import java.util.Properties;
+import java.nio.charset.StandardCharsets;
 
 public class ExWSConf {
 
@@ -32,9 +33,14 @@
 
         InputStream iFile;
         try {
-            iFile = new FileInputStream(propFile);
+
+            iFile = new FileInputStream(propFile);            
             prop = new Properties();
-            prop.load(iFile);
+            prop.load(
+                new BufferedReader(
+                    new InputStreamReader(iFile, "UTF-8")
+                    )
+                );
         }
         catch (IOException t) {
             try {
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
index 3c663b2..60b18ba 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
@@ -1,8 +1,10 @@
 package de.ids_mannheim.korap.plkexport;
 
-import java.lang.StringBuffer;
-import java.nio.charset.*;
+import java.util.Properties;
 
+import java.lang.StringBuffer;
+
+import java.nio.charset.*;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import static java.nio.charset.CodingErrorAction.REPORT;
@@ -15,11 +17,15 @@
 import java.io.IOException;
 import java.io.Writer;
 
+import de.ids_mannheim.korap.plkexport.Util.*;
+
 /**
  * Streaming RTF exporter.
  */
 public class RtfExporter extends MatchAggregator implements Exporter {
 
+    private Properties prop = ExWSConf.properties(null);
+    
     // Horizontal line
     private static final String HLINE =
         "{\\pard\\brdrb\\brdrs\\brdrw2\\brsp20\\par}\n";
@@ -48,6 +54,9 @@
     
     @Override
     public void writeHeader (Writer w) throws IOException {
+
+        String footnote = Util.convertFromUTF8(prop.getProperty("rtf.footnote"));
+        
         w.append("{")
             .append("\\rtf1\\ansi\\deff0\n")
 
@@ -59,8 +68,13 @@
 
         // Footer on every page, containing the page number
         w.append("{\\footer\\pard\\qr\\fs18\\f0 ");
-        rtfText(w, "@ Institut für Deutsche Sprache, Mannheim");
-        w.append(" \\endash  \\chpgn /{\\field{\\*\\fldinst{\\fs18\\f0 NUMPAGES}}}");
+
+        if (footnote != null && footnote.length() > 0) {
+            rtfText(w, footnote);
+            w.append(" \\endash  ");
+        };
+
+        w.append("\\chpgn /{\\field{\\*\\fldinst{\\fs18\\f0 NUMPAGES}}}");
         w.append("\\par}\n");
 
         // Title
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Service.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
index fc09678..972fb12 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
@@ -64,7 +64,6 @@
  *   of serving.
  * - Add date info.
  * - Add opaque source, in case source is an internal IP.
- * - Change to "Leibniz-Institut" in Copyright notice.
  * - Improve Readme.
  * - 100 matches as default for export form.
  * - Test ExWsConf.
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Util.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Util.java
index 169615d..3df2fff 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Util.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Util.java
@@ -43,4 +43,34 @@
 
 		return sb.toString();
 	};
+
+    /**
+     * Convert string to utf8
+     */
+    public static String convertToUTF8(String s) {
+        if (s == null)
+            return null;
+        String out = null;
+        try {
+            out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
+        } catch (java.io.UnsupportedEncodingException e) {
+            return null;
+        }
+        return out;
+    };
+
+    /**
+     * Convert string from utf8
+     */
+    public static String convertFromUTF8(String s) {
+        if (s == null)
+            return null;
+        String out = null;
+        try {
+            out = new String(s.getBytes("Windows-1252"), "UTF-8");
+        } catch (java.io.UnsupportedEncodingException e) {
+            return null;
+        }
+        return out;
+    };
 };
diff --git a/plugin/src/main/resources/exportPlugin.conf b/plugin/src/main/resources/exportPlugin.conf
index 0915b6b..ba388ea 100644
--- a/plugin/src/main/resources/exportPlugin.conf
+++ b/plugin/src/main/resources/exportPlugin.conf
@@ -25,4 +25,10 @@
 
 # The file directory to serve from
 # conf.file_dir=./files/
-# Defaults to the system's temp directory
\ No newline at end of file
+# Defaults to the system's temp directory
+
+#####################
+# RTF configuration #
+#####################
+
+rtf.footnote = @ Leibniz-Institut für Deutsche Sprache, Mannheim
\ No newline at end of file
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
index 311d479..6a67950 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
@@ -22,7 +22,8 @@
         Response resp = rtf.serve().build();
         String x = (String) resp.getEntity();
         resp.close();
-        assertTrue(x.contains("\\footer\\pard\\qr\\fs18\\f0 @ Institut"));
+
+        assertTrue(x.contains("\\footer\\pard\\qr\\fs18\\f0 @ Leibniz-Institut"));
         assertTrue(x.contains("Institut f\\u252\\'fcr Deutsche"));
     };
 
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
index 594df85..fcd3ef8 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
@@ -61,6 +61,9 @@
 
 import static de.ids_mannheim.korap.plkexport.Service.getClientIP;
 
+import de.ids_mannheim.korap.plkexport.Util.*;
+
+
 public class ServiceTest extends JerseyTest {
 
     private static ClientAndServer mockServer;
@@ -1003,17 +1006,6 @@
     };
 
 
-    // Convert string to utf8
-    private static String convertToUTF8(String s) {
-        String out = null;
-        try {
-            out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
-        } catch (java.io.UnsupportedEncodingException e) {
-            return null;
-        }
-        return out;
-    }
-
     // Get fixture from ressources utf8 encoded
     private String getFixture (String file) {
         return getFixture(file, false);
@@ -1029,7 +1021,7 @@
         if (raw) {
             return getFileString(filepath);
         };
-        return convertToUTF8(getFileString(filepath));
+        return Util.convertToUTF8(getFileString(filepath));
     };