diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index efbe416e1180a5d587ece52f9b7acb453d165bdd..c7902dddaae2e736f372b3d55f7dd4ff470d4bc7 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -68,16 +68,6 @@ <version>${junit.version}</version> <scope>test</scope> </dependency> - <!-- <dependency> --> - <!-- <groupId>org.apache.logging.log4j</groupId> --> - <!-- <artifactId>log4j-api</artifactId> --> - <!-- <version>${log4j.version}</version> --> - <!-- </dependency> --> - <!-- <dependency> --> - <!-- <groupId>org.apache.logging.log4j</groupId> --> - <!-- <artifactId>log4j-core</artifactId> --> - <!-- <version>${log4j.version}</version> --> - <!-- </dependency> --> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> 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 b1ded25337031293c42c03ec99bfcdf5d150a4be..0e03d3ad69282867b79093d808e3c2c325469bc6 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java @@ -4,9 +4,8 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.search.SearchHit; @@ -32,16 +31,16 @@ public class DublinCoreFieldLoader { // STATICS // ** - private static Log log = LogFactory.getLog(DublinCoreFieldLoader.class); + private static Logger log = Logger.getLogger(DublinCoreFieldLoader.class.getName()); /** * This function takes the results of the ElasticSearch request and fills the String-Lists with - * the specific values for the dublin core field + * the specific values for the Dublin Core field * * @param responseOfGetRequest result of the ElasticSearch request from a getRequest (Single * Result) - * @param fields String List for the specific dublin core field - * @return String List containing the values for the specific dublin core field + * @param fields String List for the specific Dublin Core field + * @return String List containing the values for the specific Dublin Core field */ /** @@ -69,12 +68,12 @@ public class DublinCoreFieldLoader { } catch (ParseException e) { // FIXME DO NOT USE INVALID DATE HERE! dates.add(responseWorkValues.getField(field).getValue().toString()); - log.debug("Tried to parse date value: " + log.fine("tried to parse date value: " + responseWorkValues.getField(field).getValue().toString()); } catch (DatatypeConfigurationException e) { // FIXME DO NOT USE INVALID DATE HERE! dates.add(responseWorkValues.getField(field).getValue().toString()); - log.debug("Tried to configure date value: " + log.fine("tried to configure date value: " + responseWorkValues.getField(field).getValue().toString()); } } @@ -139,6 +138,7 @@ public class DublinCoreFieldLoader { e.printStackTrace(); } if (nestedMap.get(requestedField[i]) instanceof Map<?, ?>) { + // TODO Comment or remove code! } } if (i == requestedField.length - 1 && 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 10e44f99c741b014048a1e2167f8733fefdaa25d..71f292cb9c61a120ddfa99249895092a583ef8c3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java @@ -4,8 +4,6 @@ import java.io.IOException; import java.text.ParseException; import java.util.Hashtable; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; @@ -29,7 +27,6 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac // STATICS // ** - private static Log log = LogFactory.getLog(IdentifierListDelivererIDIOM.class); protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); // ** @@ -53,6 +50,7 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac * @see info.textgrid.middleware.IdentifierListDelivererAbstract#processIdentifierList(java.lang. * String, java.lang.String, java.lang.String, java.lang.String) */ + @Override public ListIdentifiersType processIdentifierList(final String from, final String to, final String set, final String resumptionToken) throws ParseException, IOException { @@ -65,15 +63,15 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac BoolQueryBuilder both; RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("lastModified").from(from).to(to); - + BoolQueryBuilder test = QueryBuilders.boolQuery() .must(QueryBuilders.matchPhraseQuery("project.id", - "TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318")); + "TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318")); BoolQueryBuilder artefact = QueryBuilders.boolQuery() .must(QueryBuilders.matchPhraseQuery("format", "text/tg.inputform+rdf+xml")) .must(QueryBuilders.matchPhraseQuery("notes", "ARTEFACT")); - + BoolQueryBuilder conedakor = QueryBuilders.boolQuery() .must(QueryBuilders.matchPhraseQuery("format", "application/json")) .must(QueryBuilders.matchPhraseQuery("notes", "ConedaKorMediumData")); @@ -82,7 +80,7 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac both = QueryBuilders.boolQuery().should(artefact).should(conedakor); BoolQueryBuilder bla = QueryBuilders.boolQuery().must(rangeQuery) - .must(test.filter(both)); + .must(test.filter(both)); recordFilterForClassicMayan = bla; 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 9f35a359ac573d5df580ec1fdf8c6a99a3a8ab80..de18f8a2d5fdf092c6bc84112a543a2548c03f84 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -5,14 +5,13 @@ import java.io.StringWriter; import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Logger; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.IdentifyType; @@ -55,7 +54,7 @@ public class OAIPMHImpl implements OAIPMHProducer { // STATICS // ** - private static Log log = LogFactory.getLog(OAIPMHImpl.class); + private static Logger log = Logger.getLogger(OAIPMHImpl.class.getName()); private static ObjectFactory obf = new ObjectFactory(); // ** @@ -788,9 +787,9 @@ public class OAIPMHImpl implements OAIPMHProducer { .convertDateFormat(OAIPMHUtilities.getXMLGregorianCalendarNow().toString()); response.setResponseDate(convertedDateFormat); } catch (ParseException e) { - log.debug("can not parse date format"); + log.severe("can not parse date format"); } catch (DatatypeConfigurationException e) { - log.debug("datatype configuration failed"); + log.severe("datatype configuration failed"); } // Convert the request values. diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java index 190e26a5852632719a7043453dd0c00bf36d592d..6d2200175eb952e39daf4b60268435cf44ad415f 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDATACITE.java @@ -6,9 +6,8 @@ import java.io.InputStream; import java.text.ParseException; import java.util.List; import java.util.Properties; +import java.util.logging.Logger; import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.elasticsearch.common.Strings; import org.json.JSONObject; import org.springframework.stereotype.Component; @@ -59,7 +58,7 @@ import info.textgrid.middleware.oaipmh.Resource.Titles.Title; public class RecordDelivererDATACITE extends RecordDelivererAbstract { // Logger for errors and info - private static Log log = LogFactory.getLog(RecordDelivererDATACITE.class); + private static Logger log = Logger.getLogger(RecordDelivererDATACITE.class.getName()); // Container object for the result of the elasticsearch request. This object contains the source // of the response. @@ -103,6 +102,7 @@ public class RecordDelivererDATACITE extends RecordDelivererAbstract { * * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ + @Override public GetRecordType getRecordById(final String idInElasticSearchIndex) throws ParseException, DatatypeConfigurationException, IOException { @@ -724,7 +724,7 @@ public class RecordDelivererDATACITE extends RecordDelivererAbstract { dateInOpenAireRecord.setDateType(DateType.UPDATED); } } catch (ParseException | DatatypeConfigurationException e) { - log.error("Could not parse date field: " + e.getMessage()); + log.severe("could not parse date field: " + e.getMessage()); } dates.getDate().add(dateInOpenAireRecord); 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 be20b1849a8915116f2abfd5e0b7d731958056ff..fabcf97a5834272258913a66c510bb4dbff9d7b7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -2,9 +2,8 @@ package info.textgrid.middleware; import java.io.IOException; import java.text.ParseException; +import java.util.logging.Logger; import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.Strings; import org.json.JSONObject; @@ -21,7 +20,7 @@ import info.textgrid.middleware.oaipmh.RecordType; @Component public class RecordDelivererDC extends RecordDelivererAbstract { - private static Log log = LogFactory.getLog(RecordDelivererDC.class); + private static Logger log = Logger.getLogger(RecordDelivererDC.class.getName()); /** * @param textgrid @@ -36,6 +35,7 @@ public class RecordDelivererDC extends RecordDelivererAbstract { * * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ + @Override public GetRecordType getRecordById(String id) throws ParseException, DatatypeConfigurationException { @@ -61,7 +61,7 @@ public class RecordDelivererDC extends RecordDelivererAbstract { } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); - log.error("Could not fetch the result of ElasticSearch"); + log.severe("could not fetch the result of elasticsearch"); } if (esResultObject.isExists()) { diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java index 794bb4f4174c8c1eec9c42ac9b9a11456b842db4..d87735bed732cbb3be6bb6a9ff651f859e697fc8 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java @@ -6,9 +6,8 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; @@ -34,7 +33,7 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { // STATICS // ** - private static Log log = LogFactory.getLog(RecordListDelivererDATACITE.class); + private static Logger log = Logger.getLogger(RecordListDelivererDATACITE.class.getName()); protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); /** @@ -51,13 +50,14 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { * @see info.textgrid.middleware.RecordListDelivererInterface#getRecords(java.lang.String, * java.lang.String, java.lang.String, java.lang.String) */ + @Override public ListRecordsType getRecords(String from, String to, String set, String resumptionToken) throws ParseException, IOException { ListRecordsType openAireRecordList = new ListRecordsType(); // Create one RecordDeliverer only, to configure all fields only ONCE. - // FIYME May be solved using spring configuration, but I do not know how! + // FIXME May be solved using spring configuration, but I do not know how! RecordDelivererDATACITE openAireRecord = new RecordDelivererDATACITE(this.textgrid, this.dariah); // Must be done here, as spring does not configure this bean if instantiated with "new". @@ -237,7 +237,7 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { try { cursorCollector.remove(resumptionToken); } catch (NullPointerException couldNotRemove) { - log.debug("Could not remove hash value: " + resumptionToken + " from hash map"); + log.severe("could not remove hash value: " + resumptionToken + " from hash map"); } this.resTokenForResponse.setValue(""); } else { diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java index 0567e0729f208acd8447d2dbb27a3f657bd77cc8..729f9a0327f86e5faa4d9db6de371aadd434f1e3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java @@ -2,8 +2,7 @@ package info.textgrid.middleware; import java.io.IOException; import java.util.Map.Entry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.logging.Logger; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.RequestOptions; @@ -27,7 +26,7 @@ import info.textgrid.middleware.oaipmh.SetType; */ public class SetListDeliverer { - private static Log log = LogFactory.getLog(SetListDeliverer.class); + private static Logger log = Logger.getLogger(SetListDeliverer.class.getName()); private static final int DH_SIZE = 100000; @@ -119,7 +118,7 @@ public class SetListDeliverer { } catch (IOException e) { // TODO Auto-generated catch block - log.error(e.getMessage()); + log.severe(e.getMessage()); e.printStackTrace(); } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/ClassicMayanTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/ClassicMayanTest.java index eda8f96ab65a7879897f2f96474ff772c2b2a2f4..3ee7b137451ac5279cd7cb957d6e6c52f4220d77 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/ClassicMayanTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/ClassicMayanTest.java @@ -19,54 +19,86 @@ import org.xml.sax.SAXException; import info.textgrid.middleware.oaipmh.OAIPMHtype; +/** + * + */ public class ClassicMayanTest { - - @Test - @Ignore - public void testGetRecord() throws JSONException, IOException, SAXException, ParseException, TransformerFactoryConfigurationError, TransformerException{ - IDIOMImages imageList = new IDIOMImages(); - Document document; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - JAXB.marshal(imageList.getRecordById("11480"), new DOMResult(document)); - imageList.printXML(document); - } catch (ParserConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - @Test - @Ignore - public void testGetMediaList() throws JSONException, IOException, ParseException, SAXException, TransformerFactoryConfigurationError, TransformerException{ - - IDIOMImages imageList = new IDIOMImages(); - - imageList.setKindID("1"); - imageList.setPerPage("100"); - imageList.setPageNumber("1"); - - Document document; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - JAXB.marshal(imageList.getRecords(null, null, null, null), new DOMResult(document)); - imageList.printXML(document); - } catch (ParserConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + /** + * @throws JSONException + * @throws IOException + * @throws SAXException + * @throws ParseException + * @throws TransformerFactoryConfigurationError + * @throws TransformerException + */ + @Test + @Ignore + public void testGetRecord() throws JSONException, IOException, SAXException, ParseException, + TransformerFactoryConfigurationError, TransformerException { + + IDIOMImages imageList = new IDIOMImages(); + Document document; + try { + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + JAXB.marshal(imageList.getRecordById("11480"), new DOMResult(document)); + imageList.printXML(document); + } catch (ParserConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } + } + + /** + * @throws JSONException + * @throws IOException + * @throws ParseException + * @throws SAXException + * @throws TransformerFactoryConfigurationError + * @throws TransformerException + */ + @Test + @Ignore + public void testGetMediaList() throws JSONException, IOException, ParseException, SAXException, + TransformerFactoryConfigurationError, TransformerException { + + IDIOMImages imageList = new IDIOMImages(); - @Test - @Ignore - public void testOAIPMHRequest() throws JSONException, IOException, ParseException, SAXException, TransformerFactoryConfigurationError, TransformerException{ - OAIPMHtype request = new OAIPMHtype(); - IDIOMImages imageList = new IDIOMImages(); - - imageList.setKindID("1"); - imageList.setPerPage("100"); - imageList.setPageNumber("1"); - //request.setListRecords(imageList.getAllMedia()); + imageList.setKindID("1"); + imageList.setPerPage("100"); + imageList.setPageNumber("1"); + Document document; + try { + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + JAXB.marshal(imageList.getRecords(null, null, null, null), new DOMResult(document)); + imageList.printXML(document); + } catch (ParserConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } + } + + /** + * @throws JSONException + * @throws IOException + * @throws ParseException + * @throws SAXException + * @throws TransformerFactoryConfigurationError + * @throws TransformerException + */ + @Test + @Ignore + public void testOAIPMHRequest() throws JSONException, IOException, ParseException, SAXException, + TransformerFactoryConfigurationError, TransformerException { + + OAIPMHtype request = new OAIPMHtype(); + IDIOMImages imageList = new IDIOMImages(); + + imageList.setKindID("1"); + imageList.setPerPage("100"); + imageList.setPageNumber("1"); + // request.setListRecords(imageList.getAllMedia()); + } + }