From abbfb0fd3295a211b3b7187882fc7e49ec2dfa68 Mon Sep 17 00:00:00 2001
From: mbrodhu <brodhun@sub.uni-goettingen.de>
Date: Sat, 13 Dec 2014 13:51:17 +0100
Subject: [PATCH] Enable verb ListSets

---
 oaipmh-core/TODO                              |  8 ++-
 oaipmh-core/pom.xml                           | 59 ++++++++++++++++++-
 .../info/textgrid/middleware/OAIPMHImpl.java  | 13 +++-
 .../textgrid/middleware/OaiPmhClient.java     |  4 +-
 .../middleware/RecordListDeliverer.java       |  2 +-
 .../info/textgrid/middleware/OaiPmhTest.java  | 38 ++++++------
 pom.xml                                       |  3 +-
 7 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/oaipmh-core/TODO b/oaipmh-core/TODO
index d1ecf109..de1cca5a 100644
--- a/oaipmh-core/TODO
+++ b/oaipmh-core/TODO
@@ -1,12 +1,18 @@
 1. 
 change identifier from 123.0 to textgrid:123.0 in all/the getRecord requests,
-must be equal to the identifiers we get with the getIdentifiers() method
+must be equal to the identifiers we get with the getIdentifiers() method 
+
+DONE
 
 2.
 implement sets (for the prootype :)
 
+DONE (ListSets still has to be implemented, but it is possible to query for sets in ListIndentifiers and ListRecords)
+
 3.
 implement resumtion tokens (later)
 
 4.
 remove "yo" in class RecordDeliverer :-)
+
+DONE :D
diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml
index ee1cb577..03b903e5 100644
--- a/oaipmh-core/pom.xml
+++ b/oaipmh-core/pom.xml
@@ -20,9 +20,19 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.cxf</groupId>
-			<artifactId>cxf-rt-transports-http-hc</artifactId>
+			<artifactId>cxf-rt-transports-http</artifactId>
 			<version>${cxf.version}</version>
 		</dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-security-cors</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+       <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
 		<dependency>
 			<groupId>org.apache.cxf</groupId>
 			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
@@ -146,6 +156,53 @@
 					</execution>
 				</executions>
 			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<version>1.3</version>
+				<executions>
+					<execution>
+						<id>do-get</id>
+						<phase>initialize</phase>
+						<goals>
+							<goal>run</goal>
+						</goals>
+						<configuration>
+							<tasks>
+                                <!-- download wsdl task -->
+								<get usetimestamp="true" src="${tgauth.wsdl}" dest="tgextra.wsdl"/> 
+								<!--get usetimestamp="true" src="https://develop.sub.uni-goettingen.de/repos/textgrid/trunk/middleware/tgauth/info.textgrid.middleware.tgauth.rbac/rbacSoap/wsdl-productive/tgextra.wsdl" dest="tgextra.wsdl"/-->                         
+							</tasks>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.cxf</groupId>
+				<artifactId>cxf-codegen-plugin</artifactId>
+				<version>${cxf.version}</version>
+				<executions>
+					<execution>
+						<id>generate-sources</id>
+						<phase>generate-sources</phase>
+						<configuration>
+							<wsdlOptions>
+								<wsdlOption>
+									<wsdl>tgextra.wsdl</wsdl>
+									<extraargs>
+                    <extraarg>-fe</extraarg>
+                    <extraarg>jaxws21</extraarg>
+                  </extraargs>
+								</wsdlOption>
+							</wsdlOptions>
+						</configuration>
+						<goals>
+							<goal>wsdl2java</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
 		</plugins>
 	</build>
 </project>
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
index a52daa2b..c5d94a8c 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java
@@ -5,11 +5,13 @@ import info.textgrid.middleware.oaipmh.IdentifyType;
 import info.textgrid.middleware.oaipmh.ListIdentifiersType;
 import info.textgrid.middleware.oaipmh.ListMetadataFormatsType;
 import info.textgrid.middleware.oaipmh.ListRecordsType;
+import info.textgrid.middleware.oaipmh.ListSetsType;
 import info.textgrid.middleware.oaipmh.OAIPMHType;
 import info.textgrid.middleware.oaipmh.ObjectFactory;
 import info.textgrid.middleware.oaipmh.RequestType;
 import info.textgrid.middleware.oaipmh.VerbType;
 
