From 85a9090223af7c7519e188d0b24c25f66aa18430 Mon Sep 17 00:00:00 2001 From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:51:46 +0100 Subject: [PATCH] Added logs for context commit/abort/init and eperson init (#831) --- dspace-api/src/main/java/org/dspace/core/Context.java | 9 +++++++++ dspace-api/src/main/java/org/dspace/eperson/EPerson.java | 4 +++- dspace/config/log4j2.xml | 2 +- dspace/config/modules/authentication.cfg | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/core/Context.java b/dspace-api/src/main/java/org/dspace/core/Context.java index 8eed24348c39..5b0ac9b2bb67 100644 --- a/dspace-api/src/main/java/org/dspace/core/Context.java +++ b/dspace-api/src/main/java/org/dspace/core/Context.java @@ -169,6 +169,7 @@ public Context(Mode mode) { * Initializes a new context object. */ protected void init() { + log.info("Initializing new context, mode: {}", mode); updateDatabase(); if (eventService == null) { @@ -392,6 +393,7 @@ public String getExtraLogInfo() { * or closing the connection */ public void complete() throws SQLException { + log.info("Completing context."); // If Context is no longer open/valid, just note that it has already been closed if (!isValid()) { log.info("complete() was called on a closed Context object. No changes to commit."); @@ -405,9 +407,12 @@ public void complete() throws SQLException { commit(); } } finally { + log.info("Going to close a connection."); if (dbConnection != null) { + log.info("Closing connection."); // Free the DB connection and invalidate the Context dbConnection.closeDBConnection(); + log.info("Connection closed."); dbConnection = null; } } @@ -584,6 +589,7 @@ public void rollback() throws SQLException { * is a no-op. */ public void abort() { + log.info("Aborting context."); // If Context is no longer open/valid, just note that it has already been closed if (!isValid()) { log.info("abort() was called on a closed Context object. No changes to abort."); @@ -599,9 +605,12 @@ public void abort() { log.error("Error rolling back transaction during an abort()", se); } finally { try { + log.info("Going to close a connection."); if (dbConnection != null) { + log.info("Closing connection."); // Free the DB connection & invalidate the Context dbConnection.closeDBConnection(); + log.info("Connection closed."); dbConnection = null; } } catch (Exception ex) { diff --git a/dspace-api/src/main/java/org/dspace/eperson/EPerson.java b/dspace-api/src/main/java/org/dspace/eperson/EPerson.java index 3244a25018f7..3466b7a4dcda 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/EPerson.java +++ b/dspace-api/src/main/java/org/dspace/eperson/EPerson.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.Logger; import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObjectLegacySupport; import org.dspace.content.Item; @@ -43,6 +44,7 @@ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy") @Table(name = "eperson") public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport { + private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(EPerson.class); @Column(name = "eperson_id", insertable = false, updatable = false) private Integer legacyId; @@ -122,7 +124,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport { * {@link org.dspace.eperson.service.EPersonService#create(Context)} */ protected EPerson() { - + log.info("EPerson created"); } @Override diff --git a/dspace/config/log4j2.xml b/dspace/config/log4j2.xml index a21cef9d6f3e..ef54dd66a1e2 100644 --- a/dspace/config/log4j2.xml +++ b/dspace/config/log4j2.xml @@ -31,7 +31,7 @@ + pattern='%d %t %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/> yyyy-MM-dd diff --git a/dspace/config/modules/authentication.cfg b/dspace/config/modules/authentication.cfg index 451cdbbbf7bb..cd6df7e5da38 100644 --- a/dspace/config/modules/authentication.cfg +++ b/dspace/config/modules/authentication.cfg @@ -85,7 +85,7 @@ jwt.login.encryption.enabled = false jwt.login.compression.enabled = true # Expiration time of a token in milliseconds -jwt.login.token.expiration = 1800000 +jwt.login.token.expiration = 24000 #---------------------------------------------------------------# #---Stateless JWT Authentication for downloads of bitstreams----#