diff --git a/pom.xml b/pom.xml
index 599d76f..80aab44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,6 +12,7 @@
UTF-8
../guidelines-cris-managers
+ 2.23.1
org.eurocris.openaire.cris.validator.CRISValidator
17
@@ -37,6 +38,27 @@
2.3.8
runtime
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${logger.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${logger.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ ${logger.version}
+
+
+ com.lmax
+ disruptor
+ 4.0.0
+
diff --git a/src/main/java/org/eurocris/openaire/cris/validator/CRISValidator.java b/src/main/java/org/eurocris/openaire/cris/validator/CRISValidator.java
index 51dd8c4..b0b7769 100644
--- a/src/main/java/org/eurocris/openaire/cris/validator/CRISValidator.java
+++ b/src/main/java/org/eurocris/openaire/cris/validator/CRISValidator.java
@@ -60,6 +60,8 @@
import org.openarchives.oai._2.SetType;
import org.openarchives.oai._2.StatusType;
import org.openarchives.oai._2_0.oai_identifier.OaiIdentifierType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
@@ -77,6 +79,8 @@
@FixMethodOrder( value=MethodSorters.NAME_ASCENDING )
public class CRISValidator {
+ private static final Logger logger = LoggerFactory.getLogger(CRISValidator.class);
+
/**
* The spec of the set of equipments.
*/
@@ -221,7 +225,7 @@ private static Schema getSchema( final StreamSource ... sources ) throws IOExcep
final String targetNamespace = doc.getDocumentElement().getAttribute( "targetNamespace" );
schemaUrlsByNs.put( targetNamespace, schemaUrl );
nssBySchemaUrl.put( schemaUrl, targetNamespace );
- System.out.println( "Will use " + schemaUrl + " for namespace " + targetNamespace );
+ logger.info( "Will use " + schemaUrl + " for namespace " + targetNamespace );
}
return getXmlSchemaFactory().newSchema( schemaList.toArray( new Source[0] ) );
}
@@ -382,7 +386,7 @@ public void check010_MetadataFormats() throws Exception {
} );
final long nMetadataFormats = checker.run();
final int nOpenAireMetadataFormats = metadataFormatsByPrefix.size();
- System.out.println( "Having " + nOpenAireMetadataFormats + " OpenAIRE CRIS metadata formats (out of the total " + nMetadataFormats + " metadata formats)" );
+ logger.info( "Having " + nOpenAireMetadataFormats + " OpenAIRE CRIS metadata formats (out of the total " + nMetadataFormats + " metadata formats)" );
}
private CheckingIterable wrapCheckMetadataFormatPresent( final CheckingIterable parent ) {
@@ -396,7 +400,7 @@ public boolean test( final MetadataFormatType mf ) {
try {
final DocumentBuilder db = getDocumentBuilderFactory().newDocumentBuilder();
final String schemaUrl = mf.getSchema();
- System.out.println( "Metadata format prefix " + mf.getMetadataPrefix() + " with ns " + mf.getMetadataNamespace() );
+ logger.info( "Metadata format prefix " + mf.getMetadataPrefix() + " with ns " + mf.getMetadataNamespace() );
assertTrue( "Please reference the official XML Schema at " + OPENAIRE_CERIF_SCHEMAS_ROOT + " (2h)", schemaUrl.startsWith( OPENAIRE_CERIF_SCHEMAS_ROOT ) );
assertTrue( "The schema file should be " + OPENAIRE_CERIF_SCHEMA_FILENAME + " (2i)", schemaUrl.endsWith( "/" + OPENAIRE_CERIF_SCHEMA_FILENAME ) );
final String localSchemaUrl = schemaUrlsByNs.get( metadataNs );
@@ -729,7 +733,7 @@ public void error( final SAXParseException exception ) throws SAXException {
final String msg = exception.getMessage();
if ( msg.startsWith( "cvc-pattern-valid: " ) ) {
patternValidErrorSignalled = true;
- System.err.println( "In " + elString + ": " + msg );
+ logger.error( "In " + elString + ": " + msg );
} else {
if (!( patternValidErrorSignalled && msg.startsWith( "cvc-complex-type.2.2: " ) )) {
throw exception;
diff --git a/src/main/java/org/eurocris/openaire/cris/validator/OAIPMHEndpoint.java b/src/main/java/org/eurocris/openaire/cris/validator/OAIPMHEndpoint.java
index d4d675d..35c8f65 100644
--- a/src/main/java/org/eurocris/openaire/cris/validator/OAIPMHEndpoint.java
+++ b/src/main/java/org/eurocris/openaire/cris/validator/OAIPMHEndpoint.java
@@ -40,6 +40,8 @@
import org.openarchives.oai._2.ResumptionTokenType;
import org.openarchives.oai._2.SetType;
import org.openarchives.oai._2_0.oai_identifier.OaiIdentifierType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
/**
@@ -48,6 +50,8 @@
* @author jdvorak
*/
public class OAIPMHEndpoint {
+
+ private static final Logger logger = LoggerFactory.getLogger(OAIPMHEndpoint.class);
private final String baseUrl;
@@ -200,7 +204,7 @@ public Iterable callListIdentifiers( final String metadataFormatPref
@SuppressWarnings( "unchecked")
private OAIPMHtype makeConnection( final boolean repoWideRequest, final String verb, final String... params ) throws IOException, SAXException, JAXBException {
final URL url = makeUrl( verb, params );
- System.out.println( "Fetching and validating " + url.toExternalForm() );
+ logger.info( "Fetching and validating " + url.toExternalForm() );
final URLConnection conn = handleCompression( url.openConnection() );
conn.setRequestProperty( "User-Agent", userAgent );
conn.setRequestProperty( "Accept", "text/xml, application/xml" );
@@ -239,7 +243,7 @@ private void checkContentTypeHeader( final URLConnection conn ) {
// in the light of RFC7303 section 9.2 we accept "application/xml" as equivalent
final String contentType = conn.getContentType();
if (!( contentType.startsWith( "text/xml" ) || contentType.startsWith( "application/xml" ) )) {
- System.err.println( "The Content-Type doesn't start with 'text/xml' or 'application/xml': " + contentType );
+ logger.error( "The Content-Type doesn't start with 'text/xml' or 'application/xml': " + contentType );
}
}
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..60c6271
--- /dev/null
+++ b/src/main/resources/log4j2.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file