Renamed sruws to fcsws; Added pid check on Resource and ResourceFragment
elements.
diff --git a/pom.xml b/pom.xml
index 6eeb78f..f059437 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,11 +2,10 @@
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.mannheim.ids</groupId>
- <artifactId>SRU-WS</artifactId>
+ <artifactId>FCS-WS</artifactId>
<packaging>war</packaging>
- <version>1.0.2</version>
- <name>SRU-WS Maven Webapp</name>
- <url>http://maven.apache.org</url>
+ <version>1.0.3</version>
+ <name>Federated Content Search Webservice</name>
<dependencies>
<dependency>
@@ -57,7 +56,7 @@
</dependency>
</dependencies>
<build>
- <finalName>SRU-WS</finalName>
+ <finalName>FCS-WS</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/de/mannheim/ids/sruws/SRU_WS.java b/src/main/java/de/mannheim/ids/fcsws/Controller.java
similarity index 84%
rename from src/main/java/de/mannheim/ids/sruws/SRU_WS.java
rename to src/main/java/de/mannheim/ids/fcsws/Controller.java
index 6f10357..793adac 100644
--- a/src/main/java/de/mannheim/ids/sruws/SRU_WS.java
+++ b/src/main/java/de/mannheim/ids/fcsws/Controller.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.sruws;
+package de.mannheim.ids.fcsws;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -59,10 +59,10 @@
* */
@Path("/")
-public class SRU_WS{
+public class Controller{
private String endpointUri;
- private String endpointBase = "de.mannheim.ids.sruws.endpoint.";
+ private String endpointBase = "de.mannheim.ids.fcsws.endpoint.";
private Corpus defaultCorpus;
private static final int DEFAULT_MAX_RECORDS = 10;
@@ -83,8 +83,8 @@
@Context
ServletConfig config;
- public SRU_WS() {
- logger = (Logger) LoggerFactory.getLogger(SRU_WS.class);
+ public Controller() {
+ logger = (Logger) LoggerFactory.getLogger(Controller.class);
factory = SAXParserFactory.newInstance();
corpusList = new HashMap<String,Corpus>();
}
@@ -181,7 +181,7 @@
SAXParser saxParser = factory.newSAXParser();
SRUScanResonseHandler handler = new SRUScanResonseHandler();
saxParser.parse(bis, handler);
- corpusList = handler.getCorpora();
+ corpusList = handler.getCorpora();
} catch (ParserConfigurationException | SAXException e) {
e.printStackTrace();
@@ -294,11 +294,52 @@
String pid = reader.getAttributeValue(i);
// logger.info("Corpus: " +
// URLDecoder.decode(pid,"UTF-8"));
+// System.out.println("Resource " +pid);
c = corpusList.get(URLDecoder.decode(pid,"UTF-8"));
- if (c == null) c = defaultCorpus;
+ break;
}
}
+ if (c == null) c = defaultCorpus;
}
+
+ else if (e == XMLEvent.START_ELEMENT
+ &&
+ reader.getLocalName().equals("ResourceFragment") &&
+ reader.getPrefix().equals(FCS_PREFIX)&&
+ (reader.getNamespaceURI().equals(FCS_NS)||
+ reader.getNamespaceURI().equals(FCS_RESOURCE)) ){
+
+ for (int i=0; i<reader.getAttributeCount(); i++){
+ if (reader.getAttributeLocalName(i).equals("pid")){
+ String pid = reader.getAttributeValue(i);
+ // logger.info("Corpus: " +
+ // URLDecoder.decode(pid,"UTF-8"));
+// System.out.println("ResourceFragment " +pid);
+ c = corpusList.get(URLDecoder.decode(pid,"UTF-8"));
+ break;
+ }
+ }
+ if (c == null) c = defaultCorpus;
+ }
+ else if (e == XMLEvent.START_ELEMENT
+ &&
+ reader.getLocalName().equals("DataView") &&
+ reader.getPrefix().equals(FCS_PREFIX)&&
+ (reader.getNamespaceURI().equals(FCS_NS)||
+ reader.getNamespaceURI().equals(FCS_RESOURCE)) ){
+
+ for (int i=0; i<reader.getAttributeCount(); i++){
+ if (reader.getAttributeLocalName(i).equals("pid")){
+ String pid = reader.getAttributeValue(i);
+ // logger.info("Corpus: " +
+ // URLDecoder.decode(pid,"UTF-8"));
+// System.out.println("DataView " +pid);
+ c = corpusList.get(URLDecoder.decode(pid,"UTF-8"));
+ break;
+ }
+ }
+ if (c == null) c = defaultCorpus;
+ }
else if (e == XMLEvent.START_ELEMENT &&
reader.getLocalName().equals("kwic") ){
diff --git a/src/main/java/de/mannheim/ids/sruws/Corpus.java b/src/main/java/de/mannheim/ids/fcsws/Corpus.java
similarity index 95%
rename from src/main/java/de/mannheim/ids/sruws/Corpus.java
rename to src/main/java/de/mannheim/ids/fcsws/Corpus.java
index 3d80def..7eb0e48 100644
--- a/src/main/java/de/mannheim/ids/sruws/Corpus.java
+++ b/src/main/java/de/mannheim/ids/fcsws/Corpus.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.sruws;
+package de.mannheim.ids.fcsws;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/de/mannheim/ids/fcsws/EndpointDescriptionHandler.java b/src/main/java/de/mannheim/ids/fcsws/EndpointDescriptionHandler.java
new file mode 100644
index 0000000..67b46e5
--- /dev/null
+++ b/src/main/java/de/mannheim/ids/fcsws/EndpointDescriptionHandler.java
@@ -0,0 +1,31 @@
+package de.mannheim.ids.fcsws;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class EndpointDescriptionHandler extends DefaultHandler{
+
+ private boolean isEndpointDesc;
+ private boolean isResource;
+ private boolean isTitle;
+
+ @Override
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
+ // TODO Auto-generated method stub
+
+ if (qName.equalsIgnoreCase("ed:EndpointDescription")){
+ isEndpointDesc = true;
+ }
+ else if (qName.equalsIgnoreCase("ed:Resource")){
+ isResource = true;
+ }
+ else if (qName.equalsIgnoreCase("ed:Title")){
+ isTitle = true;
+ }
+ }
+
+
+
+}
diff --git a/src/main/java/de/mannheim/ids/sruws/SRUScanResonseHandler.java b/src/main/java/de/mannheim/ids/fcsws/SRUScanResonseHandler.java
similarity index 98%
rename from src/main/java/de/mannheim/ids/sruws/SRUScanResonseHandler.java
rename to src/main/java/de/mannheim/ids/fcsws/SRUScanResonseHandler.java
index 9b713b9..2d2f424 100644
--- a/src/main/java/de/mannheim/ids/sruws/SRUScanResonseHandler.java
+++ b/src/main/java/de/mannheim/ids/fcsws/SRUScanResonseHandler.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.sruws;
+package de.mannheim.ids.fcsws;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/main/java/de/mannheim/ids/sruws/Sentence.java b/src/main/java/de/mannheim/ids/fcsws/Sentence.java
similarity index 95%
rename from src/main/java/de/mannheim/ids/sruws/Sentence.java
rename to src/main/java/de/mannheim/ids/fcsws/Sentence.java
index 705f720..5ea3c5b 100644
--- a/src/main/java/de/mannheim/ids/sruws/Sentence.java
+++ b/src/main/java/de/mannheim/ids/fcsws/Sentence.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.sruws;
+package de.mannheim.ids.fcsws;
public class Sentence{
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index e98c4eb..3648aa5 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -1,41 +1,40 @@
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
-
-<web-app id="SRU_WEB_SERVICE">
- <display-name>SRU Web-service</display-name>
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5" id="FCS_WEB_SERVICE">
+ <display-name>Federated Content Search Web-service</display-name>
- <servlet>
- <servlet-name>SRU_WS</servlet-name>
+ <servlet>
+ <servlet-name>FCS-WS</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>de.mannheim.ids.sruws</param-value>
+ <param-value>de.mannheim.ids.fcsws</param-value>
</init-param>
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.korap</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.korap</param-name>
<param-value>http://clarin.ids-mannheim.de/korapsru</param-value>
</init-param>
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.cosmas</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.cosmas</param-name>
<param-value>http://clarin.ids-mannheim.de/cosmassru</param-value>
</init-param>
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.leipzig</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.leipzig</param-name>
<param-value>http://clarinws.informatik.uni-leipzig.de:8080/CQL</param-value>
</init-param>
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.tuebingen</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.tuebingen</param-name>
<param-value>http://weblicht.sfs.uni-tuebingen.de/rws/sru/</param-value>
</init-param>
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.stuttgart</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.stuttgart</param-name>
<param-value>http://clarin01.ims.uni-stuttgart.de/SRUCQIBridge</param-value>
</init-param>
<!-- empty pid -->
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.berlin</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.berlin</param-name>
<param-value>http://dspin.dwds.de:8088/DDC-Endpoint/sru</param-value>
</init-param>
@@ -44,43 +43,43 @@
<!-- same case like goethe, pid is sub-resource -->
<init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.muenchen</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.muenchen</param-name>
<param-value>https://clarin.phonetik.uni-muenchen.de/BASSRU/</param-value>
</init-param>
<!-- weird pid -->
<!-- <init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.mpi</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.mpi</param-name>
<param-value>http://cqlservlet.mpi.nl/</param-value>
</init-param> -->
<!-- pid doesn't match -->
<!-- <init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.hamburg</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.hamburg</param-name>
<param-value>http://virt-fedora.multilingua.uni-hamburg.de:8080/HZSKsru/</param-value>
</init-param> -->
<!-- doesnt provide scan -->
<!-- <init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.saarland</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.saarland</param-name>
<param-value>http://fedora.clarin-d.uni-saarland.de/sru2/</param-value>
</init-param> -->
<!-- <init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.lindat</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.lindat</param-name>
<param-value>http://lindat.mff.cuni.cz/services/fcs</param-value>
</init-param> -->
<!-- Dutch -->
<!-- <init-param>
- <param-name>de.mannheim.ids.sruws.endpoint.dans</param-name>
+ <param-name>de.mannheim.ids.fcsws.endpoint.dans</param-name>
<param-value>http://srucql.dans.knaw.nl</param-value>
</init-param> -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
- <servlet-name>SRU_WS</servlet-name>
+ <servlet-name>FCS-WS</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
diff --git a/src/test/java/de/mannheim/ids/sruws/test/TestClient.java b/src/test/java/de/mannheim/ids/fcsws/test/TestClient.java
similarity index 95%
rename from src/test/java/de/mannheim/ids/sruws/test/TestClient.java
rename to src/test/java/de/mannheim/ids/fcsws/test/TestClient.java
index a5870fd..fd19547 100644
--- a/src/test/java/de/mannheim/ids/sruws/test/TestClient.java
+++ b/src/test/java/de/mannheim/ids/fcsws/test/TestClient.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.sruws.test;
+package de.mannheim.ids.fcsws.test;
import static org.junit.Assert.assertEquals;
@@ -19,7 +19,7 @@
public static void main(String arg[]) throws IOException{
String url =
-// "http://localhost:8080/SRU-WS/" +
+// "http://localhost:8080/FCS-WS/" +
"http://clarin.ids-mannheim.de/fcsws" +
"?maximumRecords=10&endpoint=korap";