diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 774aa24ba36c5e9769443613840dc62eb4567874..b2712da3b3431369fc216521d038108e3d1ef563 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -74,29 +74,29 @@ <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> -<!-- <dependency> --> -<!-- <groupId>org.slf4j</groupId> --> -<!-- <artifactId>jcl-over-slf4j</artifactId> --> -<!-- <version>${slf4j.version}</version> --> -<!-- <scope>runtime</scope> --> -<!-- </dependency> --> -<!-- <dependency> --> -<!-- <groupId>org.slf4j</groupId> --> -<!-- <artifactId>slf4j-log4j12</artifactId> --> -<!-- <version>${slf4j.version}</version> --> -<!-- <scope>runtime</scope> --> -<!-- </dependency> --> -<!-- <dependency> --> -<!-- <groupId>log4j</groupId> --> -<!-- <artifactId>log4j</artifactId> --> -<!-- <version>1.2.14</version> --> -<!-- </dependency> --> - <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>2.14.1</version> + <!-- <dependency> --> + <!-- <groupId>org.slf4j</groupId> --> + <!-- <artifactId>jcl-over-slf4j</artifactId> --> + <!-- <version>${slf4j.version}</version> --> + <!-- <scope>runtime</scope> --> + <!-- </dependency> --> + <!-- <dependency> --> + <!-- <groupId>org.slf4j</groupId> --> + <!-- <artifactId>slf4j-log4j12</artifactId> --> + <!-- <version>${slf4j.version}</version> --> + <!-- <scope>runtime</scope> --> + <!-- </dependency> --> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.14</version> </dependency> + <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> + <!-- <dependency> --> + <!-- <groupId>org.apache.logging.log4j</groupId> --> + <!-- <artifactId>log4j-core</artifactId> --> + <!-- <version>2.14.1</version> --> + <!-- </dependency> --> <dependency> <groupId>org.classicmayan.tools</groupId> <artifactId>metsModsMapping</artifactId> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java index c66630c815a8d36fb842675c233d6a1b8af1e293..34f7d1bb6335715bef0d7a39315f7647e38b7c8f 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java @@ -37,7 +37,7 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { - private Log log = LogFactory.getLog("info.textgrid.middleware"); + private static Log logger = LogFactory.getLog(IdentifierListDelivererDC.class); private static final int lifeTimeResToken = 100; private static final String DH_ES_DIVIDER_CHAR = "."; @@ -167,12 +167,12 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { long size = listFurtherValues.getHits().totalHits; setResultSize(size); - log.info(" ## hits --> " + size); + logger.info(" ## hits --> " + size); for (SearchHit hit : listFurtherValues.getHits().getHits()) { i++; - this.log.info(" ## hit --> " + hit.getId()); + this.logger.info(" ## hit --> " + hit.getId()); // Handle TextGrid. if (this.textgrid) { @@ -181,9 +181,9 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { try { datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat(); } catch (ParseException e) { - this.log.error(e.getMessage()); + this.logger.error(e.getMessage()); } catch (DatatypeConfigurationException e) { - this.log.error(e.getMessage()); + this.logger.error(e.getMessage()); } String identifier = hit.getSourceAsMap().get(this.identifierField).toString(); lit = setListIdentifierHeader(datestamp, identifier, lit, set); @@ -192,7 +192,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { // Handle DARIAH. else if (this.dariah) { - this.log.info(" ## dateOfObjectCreation --> " + this.dateOfObjectCreation); + this.logger.info(" ## dateOfObjectCreation --> " + this.dateOfObjectCreation); JSONObject json = new JSONObject(hit.getSourceAsMap()); @@ -231,17 +231,17 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { // Convert datestamp. try { - this.log.info(" ## datestamp --> " + this.datestamp); + this.logger.info(" ## datestamp --> " + this.datestamp); this.datestamp = OAIPMHUtilities.convertDateFormat(this.datestamp).toXMLFormat(); - this.log.info(" ## datestamp converted --> " + this.datestamp); + this.logger.info(" ## datestamp converted --> " + this.datestamp); } catch (ParseException e) { - this.log.error(e.getMessage()); + this.logger.error(e.getMessage()); // FIXME Go to ERROR state! } catch (DatatypeConfigurationException e) { - this.log.error(e.getMessage()); + this.logger.error(e.getMessage()); // FIXME Go to ERROR state! } @@ -278,7 +278,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { identifier = hit.getSourceAsMap().get(this.identifierField).toString(); } - this.log.info(" ## identifier --> " + identifier); + this.logger.info(" ## identifier --> " + identifier); lit = setListIdentifierHeader(this.datestamp, identifier, lit, set); } 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 6a77e7848b4ab402ceae46eee75df151eed6234f..0b402b66b88f6cef48c4f26df9087b4d60f3e8bb 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java @@ -29,6 +29,7 @@ import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; @@ -73,6 +74,8 @@ import info.textgrid.middleware.common.TextGridMimetypes; */ public class OAIPMHUtilities { + private static Log logger = LogFactory.getLog(OAIPMHUtilities.class); + // ** // FINALS // ** @@ -112,11 +115,7 @@ public class OAIPMHUtilities { protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - // ** - // STATICS - // ** - - private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); + // private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); /** * @param verb @@ -328,7 +327,7 @@ public class OAIPMHUtilities { final String resumptionToken, Map<String, Integer> cursorCollector, final String scrollID, final int searchResponseSize, final int i) { - log.info("Creating a ResumptionToken:\n " + + logger.debug("Creating a ResumptionToken:\n " + "CompleteListSize: " + completeListSize + "\n" + "ResumptionToken: " + resumptionToken + "\n" + "CursorCollector: " + cursorCollector + "\n" + @@ -471,20 +470,20 @@ public class OAIPMHUtilities { return null; } } else if (fieldPathForESIndex.length == 1) { - + fieldResulsts.add(resultFromGetRequestInES.get(fieldPathForESIndex[i]).toString()); } else { String res = singlePath.get(fieldPathForESIndex[i]).toString(); - if(res.startsWith("[")) { - JSONArray array = new JSONArray(res); - for(int j=0; j<array.length(); j++) { - String find = array.getString(j).toString(); - fieldResulsts.add(find); - } - }else { - fieldResulsts.add(singlePath.get(fieldPathForESIndex[i]).toString()); + if (res.startsWith("[")) { + JSONArray array = new JSONArray(res); + for (int j = 0; j < array.length(); j++) { + String find = array.getString(j).toString(); + fieldResulsts.add(find); + } + } else { + fieldResulsts.add(singlePath.get(fieldPathForESIndex[i]).toString()); } - + } } } @@ -498,10 +497,11 @@ public class OAIPMHUtilities { * @return */ public static String fieldLoader(JSONObject resultFromGetRequestInES, String field) { - - System.out.println("Inside fieldLoader for field: " + field); + String fieldResulst = ""; + System.out.println("Inside fieldLoader for field: " + field); + String[] fieldPathForESIndex = field.split("\\."); JSONObject singlePath = resultFromGetRequestInES; for (int i = 0; i < fieldPathForESIndex.length; i++) { diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java index a3d267f355fc4c96f0fd52653763772280babc4c..64f4017b64f6f8af636f163572cb981c14785538 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java @@ -27,7 +27,7 @@ import info.textgrid.middleware.oaipmh.SetType; */ public class SetDeliverer { - private Log log = LogFactory.getLog("info.textgrid.middleware"); + private static Log logger = LogFactory.getLog(SetDeliverer.class); private static final int DH_SIZE = 100000; @@ -138,19 +138,19 @@ public class SetDeliverer { request.source(searchSourceBuilder); - this.log.info(" ## SetDeliverer() request --> " + request); + logger.info(" ## SetDeliverer() request --> " + request); // Get items with TG or DH request. SearchResponse getRecordListItems = null; try { getRecordListItems = OAI_ESClient.getEsClient().search(request, RequestOptions.DEFAULT); - this.log + logger .info(" ## SetDeliverer() list item count --> " + getRecordListItems.getHits().totalHits); } catch (IOException e) { // TODO Auto-generated catch block - this.log.error(e.getMessage()); + logger.error(e.getMessage()); e.printStackTrace(); } @@ -192,7 +192,7 @@ public class SetDeliverer { String name = entry.getKey(); - this.log.info(" ## entry key --> " + entry.getKey()); + logger.info(" ## entry key --> " + entry.getKey()); if (name.equals(DH_COLLECTION_FILTER_NAME)) { Filter filterCollection = @@ -203,16 +203,16 @@ public class SetDeliverer { // Divide ID and title. String combined = b.getKeyAsString(); - this.log.info(" ## combined --> " + combined); + logger.info(" ## combined --> " + combined); int indexOf = combined.indexOf(DH_FIELD_DIVIDER); String id = combined.substring(0, indexOf); - this.log.info(" ## id --> " + id); + logger.info(" ## id --> " + id); String title = combined.substring(indexOf + 1); - this.log.info(" ## title --> " + title); + logger.info(" ## title --> " + title); // Set set. SetType newSet = new SetType();