+import java.io.IOException;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
@@ -287,13 +289,20 @@ public class OAIPMHImpl implements OAIPMHProducer{
 	
 	/**
 	 * checks the ListSets request of correctness and response including errors in case of an incorrect request
+	 * @throws IOException 
 	 */
 	public JAXBElement<OAIPMHType> listSetsRequest(ObjectFactory obf, OAIPMHType oai, RequestType request){
 		
+		ListSetsType setList = new ListSetsType();
+		SetDeliverer sets = new SetDeliverer(oaiEsClient);
 		JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai);
 		
-		error.setError(TGConstants.OAI_NO_SET_HIERARCHY).setValue("The repository does not support sets");
-		oai.getError().add(error.setError(TGConstants.OAI_NO_SET_HIERARCHY));
+		setList = sets.setListBuilder();
+		
+		oai.setListSets(setList);
+		
+		/*error.setError(TGConstants.OAI_NO_SET_HIERARCHY).setValue("The repository does not support sets");
+		oai.getError().add(error.setError(TGConstants.OAI_NO_SET_HIERARCHY));*/
 		
 		return oaipmhRoot;
 	}
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java
index c32090aa..c0bb1ee5 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java
@@ -4,9 +4,11 @@ import java.text.ParseException;
 
 import javax.xml.bind.JAXBElement;
 
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+
 import info.textgrid.middleware.oaipmh.OAIPMHType;
 
-import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+
 
 
 public class OaiPmhClient {
diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java
index 8ad5acc9..10ffb44e 100644
--- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java
+++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java
@@ -512,7 +512,7 @@ public class RecordListDeliverer {
 
 				// Only if we have a search response AND a hit field map...
 				if (hit != null && hits != null) {
-
+						
 					if (hit.getFields().get(FORMAT).values().get(0).toString()
 							.equals(TextGridMimetypes.EDITION)) {
 
diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java
index ba84ba4f..a6359a51 100644
--- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java
+++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java
@@ -27,25 +27,22 @@ public class OaiPmhTest {
 
 	}
 
-	/*
-	 * @Test
-	 * 
-	 * @Ignore public void testListRecords() throws ParseException{
-	 * 
-	 * JAXBElement<OAIPMHType> r = testRequest.getRequest("ListRecords", "",
-	 * "oai_dc", "", "2011-02-06T20:48:39", "", ""); JAXB.marshal(r,
-	 * System.out); System.out.println("-----------------------------------\n");
-	 * }
-	 * 
-	 * 
-	 * @Test
-	 * 
-	 * @Ignore public void testListMetadataFormats() throws ParseException{
-	 * 
-	 * JAXBElement<OAIPMHType> r = testRequest.getRequest("ListMetadataFormats",
-	 * "wr67.0", "", "", "", "", ""); JAXB.marshal(r, System.out);
-	 * System.out.println("-----------------------------------\n"); }
-	 */
+	
+	@Test
+	@Ignore 
+	public void testListRecords() throws ParseException{
+		JAXBElement<OAIPMHType> r = testRequest.getRequest("ListRecords", "",
+				"oai_dc", "", "2011-02-06T20:48:39", "", ""); JAXB.marshal(r,
+		System.out); System.out.println("-----------------------------------\n");
+	}
+	
+	@Test
+	@Ignore 
+	public void testListMetadataFormats() throws ParseException{
+		JAXBElement<OAIPMHType> r = testRequest.getRequest("ListMetadataFormats",
+				"wr67.0", "", "", "", "", ""); JAXB.marshal(r, System.out);
+		System.out.println("-----------------------------------\n"); 
+	}
 
 	@Test
 	//@Ignore
@@ -93,7 +90,6 @@ public class OaiPmhTest {
 		JAXB.marshal(r, System.out);
 		System.out.println("-----------------------------------\n");
 	}
-
 	
 	@Test
 	@Ignore 
@@ -175,7 +171,7 @@ public class OaiPmhTest {
 	@Test
 	@Ignore
 	public void testListIdentifierSets() throws ParseException {
-		System.out.println("Test for the verb \"GetRecord\" with succesfull response");
+		System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response");
 		JAXBElement<OAIPMHType> p = testRequest.getRequest("ListIdentifiers",
 				"", "oai_dc", "project.value:St. Matthias Test 07", "", "", "");
 		JAXB.marshal(p, System.out);
diff --git a/pom.xml b/pom.xml
index 4b075a33..3fd1e03f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,9 +7,10 @@
   <packaging>pom</packaging>
   <name>TextGrid :: TG-OAI-PMH :: Parent</name>
   <properties>
+    <tgauth.wsdl>https://textgridlab.org/1.0/tgauth/rbacSoap/wsdl/tgextra.wsdl</tgauth.wsdl>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <sonar.host.url>https://ci.bibforge.org/sonar</sonar.host.url>
-    <cxf.version>2.7.13</cxf.version>
+    <cxf.version>3.0.3</cxf.version>
     <tgcrud.version>5.5.9-SNAPSHOT</tgcrud.version>
     <spring.version>4.0.2.RELEASE</spring.version>
     <textgrid.httpclients.version>1.3.0-SNAPSHOT</textgrid.httpclients.version>
-- 
GitLab