diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IDIOMImages.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IDIOMImages.java index 1b41a497666de52f2a7df020ff6d410913ac5298..b6eb035d3ac25fe7ef542e877b1c2bda43ff4599 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IDIOMImages.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IDIOMImages.java @@ -8,6 +8,7 @@ import java.text.ParseException; import java.util.Hashtable; import java.util.Map; import java.util.UUID; +import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -41,6 +42,8 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; public class IDIOMImages implements RecordDelivererInterface, RecordListDelivererInterface, IdentifierListDelivererInterface { + private static Logger log = Logger.getLogger(IDIOMImages.class.getName()); + private String kindID; private String perPage; private String pageNumber; @@ -52,7 +55,9 @@ public class IDIOMImages implements RecordDelivererInterface, RecordListDelivere /** * */ - public IDIOMImages() {} + public IDIOMImages() { + // + } /** * @@ -120,6 +125,7 @@ public class IDIOMImages implements RecordDelivererInterface, RecordListDelivere } imageMetsModsList.setResumptionToken( buildResumptionToken(resumptionToken, getTotalHits(), useThisFrom, useThisTo)); + return imageMetsModsList; } @@ -174,27 +180,20 @@ public class IDIOMImages implements RecordDelivererInterface, RecordListDelivere // ImageMetsMods imm = new ImageMetsMods(new ConedaKorID(id)); ImageMetsMods immByTGURI = null; - // System.out.println(id); - // TextGridUri asa = new TextGridUri(); - - System.out.println(" ++ id.1: " + id); - if (!id.startsWith("textgrid:")) { id = "textgrid:" + id; } - System.out.println(" ++ id.2: " + id); + log.fine("processing id: " + id); try { immByTGURI = new ImageMetsMods(new TextGridUri(id)); - System.out - .println(" ++ image METS/MODS: " + immByTGURI.getID() + " / " + immByTGURI.getTitle()); + log.fine("image id/title: " + immByTGURI.getID() + " / " + immByTGURI.getTitle()); builder = factory.newDocumentBuilder(); - System.out - .println(" ++ immByTGURI: " + (immByTGURI != null ? immByTGURI.getXML() : "NULL")); + log.fine("immByTGURI: " + (immByTGURI != null ? immByTGURI.getXML() : "NULL")); Document doc = builder.parse(new InputSource(new StringReader(immByTGURI.getXML()))); metadataMets.setAny(doc.getDocumentElement()); @@ -211,7 +210,7 @@ public class IDIOMImages implements RecordDelivererInterface, RecordListDelivere singleImageMetsMods.setRecord(conedaKorRecord); } catch (ParserConfigurationException | SAXException | CrudClientException e) { - System.out.println("error " + e.getClass().getName() + ": " + e.getMessage()); + log.severe("error! " + e.getClass().getName() + ": " + e.getMessage()); return null; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java index 71f292cb9c61a120ddfa99249895092a583ef8c3..dece890bff0b73aab56e4765c8cdc0be001dd7e3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java @@ -54,8 +54,6 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac public ListIdentifiersType processIdentifierList(final String from, final String to, final String set, final String resumptionToken) throws ParseException, IOException { - // String resTokenValue = resumptionToken; - ListIdentifiersType identifierList = new ListIdentifiersType(); BoolQueryBuilder recordFilterForClassicMayan; @@ -64,9 +62,8 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("lastModified").from(from).to(to); - BoolQueryBuilder test = QueryBuilders.boolQuery() - .must(QueryBuilders.matchPhraseQuery("project.id", - "TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318")); + BoolQueryBuilder test = QueryBuilders.boolQuery().must( + QueryBuilders.matchPhraseQuery("project.id", "TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318")); BoolQueryBuilder artefact = QueryBuilders.boolQuery() .must(QueryBuilders.matchPhraseQuery("format", "text/tg.inputform+rdf+xml")) diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java index c513a91e59c0f9cd1b893d3eb2930c9efac2e444..d29fc5263a4c40371ce1fdc1b908d7026ef53915 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java @@ -585,8 +585,6 @@ public class OAIPMHUtilities { } } - log.fine(" ## omit prefix? " + identifier + " --> " + result); - return result; } 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 25b02c58288a684a7e49c91aaddde743478addc6..b5ad67850195b47ba2c27b027ca4ee921bf27aa6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java @@ -2,17 +2,20 @@ package info.textgrid.middleware; import java.util.ArrayList; import java.util.List; +import java.util.logging.Logger; import info.textgrid.middleware.oaipmh.RequestType; /** * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2021-07-21 + * @version 2022-08-29 * @since 2019-03-07 */ public abstract class RecordDelivererAbstract implements RecordDelivererInterface { + protected static Logger log = Logger.getLogger(RecordDelivererAbstract.class.getName()); + protected boolean textgrid; protected boolean dariah; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java index 7265c593b48c2d05ad608281d79524a1bfc3f9b0..94983b821c2dcd00a16655fb3e9d969d05807ca6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java @@ -5,16 +5,19 @@ import java.io.StringReader; import java.text.ParseException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import org.classicmayan.tools.ClassicMayanMetsMods; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.common.Strings; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; +import org.json.JSONException; import org.json.JSONObject; import org.springframework.stereotype.Component; import org.w3c.dom.Document; import org.xml.sax.InputSource; +import org.xml.sax.SAXException; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.MetadataType; @@ -23,7 +26,7 @@ import info.textgrid.middleware.oaipmh.RecordType; /** * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2022-08-17 + * @version 2022-08-29 * @since 2019-03-12 */ @Component @@ -109,42 +112,47 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { GetRecordType grt = new GetRecordType(); + log.fine("identifier: " + id); + setDatestamps(id); - String textgridBaseURI_FromID; + + // Get TG URI and TG base URI from ID. + String tgURI = id; if (!id.startsWith("textgrid:")) { - textgridBaseURI_FromID = "textgrid:" + id.replace(".0", ""); - } else { - textgridBaseURI_FromID = id; + tgURI = "textgrid:" + id; } + String tgBaseURI = tgURI; + // FIXME Why we only replace ".0" here?? + tgBaseURI = tgBaseURI.replace(".0", ""); + + log.fine("tg uri/base uri: " + tgURI + "/" + tgBaseURI); + + log.fine("object type is: " + this.getObjectType()); + if (this.getObjectType().equals("ARTEFACT")) { this.metsmods = new ClassicMayanMetsMods( - textgridBaseURI_FromID, + tgBaseURI, this.dateOfObjectCreation, this.dateOfLastOblectModification); this.record.setMetadata(idiomMets()); } else if (this.getObjectType().startsWith("ConedaKorMediumData")) { - GetRecordType idi = new IDIOMImages().getRecordById(id); - // Fixes #64 if (idi != null) { this.record = idi.getRecord(); } } - // See that IDs begin with "textgrid:" - String identifierToSet = ""; - if (!id.startsWith("textgrid:")) { - identifierToSet = "textgrid:" + id; - } else { - identifierToSet = id; - } - // See, that IDs have NO revision number. + // FIXME Why we replace ALL revision numbers here?? Is there a difference to tgBaseURI with ".0" + // and ".n"?? + String identifierToSet = tgURI; if (identifierToSet.contains(".")) { identifierToSet = identifierToSet.substring(0, identifierToSet.indexOf(".")); } + log.fine("identifier to set: " + identifierToSet); + // No setSpec needed here! String setSpec = ""; HeaderType header = @@ -178,7 +186,10 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(this.metsmods.getMets()))); metadataMets.setAny(doc.getDocumentElement()); - } catch (Exception e) { + } catch (JSONException | SAXException | IOException | ParseException + | ParserConfigurationException e) { + // TODO Auto-generated catch block + log.severe("error! " + e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java index acc4eaf31867d24f807486a2002b8fc6dae451c0..50a20dbee46d76fe39c9f9c0926d059bc8ccf946 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java @@ -42,7 +42,7 @@ public class OaiPmhTextgridOnlineTests { // ** private static final String PROPERTIES_FILE = "oaipmh.test.textgridlab-org.properties"; - // NOTE/TODO There is NO IDIOM test data for testing on dev.textgridlab.org! So eventually all + // TODO There is NO IDIOM test data for testing on dev.textgridlab.org! So eventually all // IDIOM tests will fail! // private static final String PROPERTIES_FILE = "oaipmh.test.dev-textgridlab-org.properties"; diff --git a/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties b/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties index da78cecb493c6091927b888d0c4ce1513a2377fd..db6888109fc0ed7c5f48682154ff60f33f9b0951 100644 --- a/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties +++ b/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties @@ -8,7 +8,7 @@ expectedGetRecordDC = Heidi checkGetRecordIDIOM = textgrid:2sg18.0 expectedGetRecordIDIOM = Aguateca checkGetRecordIDIOM_Images = textgrid:3x641.0 -expectedGetRecordIDIOM_Images = Acanceh +expectedGetRecordIDIOM_Images = Aguateca checkGetRecordDATACITE = textgrid:mq05.0 expectedGetRecordDATACITE = Weise Klugredenn checkGetRecordIDList = textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0, textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0