Skip to content
Snippets Groups Projects
Commit 20ac36c9 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Improve logging

parent 24ac3dda
No related branches found
No related tags found
No related merge requests found
......@@ -5,13 +5,13 @@
<parent>
<artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>3.3.3.1-ES6-SNAPSHOT</version>
<version>3.3.3.1-ES6-SNAPSHOT</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-core</artifactId>
<packaging>jar</packaging>
<name>DARIAHDE :: OAI-PMH DataProvider :: Core</name>
<url>https://projects.gwdg.de/projects/oai-pmh</url>
<url>https://projects.gwdg.de/projects/oai-pmh</url>
<dependencies>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
......@@ -23,7 +23,7 @@
<artifactId>const</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<dependency>
<groupId>info.textgrid.utils</groupId>
<artifactId>httpclients</artifactId>
<version>${common.version}</version>
......@@ -74,22 +74,28 @@
<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> -->
<!-- <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>
......@@ -107,18 +113,18 @@
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.12</version>
</dependency>
</dependencies>
......
......@@ -2,10 +2,10 @@ package info.textgrid.middleware;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
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;
......@@ -37,12 +37,14 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType;
public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
private Log log = LogFactory.getLog(SetDeliverer.class);
private static final int lifeTimeResToken = 100;
private static final String DH_ES_DIVIDER_CHAR = ".";
private static final String DH_ES_DIVIDER_REGEXP = "\\.";
private static org.apache.commons.logging.Log log =
LogFactory.getLog(IdentifierListDelivererDC.class);
// private static org.apache.commons.logging.Log log =
// LogFactory.getLog(IdentifierListDelivererDC.class);
public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>();
private String datestamp;
......@@ -165,12 +167,12 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
long size = listFurtherValues.getHits().totalHits;
setResultSize(size);
// System.out.println(" ## hits --> " + size);
log.info(" ## hits --> " + size);
for (SearchHit hit : listFurtherValues.getHits().getHits()) {
i++;
// System.out.println(" ## hit --> " + hit.getId());
this.log.info(" ## hit --> " + hit.getId());
// Handle TextGrid.
if (this.textgrid) {
......@@ -178,10 +180,10 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString();
try {
datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat();
} catch (ParseException e1) {
log.debug(e1);
} catch (DatatypeConfigurationException e1) {
log.debug(e1);
} catch (ParseException e) {
this.log.error(e.getMessage());
} catch (DatatypeConfigurationException e) {
this.log.error(e.getMessage());
}
String identifier = hit.getSourceAsMap().get(this.identifierField).toString();
lit = setListIdentifierHeader(datestamp, identifier, lit, set);
......@@ -190,7 +192,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
// Handle DARIAH.
else if (this.dariah) {
// System.out.println(" ## dateOfObjectCreation --> " + this.dateOfObjectCreation);
this.log.info(" ## dateOfObjectCreation --> " + this.dateOfObjectCreation);
JSONObject json = new JSONObject(hit.getSourceAsMap());
......@@ -199,46 +201,47 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
this.datestamp = OAIPMHUtilities.fieldLoader(json, this.dateOfObjectCreation);
// // Divide object.
// String dateOfObjectCreationEntries[] =
// this.dateOfObjectCreation.split(DH_ES_DIVIDER_REGEXP);
//
// // System.out.println(" ## divider --> " + DH_ES_DIVIDER_CHAR);
// // System.out.println(" ## length of dOOCD --> " + dateOfObjectCreationEntries.length);
// // System.out.println(" ## dOOCD --> " + dateOfObjectCreationEntries);
//
// if (dateOfObjectCreationEntries.length != 2) {
// // FIXME Go to ERROR state!
// } else {
// String prefix = dateOfObjectCreationEntries[0];
// String suffix = dateOfObjectCreationEntries[1];
//
// if (hit.getSourceAsMap().containsKey(prefix)) {
//
// HashMap<String, Object> prefixMap =
// (HashMap<String, Object>) hit.getSourceAsMap().get(prefix);
//
// // System.out.println(" ## prefix value (" + prefix + ") --> " + prefixMap);
//
// this.datestamp = prefixMap.get(suffix).toString();
// }
// }
// // Divide object.
// String dateOfObjectCreationEntries[] =
// this.dateOfObjectCreation.split(DH_ES_DIVIDER_REGEXP);
//
// // System.out.println(" ## divider --> " + DH_ES_DIVIDER_CHAR);
// // System.out.println(" ## length of dOOCD --> " + dateOfObjectCreationEntries.length);
// // System.out.println(" ## dOOCD --> " + dateOfObjectCreationEntries);
//
// if (dateOfObjectCreationEntries.length != 2) {
// // FIXME Go to ERROR state!
// } else {
// String prefix = dateOfObjectCreationEntries[0];
// String suffix = dateOfObjectCreationEntries[1];
//
// if (hit.getSourceAsMap().containsKey(prefix)) {
//
// HashMap<String, Object> prefixMap =
// (HashMap<String, Object>) hit.getSourceAsMap().get(prefix);
//
// // System.out.println(" ## prefix value (" + prefix + ") --> " + prefixMap);
//
// this.datestamp = prefixMap.get(suffix).toString();
// }
// }
} else {
this.datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString();
}
// Convert datestamp.
try {
// System.out.println(" ## datestamp --> " + this.datestamp);
this.log.info(" ## datestamp --> " + this.datestamp);
this.datestamp = OAIPMHUtilities.convertDateFormat(this.datestamp).toXMLFormat();
// System.out.println(" ## datestamp converted --> " + this.datestamp);
this.log.info(" ## datestamp converted --> " + this.datestamp);
} catch (ParseException e) {
log.debug(e);
this.log.error(e.getMessage());
// FIXME Go to ERROR state!
} catch (DatatypeConfigurationException e) {
log.debug(e);
this.log.error(e.getMessage());
// FIXME Go to ERROR state!
}
......@@ -247,35 +250,35 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract {
if (this.identifierField.contains(DH_ES_DIVIDER_CHAR)) {
identifier = OAIPMHUtilities.fieldLoader(json, this.identifierField);
// // Divide object.
// String identifierEntries[] = this.identifierField.split(DH_ES_DIVIDER_REGEXP);
//
// // System.out.println(" ## divider --> " + DH_ES_DIVIDER_CHAR);
// // System.out.println(" ## length of iE --> " + identifierEntries.length);
// // System.out.println(" ## iE --> " + identifierEntries);
//
// if (identifierEntries.length != 2) {
// // FIXME Go to ERROR state!
// } else {
// String prefix = identifierEntries[0];
// String suffix = identifierEntries[1];
//
// if (hit.getSourceAsMap().containsKey(prefix)) {
//
// HashMap<String, Object> prefixMap =
// (HashMap<String, Object>) hit.getSourceAsMap().get(prefix);
//
// // System.out.println(" ## prefix value (" + prefix + ") --> " + prefixMap);
//
// identifier = prefixMap.get(suffix).toString();
// }
// }
// // Divide object.
// String identifierEntries[] = this.identifierField.split(DH_ES_DIVIDER_REGEXP);
//
// // System.out.println(" ## divider --> " + DH_ES_DIVIDER_CHAR);
// // System.out.println(" ## length of iE --> " + identifierEntries.length);
// // System.out.println(" ## iE --> " + identifierEntries);
//
// if (identifierEntries.length != 2) {
// // FIXME Go to ERROR state!
// } else {
// String prefix = identifierEntries[0];
// String suffix = identifierEntries[1];
//
// if (hit.getSourceAsMap().containsKey(prefix)) {
//
// HashMap<String, Object> prefixMap =
// (HashMap<String, Object>) hit.getSourceAsMap().get(prefix);
//
// // System.out.println(" ## prefix value (" + prefix + ") --> " + prefixMap);
//
// identifier = prefixMap.get(suffix).toString();
// }
// }
} else {
identifier = hit.getSourceAsMap().get(this.identifierField).toString();
}
// System.out.println(" ## identifier --> " + identifier);
this.log.info(" ## identifier --> " + identifier);
lit = setListIdentifierHeader(this.datestamp, identifier, lit, set);
}
......
......@@ -2,6 +2,8 @@ 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 org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
......@@ -25,6 +27,8 @@ import info.textgrid.middleware.oaipmh.SetType;
*/
public class SetDeliverer {
private Log log = LogFactory.getLog(SetDeliverer.class);
private static final int DH_SIZE = 100000;
private static final String DH_COLLECTION_FILTER_NAME = "collectionFilter";
......@@ -134,18 +138,19 @@ public class SetDeliverer {
request.source(searchSourceBuilder);
// System.out.println(" ## SetDeliverer() request --> " + request);
this.log.info(" ## SetDeliverer() request --> " + request);
// Get items with TG or DH request.
SearchResponse getRecordListItems = null;
try {
getRecordListItems = OAI_ESClient.getEsClient().search(request, RequestOptions.DEFAULT);
// System.out.println(
// " ## SetDeliverer() list item count --> " + getRecordListItems.getHits().totalHits);
this.log
.info(" ## SetDeliverer() list item count --> " + getRecordListItems.getHits().totalHits);
} catch (IOException e) {
// TODO Auto-generated catch block
this.log.error(e.getMessage());
e.printStackTrace();
}
......@@ -187,7 +192,7 @@ public class SetDeliverer {
String name = entry.getKey();
// System.out.println(" ## entry key --> " + entry.getKey());
this.log.info(" ## entry key --> " + entry.getKey());
if (name.equals(DH_COLLECTION_FILTER_NAME)) {
Filter filterCollection =
......@@ -198,16 +203,16 @@ public class SetDeliverer {
// Divide ID and title.
String combined = b.getKeyAsString();
// System.out.println(" ## combined --> " + combined);
this.log.info(" ## combined --> " + combined);
int indexOf = combined.indexOf(DH_FIELD_DIVIDER);
String id = combined.substring(0, indexOf);
// System.out.println(" ## id --> " + id);
this.log.info(" ## id --> " + id);
String title = combined.substring(indexOf + 1);
// System.out.println(" ## title --> " + title);
this.log.info(" ## title --> " + title);
// Set set.
SetType newSet = new SetType();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment