Implemented FCS 1.0 specification.
diff --git a/pom.xml b/pom.xml
index 0166501..ea5cb49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.mannheim.ids</groupId>
<artifactId>KorapSRU</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>KorapSRU</name>
@@ -15,7 +15,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.1</version>
+ <version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
@@ -32,13 +32,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>eu.clarin.sru.fcs</groupId>
<artifactId>fcs-simple-endpoint</artifactId>
- <version>1.2.0</version>
+ <version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -55,7 +55,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.2.3</version>
+ <version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java b/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java
index eecdcb3..0776c56 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java
@@ -1,20 +1,13 @@
package de.mannheim.ids.korap.sru;
import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpResponseException;
@@ -27,7 +20,6 @@
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xml.sax.SAXException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -36,26 +28,23 @@
public class KorapClient {
- private static final String SERVICE_URI = "http://10.0.10.13:8888/api/v0.1/";
+ private static final String SERVICE_URI = "http://10.0.10.13:7070/api/v0.1/";
private String QUERY_LANGUAGE = "CQL";
private String CONTEXT_TYPE = "sentence";
- private int defaultNumOfRecords;
- private int defaultMaxRecords;
+ private int defaultNumOfRecords = 10;
+ private int defaultMaxRecords = 10;
private ObjectMapper objectMapper;
- private SAXParserFactory saxParserFactory;
private Logger logger = (Logger) LoggerFactory.getLogger(KorapClient.class);
public KorapClient(int numOfRecords, int maxRecords) {
- objectMapper = new ObjectMapper();
- saxParserFactory = SAXParserFactory.newInstance();
-
+ this.objectMapper = new ObjectMapper();
this.defaultNumOfRecords = numOfRecords;
this.defaultMaxRecords = maxRecords;
}
- public JsonNode retrieveResources() throws HttpResponseException, Exception{
+ public JsonNode retrieveResources() throws URISyntaxException, IOException {
URIBuilder builder = new URIBuilder(SERVICE_URI+"VirtualCollection");
//builder.addParameter("type", "VirtualCollection");
@@ -65,7 +54,7 @@
CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = null;
- JsonNode resources;
+ JsonNode resources = null;
try {
response = client.execute(httpRequest);
@@ -80,13 +69,11 @@
}
BufferedInputStream jsonStream = new BufferedInputStream(
- response.getEntity().getContent() );
+ response.getEntity().getContent() );
try {
resources = objectMapper.readValue(jsonStream, JsonNode.class);
- } catch (JsonParseException e) {
- throw new Exception("Failed parsing JSON.");
- } catch (JsonMappingException e) {
- throw new Exception("Failed mapping JSON.");
+ } catch (JsonParseException | JsonMappingException e) {
+ throw e;
}
finally{
jsonStream.close();
@@ -101,7 +88,8 @@
public KorapResult query(String query, String version, int startRecord,
- int maximumRecords, String[] corpora) throws HttpResponseException, Exception{
+ int maximumRecords, String[] corpora) throws HttpResponseException,
+ IOException {
checkQuery(query, startRecord, maximumRecords);
@@ -157,10 +145,8 @@
response.getEntity().getContent() );
try {
result = objectMapper.readValue(jsonStream, KorapResult.class);
- } catch (JsonParseException e) {
- throw new Exception("Failed parsing JSON.");
- } catch (JsonMappingException e) {
- throw new Exception("Failed mapping JSON.");
+ } catch (IOException e) {
+ throw new IOException("Failed processing response.");
}
finally{
jsonStream.close();
@@ -170,15 +156,6 @@
response.close();
}
- try {
- logger.info("Matches size: "+ result.getMatches().size());
- logger.debug("Parsing snippets");
- parseMatchSnippets(result);
-
- } catch (ParserConfigurationException | SAXException e) {
- throw new Exception("Failed parsing snippet.");
- }
-
return result;
}
@@ -193,20 +170,6 @@
return errorItems;
}
- private void parseMatchSnippets(KorapResult result)
- throws ParserConfigurationException, SAXException, IOException {
-
- String snippet;
- InputStream is;
- SAXParser saxParser = saxParserFactory.newSAXParser();
- for (KorapMatch m : result.getMatches()){
- snippet = "<snippet>"+m.getSnippet()+"</snippet>";
- is = new ByteArrayInputStream(snippet.getBytes());
- saxParser.parse(is, new KorapMatchHandler(m));
- //logger.info("left {}, key {}, right {} ", m.getLeftContext(), m.getKeyword(), m.getRightContext());
- }
- }
-
private HttpGet createRequest(String query, String version, int startRecord,
int maximumRecords)
throws URISyntaxException {
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java b/src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java
new file mode 100644
index 0000000..2e7d1f2
--- /dev/null
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java
@@ -0,0 +1,108 @@
+package de.mannheim.ids.korap.sru;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import eu.clarin.sru.server.SRUConfigException;
+import eu.clarin.sru.server.SRUConstants;
+import eu.clarin.sru.server.SRUException;
+import eu.clarin.sru.server.fcs.DataView;
+import eu.clarin.sru.server.fcs.DataView.DeliveryPolicy;
+import eu.clarin.sru.server.fcs.EndpointDescription;
+import eu.clarin.sru.server.fcs.ResourceInfo;
+
+public class KorapEndpointDescription implements EndpointDescription {
+
+ private List<DataView> dataviews;
+ private List<URI> capabilities;
+
+ private List<String> languages;
+
+ private String defaultDataview = "hits";
+
+ public KorapEndpointDescription() throws SRUConfigException {
+ dataviews = new ArrayList<DataView>();
+ dataviews.add(new DataView("hits", "application/x-clarin-fcs-hits+xml",
+ DeliveryPolicy.SEND_BY_DEFAULT));
+ dataviews.add(new DataView("kwic", "application/x-clarin-fcs-kwic+xml",
+ DeliveryPolicy.NEED_TO_REQUEST));
+
+ capabilities = new ArrayList<URI>();
+ try {
+ capabilities.add(new URI(
+ "http://clarin.eu/fcs/capability/basic-search"));
+ } catch (URISyntaxException e) {
+ throw new SRUConfigException("Found an invalid capability URI.");
+ }
+
+ languages = new ArrayList<String>();
+ languages.add("deu");
+ }
+
+ @Override
+ public void destroy() {
+ dataviews.clear();
+ capabilities.clear();
+ languages.clear();
+ }
+
+ @Override
+ public List<URI> getCapabilities() {
+ return capabilities;
+ }
+
+ @Override
+ public List<DataView> getSupportedDataViews() {
+ return dataviews;
+ }
+
+ @Override
+ public List<ResourceInfo> getResourceList(String pid) throws SRUException {
+
+ List<ResourceInfo> resourceList = new ArrayList<ResourceInfo>();
+
+ Map<String,String> title;
+ Map<String,String> description;
+
+ JsonNode resources;
+
+ try {
+ resources = KorapSRU.korapClient.retrieveResources();
+ } catch (URISyntaxException | IOException e) {
+ throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR,
+ "Failed retrieving resources.");
+ }
+
+ for (JsonNode r : resources) {
+ title = new HashMap<String, String>();
+ title.put("de", r.get("name").asText());
+ title.put("en", r.get("name").asText());
+
+ description = new HashMap<String, String>();
+ description.put("de", r.get("description").asText());
+
+ ResourceInfo ri = new ResourceInfo(r.get("id").asText(), title,
+ description, KorapSRU.KORAP_WEB_URL, languages, dataviews,
+ null);
+ resourceList.add(ri);
+ }
+
+ return resourceList;
+ }
+
+ public String getDefaultDataView() {
+ return defaultDataview;
+ }
+
+ public void setDefaultDataView(String defaultDataview) {
+ this.defaultDataview = defaultDataview;
+ }
+
+}
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java b/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java
index d70ec35..5c960af 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java
@@ -1,15 +1,18 @@
package de.mannheim.ids.korap.sru;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class KorapMatch {
+ private String ID;
private String docID;
private String leftContext;
private String keyword;
private String rightContext;
private String snippet;
+ private String text;
public KorapMatch() {}
@@ -21,6 +24,13 @@
this.rightContext = rightContext;
}
+ @JsonProperty("ID")
+ public String getID() {
+ return ID;
+ }
+ public void setID(String id) {
+ this.ID = id;
+ }
public String getDocID() {
return docID;
@@ -60,6 +70,14 @@
public void setSnippet(String snippet) {
this.snippet = snippet;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
}
}
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java b/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java
index e5d9f91..ea73fb3 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java
@@ -7,8 +7,8 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class KorapResult {
- int totalResults;
- List<KorapMatch> matches;
+ private int totalResults;
+ private List<KorapMatch> matches;
public KorapResult() {
matches = new ArrayList<KorapMatch>();
@@ -28,13 +28,13 @@
}
public KorapMatch getMatch(int i){
- if (i>=0 && i< getSize())
+ if (i>=0 && i< getMatchSize())
return matches.get(i);
return null;
}
- public int getSize(){
+ public int getMatchSize(){
return matches.size();
}
}
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java b/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java
index 15e2791..e36713e 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java
@@ -1,22 +1,14 @@
package de.mannheim.ids.korap.sru;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
+import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletContext;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
import org.apache.http.client.HttpResponseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.z3950.zing.cql.CQLNode;
-import org.z3950.zing.cql.CQLTermNode;
-
-import com.fasterxml.jackson.databind.JsonNode;
import eu.clarin.sru.server.SRUConfigException;
import eu.clarin.sru.server.SRUConstants;
@@ -26,11 +18,10 @@
import eu.clarin.sru.server.SRUSearchResultSet;
import eu.clarin.sru.server.SRUServerConfig;
import eu.clarin.sru.server.SRUVersion;
-import eu.clarin.sru.server.fcs.ResourceInfo;
-import eu.clarin.sru.server.fcs.ResourceInfoInventory;
+import eu.clarin.sru.server.fcs.Constants;
+import eu.clarin.sru.server.fcs.DataView;
+import eu.clarin.sru.server.fcs.EndpointDescription;
import eu.clarin.sru.server.fcs.SimpleEndpointSearchEngineBase;
-import eu.clarin.sru.server.fcs.XMLStreamWriterHelper;
-import eu.clarin.sru.server.fcs.utils.SimpleResourceInfoInventory;
/**
* @author margaretha
@@ -39,58 +30,27 @@
// private static final String RESOURCE_INFO_INVENTORY_URL =
// "/WEB-INF/resource-info.xml";
- private static final String CLARIN_FCS_RECORD_SCHEMA =
+ public static final String CLARIN_FCS_RECORD_SCHEMA =
"http://clarin.eu/fcs/1.0";
- private static final String KORAP_WEB_URL =
- "http://korap.ids-mannheim.de/app/#!login";
+ public static final String KORAP_WEB_URL =
+ "http://korap.ids-mannheim.de/kalamar";
- private KorapClient korapClient;
+ public static KorapClient korapClient;
+ private KorapEndpointDescription korapEndpointDescription;
private SRUServerConfig serverConfig;
- private String redirectBaseURI;
+
+ public static String redirectBaseURI;
private Logger logger = (Logger) LoggerFactory.getLogger(KorapSRU.class);
-
+
@Override
- protected ResourceInfoInventory createResourceInfoInventory(
+ protected EndpointDescription createEndpointDescription(
ServletContext context, SRUServerConfig config,
Map<String, String> params) throws SRUConfigException {
-
- List<ResourceInfo> resourceList = new ArrayList<ResourceInfo>();
-
- List<String> languages = new ArrayList<String>();
- languages.add("deu");
-
- /*Locale locale = new Locale.Builder().setRegion("DE").build();
- for (Locale l : locale.getAvailableLocales()){
- if (l.getCountry().equals("DE"))
- logger.info("locale "+l.getISO3Language());
- }*/
-
- Map<String,String> title;
- Map<String,String> description;
- try {
- JsonNode resources = korapClient.retrieveResources();
- for (JsonNode r : resources){
- title = new HashMap<String,String>();
- title.put("de", r.get("name").asText());
- title.put("en", r.get("name").asText());
-
- description = new HashMap<String,String>();
- description.put("de", r.get("description").asText());
-
- ResourceInfo ri = new ResourceInfo(
- r.get("id").asText(), -1, title, description,
- KORAP_WEB_URL, languages , null);
- resourceList.add(ri);
- }
-
- } catch (Exception e) {
- throw new SRUConfigException(
- "error initializing resource info inventory", e);
- }
- return new SimpleResourceInfoInventory(resourceList, false);
+ korapEndpointDescription = new KorapEndpointDescription();
+ return korapEndpointDescription;
}
-
+
@Override
protected void doInit(ServletContext context, SRUServerConfig config,
Map<String, String> params) throws SRUConfigException {
@@ -110,28 +70,20 @@
sb.append("/").append("redirect/");
this.redirectBaseURI = sb.toString();
}
-
- private Map<String, String> createLocaleMap(){
- // country,language
- Map<String, String> map = new HashMap<String,String>();
- Locale locale = new Locale("en");
- for (String country : locale.getISOCountries()){
- for (Locale l : locale.getAvailableLocales()){
- if (l.getCountry().equals(country)){
- map.put(country, l.getISO3Language());
- }
- }
- }
- return map;
- }
-
+
@Override
public SRUSearchResultSet search(SRUServerConfig config,
SRURequest request, SRUDiagnosticList diagnostics)
throws SRUException {
- checkSchema(request);
-
+ checkRequestRecordSchema(request);
+
+ String dataview = korapEndpointDescription.getDefaultDataView();
+ if (request.getExtraRequestDataNames().contains("x-fcs-dataviews")) {
+ dataview = getRequestDataView(
+ request.getExtraRequestData("x-fcs-dataviews"), diagnostics);
+ }
+
String korapQuery = translateCQLtoKorapQuery(request.getQuery());
String version = null;
if (request.isVersion(SRUVersion.VERSION_1_1)){
@@ -143,10 +95,10 @@
else {
serverConfig.getDefaultVersion();
}
-
- KorapResult result = null;
+
+ KorapResult korapResult = new KorapResult();
try {
- result = korapClient.query(
+ korapResult = korapClient.query(
korapQuery,
version,
request.getStartRecord(),
@@ -173,15 +125,18 @@
throw new SRUException(SRUConstants.SRU_QUERY_FEATURE_UNSUPPORTED,
e.getMessage());
default:
- throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR);
+ throw new SRUException(
+ SRUConstants.SRU_GENERAL_SYSTEM_ERROR,
+ e.getMessage());
}
}
- catch (Exception e) {
- throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR);
+ catch (IOException e) {
+ throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR,
+ e.getMessage());
}
- return generateSRUResultSet(diagnostics, result);
+ return new KorapSRUSearchResultSet(diagnostics, korapResult, dataview);
}
private String[] getCorporaList(SRURequest request){
@@ -200,7 +155,6 @@
}
}
-
private String translateCQLtoKorapQuery(CQLNode query) throws SRUException {
String queryStr = query.toString();
if ((queryStr == null) || queryStr.isEmpty()) {
@@ -210,7 +164,7 @@
return queryStr;
}
- private void checkSchema(SRURequest request) throws SRUException{
+ private void checkRequestRecordSchema(SRURequest request) throws SRUException{
final String recordSchemaIdentifier =
request.getRecordSchemaIdentifier();
if ((recordSchemaIdentifier != null) &&
@@ -222,55 +176,23 @@
"\" is not supported by this endpoint.");
}
}
-
- private SRUSearchResultSet generateSRUResultSet(SRUDiagnosticList diagnostics,
- final KorapResult result) {
-
- return new SRUSearchResultSet(diagnostics) {
-
- private int i = -1;
-
- @Override
- public void writeRecord(XMLStreamWriter writer) throws XMLStreamException {
- KorapMatch match = result.getMatch(i);
- XMLStreamWriterHelper.writeResourceWithKWICDataView(writer,
- match.getDocID(), redirectBaseURI + match.getDocID(),
- match.getLeftContext(), match.getKeyword(),
- match.getRightContext()
- );
-// FCSResultWriter.writeResource(writer,
-// // pid, ref
-// "", redirectBaseURI + match.getDocID(),
-// match.getLeftContext(), match.getKeyword(),
-// match.getRightContext()
-// );
- //logger.info("left {}, key {}, right {} ", match.getLeftContext(), match.getKeyword(), match.getRightContext());
+
+ private String getRequestDataView(String requestDataview,
+ SRUDiagnosticList diagnostics) {
+ if (requestDataview != null & !requestDataview.isEmpty()) {
+ for (DataView dv : korapEndpointDescription.getSupportedDataViews()) {
+ if (dv.getIdentifier().equals(requestDataview)) {
+ return requestDataview;
+ }
}
-
- @Override
- public boolean nextRecord() throws SRUException {
- return (++i < result.getSize() ? true : false );
- }
-
- @Override
- public int getTotalRecordCount() {
- return result.getTotalResults();
- }
-
- @Override
- public String getRecordSchemaIdentifier() {
- return CLARIN_FCS_RECORD_SCHEMA;
- }
-
- @Override
- public String getRecordIdentifier() {
- return null;
- }
-
- @Override
- public int getRecordCount() {
- return result.getSize();
- }
- };
+ diagnostics.addDiagnostic(
+ Constants.FCS_DIAGNOSTIC_REQUESTED_DATA_VIEW_INVALID,
+ "The requested Data View " + requestDataview
+ + " is not supported.", "The default Data View "
+ + korapEndpointDescription.getDefaultDataView()
+ + " is used.");
+ }
+ return korapEndpointDescription.getDefaultDataView();
}
+
}
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java b/src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java
new file mode 100644
index 0000000..78a2309
--- /dev/null
+++ b/src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java
@@ -0,0 +1,98 @@
+package de.mannheim.ids.korap.sru;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+
+import eu.clarin.sru.server.SRUConstants;
+import eu.clarin.sru.server.SRUDiagnosticList;
+import eu.clarin.sru.server.SRUException;
+import eu.clarin.sru.server.SRUSearchResultSet;
+import eu.clarin.sru.server.fcs.XMLStreamWriterHelper;
+
+public class KorapSRUSearchResultSet extends SRUSearchResultSet {
+
+ private Logger logger = (Logger) LoggerFactory
+ .getLogger(KorapSRUSearchResultSet.class);
+
+ private int i = -1;
+ private KorapResult korapResult;
+ private String dataview;
+ private SAXParser saxParser;
+
+ public KorapSRUSearchResultSet(SRUDiagnosticList diagnostics,
+ KorapResult korapResult, String dataview)
+ throws SRUException {
+ super(diagnostics);
+
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ try {
+ saxParser = saxParserFactory.newSAXParser();
+ } catch (ParserConfigurationException | SAXException e) {
+ throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR);
+ }
+
+ this.korapResult = korapResult;
+ this.dataview = dataview;
+ }
+
+ @Override
+ public int getTotalRecordCount() {
+ return korapResult.getTotalResults();
+ }
+
+ @Override
+ public int getRecordCount() {
+ return korapResult.getMatchSize();
+ }
+
+ @Override
+ public String getRecordSchemaIdentifier() {
+ return KorapSRU.CLARIN_FCS_RECORD_SCHEMA;
+ }
+
+ @Override
+ public boolean nextRecord() throws SRUException {
+ return (++i < korapResult.getMatchSize() ? true : false);
+ }
+
+ @Override
+ public String getRecordIdentifier() {
+ return korapResult.getMatch(i).getID();
+ }
+
+ @Override
+ public void writeRecord(XMLStreamWriter writer) throws XMLStreamException {
+ KorapMatch match = korapResult.getMatch(i);
+ String snippet = "<snippet>" + match.getSnippet() + "</snippet>";
+ InputStream is = new ByteArrayInputStream(snippet.getBytes());
+ try {
+ saxParser.parse(is, new KorapMatchHandler(match));
+ } catch (SAXException | IOException e) {
+ // /throw e;
+ }
+
+ if (dataview.equals("kwic")) {
+ XMLStreamWriterHelper.writeResourceWithKWICDataView(writer,
+ match.getID(), KorapSRU.redirectBaseURI + match.getID(),
+ match.getLeftContext(), match.getKeyword(),
+ match.getRightContext());
+
+ } else {
+ XMLStreamWriterHelper.writeResourceWithHitsDataView(writer,
+ match.getID(), KorapSRU.redirectBaseURI + match.getID(),
+ match.getLeftContext(), match.getKeyword(),
+ match.getRightContext());
+ }
+ }
+}
diff --git a/src/main/webapp/WEB-INF/resource-info.xml b/src/main/webapp/WEB-INF/resource-info.xml
deleted file mode 100644
index dedb24c..0000000
--- a/src/main/webapp/WEB-INF/resource-info.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ResourceCollection xmlns="http://clarin.eu/fcs/1.0/resource-info">
- <ResourceInfo pid="Wikipedia">
- <Title xml:lang="de">Wikipedia</Title>
- <Title xml:lang="en">Wikipedia</Title>
- <Description xml:lang="de">
- The German Wikipedia.
- </Description>
- <Description xml:lang="en">
- The German Wikipedia.
- </Description>
- <LandingPageURI>http://korap.ids-mannheim.de/app/#!login</LandingPageURI>
- <Languages>
- <Language>deu</Language>
- </Languages>
- </ResourceInfo>
-</ResourceCollection>
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 5b3a74b..b1cc769 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -58,7 +58,7 @@
<jsp-file>/_redirect.jsp</jsp-file>
<init-param>
<param-name>korapWebUrl</param-name>
- <param-value>http://korap.ids-mannheim.de/app/#!login</param-value>
+ <param-value>http://korap.ids-mannheim.de/kalamar</param-value>
</init-param>
</servlet>
<servlet-mapping>