Fixed matchinfo in lightservice
Change-Id: I0cba0cad0d39c762ce0bf1ec47ea93617b70aa31
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
deleted file mode 100644
index a70d205..0000000
--- a/dependency-reduced-pom.xml
+++ /dev/null
@@ -1,236 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>de.ids_mannheim.korap</groupId>
-  <artifactId>Kustvakt-core</artifactId>
-  <name>Kustvakt core</name>
-  <version>0.59.6</version>
-  <description>Kustvakt core, basic rest api for testing purposes and default
-        interfaces</description>
-  <build>
-    <resources>
-      <resource>
-        <filtering>true</filtering>
-        <directory>src/main/resources</directory>
-        <includes>
-          <include>**/*.info</include>
-          <include>**/*.xml</include>
-          <include>**/*.conf</include>
-          <include>**/*.kustvakt</include>
-          <include>**/*.properties</include>
-          <include>**/*.sql</include>
-        </includes>
-      </resource>
-    </resources>
-    <testResources>
-      <testResource>
-        <filtering>true</filtering>
-        <directory>src/test/resources</directory>
-        <includes>
-          <include>**/*.prop</include>
-          <include>**/*.xml</include>
-          <include>**/*.conf</include>
-          <include>**/*.info</include>
-          <include>**/*.properties</include>
-        </includes>
-      </testResource>
-      <testResource>
-        <filtering>true</filtering>
-        <directory>src/main/resources</directory>
-        <includes>
-          <include>**/*.info</include>
-          <include>**/*.properties</include>
-        </includes>
-      </testResource>
-    </testResources>
-    <plugins>
-      <plugin>
-        <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
-        <artifactId>maven-java-formatter-plugin</artifactId>
-        <version>0.4</version>
-        <configuration>
-          <configFile>${project.basedir}/Format.xml</configFile>
-          <overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
-          <compilerSource>1.7</compilerSource>
-          <compilerCompliance>1.7</compilerCompliance>
-          <compilerTargetPlatform>1.7</compilerTargetPlatform>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.3</version>
-        <configuration>
-          <compilerVersion>1.7</compilerVersion>
-          <source>1.7</source>
-          <target>1.7</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.1</version>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.19.1</version>
-        <configuration>
-          <reuseForks>false</reuseForks>
-          <forkCount>2</forkCount>
-          <threadCount>10</threadCount>
-          <excludes>
-            <exclude>**/*APITest.java</exclude>
-            <exclude>de/ids_mannheim/korap/suites/*.java</exclude>
-          </excludes>
-          <includes>
-            <include>de/ids_mannheim/korap/**/*.java</include>
-          </includes>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-shade-plugin</artifactId>
-        <version>2.1</version>
-        <executions>
-          <execution>
-            <id>full</id>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <transformers>
-                <transformer>
-                  <mainClass>de.ids_mannheim.korap.web.KustvaktServer</mainClass>
-                </transformer>
-                <transformer>
-                  <resource>META-INF/spring.handlers</resource>
-                </transformer>
-                <transformer>
-                  <resource>META-INF/spring.schemas</resource>
-                </transformer>
-              </transformers>
-              <filters>
-                <filter>
-                  <artifact>*:*</artifact>
-                  <excludes>
-                    <exclude>META-INF/*.SF</exclude>
-                    <exclude>META-INF/*.DSA</exclude>
-                    <exclude>META-INF/*.RSA</exclude>
-                  </excludes>
-                </filter>
-              </filters>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <profiles>
-    <profile>
-      <id>light</id>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-shade-plugin</artifactId>
-            <version>2.1</version>
-            <executions>
-              <execution>
-                <id>light</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>shade</goal>
-                </goals>
-                <configuration>
-                  <finalName>Kustvakt-core-${project.version}-light</finalName>
-                  <transformers>
-                    <transformer>
-                      <mainClass>de.ids_mannheim.korap.web.KustvaktBaseServer</mainClass>
-                    </transformer>
-                    <transformer>
-                      <resource>META-INF/spring.handlers</resource>
-                    </transformer>
-                    <transformer>
-                      <resource>META-INF/spring.schemas</resource>
-                    </transformer>
-                  </transformers>
-                  <filters>
-                    <filter>
-                      <artifact>*:*</artifact>
-                      <excludes>
-                        <exclude>META-INF/*.SF</exclude>
-                        <exclude>META-INF/*.DSA</exclude>
-                        <exclude>META-INF/*.RSA</exclude>
-                      </excludes>
-                    </filter>
-                  </filters>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
-  <dependencies>
-    <dependency>
-      <groupId>com.sun.jersey.jersey-test-framework</groupId>
-      <artifactId>jersey-test-framework-core</artifactId>
-      <version>1.19</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <artifactId>javax.servlet-api</artifactId>
-          <groupId>javax.servlet</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>jersey-servlet</artifactId>
-          <groupId>com.sun.jersey</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>jersey-client</artifactId>
-          <groupId>com.sun.jersey</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>com.sun.jersey.jersey-test-framework</groupId>
-      <artifactId>jersey-test-framework-grizzly</artifactId>
-      <version>1.19</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <artifactId>grizzly-servlet-webserver</artifactId>
-          <groupId>com.sun.grizzly</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>jersey-grizzly</artifactId>
-          <groupId>com.sun.jersey</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.11</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.projectlombok</groupId>
-      <artifactId>lombok</artifactId>
-      <version>1.16.6</version>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <maven.compiler.source>1.7</maven.compiler.source>
-    <maven.compiler.target>1.7</maven.compiler.target>
-  </properties>
-</project>
-
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 06b6106..0db2b48 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
@@ -1007,6 +1007,7 @@
             user = controller.getUser(tokenContext.getUsername());
         }
         catch (KustvaktException e) {
+
             jlog.error("Exception encountered: {}", e.string());
             throw KustvaktResponseHandler.throwit(e);
         }
@@ -1030,7 +1031,7 @@
                     if (spl != null) {
                         f_list.add(sep[0]);
                         l_list.add(sep[1]);
-                    }
+                    };
                     results = searchKrill.getMatch(matchid, new ArrayList<>(
                             f_list), new ArrayList<>(l_list), spans, false,
                             true);
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 e28b85b..1003e0d 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
@@ -313,6 +313,8 @@
                 && !foundries.contains("*"))
             f_list = new ArrayList<>(foundries);
 
+        spans = spans != null ? spans : false;
+		
         boolean match_only = foundries == null || foundries.isEmpty();
         String results;
         if (match_only)
diff --git a/src/main/resources/changelog b/src/main/resources/changelog
index 58275c3..e7e868c 100644
--- a/src/main/resources/changelog
+++ b/src/main/resources/changelog
@@ -2,6 +2,7 @@
 
 13/10/2016
     - MOD: updated search to use new siglen (diewald)
+    - MOD: fixed matchinfo retrieval in light service (diewald)
 
 05/05/2015
     - ADD: rest test suite for user service (hanl)
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index cba69e9..2b8d2a1 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,7 +1,7 @@
 
 # Root logger option
 #log4j.threshold=ALL
-log4j.rootLogger=INFO, stdout, debugLog
+log4j.rootLogger=ERROR, stdout, debugLog
 log4j.logger.log=ERROR, errorLog
 
 # Direct log messages to stdout
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java b/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
index 5e0c730..40fb0ad 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
@@ -31,7 +31,6 @@
     @Test
     public void testInit () {
         KustvaktConfiguration config = helper().getContext().getConfiguration();
-        System.out.println("'" + config.getIndexDir() + "'");
         SearchKrill krill = new SearchKrill(config.getIndexDir());
         assertNotNull(krill);
     }
@@ -56,6 +55,15 @@
         assertNotEquals(0, krill.getIndex().numberOf("documents"));
     }
 
+	@Test
+    public void testMatchInfo () {
+        KustvaktConfiguration config = helper().getContext().getConfiguration();
+        SearchKrill krill = new SearchKrill(config.getIndexDir());
+        assertNotNull(krill);
+		String matchinfo = krill.getMatch("WPD/AAA.00002/p169-197");
+		JsonNode node = JsonUtils.readTree(matchinfo);
+		assertEquals("Invalid match identifier", node.at("/errors/0/1").asText());
+	}
 
     @Test
     public void testSearch () {
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
index ceb9a35..8a94c44 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
@@ -143,6 +143,40 @@
                 .toString());
     }
 
+	@Test
+	public void testMatchInfoGet1 () {
+		// match-WPD_AAA.00001-p4-5
+        ClientResponse response = resource()
+			.path(getAPIVersion())
+			//.path("corpus/GOE/AGI.00200/p13576-13577/matchInfo")
+			.path("corpus/WPD/AAA.00001/p4-5/matchInfo")
+			.queryParam("foundry", "*")
+			.queryParam("spans", "false")
+			.get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+					 response.getStatus());
+        String ent = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(ent);
+        assertNotNull(node);
+        assertEquals("WPD/AAA/00001", node.at("/textSigle").asText());
+	};
+
+	@Test
+	public void testMatchInfoGet2 () {
+		// match-WPD_AAA.00001-p4-5
+        ClientResponse response = resource()
+			.path(getAPIVersion())
+			//.path("corpus/GOE/AGI.00200/p13576-13577/matchInfo")
+			.path("corpus/WPD/AAA.00001/p4-5/matchInfo")
+			.queryParam("foundry", "*")
+			.get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+					 response.getStatus());
+        String ent = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(ent);
+        assertNotNull(node);
+        assertEquals("WPD/AAA/00001", node.at("/textSigle").asText());
+	};
 
     @Test
     public void testCQParameter () {
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index c3b0e84..c541e7a 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -427,7 +427,7 @@
         assertEquals(response.getStatus(),
                 ClientResponse.Status.OK.getStatusCode());
         String ent = response.getEntity(String.class);
-        JsonNode node = JsonUtils.readTree(ent);
+		JsonNode node = JsonUtils.readTree(ent);
         assertNotNull(node);
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
         assertEquals("operation:or", node.at("/collection/operation").asText());
@@ -451,7 +451,6 @@
 
     @Test
     public void testMatchInfoGet () {
-
     }