diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java index a6f15360b2703a8f264e68149dd86d040a6f0242..50a9b56f4359e8930c8a4ed858c40603ecdbc2e6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java @@ -31,7 +31,7 @@ public class DublinCoreFieldLoader { public static String collectionTitle; private static org.apache.commons.logging.Log log = LogFactory - .getLog(RecordDeliverer.class); + .getLog(OAIPMHImpl.class); // ----DC-Contributor diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java index 5197062957db4c2cd21d5f96f7238d6e46521efe..f3b28cd589085484db093994850cc8b6a857cfa1 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java @@ -5,6 +5,7 @@ import info.textgrid.middleware.oaipmh.OAIPMHerrorcodeType; /** * Handling the errors for a incorrect request + * * @author Maximilian Brodhun * @version 1.1 * @since 29.01.2014 @@ -12,39 +13,46 @@ import info.textgrid.middleware.oaipmh.OAIPMHerrorcodeType; public class ErrorHandler { - private OAIPMHerrorType error = new OAIPMHerrorType(); - private OAIPMHerrorcodeType errorCode; - - /** - * The function gets an error description and set the responded error code for the OAIPMH error type - * @param errorDescription: String with the errorDescrption - * @return error returns the complete error as OAIPMHerrorType - */ - - public OAIPMHerrorType setError(String errorDescription){ - - if(errorDescription.equals("BadArgument")){ - errorCode = OAIPMHerrorcodeType.BAD_ARGUMENT; - }else if(errorDescription.equals("ResumptionTokenError")){ - errorCode = OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN; - }else if(errorDescription.equals("VerbError")){ - errorCode = OAIPMHerrorcodeType.BAD_VERB; - error.setValue("Illegal OAI-PMH verb"); - }else if(errorDescription.equals("FormatError")){ - errorCode = OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT; - }else if(errorDescription.equals("IDError")){ - errorCode = OAIPMHerrorcodeType.ID_DOES_NOT_EXIST; - }else if(errorDescription.equals("MetadataFormatError")){ - error.setValue("There are no metadata formats available for the specified item."); - }else if(errorDescription.equals("RecordMatchError")){ - errorCode = OAIPMHerrorcodeType.NO_RECORDS_MATCH; - }else if(errorDescription.equals("SetHierarchyError")){ - errorCode = OAIPMHerrorcodeType.NO_SET_HIERARCHY; - } - - error.setCode(errorCode); - - return error; - } - + private OAIPMHerrorType error = new OAIPMHerrorType(); + private OAIPMHerrorcodeType errorCode; + + /** + * The function gets an error description and set the responded error code for the OAIPMH error + * type + * + * @param errorDescription: String with the errorDescrption + * @return error returns the complete error as OAIPMHerrorType + */ + public void setError(String errorDescription, String errorValue) { + + if (errorDescription.equals("BadArgument")) { + errorCode = OAIPMHerrorcodeType.BAD_ARGUMENT; + } else if (errorDescription.equals("ResumptionTokenError")) { + errorCode = OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN; + } else if (errorDescription.equals("VerbError")) { + errorCode = OAIPMHerrorcodeType.BAD_VERB; + error.setValue("Illegal OAI-PMH verb"); + } else if (errorDescription.equals("FormatError")) { + errorCode = OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT; + } else if (errorDescription.equals("IDError")) { + errorCode = OAIPMHerrorcodeType.ID_DOES_NOT_EXIST; + } else if (errorDescription.equals("MetadataFormatError")) { + error.setValue("There are no metadata formats available for the specified item."); + } else if (errorDescription.equals("RecordMatchError")) { + errorCode = OAIPMHerrorcodeType.NO_RECORDS_MATCH; + } else if (errorDescription.equals("SetHierarchyError")) { + errorCode = OAIPMHerrorcodeType.NO_SET_HIERARCHY; + } + + error.setCode(errorCode); + error.setValue(errorValue); + } + + /** + * @return + */ + public OAIPMHerrorType getError() { + return error; + } + } 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 7f846898835b8cbfcfd1dca88998a9a2861fff43..efdb7d88962df2d32a857c5dc9b846b3ed89d4de 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -25,17 +25,16 @@ import info.textgrid.middleware.oaipmh.VerbType; * </p> * * @author Maximilian Brodhun, SUB Göttingen - * @version 2018-05-16 + * @version 2019-03-07 * @since 2014-01-29 */ public class OAIPMHImpl implements OAIPMHProducer { private ErrorHandler error = new ErrorHandler(); private org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); - private OAI_ESClient oaiEsClient; private RepIdentification rep; private RecordListDeliverer recordList; - private RecordDeliverer recDeliv; + private RecordDelivererDC recDelivDC; private MetadataFormatListDeliverer metadataFormatList; private SetDeliverer setList; private IdentifierListDeliverer identifierList; @@ -53,12 +52,11 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param setList * @param identifierList */ - public OAIPMHImpl(OAI_ESClient oaiEsClient, RepIdentification rep, RecordDeliverer recDeliv, + public OAIPMHImpl(RepIdentification rep, RecordDelivererDC recDelivDC, RecordListDeliverer recordList, MetadataFormatListDeliverer metadataFormatList, SetDeliverer setList, IdentifierListDeliverer identifierList) { - this.oaiEsClient = oaiEsClient; this.rep = rep; - this.recDeliv = recDeliv; + this.recDelivDC = recDelivDC; this.recordList = recordList; this.metadataFormatList = metadataFormatList; this.setList = setList; @@ -111,15 +109,15 @@ public class OAIPMHImpl implements OAIPMHProducer { JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); IdentifyType tgRepIdentificationRequest = new IdentifyType(); - if (rep.requestChecker(request)) { + if (this.rep.requestChecker(request)) { - tgRepIdentificationRequest.setBaseURL(rep.getBaseUrl()); - tgRepIdentificationRequest.setDeletedRecord(rep.getDeletedRecordStatus()); - tgRepIdentificationRequest.setEarliestDatestamp(rep.getEarliestDatestamp()); - tgRepIdentificationRequest.setGranularity(rep.getGranularity()); - tgRepIdentificationRequest.setRepositoryName(rep.getRepositoryName()); - tgRepIdentificationRequest.setProtocolVersion(rep.getProtocolVersion()); - tgRepIdentificationRequest.getAdminEmail().add(rep.getAdminMaiAddresss()); + tgRepIdentificationRequest.setBaseURL(this.rep.getBaseUrl()); + tgRepIdentificationRequest.setDeletedRecord(this.rep.getDeletedRecordStatus()); + tgRepIdentificationRequest.setEarliestDatestamp(this.rep.getEarliestDatestamp()); + tgRepIdentificationRequest.setGranularity(this.rep.getGranularity()); + tgRepIdentificationRequest.setRepositoryName(this.rep.getRepositoryName()); + tgRepIdentificationRequest.setProtocolVersion(this.rep.getProtocolVersion()); + tgRepIdentificationRequest.getAdminEmail().add(this.rep.getAdminMaiAddresss()); oai.setIdentify(tgRepIdentificationRequest); } else { @@ -142,9 +140,9 @@ public class OAIPMHImpl implements OAIPMHProducer { errorValues.add("Set"); } - error.setError(TGConstants.OAI_BAD_ARGUMENT) - .setValue("The request includes illegal arguments: " + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, + "The request includes illegal arguments: " + errorValues); + oai.getError().add(this.error.getError()); } return oaipmhRoot; @@ -162,23 +160,26 @@ public class OAIPMHImpl implements OAIPMHProducer { public JAXBElement<OAIPMHType> getRecordRequest(ObjectFactory obf, OAIPMHType oai, RequestType request) { - List<String> errorValues = new ArrayList<String>(); - // RecordDeliverer recDeliv = new RecordDeliverer(oaiEsClient, - // TGConstants.TGFields); JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - if (request.getMetadataPrefix() != null && !request.getMetadataPrefix().equals("oai_dc")) { - 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)); + // Check request. + ErrorHandler requestErrors = RecordDelivererAbstract.requestChecker(request); + if (requestErrors != null) { + oai.getError().add(requestErrors.getError()); } - else if (recDeliv.requestChecker(request)) { + // Get Record Request is done HERE! + else { - // recDeliv.getRecordById(request.getIdentifier()); + // Default is DC. + RecordDelivererInterface recDeliv = this.recDelivDC; + // Take IDIOM if IDIOM prefix. + if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + // recDeliv = recDelivDC; + } + + // Finally start the QUERY! GetRecordType getRecord = new GetRecordType(); getRecord = recDeliv.getRecordById(request.getIdentifier()); @@ -186,34 +187,11 @@ public class OAIPMHImpl implements OAIPMHProducer { // getRecord = recDeliv.getRecordById(request.getIdentifier()); oai.setGetRecord(getRecord); } else { - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The value of the identifier: " + ErrorHandler idError = new ErrorHandler(); + idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); - } - } else { - - if (request.getFrom() != null) { - errorValues.add("from"); - } - if (request.getResumptionToken() != null) { - errorValues.add("resumptionToken"); - } - if (request.getSet() != null) { - errorValues.add("set"); - } - if (request.getUntil() != null) { - errorValues.add("until"); - } - if (request.getMetadataPrefix() == null) { - errorValues.add("metadataPrefix"); - } - if (request.getIdentifier() == null) { - errorValues.add("identifier"); + oai.getError().add(idError.getError()); } - 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; @@ -239,43 +217,43 @@ public class OAIPMHImpl implements OAIPMHProducer { if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getResumptionToken() != null && request.getSet() != null) { errorValues.add("Set"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getMetadataPrefix() != null && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { - error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR) - .setValue("The value of the metadataPrefix: " + request.getMetadataPrefix() + this.error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, + "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)); + oai.getError().add(this.error.getError()); } else { // System.out.println("bla1000"); if (request.getResumptionToken() != null && RecordListDeliverer.cursorCollector.containsKey(request.getResumptionToken())) { - error.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN) - .setValue("The value of the resumptionToken argument is invalid or expired"); - oai.getError().add(error.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN)); + this.error.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, + "The value of the resumptionToken argument is invalid or expired"); + oai.getError().add(this.error.getError()); } else { - lit = identifierList.processIdentifierList(request.getFrom(), request.getUntil(), + this.lit = this.identifierList.processIdentifierList(request.getFrom(), request.getUntil(), request.getSet(), request.getResumptionToken()); - if (lit != null) { + if (this.lit != null) { // System.out.println("bla2000"); - oai.setListIdentifiers(lit); + oai.setListIdentifiers(this.lit); } else { - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The combination of the values " + this.error.setError(TGConstants.OAI_NO_RECORD_MATCH, "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)); + oai.getError().add(this.error.getError()); } } } @@ -317,21 +295,21 @@ public class OAIPMHImpl implements OAIPMHProducer { ListMetadataFormatsType listMF = new ListMetadataFormatsType(); JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - if (metadataFormatList.requestChecker(request)) { + if (this.metadataFormatList.requestChecker(request)) { if (id.isEmpty()) { - listMF = metadataFormatList.setMetadataFormatListWithoutId(); + listMF = this.metadataFormatList.setMetadataFormatListWithoutId(); } else { - listMF = metadataFormatList.setMetadataFormatList(request.getIdentifier()); + listMF = this.metadataFormatList.setMetadataFormatList(request.getIdentifier()); } if (listMF != null) { oai.setListMetadataFormats(listMF); } else { - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The value of the identifier: " + this.error.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); + oai.getError().add(this.error.getError()); } } else { if (request.getFrom() != null) { @@ -350,9 +328,9 @@ public class OAIPMHImpl implements OAIPMHProducer { errorValues.add("until"); } - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue("The request includes illegal " + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal " + "arguments or is missing required arguments: " + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } return oaipmhRoot; @@ -376,35 +354,36 @@ public class OAIPMHImpl implements OAIPMHProducer { if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getResumptionToken() != null && request.getSet() != null) { errorValues.add("Set"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { errorValues.add("MetadataPrefix"); - error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue( + this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); + oai.getError().add(this.error.getError()); } else if (request.getMetadataPrefix() != null && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { - error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR) - .setValue("The value of the metadataPrefix: " + request.getMetadataPrefix() + this.error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, + "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)); + oai.getError().add(this.error.getError()); } else { - listRecords = recordList.getRecords(request.getFrom(), request.getUntil(), request.getSet(), - request.getResumptionToken()); + listRecords = + this.recordList.getRecords(request.getFrom(), request.getUntil(), request.getSet(), + request.getResumptionToken()); if (listRecords != null) { oai.setListRecords(listRecords); } else { - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The combination of the values " + this.error.setError(TGConstants.OAI_NO_RECORD_MATCH, "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)); + oai.getError().add(this.error.getError()); } } @@ -438,7 +417,8 @@ public class OAIPMHImpl implements OAIPMHProducer { } else if (verb != null && verb.equals("GetRecord")) { verbParam = VerbType.GET_RECORD; } else { - error.setError("VerbError"); + // FIXME + this.error.setError("VerbError", "!!!!!!!!!FIXME MAXI!!!!!!!!!!!!!"); } return verbParam; @@ -558,9 +538,9 @@ public class OAIPMHImpl implements OAIPMHProducer { .convertDateFormat(OAIPMHUtillities.getXMLGregorianCalendarNow().toString()); response.setResponseDate(convertedDateFormat); } catch (ParseException e) { - log.debug("can not parse date format"); + this.log.debug("can not parse date format"); } catch (DatatypeConfigurationException e) { - log.debug("Datatype configuration failed"); + this.log.debug("Datatype configuration failed"); } /* converting the request values */ @@ -574,10 +554,10 @@ public class OAIPMHImpl implements OAIPMHProducer { // request.setSet(set); request.setVerb(verbParam); - if (textgrid == true) { + if (this.textgrid == true) { request.setValue(TGConstants.TG_REP_BASEURL); } - if (dariah == true) { + if (this.dariah == true) { request.setValue(DARIAHConstants.DARIAH_REP_BASEURL); } @@ -601,7 +581,8 @@ public class OAIPMHImpl implements OAIPMHProducer { oaipmhRoot = listRecordsRequest(obf, response, request); } } else { - response.getError().add(error.setError("VerbError")); + this.error.setError("VerbError", "!!!!!!!!!FIXME MAXI!!!!!!!!!!!!!"); + response.getError().add(this.error.getError()); } response.setRequest(request); diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java index 80c436fe223b7e0b8ce1375908e27a3672e3a735..98cf56123aa835181ae5a5d3da72e5c2b117c59b 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java @@ -1,5 +1,9 @@ package info.textgrid.middleware; +import java.util.ArrayList; +import java.util.List; +import info.textgrid.middleware.oaipmh.RequestType; + /** * FIXME * @@ -23,4 +27,55 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac this.dariah = dariah; } + /* + * (non-Javadoc) + * + * @see info.textgrid.middleware.RecordDelivererInterface#requestChecker(info.textgrid.middleware. + * oaipmh.RequestType) + */ + public static ErrorHandler requestChecker(RequestType request) { + + ErrorHandler result = new ErrorHandler(); + + // Check if metadata prefix is existing and valid. + if (request.getMetadataPrefix() != null + && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, + "The value of the metadataPrefix: " + request.getMetadataPrefix() + + " is not supported by the item identified by the value of: " + + request.getIdentifier()); + } + + // Check if other params are existing, they shouldn't! + else { + + List<String> errorValues = new ArrayList<String>(); + + if (request.getFrom() != null) { + errorValues.add("from"); + } + if (request.getResumptionToken() != null) { + errorValues.add("resumptionToken"); + } + if (request.getSet() != null) { + errorValues.add("set"); + } + if (request.getUntil() != null) { + errorValues.add("until"); + } + if (request.getMetadataPrefix() == null) { + errorValues.add("metadataPrefix"); + } + if (request.getIdentifier() == null) { + errorValues.add("identifier"); + } + + result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments " + + "or is missing required arguments: " + errorValues); + } + + return result; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java index a7921450953a7938f25a177f01b1a4627cf1016f..3a1b619bfa603c3c3958ac518efe83a6ad4c85fa 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -77,29 +77,20 @@ public class RecordDelivererDC extends RecordDelivererAbstract { private OAI_ESClient oaiEsClient; /** - * @param oaiEsClient - * @param workFields * @param textgrid * @param dariah */ - public RecordDelivererDC(OAI_ESClient oaiEsClient, String[] workFields, boolean textgrid, - boolean dariah) { - this.oaiEsClient = oaiEsClient; - this.workFields = workFields; - this.textgrid = textgrid; - this.dariah = dariah; + public RecordDelivererDC(boolean textgrid, boolean dariah) { + super(textgrid, dariah); } - /** - * Query ElasticSearch index for the values mapped to dublinCore for a specific object + /* + * (non-Javadoc) * - * @param id identifier within the EalsticSearch index - * @return Get the GetRecord response for the request + * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ public GetRecordType getRecordById(String id) { - // FIXME Interface! - ObjectFactory of = new ObjectFactory(); OaiDcType odt = new OaiDcType(); GetRecordType grt = new GetRecordType(); @@ -174,32 +165,6 @@ public class RecordDelivererDC extends RecordDelivererAbstract { return grt; } - /** - * Checking if necessary values are set and not allowed values are not set - * - * @param request the request from the client - * @return requestCheck indicating if the request is correct or not - */ - public boolean requestChecker(RequestType request) { - - boolean requestCheck; - - if (request.getFrom() != null || request.getUntil() != null - || request.getResumptionToken() != null) { - - requestCheck = false; - } else if (request.getSet() != null || request.getIdentifier() == null - || request.getMetadataPrefix() == null) { - requestCheck = false; - } - - else { - requestCheck = true; - } - - return requestCheck; - } - // ** // PRIVATE METHODS // ** @@ -412,10 +377,6 @@ public class RecordDelivererDC extends RecordDelivererAbstract { return this.fields; } - public void setWorkFields(String[] workFields) { - this.workFields = workFields; - } - public void setContributor(String[] contributorList) { this.contributorList = contributorList; } @@ -425,78 +386,91 @@ public class RecordDelivererDC extends RecordDelivererAbstract { } public void setCoverage(String[] coveragesList) { - this.coverageList = coveragesList; } public void setCreator(String[] creatorsList) { - this.creatorList = creatorsList; } public void setDates(String[] datesList) { - this.dateList = datesList; } public void setDescriptions(String[] descriptionsList) { - this.descriptionList = descriptionsList; } public void setFormats(String[] formatsList) { - this.formatList = formatsList; } public void setIdentifiers(String[] identifiersList) { - this.identifierList = identifiersList; } public void setLanguages(String[] languagesList) { - this.languageList = languagesList; } public void setPublishers(String[] publishersList) { - this.publisherList = publishersList; } public void setRelations(String[] relationsList) { - this.relationList = relationsList; } public void setRelationsForWork(String[] relationsList) { - this.relationForWorkList = relationsList; } public void setRights(String[] rightsList) { - this.rightList = rightsList; } public void setSources(String[] sourcesList) { - this.sourceList = sourcesList; } public void setSubjects(String[] subjectsList) { - this.subjectList = subjectsList; } public void setTitles(String[] titlesList) { - this.titleList = titlesList; } public void setTypes(String[] typesList) { - this.typeList = typesList; } + /** + * @return + */ + public OAI_ESClient getOaiEsClient() { + return this.oaiEsClient; + } + + /** + * @param oaiEsClient + */ + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } + + /** + * @return + */ + public String[] getWorkFields() { + return this.workFields; + } + + /** + * @param workFields + */ + public void setWorkFields(String[] workFields) { + this.workFields = workFields; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java index 65f66e4eaf41ea6e7cee2d0ab8866987d0e80af0..8e0ee0a8d193f5c368413e6b562d666e8bbefa9c 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java @@ -1,7 +1,6 @@ package info.textgrid.middleware; import info.textgrid.middleware.oaipmh.GetRecordType; -import info.textgrid.middleware.oaipmh.RequestType; /** * FIXME @@ -24,14 +23,4 @@ public interface RecordDelivererInterface { */ GetRecordType getRecordById(String id); - /** - * <p> - * Checking if necessary values are set and not allowed values are not set. - * </p> - * - * @param request the request from the client - * @return requestCheck indicating if the request is correct or not - */ - boolean requestChecker(RequestType request); - } 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 fbbb6aee85177cb8b418b46bccfb3d92c3b61a44..968513892ba44a4bad373901446e1e007f731f84 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java @@ -35,7 +35,7 @@ public class RecordListDeliverer { // STATICS // ** - private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDeliverer.class); + private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); // ** // CLASS VARIABLES 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 307aba47fe2b2ec214b95ca6279b1f63796352f8..e1b1da7c78eb477d85a785987c4b61fd131be3bf 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -1,21 +1,18 @@ package info.textgrid.middleware; import java.text.ParseException; - -import info.textgrid.middleware.oaipmh.DeletedRecordType; -import info.textgrid.middleware.oaipmh.GranularityType; -import info.textgrid.middleware.oaipmh.OAIPMHType; -import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; -import info.textgrid.utils.sesameclient.SesameClient; - import javax.xml.bind.JAXB; import javax.xml.bind.JAXBElement; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; - import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import info.textgrid.middleware.oaipmh.DeletedRecordType; +import info.textgrid.middleware.oaipmh.GranularityType; +import info.textgrid.middleware.oaipmh.OAIPMHType; +import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; +import info.textgrid.utils.sesameclient.SesameClient; /** * @@ -23,503 +20,522 @@ import org.junit.Test; public class OaiPmhTest { - public static OAI_ESClient oaiEsClient; - private static SesameClient sc; - DeletedRecordType bla = DeletedRecordType.NO; - GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; - private RepIdentification rep = new RepIdentification( - "TextGrid-Repository", "www.textgridrep.de", this.bla, - "2011-06-11T02:32:40Z", this.bla2, "2.0", - "textgrid-support@gwdg.de"); - - // private RecordDeliverer record = new RecordDeliverer( - // oaiEsClient, - // TGConstants.TGWorkFields, - // true, false); - //private RecordDeliverer record = new RecordDeliverer(oaiEsClient, DARIAHConstants.DARIAHFields, false, true); - - private RecordDeliverer record = new RecordDeliverer(oaiEsClient, TGConstants.TGFields, true, false); - - //private RecordListDeliverer recordList = new RecordListDeliverer(TGConstants.TGFields, TGConstants.TGWorkFields, true, false); - - private RecordListDeliverer recordList = new RecordListDeliverer(DARIAHConstants.DARIAHFields, DARIAHConstants.DARIAHFields, false, true); - - - // TGConstants.TGWorkFields, true, false); - private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(oaiEsClient); - private SetDeliverer setListDARIAH = new SetDeliverer(oaiEsClient, false, true); - private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false); - //private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, false, true); - private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, true, false); - private OAIPMHImpl request = new OAIPMHImpl(oaiEsClient, this.rep, this.record, this.recordList, this.metadataFormatList, this.setListDARIAH, this.identifierList); - - /** - * @throws Exception - */ - @BeforeClass - public static void setUp() throws Exception { - - //sc = new SesameClient("http://localhost:9091/openrdf-workbench/repositories/textgrid-public"); - oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); - //oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); - OAI_ESClient.setEsIndex("textgrid-public"); - OAI_ESClient.setEsType("metadata"); - //oaiEsClient.setEsIndex("dariahreptest"); - //oaiEsClient.setEsType("oai"); - } - - /** - * @throws DatatypeConfigurationException - */ - @Test - @Ignore - public void testDateNow() throws DatatypeConfigurationException { - System.out.println("---------------Now Version-----------------"); - XMLGregorianCalendar nowTest = OAIPMHUtillities - .getXMLGregorianCalendarNow(); - System.out.println(nowTest); - System.out.println("-------------------------------------------"); - } - - /** - * @throws ParseException - * @throws DatatypeConfigurationException - */ - @Test - @Ignore - public void testDateGregorianType() throws ParseException, - DatatypeConfigurationException { - String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; - - System.out.println("---------XML Gregorian Version---------------"); - System.out.println("Original date: " + dateformatbefore); - XMLGregorianCalendar testDate = OAIPMHUtillities - .convertDateFormat(dateformatbefore); - System.out.println("Date after conversion: " + testDate); - System.out.println("---------------------------------------------"); - } - - /** - * @throws ParseException - * @throws DatatypeConfigurationException - */ - @Test - @Ignore - public void testDateStringType() throws ParseException, - DatatypeConfigurationException { - String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; - - System.out.println("------------String Version-------------------"); - System.out.println("Original date: " + dateformatbefore); - String testDate = OAIPMHUtillities.datestampAsString(dateformatbefore); - System.out.println("Date after conversion: " + testDate); - System.out.println("---------------------------------------------"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestIdentify() throws ParseException { - - System.out - .println("Test for the verb \"Identify\" with succesfull response"); - JAXBElement<OAIPMHType> r = this.request.getRequest("Identify", "", "", - "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestIdentifyVerbError() throws ParseException { - JAXBElement<OAIPMHType> t = this.request.getRequest("Identify", "", - "a", "", "", "", ""); - JAXB.marshal(t, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestIdentifyArgumentError() throws ParseException { - System.out - .println("Test for the verb \"Identify\" with error response"); - JAXBElement<OAIPMHType> z = this.request.getRequest("Identify", "a", - "", "", "", "a", ""); - JAXB.marshal(z, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestGetRecordError() throws ParseException { - - System.out - .println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> t = this.request.getRequest("GetRecord", - "textgrid:vqn0.0", "oai_dc", "", "", "", ""); - JAXB.marshal(t, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestGetRecordError2() throws ParseException { - - this.record.setContributor(TGConstants.CONTRIBUTOR_LIST); - this.record.setCoverage(TGConstants.COVERAGE_LIST); - this.record.setCreator(TGConstants.CREATOR_LIST); - this.record.setDates(TGConstants.DATE_LIST); - this.record.setDescriptions(TGConstants.DESCRIPTION_LIST); - this.record.setFormats(TGConstants.FORMAT_LIST); - this.record.setIdentifiers(TGConstants.IDENTIFIER_LIST); - this.record.setLanguages(TGConstants.LANGUAGE_LIST); - this.record.setPublishers(TGConstants.PUBLISHER_LIST); - this.record.setRelations(TGConstants.RELATIONS_LIST); - this.record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); - this.record.setRights(TGConstants.RIGHTS_LIST); - this.record.setSources(TGConstants.SOURCE_LIST); - this.record.setSubjects(TGConstants.SUBJECT_LIST); - this.record.setTitles(TGConstants.TITLE_LIST); - this.record.setTypes(TGConstants.TYPE_LIST); - this.record.setFields(TGConstants.TGFields); - this.record.setFormatField(TGConstants.FORMAT); - this.record.setFormatToFilter(TextGridMimetypes.EDITION); - this.record.setDateOfObjectCreation(TGConstants.CREATED); - this.record.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - this.record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - this.record.setIdentifierField("textgridUri"); - - System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord","wr71.0", "oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestGetRecordDariah() throws ParseException { - - this.record.setContributor(DARIAHConstants.CONTRIBUTOR_LIST); - this.record.setCoverage(DARIAHConstants.COVERAGE_LIST); - this.record.setCreator(DARIAHConstants.CREATOR_LIST); - this.record.setDates(DARIAHConstants.DATE_LIST); - this.record.setDescriptions(DARIAHConstants.DESCRIPTION_LIST); - this.record.setFormats(DARIAHConstants.FORMAT_LIST); - this.record.setIdentifiers(DARIAHConstants.IDENTIFIER_LIST); - this.record.setLanguages(DARIAHConstants.LANGUAGE_LIST); - this.record.setPublishers(DARIAHConstants.PUBLISHER_LIST); - this.record.setRelations(DARIAHConstants.RELATIONS_LIST); - this.record.setRights(DARIAHConstants.RIGHTS_LIST); - this.record.setSources(DARIAHConstants.SOURCE_LIST); - this.record.setSubjects(DARIAHConstants.SUBJECT_LIST); - this.record.setTitles(DARIAHConstants.TITLE_LIST); - this.record.setTypes(DARIAHConstants.TYPE_LIST); - this.record.setFields(DARIAHConstants.DARIAHFields); - this.record.setFormatField(DARIAHConstants.FORMAT); - this.record.setFormatToFilter("metadata"); - this.record.setDateOfObjectCreation(DARIAHConstants.MODIFIED_FIELD); - this.record.setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX); - this.record.setIdentifierField("administrativeMetadata.dcterms:identifier"); - - System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord","hdl:21.T11991/0000-0003-5667-9", "oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testGetRequestGetRecordError3() throws ParseException { - System.out - .println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord", "", - "", "", "", "", ""); - JAXB.marshal(p, System.out); - System.out.println("-----------------------------------\n"); - - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListIdentifierSets() throws ParseException { - this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); - this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); - this.identifierList.setFormatField(TGConstants.FORMAT); - this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); - this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); - this.identifierList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - this.identifierList.setIdentifierField("textgridUri"); - - System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers","", "oai_dc", "project:TGPR-26236625-1acc-b921-a5fa-53567c3eeb80", "", "", ""); - JAXB.marshal(p, System.out); - System.out.println("-----------------------------------\n"); - - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListRecordSets() throws ParseException { - this.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); - this.recordList.setCoverage(TGConstants.COVERAGE_LIST); - this.recordList.setCreators(TGConstants.CREATOR_LIST); - this.recordList.setDates(TGConstants.DATE_LIST); - this.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); - this.recordList.setFormats(TGConstants.FORMAT_LIST); - this.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); - this.recordList.setLanguages(TGConstants.LANGUAGE_LIST); - this.recordList.setPublishers(TGConstants.PUBLISHER_LIST); - this.recordList.setRelations(TGConstants.RELATIONS_LIST); - this.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); - this.recordList.setRights(TGConstants.RIGHTS_LIST); - this.recordList.setSources(TGConstants.SOURCE_LIST); - this.recordList.setSubjects(TGConstants.SUBJECT_LIST); - this.recordList.setTitles(TGConstants.TITLE_LIST); - this.recordList.setTypes(TGConstants.TYPE_LIST); - this.recordList.setFormatField(TGConstants.FORMAT); - this.recordList.setFormatToFilter(TextGridMimetypes.EDITION); - this.recordList.setDateOfObjectCreation(TGConstants.CREATED); - this.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - this.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - this.recordList.setFieldForRange(TGConstants.CREATED); - this.recordList.setModifiedField(TGConstants.MODIFIED_FIELD); - - System.out.println("Test for the verb \"ListRecord\" with sets with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("ListRecords", "","oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); - System.out.println("-----------------------------------\n"); - - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListRecords() throws ParseException { - - JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "", "2011-02-06T20:48:39", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListRecords2() throws ParseException { - - System.out.println("TG"); - - this.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); - this.recordList.setCoverage(TGConstants.COVERAGE_LIST); - this.recordList.setCreators(TGConstants.CREATOR_LIST); - this.recordList.setDates(TGConstants.DATE_LIST); - this.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); - this.recordList.setFormats(TGConstants.FORMAT_LIST); - this.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); - this.recordList.setLanguages(TGConstants.LANGUAGE_LIST); - this.recordList.setPublishers(TGConstants.PUBLISHER_LIST); - this.recordList.setRelations(TGConstants.RELATIONS_LIST); - this.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); - this.recordList.setRights(TGConstants.RIGHTS_LIST); - this.recordList.setSources(TGConstants.SOURCE_LIST); - this.recordList.setSubjects(TGConstants.SUBJECT_LIST); - this.recordList.setTitles(TGConstants.TITLE_LIST); - this.recordList.setTypes(TGConstants.TYPE_LIST); - this.recordList.setFormatField(TGConstants.FORMAT); - this.recordList.setFormatToFilter(TextGridMimetypes.EDITION); - this.recordList.setDateOfObjectCreation(TGConstants.CREATED); - this.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - this.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - this.recordList.setFieldForRange(TGConstants.CREATED); - this.recordList.setModifiedField(TGConstants.CREATED); - this.recordList.setIdentifierField("textgridUri"); - this.recordList.setSearchResponseSize("100"); - - JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListRecordsDariah() throws ParseException { - - //System.out.println("BUJA"); - - this.recordList.setContributor(DARIAHConstants.CONTRIBUTOR_LIST); - this.recordList.setCoverage(DARIAHConstants.COVERAGE_LIST); - this.recordList.setCreators(DARIAHConstants.CREATOR_LIST); - this.recordList.setDates(DARIAHConstants.DATE_LIST); - this.recordList.setDescriptions(DARIAHConstants.DESCRIPTION_LIST); - this.recordList.setFormats(DARIAHConstants.FORMAT_LIST); - this.recordList.setIdentifiers(DARIAHConstants.IDENTIFIER_LIST); - this.recordList.setLanguages(DARIAHConstants.LANGUAGE_LIST); - this.recordList.setPublishers(DARIAHConstants.PUBLISHER_LIST); - this.recordList.setRelations(DARIAHConstants.RELATIONS_LIST); - this.recordList.setRights(DARIAHConstants.RIGHTS_LIST); - this.recordList.setSources(DARIAHConstants.SOURCE_LIST); - this.recordList.setSubjects(DARIAHConstants.SUBJECT_LIST); - this.recordList.setTitles(DARIAHConstants.TITLE_LIST); - this.recordList.setTypes(DARIAHConstants.TYPE_LIST); - this.recordList.setFormatField(DARIAHConstants.FORMAT); - this.recordList.setDateOfObjectCreation(DARIAHConstants.CREATED); - this.recordList.setFieldForRange(DARIAHConstants.MODIFIED_FIELD); - this.recordList.setDateOfObjectCreation(DARIAHConstants.RANGE_FIELD); - this.recordList.setIdentifierField(DARIAHConstants.IDENTIFIER); - this.recordList.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); - this.recordList.setModifiedField(DARIAHConstants.MODIFIED_FIELD); - this.recordList.setRelationToFurtherMetadataObject("descriptiveMetadata.dc:relation"); - this.recordList.setSearchResponseSize("100"); - - JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "","oai_dc", "21.T11991/0000-0003-718E-E", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListMetadataFormats() throws ParseException { - JAXBElement<OAIPMHType> r = this.request.getRequest( - "ListMetadataFormats", "7t.0", "", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListMetadataFormatsWithoutID() throws ParseException { - JAXBElement<OAIPMHType> r = this.request.getRequest( - "ListMetadataFormats", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListSets() throws ParseException { - System.out.println("bla"); - this.setListTextGrid.setFormatField("format"); - this.setListTextGrid.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); - this.setListTextGrid.setIdentifierField("textgridUri"); - this.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); - - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListSetsDARIAH() throws ParseException { - System.out.println("TEST DARIAH"); - - this.setListDARIAH.setFormatField(DARIAHConstants.FORMAT); - this.setListDARIAH.setFormatToFilter(DARIAHConstants.COLLECTION_MIMETYPE); - this.setListDARIAH.setIdentifierField(DARIAHConstants.IDENTIFIER); - this.setListDARIAH.setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX); - this.setListDARIAH.setIdentifierField("administrativeMetadata.dcterms:identifier"); - this.setListDARIAH.setSpecField("descriptiveMetadata.dc:title"); - this.setListDARIAH.setSpecFieldPrefix(DARIAHConstants.COLLECTIONREGISTRY_PREFIX); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - /** - * @throws ParseException - */ - @Test - @Ignore - public void testListIdentifiers() throws ParseException { - this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); - this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); - this.identifierList.setFormatField(TGConstants.FORMAT); - this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); - this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); - this.identifierList.setIdentifierField("textgridUri"); - this.identifierList.setRepositoryObjectURIPrefix("textgrid:"); - this.identifierList.setSearchResponseSize("100"); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListIdentifiers", "", "oai_dc", "project:TGPR-f2242b43-bc28-712e-59ca-54801b1bbf52", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - @Test - @Ignore - public void testListIdentifiersDARIAH() throws ParseException { - this.identifierList.setFieldForRange(DARIAHConstants.RANGE_FIELD); - this.identifierList.setIdentifierListFields(DARIAHConstants.IDENTIFIER_LIST_FIELDS); - this.identifierList.setFormatField(DARIAHConstants.FORMAT); - // this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); - this.identifierList.setDateOfObjectCreation("administrativeMetadata.dcterms:modified"); - this.identifierList.setRepositoryObjectURIPrefix("hdl:"); - this.identifierList.setIdentifierField("administrativeMetadata.dcterms:identifier"); - this.identifierList.setSearchResponseSize("100"); - //System.out.println("BLABLUBB"); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListIdentifiers","", "oai_dc", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } - - - @Test - @Ignore - public void testEmptyRequest() throws ParseException { - this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); - this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); - this.identifierList.setFormatField(TGConstants.FORMAT); - this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); - this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); - this.identifierList.setIdentifierField("textgridUri"); - this.identifierList.setRepositoryObjectURIPrefix("textgrid:"); - this.identifierList.setSearchResponseSize("100"); - JAXBElement<OAIPMHType> r = this.request.getRequest("", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); - System.out.println("-----------------------------------\n"); - } + public static OAI_ESClient oaiEsClient; + private static SesameClient sc; + DeletedRecordType bla = DeletedRecordType.NO; + GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; + private RepIdentification rep = new RepIdentification("TextGrid-Repository", "www.textgridrep.de", + this.bla, "2011-06-11T02:32:40Z", this.bla2, "2.0", "textgrid-support@gwdg.de"); + + // private RecordDeliverer record = new RecordDeliverer( + // oaiEsClient, + // TGConstants.TGWorkFields, + // true, false); + // private RecordDeliverer record = new RecordDeliverer(oaiEsClient, DARIAHConstants.DARIAHFields, + // false, true); + + private static RecordDelivererDC record; + + // private RecordListDeliverer recordList = new RecordListDeliverer(TGConstants.TGFields, + // TGConstants.TGWorkFields, true, false); + + private RecordListDeliverer recordList = new RecordListDeliverer(DARIAHConstants.DARIAHFields, + DARIAHConstants.DARIAHFields, false, true); + + // TGConstants.TGWorkFields, true, false); + private MetadataFormatListDeliverer metadataFormatList = + new MetadataFormatListDeliverer(oaiEsClient); + private SetDeliverer setListDARIAH = new SetDeliverer(oaiEsClient, false, true); + private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false); + // private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, + // false, true); + private IdentifierListDeliverer identifierList = + new IdentifierListDeliverer(oaiEsClient, true, false); + private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhTest.record, this.recordList, + this.metadataFormatList, this.setListDARIAH, this.identifierList); + + /** + * @throws Exception + */ + @BeforeClass + public static void setUp() throws Exception { + + // sc = new + // SesameClient("http://localhost:9091/openrdf-workbench/repositories/textgrid-public"); + oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); + // oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); + OAI_ESClient.setEsIndex("textgrid-public"); + OAI_ESClient.setEsType("metadata"); + // oaiEsClient.setEsIndex("dariahreptest"); + // oaiEsClient.setEsType("oai"); + + // Set OSI client for record. + record = new RecordDelivererDC(true, false); + record.setOaiEsClient(oaiEsClient); + record.setWorkFields(TGConstants.TGWorkFields); + } + + /** + * @throws DatatypeConfigurationException + */ + @Test + @Ignore + public void testDateNow() throws DatatypeConfigurationException { + System.out.println("---------------Now Version-----------------"); + XMLGregorianCalendar nowTest = OAIPMHUtillities + .getXMLGregorianCalendarNow(); + System.out.println(nowTest); + System.out.println("-------------------------------------------"); + } + + /** + * @throws ParseException + * @throws DatatypeConfigurationException + */ + @Test + @Ignore + public void testDateGregorianType() throws ParseException, + DatatypeConfigurationException { + String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; + + System.out.println("---------XML Gregorian Version---------------"); + System.out.println("Original date: " + dateformatbefore); + XMLGregorianCalendar testDate = OAIPMHUtillities + .convertDateFormat(dateformatbefore); + System.out.println("Date after conversion: " + testDate); + System.out.println("---------------------------------------------"); + } + + /** + * @throws ParseException + * @throws DatatypeConfigurationException + */ + @Test + @Ignore + public void testDateStringType() throws ParseException, + DatatypeConfigurationException { + String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; + + System.out.println("------------String Version-------------------"); + System.out.println("Original date: " + dateformatbefore); + String testDate = OAIPMHUtillities.datestampAsString(dateformatbefore); + System.out.println("Date after conversion: " + testDate); + System.out.println("---------------------------------------------"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestIdentify() throws ParseException { + + System.out + .println("Test for the verb \"Identify\" with succesfull response"); + JAXBElement<OAIPMHType> r = this.request.getRequest("Identify", "", "", + "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestIdentifyVerbError() throws ParseException { + JAXBElement<OAIPMHType> t = this.request.getRequest("Identify", "", + "a", "", "", "", ""); + JAXB.marshal(t, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestIdentifyArgumentError() throws ParseException { + System.out + .println("Test for the verb \"Identify\" with error response"); + JAXBElement<OAIPMHType> z = this.request.getRequest("Identify", "a", + "", "", "", "a", ""); + JAXB.marshal(z, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestGetRecordError() throws ParseException { + + System.out + .println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> t = this.request.getRequest("GetRecord", + "textgrid:vqn0.0", "oai_dc", "", "", "", ""); + JAXB.marshal(t, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestGetRecordError2() throws ParseException { + + record.setContributor(TGConstants.CONTRIBUTOR_LIST); + record.setCoverage(TGConstants.COVERAGE_LIST); + record.setCreator(TGConstants.CREATOR_LIST); + record.setDates(TGConstants.DATE_LIST); + record.setDescriptions(TGConstants.DESCRIPTION_LIST); + record.setFormats(TGConstants.FORMAT_LIST); + record.setIdentifiers(TGConstants.IDENTIFIER_LIST); + record.setLanguages(TGConstants.LANGUAGE_LIST); + record.setPublishers(TGConstants.PUBLISHER_LIST); + record.setRelations(TGConstants.RELATIONS_LIST); + record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + record.setRights(TGConstants.RIGHTS_LIST); + record.setSources(TGConstants.SOURCE_LIST); + record.setSubjects(TGConstants.SUBJECT_LIST); + record.setTitles(TGConstants.TITLE_LIST); + record.setTypes(TGConstants.TYPE_LIST); + record.setFields(TGConstants.TGFields); + record.setFormatField(TGConstants.FORMAT); + record.setFormatToFilter(TextGridMimetypes.EDITION); + record.setDateOfObjectCreation(TGConstants.CREATED); + record.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); + record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + record.setIdentifierField("textgridUri"); + + System.out.println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> p = + this.request.getRequest("GetRecord", "wr71.0", "oai_dc", "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestGetRecordDariah() throws ParseException { + + record.setContributor(DARIAHConstants.CONTRIBUTOR_LIST); + record.setCoverage(DARIAHConstants.COVERAGE_LIST); + record.setCreator(DARIAHConstants.CREATOR_LIST); + record.setDates(DARIAHConstants.DATE_LIST); + record.setDescriptions(DARIAHConstants.DESCRIPTION_LIST); + record.setFormats(DARIAHConstants.FORMAT_LIST); + record.setIdentifiers(DARIAHConstants.IDENTIFIER_LIST); + record.setLanguages(DARIAHConstants.LANGUAGE_LIST); + record.setPublishers(DARIAHConstants.PUBLISHER_LIST); + record.setRelations(DARIAHConstants.RELATIONS_LIST); + record.setRights(DARIAHConstants.RIGHTS_LIST); + record.setSources(DARIAHConstants.SOURCE_LIST); + record.setSubjects(DARIAHConstants.SUBJECT_LIST); + record.setTitles(DARIAHConstants.TITLE_LIST); + record.setTypes(DARIAHConstants.TYPE_LIST); + record.setFields(DARIAHConstants.DARIAHFields); + record.setFormatField(DARIAHConstants.FORMAT); + record.setFormatToFilter("metadata"); + record.setDateOfObjectCreation(DARIAHConstants.MODIFIED_FIELD); + record.setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX); + record.setIdentifierField("administrativeMetadata.dcterms:identifier"); + + System.out.println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord", + "hdl:21.T11991/0000-0003-5667-9", "oai_dc", "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetRequestGetRecordError3() throws ParseException { + System.out + .println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord", "", + "", "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListIdentifierSets() throws ParseException { + this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); + this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); + this.identifierList.setFormatField(TGConstants.FORMAT); + this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); + this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); + this.identifierList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + this.identifierList.setIdentifierField("textgridUri"); + + System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); + JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "oai_dc", + "project:TGPR-26236625-1acc-b921-a5fa-53567c3eeb80", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListRecordSets() throws ParseException { + this.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); + this.recordList.setCoverage(TGConstants.COVERAGE_LIST); + this.recordList.setCreators(TGConstants.CREATOR_LIST); + this.recordList.setDates(TGConstants.DATE_LIST); + this.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); + this.recordList.setFormats(TGConstants.FORMAT_LIST); + this.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); + this.recordList.setLanguages(TGConstants.LANGUAGE_LIST); + this.recordList.setPublishers(TGConstants.PUBLISHER_LIST); + this.recordList.setRelations(TGConstants.RELATIONS_LIST); + this.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + this.recordList.setRights(TGConstants.RIGHTS_LIST); + this.recordList.setSources(TGConstants.SOURCE_LIST); + this.recordList.setSubjects(TGConstants.SUBJECT_LIST); + this.recordList.setTitles(TGConstants.TITLE_LIST); + this.recordList.setTypes(TGConstants.TYPE_LIST); + this.recordList.setFormatField(TGConstants.FORMAT); + this.recordList.setFormatToFilter(TextGridMimetypes.EDITION); + this.recordList.setDateOfObjectCreation(TGConstants.CREATED); + this.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); + this.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + this.recordList.setFieldForRange(TGConstants.CREATED); + this.recordList.setModifiedField(TGConstants.MODIFIED_FIELD); + + System.out.println("Test for the verb \"ListRecord\" with sets with succesfull response"); + JAXBElement<OAIPMHType> p = + this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListRecords() throws ParseException { + + JAXBElement<OAIPMHType> r = + this.request.getRequest("ListRecords", "", "oai_dc", "", "2011-02-06T20:48:39", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListRecords2() throws ParseException { + + System.out.println("TG"); + + this.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); + this.recordList.setCoverage(TGConstants.COVERAGE_LIST); + this.recordList.setCreators(TGConstants.CREATOR_LIST); + this.recordList.setDates(TGConstants.DATE_LIST); + this.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); + this.recordList.setFormats(TGConstants.FORMAT_LIST); + this.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); + this.recordList.setLanguages(TGConstants.LANGUAGE_LIST); + this.recordList.setPublishers(TGConstants.PUBLISHER_LIST); + this.recordList.setRelations(TGConstants.RELATIONS_LIST); + this.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + this.recordList.setRights(TGConstants.RIGHTS_LIST); + this.recordList.setSources(TGConstants.SOURCE_LIST); + this.recordList.setSubjects(TGConstants.SUBJECT_LIST); + this.recordList.setTitles(TGConstants.TITLE_LIST); + this.recordList.setTypes(TGConstants.TYPE_LIST); + this.recordList.setFormatField(TGConstants.FORMAT); + this.recordList.setFormatToFilter(TextGridMimetypes.EDITION); + this.recordList.setDateOfObjectCreation(TGConstants.CREATED); + this.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); + this.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + this.recordList.setFieldForRange(TGConstants.CREATED); + this.recordList.setModifiedField(TGConstants.CREATED); + this.recordList.setIdentifierField("textgridUri"); + this.recordList.setSearchResponseSize("100"); + + JAXBElement<OAIPMHType> r = + this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListRecordsDariah() throws ParseException { + + // System.out.println("BUJA"); + + this.recordList.setContributor(DARIAHConstants.CONTRIBUTOR_LIST); + this.recordList.setCoverage(DARIAHConstants.COVERAGE_LIST); + this.recordList.setCreators(DARIAHConstants.CREATOR_LIST); + this.recordList.setDates(DARIAHConstants.DATE_LIST); + this.recordList.setDescriptions(DARIAHConstants.DESCRIPTION_LIST); + this.recordList.setFormats(DARIAHConstants.FORMAT_LIST); + this.recordList.setIdentifiers(DARIAHConstants.IDENTIFIER_LIST); + this.recordList.setLanguages(DARIAHConstants.LANGUAGE_LIST); + this.recordList.setPublishers(DARIAHConstants.PUBLISHER_LIST); + this.recordList.setRelations(DARIAHConstants.RELATIONS_LIST); + this.recordList.setRights(DARIAHConstants.RIGHTS_LIST); + this.recordList.setSources(DARIAHConstants.SOURCE_LIST); + this.recordList.setSubjects(DARIAHConstants.SUBJECT_LIST); + this.recordList.setTitles(DARIAHConstants.TITLE_LIST); + this.recordList.setTypes(DARIAHConstants.TYPE_LIST); + this.recordList.setFormatField(DARIAHConstants.FORMAT); + this.recordList.setDateOfObjectCreation(DARIAHConstants.CREATED); + this.recordList.setFieldForRange(DARIAHConstants.MODIFIED_FIELD); + this.recordList.setDateOfObjectCreation(DARIAHConstants.RANGE_FIELD); + this.recordList.setIdentifierField(DARIAHConstants.IDENTIFIER); + this.recordList.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); + this.recordList.setModifiedField(DARIAHConstants.MODIFIED_FIELD); + this.recordList.setRelationToFurtherMetadataObject("descriptiveMetadata.dc:relation"); + this.recordList.setSearchResponseSize("100"); + + JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "", "oai_dc", + "21.T11991/0000-0003-718E-E", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListMetadataFormats() throws ParseException { + JAXBElement<OAIPMHType> r = this.request.getRequest( + "ListMetadataFormats", "7t.0", "", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListMetadataFormatsWithoutID() throws ParseException { + JAXBElement<OAIPMHType> r = this.request.getRequest( + "ListMetadataFormats", "", "", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListSets() throws ParseException { + System.out.println("bla"); + this.setListTextGrid.setFormatField("format"); + this.setListTextGrid.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); + this.setListTextGrid.setIdentifierField("textgridUri"); + this.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); + JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListSetsDARIAH() throws ParseException { + System.out.println("TEST DARIAH"); + + this.setListDARIAH.setFormatField(DARIAHConstants.FORMAT); + this.setListDARIAH.setFormatToFilter(DARIAHConstants.COLLECTION_MIMETYPE); + this.setListDARIAH.setIdentifierField(DARIAHConstants.IDENTIFIER); + this.setListDARIAH.setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX); + this.setListDARIAH.setIdentifierField("administrativeMetadata.dcterms:identifier"); + this.setListDARIAH.setSpecField("descriptiveMetadata.dc:title"); + this.setListDARIAH.setSpecFieldPrefix(DARIAHConstants.COLLECTIONREGISTRY_PREFIX); + JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListIdentifiers() throws ParseException { + this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); + this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); + this.identifierList.setFormatField(TGConstants.FORMAT); + this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); + this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); + this.identifierList.setIdentifierField("textgridUri"); + this.identifierList.setRepositoryObjectURIPrefix("textgrid:"); + this.identifierList.setSearchResponseSize("100"); + JAXBElement<OAIPMHType> r = this.request.getRequest("ListIdentifiers", "", "oai_dc", + "project:TGPR-f2242b43-bc28-712e-59ca-54801b1bbf52", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + @Test + @Ignore + public void testListIdentifiersDARIAH() throws ParseException { + this.identifierList.setFieldForRange(DARIAHConstants.RANGE_FIELD); + this.identifierList.setIdentifierListFields(DARIAHConstants.IDENTIFIER_LIST_FIELDS); + this.identifierList.setFormatField(DARIAHConstants.FORMAT); + // this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); + this.identifierList.setDateOfObjectCreation("administrativeMetadata.dcterms:modified"); + this.identifierList.setRepositoryObjectURIPrefix("hdl:"); + this.identifierList.setIdentifierField("administrativeMetadata.dcterms:identifier"); + this.identifierList.setSearchResponseSize("100"); + // System.out.println("BLABLUBB"); + JAXBElement<OAIPMHType> r = + this.request.getRequest("ListIdentifiers", "", "oai_dc", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } + + + @Test + @Ignore + public void testEmptyRequest() throws ParseException { + this.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); + this.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); + this.identifierList.setFormatField(TGConstants.FORMAT); + this.identifierList.setFormatToFilter(TextGridMimetypes.EDITION); + this.identifierList.setDateOfObjectCreation(TGConstants.CREATED); + this.identifierList.setIdentifierField("textgridUri"); + this.identifierList.setRepositoryObjectURIPrefix("textgrid:"); + this.identifierList.setSearchResponseSize("100"); + JAXBElement<OAIPMHType> r = this.request.getRequest("", "", "", "", "", "", ""); + JAXB.marshal(r, System.out); + System.out.println("-----------------------------------\n"); + } } diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index c5f849dd288e2dd43289e6ef49ec75567e6e9f25..646c6f52094cd3480c68c4fd033b7b0d94060300 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -97,7 +97,7 @@ value="${searchResponseSize}" /> </bean> - <bean id="Record" class="info.textgrid.middleware.RecordDeliverer"> + <bean id="RecordDC" class="info.textgrid.middleware.RecordDelivererDC"> <constructor-arg index="0" ref="ElasticSearchClient" /> <constructor-arg index="1" value="${workFields}" /> <constructor-arg index="2" value="${textgrid}" /> @@ -180,9 +180,9 @@ </bean> <bean id="oai" class="info.textgrid.middleware.OAIPMHImpl"> - <constructor-arg ref="ElasticSearchClient" /> <constructor-arg ref="RepIdentification" /> - <constructor-arg ref="Record" /> + <constructor-arg ref="RecordAbstract" /> + <constructor-arg ref="RecordDC" /> <constructor-arg ref="RecordList" /> <constructor-arg ref="MetadataFormatList" /> <constructor-arg ref="SetDeliverer" />