Skip to content
Snippets Groups Projects
Commit 6c90dc09 authored by mbrodhu's avatar mbrodhu
Browse files

new stuff

parent afa9b468
No related branches found
No related tags found
No related merge requests found
......@@ -55,10 +55,14 @@ public class OAIPMHImpl implements OAIPMHProducer {
ListIdentifiersType lit = new ListIdentifiersType();
public OAIPMHImpl(OAI_ESClient oaiEsClient, RepIdentification rep,
RecordDeliverer recDeliv, RecordListDeliverer recordList,
MetadataFormatListDeliverer metadataFormatList,
SetDeliverer setList, IdentifierListDeliverer identifierList) {
public OAIPMHImpl(
OAI_ESClient oaiEsClient,
RepIdentification rep,
RecordDeliverer recDeliv,
RecordListDeliverer recordList,
MetadataFormatListDeliverer metadataFormatList,
SetDeliverer setList,
IdentifierListDeliverer identifierList) {
this.oaiEsClient = oaiEsClient;
this.rep = rep;
this.recDeliv = recDeliv;
......@@ -96,9 +100,7 @@ public class OAIPMHImpl implements OAIPMHProducer {
/*----Setting the responseDate of today-----*/
try {
XMLGregorianCalendar convertedDateFormat;
convertedDateFormat = OAIPMHUtillities
.convertDateFormat(OAIPMHUtillities
.getXMLGregorianCalendarNow().toString());
convertedDateFormat = OAIPMHUtillities.convertDateFormat(OAIPMHUtillities.getXMLGregorianCalendarNow().toString());
response.setResponseDate(convertedDateFormat);
} catch (ParseException e) {
log.debug("can not parse date format");
......@@ -114,7 +116,7 @@ public class OAIPMHImpl implements OAIPMHProducer {
setMetadataPrefixRequestValue(metadataPrefix, request);
setResumptionTokenRequestValue(resumptionToken, request);
setSetRequestValue(set, request);
//request.setSet(set);
request.setVerb(verbParam);
if (textgrid == true) {
......@@ -359,55 +361,6 @@ public class OAIPMHImpl implements OAIPMHProducer {
}
}
// }
/*
* if(request.getResumptionToken() != null && (request.getSet() != null
* || request.getMetadataPrefix() != null)){
* error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue(
* "The request includes illegal arguments or missing requiered arguments:"
* + errorValues);
* oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); }
* else {
*
*
* if (request.getMetadataPrefix() != null &&
* !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX ))
* { try {
* error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR).setValue
* ("The value of the metadataPrefix: " + request.getMetadataPrefix() +
* " is not supported by the item identified by the value of: " +
* request.getIdentifier());
* oai.getError().add(error.setError(TGConstants
* .OAI_METADATA_FORMAT_ERROR));
*
* } catch (Exception e) { // TODO Auto-generated catch block
* log.debug(e); } } else { try { lit =
* identifierList.processIdentifierList(request.getFrom(),
* request.getUntil(), request.getSet(), request.getResumptionToken());
* if (lit != null) { oai.setListIdentifiers(lit); } else {
* error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue(
* "The combination of the values " + request.getFrom() + " and " +
* request.getUntil() + " results in an empty list");
* oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH));
* }
*
* } catch (Exception e) { // TODO Auto-generated catch block
* log.debug(e); } }
*
* }
*
* } else { if (request.getIdentifier() != null) {
* errorValues.add("identifier"); } if (request.getMetadataPrefix() ==
* null) { errorValues.add("metadataPrefix"); }
* error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue(
* "The request includes illegal arguments " +
* "or missing requiered arguments: " + errorValues);
* oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT));
*
* }
*/
return oaipmhRoot;
}
......@@ -421,19 +374,14 @@ public class OAIPMHImpl implements OAIPMHProducer {
OAIPMHType oai, RequestType request) {
ListSetsType sl = new ListSetsType();
// SetDeliverer sets = new SetDeliverer(oaiEsClient);
JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai);
sl = this.setList.setListBuilder();
oai.setListSets(sl);
/*
* 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;
}
......@@ -547,35 +495,6 @@ public class OAIPMHImpl implements OAIPMHProducer {
}
}
/*
* if (recordList.requestChecker(request)) {
*
* if
* (!request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX))
* { error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR).setValue(
* "The value of the metadataPrefix: " + request.getMetadataPrefix() +
* " is not supported by the item identified by the value of: " +
* request.getIdentifier());
* oai.getError().add(error.setError(TGConstants
* .OAI_METADATA_FORMAT_ERROR)); } else {
* //System.out.println("SET FROM REQUEST: " + request.getSet());
* listRecords = recordList.getRecords(request.getFrom(),
* request.getUntil(), request.getSet(), request.getResumptionToken());
* if (recordList.isFoundItems()) { // if(listRecords!=null){
* oai.setListRecords(listRecords); } else {
* error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue(
* "The combination of the values " + request.getFrom() + " and " +
* request.getUntil() + " results in an empty list");
* oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH));
* } } } else { if (request.getIdentifier() != null) {
* errorValues.add("identifier"); } if (request.getMetadataPrefix() ==
* null) { errorValues.add("metadataPrefix"); }
* error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue(
* "The request includes illegal " +
* "arguments or is missing required arguments: " + errorValues);
* oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); }
*/
return oaipmhRoot;
}
......@@ -693,17 +612,11 @@ public class OAIPMHImpl implements OAIPMHProducer {
if (!set.isEmpty()) {
request.setSet(set);
}
}
public RequestType setRequestType(String verb) {
RequestType request = new RequestType();
return request;
}
public void setTextGrid(boolean textgrid) {
this.textgrid = textgrid;
......
......@@ -37,11 +37,9 @@ public class OAIPMHUtillities {
public MetadataFormatType setMetadataFormats() {
MetadataFormatType tgDublinCore = new MetadataFormatType();
tgDublinCore
.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/");
tgDublinCore.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/");
tgDublinCore.setMetadataPrefix("oai:dc");
tgDublinCore
.setSchema("http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
tgDublinCore.setSchema("http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
return tgDublinCore;
}
......@@ -71,8 +69,7 @@ public class OAIPMHUtillities {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
XMLGregorianCalendar now = datatypeFactory
.newXMLGregorianCalendar(gregorianCalendar);
XMLGregorianCalendar now = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
return now;
}
......@@ -90,15 +87,12 @@ public class OAIPMHUtillities {
String originalDateTimeString) throws ParseException,
DatatypeConfigurationException {
SimpleDateFormat tgItemTime = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.S");
SimpleDateFormat tgItemTime = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.S");
Date date = tgItemTime.parse(originalDateTimeString);
SimpleDateFormat outFormatter = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
outFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
String output2 = outFormatter.format(date);
XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(output2);
XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(output2);
return xmlCal;
}
......
package info.textgrid.middleware;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.text.ParseException;
import java.util.ArrayList;
......@@ -36,11 +35,6 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType;
public class RecordListDeliverer {
// private static final String BIBCIT_BIBID =
// "edition.source.bibliographicCitation.bibidentifier";
//private String set;
// **
// STATICS
// **
......@@ -51,7 +45,7 @@ public class RecordListDeliverer {
// CLASS VARIABLES
// **
private OAI_ESClient oaiEsClient;
// private OAI_ESClient oaiEsClient;
private String[] fields;
private String[] workFields;
private boolean textgrid;
......@@ -115,7 +109,7 @@ public class RecordListDeliverer {
* @param oaiEsClient
*/
public RecordListDeliverer(OAI_ESClient oaiEsClient, String[] fields,String[] workFields, boolean textgrid, boolean dariah) {
this.oaiEsClient = oaiEsClient;
//this.oaiEsClient = oaiEsClient;
this.fields = fields;
this.workFields = workFields;
this.textgrid = textgrid;
......
......@@ -335,7 +335,7 @@ public class OaiPmhTest {
* @throws ParseException
*/
@Test
@Ignore
//@Ignore
public void testListRecords2() throws ParseException {
System.out.println("TG");
......@@ -366,7 +366,7 @@ public class OaiPmhTest {
this.recordList.setIdentifierField("textgridUri");
this.recordList.setSearchResponseSize("100");
JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "project:TGPR-355b6bcd-668d-5f79-e661-582305346ed1", "", "", "");
JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "", "", "", "");
JAXB.marshal(r, System.out);
System.out.println("-----------------------------------\n");
}
......@@ -512,7 +512,7 @@ public class OaiPmhTest {
@Test
//@Ignore
@Ignore
public void testEmptyRequest() throws ParseException {
this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD);
this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS);
......
......@@ -52,7 +52,7 @@
</bean>
<bean id="RecordList" class="info.textgrid.middleware.RecordListDeliverer">
<constructor-arg index="0" ref="ElasticSearchClient" />
<!--constructor-arg index="0" ref="ElasticSearchClient" /-->
<constructor-arg index="1" value="${fields}" />
<constructor-arg index="2" value="${workFields}" />
<constructor-arg index="3" value="${textgrid}" />
......
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