Skip to content
Snippets Groups Projects
Commit c9cb6e07 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Only include schemaLocations if dc and oai_dc used in response. Thought...

Only include schemaLocations if dc and oai_dc used in response. Thought prefixes are always plotted. Hm. DoesnÄt matter. I hsuppose.
parent 32de9f52
No related branches found
No related tags found
No related merge requests found
......@@ -41,10 +41,12 @@ public class OAIPMHImpl implements OAIPMHProducer {
// FINALS
// **
private static final String SCHEMA_LOCATIONS =
"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd "
+ "http://www.openarchives.org/OAI/2.0/ https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd "
+ "http://purl.org/dc/elements/1.1/ https://dublincore.org/schemas/xmls/simpledc20021212.xsd";
private static final String OAIPMH_SCHEMA_LOCATION =
"http://www.openarchives.org/OAI/2.0/ https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd";
private static final String OAIDC_SCHEMA_LOCATION =
"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd";
private static final String DC_SCHEMA_LOCATION =
"http://purl.org/dc/elements/1.1/ https://dublincore.org/schemas/xmls/simpledc20021212.xsd";
// **
// STATICS
......@@ -117,7 +119,7 @@ public class OAIPMHImpl implements OAIPMHProducer {
String result = "";
try {
result = getStringFromJAXBOAIElement(
result = getStringFromJAXBOAIElement(verb,
handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken));
} catch (ParseException e) {
// TODO Auto-generated catch block
......@@ -139,7 +141,7 @@ public class OAIPMHImpl implements OAIPMHProducer {
String result = "";
try {
result = getStringFromJAXBOAIElement(
result = getStringFromJAXBOAIElement(verb,
handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken));
} catch (ParseException e) {
// TODO Auto-generated catch block
......@@ -658,21 +660,33 @@ public class OAIPMHImpl implements OAIPMHProducer {
* other way has been working here! I tried EVERYTHING else! Really!
* </p>
*
* @param theVerb
* @param theJAXBOAIElement
* @return
*/
private static String getStringFromJAXBOAIElement(
private static String getStringFromJAXBOAIElement(final String theVerb,
final JAXBElement<OAIPMHtype> theJAXBOAIElement) {
String result = "";
// Always add OAIPMH schema location.
String schemaLocations = OAIPMH_SCHEMA_LOCATION;
// Add OAI_DC and DC schema location if needed.
if (theVerb.equals("GetRecord") || theVerb.endsWith("ListRecords")) {
schemaLocations += OAIDC_SCHEMA_LOCATION + " " + DC_SCHEMA_LOCATION;
}
// PLEASE NOTE We always get oai_dc and dc prefixes defined in the root element due to the
// bindings.xml file. Seems to be no problem for the time being.
try {
// FIXME GEMOKEL: Add schemaLocations to OAI root element.
// OBACHT! GEMOKEL! Add schemaLocations to OAI root element here!
JAXBContext jc = JAXBContext.newInstance(OAIPMHtype.class);
Marshaller marshaller = jc.createMarshaller();
// Comment out if one-line-output wanted!
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, SCHEMA_LOCATIONS);
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocations);
StringWriter sw = new StringWriter();
marshaller.marshal(theJAXBOAIElement, sw);
......
package info.textgrid.middleware;
import info.textgrid.middleware.oaipmh.OAIPMHtype;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBElement;
/**
* <p>
......
package info.textgrid.middleware;
import info.textgrid.middleware.oaipmh.OAIPMHtype;
import java.text.ParseException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBElement;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
/**
......
......@@ -468,6 +468,7 @@ public class OaiPmhTest {
OaiPmhTest.identifierList.setIdentifierField("textgridUri");
OaiPmhTest.identifierList.setRepositoryObjectURIPrefix("textgrid:");
OaiPmhTest.identifierList.setSearchResponseSize("100");
String r = this.request.getRequest("", "", "", "", "", "", "");
System.out.println(r);
System.out.println("-----------------------------------\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment