Skip to content

Commit

Permalink
Added logs for context commit/abort/init and eperson init
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Dec 17, 2024
1 parent 56b4862 commit 7edc451
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions dspace-api/src/main/java/org/dspace/core/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.");
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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.");
Expand All @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion dspace-api/src/main/java/org/dspace/eperson/EPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dspace/config/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- NOTE: The %equals patterns are providing a default value of "unknown" if "correlationID" or
"requestID" are not currently set in the ThreadContext. -->
<Layout type='PatternLayout'
pattern='%d %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/>
pattern='%d %t %-5p %equals{%X{correlationID}}{}{unknown} %equals{%X{requestID}}{}{unknown} %c @ %m%n'/>
<policies>
<policy type='TimeBasedTriggeringPolicy'>yyyy-MM-dd</policy>
</policies>
Expand Down
2 changes: 1 addition & 1 deletion dspace/config/modules/authentication.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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----#
Expand Down

0 comments on commit 7edc451

Please sign in to comment.