Skip to content

Commit

Permalink
Switch to slf4j logger
Browse files Browse the repository at this point in the history
This simplifies dependencies.

- update metafix dependency to 0.5.1
  • Loading branch information
dr0i committed Jul 3, 2023
1 parent d8e713e commit ab0d44e
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
git clone https://github.com/metafacture/metafacture-fix.git
cd metafacture-fix
git reset --hard 0.4.0
git reset --hard 0.5.1
./gradlew publishToMavenLocal
cd ..
- name: Build with Maven
Expand Down
33 changes: 7 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<dependency>
<groupId>org.metafacture</groupId>
<artifactId>metafix</artifactId>
<version>0.4.0</version>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>com.github.jsonld-java</groupId>
Expand All @@ -118,11 +118,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
Expand All @@ -132,27 +127,18 @@
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.3</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -178,11 +164,6 @@
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.2</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/hbz/lobid/helper/CompareJsonMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -33,7 +33,7 @@
*/
@SuppressWarnings("javadoc")
public final class CompareJsonMaps {
final static Logger logger = LogManager.getLogger(CompareJsonMaps.class);
final static Logger logger = LoggerFactory.getLogger(CompareJsonMaps.class);
Stack<String> stack = new Stack<>();
static final String JSON_LD_CONTEXT = "[@context";
private static boolean IGNORE_CONTEXT = true;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/hbz/lobid/helper/Etikett.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import javax.xml.bind.annotation.XmlRootElement;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -24,7 +24,7 @@
*/
@XmlRootElement
public class Etikett {
final static Logger logger = LogManager.getLogger(Etikett.class);
final static Logger logger = LoggerFactory.getLogger(Etikett.class);

public enum EtikettType {
CACHE, CONTEXT, STORE
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/hbz/lobid/helper/EtikettMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand All @@ -30,7 +30,7 @@ public class EtikettMaker implements EtikettMakerInterface {
private static final String ID = "id";
private String contextLocation = "web/conf/context.jsonld";

final static Logger logger = LogManager.getLogger(EtikettMaker.class);
final static Logger logger = LoggerFactory.getLogger(EtikettMaker.class);

/**
* A map with URIs as key
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/de/hbz/lobid/helper/HttpPoster.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package de.hbz.lobid.helper;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.*;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;

/**
* Uploads data using {@link URLConnection} with POST method and returns the response.
Expand All @@ -17,7 +21,7 @@ public final class HttpPoster {
public final String POST = "POST";
private String contentType = "application/json";
private URL url;
private static final Logger LOG = LogManager.getLogger(HttpPoster.class);
private static final Logger LOG = LoggerFactory.getLogger(HttpPoster.class);

/**
* Creates an instance of {@link HttpPoster}.
Expand Down
22 changes: 7 additions & 15 deletions src/main/java/org/lobid/resources/ElasticsearchIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.TimeUnit;
import java.util.stream.StreamSupport;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import com.google.common.collect.SortedSetMultimap;
import com.google.common.collect.TreeMultimap;
import com.google.gdata.util.common.base.Pair;
import com.google.gdata.util.common.io.CharStreams;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
Expand All @@ -46,15 +42,12 @@
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

import org.metafacture.framework.ObjectReceiver;
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
Expand All @@ -71,8 +64,7 @@
public class ElasticsearchIndexer
extends DefaultObjectPipe<HashMap<String, String>, ObjectReceiver<Void>> {

private static final Logger LOG =
LogManager.getLogger(ElasticsearchIndexer.class);
private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchIndexer.class);
private String hostname;
private String clustername;
private BulkRequestBuilder bulkRequest;
Expand Down Expand Up @@ -227,7 +219,7 @@ public void process(final HashMap<String, String> json) {
LOG.warn("Retry indexing record" + json.get(Properties.ID.getName())
+ ":" + e.getMessage() + " (" + retries + " more retries)");
} catch (final Exception ex) {
LOG.warn(ex);
LOG.warn(ex.getMessage());
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/lobid/resources/EtikettJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

import com.github.jsonldjava.utils.JsonUtils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.metafacture.framework.ObjectReceiver;
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
Expand All @@ -32,7 +33,7 @@
@Out(String.class)
public final class EtikettJson
extends DefaultObjectPipe<String, ObjectReceiver<String>> {
private static final Logger LOG = LogManager.getLogger(EtikettJson.class);
private static final Logger LOG = LoggerFactory.getLogger(EtikettJson.class);
private String labelsDirectoryName = "labels";
private String contextFilenameLocation;
private boolean generateContext = false;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/lobid/resources/JsonLdEtikett.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.metafacture.framework.ObjectReceiver;
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
Expand All @@ -27,7 +28,7 @@
@Out(HashMap.class)
public final class JsonLdEtikett extends
DefaultObjectPipe<Map<String, Object>, ObjectReceiver<Map<String, Object>>> {
private static final Logger LOG = LogManager.getLogger(JsonLdEtikett.class);
private static final Logger LOG = LoggerFactory.getLogger(JsonLdEtikett.class);
private static String labelsDirectoryName = "labels";
private static String contextFilenameLocation = "web/conf/context.jsonld";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.util.stream.Stream;

import de.hbz.lobid.helper.HttpPoster;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lobid.resources.ElasticsearchIndexer;
import org.lobid.resources.EtikettJson;
import org.lobid.resources.JsonToElasticsearchBulkMap;
Expand All @@ -28,6 +26,9 @@
import org.metafacture.xml.XmlElementSplitter;
import org.metafacture.metafix.Metafix;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.hbz.lobid.helper.Email;

/**
Expand Down Expand Up @@ -57,8 +58,7 @@ public class AlmaMarcXmlFix2lobidJsonEs {
private static String triggerWebhookData;
private static String kind = "";
private static boolean switchAutomatically = false;
private static final Logger LOG =
LogManager.getLogger(AlmaMarcXmlFix2lobidJsonEs.class);
private static final Logger LOG = LoggerFactory.getLogger(AlmaMarcXmlFix2lobidJsonEs.class);
public static boolean threadAlreadyStarted = false;
private static String switchAlias1;
private static String switchAlias2;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/lobid/resources/run/SwitchEsAlmaAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -34,8 +35,7 @@ public final class SwitchEsAlmaAlias {
private static final int DOCS_MINIMUM = 83000000;
private static final int BYTES_MINIMUM = 49 * 1024 * 1024 * 1024;
private static ObjectMapper objectMapper = new ObjectMapper();
private static final Logger LOG =
LogManager.getLogger(SwitchEsAlmaAlias.class);
private static final Logger LOG = LoggerFactory.getLogger(SwitchEsAlmaAlias.class);
private static StringBuilder logMessages = new StringBuilder(512);

private SwitchEsAlmaAlias() {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/lobid/resources/run/UpdateAliases.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -40,7 +41,7 @@
*/
public class UpdateAliases {
private static ObjectMapper objectMapper = new ObjectMapper();
private static final Logger LOG = LogManager.getLogger(UpdateAliases.class);
private static final Logger LOG = LoggerFactory.getLogger(UpdateAliases.class);
private static boolean success = false;
private static String logMessage;
private static StringBuilder logMessages = new StringBuilder(512);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hbz.lobid.helper.JsonFileWriter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.metafacture.biblio.marc21.MarcXmlHandler;
Expand All @@ -23,6 +21,9 @@
import org.metafacture.xml.XmlFilenameWriter;
import org.metafacture.metafix.Metafix;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
Expand All @@ -44,7 +45,7 @@ public final class AlmaMarc21XmlToLobidJsonMetafixTest {
private static final File DIRECTORY = new File(DIRECTORY_NAME);
final HashMap<String, String> fixVariables = new HashMap<>();
private static final boolean GENERATE_TESTDATA = System.getProperty("generateTestData", "false").equals("true");
private static final Logger LOG = LogManager.getLogger(AlmaMarc21XmlToLobidJsonMetafixTest.class);
private static final Logger LOG = LoggerFactory.getLogger(AlmaMarc21XmlToLobidJsonMetafixTest.class);
// try patterns like e.g."662", NOT".*662" (which just would slow down)
private static final String PATTERN_TO_IDENTIFY_XML_RECORDS = "";

Expand Down

0 comments on commit ab0d44e

Please sign in to comment.