Skip to content
Snippets Groups Projects
Commit 48a62fd4 authored by mbrodhu's avatar mbrodhu
Browse files

Merge branch 'release/2.27.3'

parents 4f1e52f1 bdf23cb6
No related branches found
No related tags found
No related merge requests found
Showing
with 242 additions and 71 deletions
......@@ -5,7 +5,7 @@
<parent>
<artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>2.27.1</version>
<version>2.27.3</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-core</artifactId>
......@@ -94,7 +94,7 @@
<dependency>
<groupId>org.classicmayan.tools</groupId>
<artifactId>metsModsMapping</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
</dependency>
<!--dependency>
<groupId>org.apache.jena</groupId>
......
......@@ -10,6 +10,8 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD
protected boolean textgrid;
protected boolean dariah;
private static boolean idiomMets;
private static boolean dublinCore;
public IdentifierListDelivererAbstract(boolean textgrid, boolean dariah) {
this.textgrid = textgrid;
......@@ -35,17 +37,42 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD
+ " is not supported by the item identified by the value of: "
+ request.getIdentifier());
}
// Check if resumptioToken is valid
if(request.getResumptionToken() != null) {
if(IdentifierListDelivererAbstract.isIdiomMets() && IdentifierListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken())) {
IdentifierListDelivererAbstract.setIdiomMets(true);
IdentifierListDelivererAbstract.setDublinCore(false);
}else if(IdentifierListDelivererAbstract.isDublinCore() && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken())){
IdentifierListDelivererAbstract.setDublinCore(true);
IdentifierListDelivererAbstract.setIdiomMets(false);
}else {
result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN,
"The value of the " + request.getResumptionToken() + " argument is invalid or expired.");
}
}
if (request.getResumptionToken() == null && request.getMetadataPrefix() != null) {
if(request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
IdentifierListDelivererAbstract.setIdiomMets(true);
IdentifierListDelivererAbstract.setDublinCore(false);
}
if(request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) {
IdentifierListDelivererAbstract.setDublinCore(true);
IdentifierListDelivererAbstract.setIdiomMets(false);
}
}
// Check if other params are existing, they shouldn't!
else {
List<String> errorValues = new ArrayList<String>();
if (request.getResumptionToken() != null) {
errorValues.add("resumptionToken");
}
if (request.getMetadataPrefix() == null) {
if (request.getResumptionToken() != null && request.getMetadataPrefix() !=null) {
errorValues.add("metadataPrefix");
}
if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) {
errorValues.add("metadataPrefix");
}
if (request.getIdentifier() != null) {
errorValues.add("identifier");
......@@ -59,6 +86,21 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD
return result;
}
public static boolean isIdiomMets() {
return idiomMets;
}
public static void setIdiomMets(boolean idiomMets) {
IdentifierListDelivererAbstract.idiomMets = idiomMets;
}
public static boolean isDublinCore() {
return dublinCore;
}
public static void setDublinCore(boolean dublinCore) {
IdentifierListDelivererAbstract.dublinCore = dublinCore;
}
}
......@@ -37,14 +37,12 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
private String[] identifierListFields; //Fields for the elasticsearch request
private String rangeField; // Field for the optional range query
//private String formatToFilter; // just necessary in textgrid case to just get the editions
//private String formatField; // just necessary in textgrid to just get the editions
private String dateOfObjectCreation; // Field for the object creation in the repository
private String repositoryObjectURIPrefix; //
private String identifierField;
private static final int lifeTimeResToken = 10000;
private static Map<String, Integer> cursorCollector = new Hashtable<String, Integer >();
public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer >();
private int searchResponseSize;
......@@ -131,7 +129,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
int i = 0;
for (SearchHit hit : listFurtherValues.getHits().getHits()) {
i++;
if (this.textgrid ) {
if (this.textgrid) {
String datestamp = hit.getFields().get(dateOfObjectCreation).getValue().toString();
try {
......@@ -221,7 +219,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
else
query = QueryBuilders.boolQuery().must(rangeQuery).must(formatQuery);
}
// System.out.println(query);
return query;
}
......@@ -230,15 +228,6 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
return lit;
}
/* public void setFormatToFilter(String formatToFilter) {
this.formatToFilter = formatToFilter;
}
public void setFormatField(String formatField) {
this.formatField = formatField;
}*/
public String getDateOfObjectCreation() {
return dateOfObjectCreation;
}
......
package info.textgrid.middleware;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
......@@ -13,19 +14,18 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType;
public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstract{
static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>();
public IdentifierListDelivererIDIOM(boolean textgrid, boolean dariah) {
super(textgrid, dariah);
}
public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) {
ListIdentifiersType lit = new ListIdentifiersType();
List<String> artefactURIs;
List<String> artefactURIs = new ArrayList<String>();
Queries querisForArtefactList = new Queries();
if(resumptionToken==null) {
artefactURIs = Queries.getArtefactList(0);
artefactURIs = querisForArtefactList.getArtefactList(0);
}else {
artefactURIs = Queries.getArtefactList(cursorCollector.get(resumptionToken));
artefactURIs = querisForArtefactList.getArtefactList(cursorCollector.get(resumptionToken));
}
long listSize = Queries.getAmountOfArtefacts();
......@@ -41,7 +41,7 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac
// Check the need for a resumption token!
ResumptionTokenType resTokenForResponse = OAIPMHUtillities.getResumptionToken(
listSize, resumptionToken, cursorCollector, resTokenValue, 100, i);
listSize, resumptionToken, cursorCollector, resTokenValue, 30, i);
if (resTokenForResponse != null) {
lit.setResumptionToken(resTokenForResponse);
......
......@@ -229,17 +229,22 @@ public class OAIPMHImpl implements OAIPMHProducer {
JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai);
ErrorHandler requestErrors = IdentifierListDelivererAbstract.requestChecker(request);
if (requestErrors.getError().getCode() != null) {
if (requestErrors.getError().getValue() != null) {
oai.getError().add(requestErrors.getError());
}else {
// Default is DC.
IdentifierListDelivererInterface listDeliv = this.identifierListDC;
// Take IDIOM if IDIOM prefix.
if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
listDeliv = this.identifierListIDIOM;
}
ListIdentifiersType listIdentifiers = new ListIdentifiersType();
IdentifierListDelivererInterface listDeliv = identifierListDC;
log.info("Actual Value of IDIOM MetsMods Boolean is: " + IdentifierListDelivererAbstract.isIdiomMets());
log.info("Actual Value of DublinCore Boolean is: " + IdentifierListDelivererAbstract.isDublinCore());
if(IdentifierListDelivererAbstract.isIdiomMets()) {
listDeliv = identifierListIDIOM;
}else if(IdentifierListDelivererAbstract.isDublinCore()){
listDeliv = identifierListDC;
}
ListIdentifiersType listIdentifiers = new ListIdentifiersType();
listIdentifiers = listDeliv.processIdentifierList(request.getFrom(), request.getUntil(),
request.getSet(), request.getResumptionToken());
......@@ -349,12 +354,18 @@ public class OAIPMHImpl implements OAIPMHProducer {
}else {
// Default is DC.
RecordListDelivererInterface recListDeliv = this.recordListDC;
if(RecordListDelivererAbstract.isIdiomMets()) {
recListDeliv = recordListIDIOM;
}else if(RecordListDelivererAbstract.isDublinCore()){
recListDeliv = recordListDC;
}
// Take IDIOM if IDIOM prefix.
if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
/*if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
recListDeliv = this.recordListIDIOM;
}
}*/
ListRecordsType listRecords = new ListRecordsType();
listRecords = recListDeliv.getRecords(request.getFrom(), request.getUntil(), request.getSet(),
......
......@@ -70,7 +70,7 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract {
if(!idInDatabase.contains(".0")) {
changedId = changedId + ".0";
}
//sSystem.out.println(changedId);
GetRequestBuilder recordById = OAI_ESClient.getOaiESClient()
.prepareGet()
.setIndex("textgrid-nonpublic")
......@@ -99,7 +99,7 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract {
}else {
textgridBaseURI_FromID = id;
}
log.info("ID for generating the METS/MODS file is: " + textgridBaseURI_FromID);
metsmods = new ClassicMayanMetsMods(
textgridBaseURI_FromID,
dateOfObjectCreation,
......
......@@ -9,7 +9,8 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer
protected boolean textgrid;
protected boolean dariah;
private static boolean idiomMets;
private static boolean dublinCore;
/**
* @param textgrid
* @param dariah
......@@ -33,24 +34,68 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer
+ " is not supported by the item identified by the value of: "
+ request.getIdentifier());
}
// Check if resumptioToken is valid
if(request.getResumptionToken() != null) {
if(RecordListDelivererAbstract.isIdiomMets() && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken())) {
RecordListDelivererAbstract.setIdiomMets(true);
RecordListDelivererAbstract.setDublinCore(false);
}else if(RecordListDelivererAbstract.isDublinCore() && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken())){
RecordListDelivererAbstract.setDublinCore(true);
RecordListDelivererAbstract.setIdiomMets(false);
}else {
result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN,
"The value of the " + request.getResumptionToken() + " argument is invalid or expired.");
}
}
if (request.getResumptionToken() == null && request.getMetadataPrefix() != null) {
if(request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
RecordListDelivererAbstract.setIdiomMets(true);
RecordListDelivererAbstract.setDublinCore(false);
}
if(request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) {
RecordListDelivererAbstract.setDublinCore(true);
RecordListDelivererAbstract.setIdiomMets(false);
}
}
// Check if other params are existing, they shouldn't!
else {
List<String> errorValues = new ArrayList<String>();
if (request.getMetadataPrefix() == null) {
errorValues.add("metadataPrefix");
}
if (request.getIdentifier() != null) {
errorValues.add("identifier");
}
if(errorValues.size()>0) {
result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments "
+ "or is missing required arguments: " + errorValues);
}
if (request.getResumptionToken() != null && request.getMetadataPrefix() !=null) {
errorValues.add("metadataPrefix");
}
if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) {
errorValues.add("metadataPrefix");
}
if (request.getIdentifier() != null) {
errorValues.add("identifier");
}
if(errorValues.size()>0) {
result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments "
+ "or is missing required arguments: " + errorValues);
}
}
return result;
}
public static boolean isIdiomMets() {
return idiomMets;
}
public static void setIdiomMets(boolean idiomMets) {
RecordListDelivererAbstract.idiomMets = idiomMets;
}
public static boolean isDublinCore() {
return dublinCore;
}
public static void setDublinCore(boolean dublinCore) {
RecordListDelivererAbstract.dublinCore = dublinCore;
}
}
......@@ -46,11 +46,12 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract{
ListRecordsType recordList = new ListRecordsType();
List<String> artefactURIs;
Queries queries = new Queries();
if(resumptionToken==null) {
artefactURIs = Queries.getArtefactList(0);
artefactURIs = queries.getArtefactList(0);
}else {
artefactURIs = Queries.getArtefactList(cursorCollector.get(resumptionToken));
artefactURIs = queries.getArtefactList(cursorCollector.get(resumptionToken));
}
long listSize = Queries.getAmountOfArtefacts();
......
package info.textgrid.middleware;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXB;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConfigurationException;
......@@ -32,7 +35,7 @@ public class OaiPmhTest {
private static RecordDelivererIDIOM recordIDIOM;
private static RecordListDelivererDC recordList;
private static RecordListDelivererIDIOM recordListIDIOM;
private static IdentifierListDelivererDC identifierList;
private static IdentifierListDelivererDC identifierList = new IdentifierListDelivererDC(true, false);
private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false);
private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer();
private SetDeliverer setListDARIAH = new SetDeliverer(false, true);
......@@ -63,7 +66,7 @@ public class OaiPmhTest {
recordList.setFields(TGConstants.TGFields);
recordList.setWorkFields(TGConstants.TGWorkFields);
recordList.setOaiEsClient(oaiEsClient);
recordList.setSearchResponseSize("10");
recordList.setSearchResponseSize("100");
recordListIDIOM = new RecordListDelivererIDIOM(true, false);
recordListIDIOM.setOaiEsClient(oaiEsClient);
......@@ -90,7 +93,7 @@ public class OaiPmhTest {
* @throws DatatypeConfigurationException
*/
@Test
//@Ignore
@Ignore
public void testDateGregorianType() throws ParseException,
DatatypeConfigurationException {
String dateformatbefore = "2012-02-06T20:48:39.614+01:00";
......@@ -107,7 +110,7 @@ public class OaiPmhTest {
* @throws DatatypeConfigurationException
*/
@Test
//@Ignore
@Ignore
public void testDateStringType() throws ParseException,
DatatypeConfigurationException {
String dateformatbefore = "2012-02-06T20:48:39.614+01:00";
......@@ -123,7 +126,7 @@ public class OaiPmhTest {
* @throws ParseException
*/
@Test
//@Ignore
@Ignore
public void testGetRequestIdentify() throws ParseException {
System.out.println("Test for the verb \"Identify\" with succesfull response");
......@@ -137,7 +140,7 @@ public class OaiPmhTest {
* @throws ParseException
*/
@Test
//@Ignore
@Ignore
public void testGetRequestIdentifyVerbError() throws ParseException {
System.out.println("Test for the verb \"Identify\" with error response (MetadaFormat)");
JAXBElement<OAIPMHType> t =
......@@ -150,7 +153,7 @@ public class OaiPmhTest {
* @throws ParseException
*/
@Test
//@Ignore
@Ignore
public void testGetRequestIdentifyArgumentError() throws ParseException {
System.out.println("Test for the verb \"Identify\" with error response (Until and Identifier)");
JAXBElement<OAIPMHType> z =
......@@ -206,7 +209,7 @@ public class OaiPmhTest {
System.out.println("Test for the verb \"GetRecord\" with succesfull response");
JAXBElement<OAIPMHType> p =
this.request.getRequest("GetRecord", "textgrid:vqmx.0", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", "");
this.request.getRequest("GetRecord", "textgrid:2rcj2", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", "");
JAXB.marshal(p, System.out);
System.out.println("-----------------------------------\n");
}
......@@ -232,7 +235,7 @@ public class OaiPmhTest {
*/
@Test
@Ignore
public void testListIdentifierSets() throws ParseException {
public void testListIdentifierSetsDC() throws ParseException {
OaiPmhTest.identifierList.setFieldForRange(TGConstants.RANGE_FIELD);
OaiPmhTest.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS);
......@@ -245,18 +248,72 @@ public class OaiPmhTest {
"project:TGPR-26236625-1acc-b921-a5fa-53567c3eeb80", "", "", "");
JAXB.marshal(p, System.out);
System.out.println("-----------------------------------\n");
}
@Test
@Ignore
public void testListIdentifierWithResumptionTokenDC() throws ParseException {
OaiPmhTest.identifierList.setFieldForRange(TGConstants.RANGE_FIELD);
OaiPmhTest.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS);
OaiPmhTest.identifierList.setDateOfObjectCreation(TGConstants.CREATED);
OaiPmhTest.identifierList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX);
OaiPmhTest.identifierList.setIdentifierField("textgridUri");
OaiPmhTest.identifierList.setSearchResponseSize("100");
System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response");
JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "oai_dc",
"", "", "", "");
JAXB.marshal(p, System.out);
String resToken ="";
for(Map.Entry<String, Integer> entry : IdentifierListDelivererDC.cursorCollector.entrySet()) {
resToken = entry.getKey();
}
System.out.println("HASH MAP BEFORE: ");
System.out.println(IdentifierListDelivererDC.cursorCollector);
System.out.println(resToken);
JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListIdentifiers", "", "",
"", "", "", resToken);
JAXB.marshal(p2, System.out);
System.out.println("HASH MAP AFTER: ");
System.out.println(IdentifierListDelivererDC.cursorCollector);
System.out.println("-----------------------------------\n");
}
@Test
@Ignore
public void testListIdentifierIDIOM() throws ParseException {
public void testListIdentifierIDIOMInvalidResumptionToken() throws ParseException {
System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response");
System.out.println("Test for the verb \"ListIdentifiers\" in IDIOM with an invalid resumption token");
JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "",
"", "", "", "45d8b524-b69e-44e8-81a9-a3634005a430");
JAXB.marshal(p, System.out);
System.out.println("-----------------------------------\n");
}
@Test
@Ignore
public void testListIdentifierIDIOMWithResumptionToken() throws ParseException {
System.out.println("Test for the verb \"ListIdentifiers\" in IDIOM with successfull response");
JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", TGConstants.METADATA_IDIOM_PREFIX,
"", "", "", "");
JAXB.marshal(p, System.out);
String resToken ="";
for(Map.Entry<String, Integer> entry : IdentifierListDelivererIDIOM.cursorCollector.entrySet()) {
resToken = entry.getKey();
}
JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListIdentifiers", "", "",
"", "", "", resToken);
JAXB.marshal(p2, System.out);
System.out.println("HASH MAP AFTER: ");
System.out.println(IdentifierListDelivererIDIOM.cursorCollector);
System.out.println("-----------------------------------\n");
}
......@@ -296,18 +353,44 @@ public class OaiPmhTest {
JAXBElement<OAIPMHType> p =
this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", "");
JAXB.marshal(p, System.out);
String resToken ="";
for(Map.Entry<String, Integer> entry : RecordListDelivererDC.cursorCollector.entrySet()) {
resToken = entry.getKey();
}
JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListRecords", "", "",
"", "", "", resToken);
JAXB.marshal(p2, System.out);
System.out.println("HASH MAP AFTER: ");
System.out.println(RecordListDelivererDC.cursorCollector);
System.out.println("-----------------------------------\n");
}
@Test
@Ignore
public void testListRecordSetsForIDIOM() throws ParseException {
public void testListRecordWithResumptionTokenForIDIOM() throws ParseException {
System.out.println("Test for the verb \"ListRecords\" for IDIOM with succesfull response");
JAXBElement<OAIPMHType> p =
this.request.getRequest("ListRecords", "", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", "");
JAXB.marshal(p, System.out);
String resToken ="";
for(Map.Entry<String, Integer> entry : RecordListDelivererIDIOM.cursorCollector.entrySet()) {
resToken = entry.getKey();
}
JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListRecords", "", "",
"", "", "", resToken);
JAXB.marshal(p2, System.out);
System.out.println("HASH MAP AFTER: ");
System.out.println(RecordListDelivererIDIOM.cursorCollector);
System.out.println("-----------------------------------\n");
}
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>2.27.1</version>
<version>2.27.3</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-webapp</artifactId>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh</artifactId>
<version>2.27.1</version>
<version>2.27.3</version>
<packaging>pom</packaging>
<name>DARIAHDE :: OAI-PMH DataProvider</name>
<properties>
......
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