Skip to content

Commit

Permalink
chore: upgrade to spring 6 (#18314)
Browse files Browse the repository at this point in the history
* chore: upgrade spring 6

* replace httpclient with httpclient5

* fix: setReadTimeOut is removed

* fix use jakarta adapter for ActiveMQ lib

* fix HttpStatusCode

* upgrade spring-security to 6.3.1

* upgrade jakarta-persistence-api 3.2.0

* replace hibernate-types with hypersistence-utils

* Fix CommonsMultipartFile

* fix micrometer-hibernate

* exclude hibernate-core dependency

* fix jasperreport jakarta

* upgrade tomcat-embed-core to 10.1.28

* upgrade jetty to 12.0.12

* minor fix

* Add DhisPersistenceUnitManager and DhisPersistenceUnitInfo

* fix programruleaction.notificationtemplateid type in database

* fix spring security conflicts

* fix prometheus conflicts

* remove redundant class

* merge from master

* merge from master

* merge from master

* remove redundant hibernate config

* fix HttpUtils

* fix maven dependency issues

* fix maven dependency issues

* fix BulkSmsGatewayTest

* merge from master

* fix TrackedEntityAttributeStoreTest

* revert javax package fix

* fix cors config for spring security 6

* merge from master

* merge from master

* clear cache

* fix setUseTrailingSlashMatch issue

* merge from master

* fix CustomRequestMappingHandlerMapping

* fix ContentNegotiationManager in test

* fix: hibernate configs

* fix messageSender test

* merge from masterwq

* fix HibernateApiTrackedEntityAuditStorewq

* fix messageSender in test config

* merge from master

* merge from master

* fix dataSource bean config

* replace @EnableMethodSecurity

* fix messageSender bean wiring

* fix flyway migration

* fix emailMessageSender wiring

* fix emailMessageSender in test

* fix DataApprovalControllerTest

* fix MessageSender bean autowire issue

* fix merge conflicts

* fix code formats

* fix maven dependency issue

* fix merge conflicts

* fix maven dependency

* fix tracker tests

* fix NodeService bean injection

* code format

* code format

* Disable test testDeleteWithException

* fix test

* revert debug log

* fix: fix ecache issue with DataDimensionTypeUserType

* fix jakarta in TrailingSlashInterceptor

* fix: remove usage of requires_new

* Change tomcat version

* fix test

* fix: revert remove usage of requires_new, except for jobs

* fix HttpStatusCode

* fix deps

* fix job update status

* code format

* fix systemSettings api content-type

* code format

* code format

* code format

* chore: Fix file resource multipart upload test

* chore: fix formatting

* fix: wrong charset in content-type headers

* fix: remove merge artifacts

* fix: merge artifacts

* fix: fake message sender refactorings

* code format

* fix sonarcloud issue

* fix sonarcloud issue

* chore: adjust sms related

* fix: adjust sms test

* fix: adjust sms test

* add jobSchedulerService.createThenExecute method

* code format

* remove entityManager.getReference in HibernateIdentifiableObjectStore

* fix sonar issues

* fix merge conflicts

* code format

* fix DhisCorsFilter

* remove interface FakeMessageSender

* fix DhisCorsProcessor

* revert build.sh

* temp amend jenkins dev file for pipeline test

* update docker build image to use tomcat 10 to test pipeline

* update root pom to tomcat 10 to test pipeline

* update jenkins dev to tomcat 10 to test pipeline

* uncomment code in jenkins dev file after testing

* format

---------

Co-authored-by: Morrten Svanaes <[email protected]>
Co-authored-by: Enrico <[email protected]>
Co-authored-by: David Mackessy <[email protected]>
Co-authored-by: Jan Bernitt <[email protected]>
  • Loading branch information
5 people authored Oct 3, 2024
1 parent 942cd60 commit 2097f7e
Show file tree
Hide file tree
Showing 516 changed files with 2,601 additions and 1,535 deletions.
2 changes: 1 addition & 1 deletion dhis-2/build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jdk_version="$(
echo "$stable_versions_json" |
jq -r --argjson major "$major" '.versions[] | select(.version == $major) .jdk'
)"
BASE_IMAGE="${BASE_IMAGE:-"tomcat:9.0-jre$jdk_version"}"
BASE_IMAGE="${BASE_IMAGE:-"tomcat:10.0-jre$jdk_version"}"

build_main_image

Expand Down
Empty file modified dhis-2/build.sh
100755 → 100644
Empty file.
18 changes: 9 additions & 9 deletions dhis-2/dhis-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
Expand Down Expand Up @@ -117,18 +121,14 @@
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<artifactId>hibernate-core-jakarta</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -139,8 +139,8 @@
<artifactId>gt-opengis</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>

<!-- SMPP -->
Expand Down Expand Up @@ -186,8 +186,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
* @author Lars Helge Overland
*/
public class ObjectDeletionRequestedEvent extends ApplicationEvent {

/** Should rollback the transaction if DeleteNotAllowedException is thrown */
private boolean shouldRollBack = true;
private boolean rollback = true;

// -------------------------------------------------------------------------
// Constructors
Expand All @@ -44,15 +45,16 @@ public ObjectDeletionRequestedEvent(Object source) {
super(source);
}

public ObjectDeletionRequestedEvent(Object source, boolean rollback) {
super(source);
this.rollback = rollback;
}

// -------------------------------------------------------------------------
// Getter && Setter
// -------------------------------------------------------------------------

public boolean isShouldRollBack() {
return shouldRollBack;
}

public void setShouldRollBack(boolean shouldRollBack) {
this.shouldRollBack = shouldRollBack;
public boolean isRollback() {
return rollback;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.UniqueConstraint;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
package org.hisp.dhis.fileresource;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;

/** This is simple class to represent the list of possible static image resources. */
@XmlRootElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.util.Objects;
import org.hibernate.Hibernate;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.HibernateProxyHelper;

/**
Expand All @@ -55,15 +54,4 @@ public static Class getRealClass(Object object) {
public static <T> T unproxy(T proxy) {
return (T) Hibernate.unproxy(proxy);
}

public static <T> void initializeAndUnproxy(T entity) {
if (entity == null) {
return;
}

Hibernate.initialize(entity);
if (entity instanceof HibernateProxy) {
((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
*/
package org.hisp.dhis.message;

import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
import org.hisp.dhis.outboundmessage.OutboundMessage;
import org.hisp.dhis.outboundmessage.OutboundMessageBatch;
import org.hisp.dhis.outboundmessage.OutboundMessageResponse;
import org.hisp.dhis.outboundmessage.OutboundMessageResponseSummary;
Expand All @@ -39,6 +41,7 @@
* @author Lars Helge Overland
*/
public interface MessageSender {

/**
* Sends a message. The given message will be sent to the given set of users.
*
Expand Down Expand Up @@ -71,4 +74,14 @@ ListenableFuture<OutboundMessageResponseSummary> sendMessageBatchAsync(

/** To check if given service is configured and ready to use. */
boolean isConfigured();

default List<OutboundMessage> getMessagesByEmail(String recipient) {
return List.of();
}

default void clearMessages() {}

default List<OutboundMessage> getAllMessages() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Map;
import javax.annotation.Nonnull;
import org.hisp.dhis.feedback.ConflictException;
import org.hisp.dhis.feedback.NotFoundException;
import org.hisp.dhis.schema.Property;
import org.hisp.dhis.user.UserDetails;
import org.springframework.util.MimeType;
Expand Down Expand Up @@ -61,6 +62,13 @@ String create(JobConfiguration config, MimeType contentType, InputStream content

void createDefaultJob(JobType type, UserDetails actingUser);

String createInTransaction(
JobConfiguration jobConfiguration, MimeType contentType, InputStream content)
throws ConflictException, NotFoundException;

String createInTransaction(JobConfiguration jobConfiguration)
throws ConflictException, NotFoundException;

/**
* Updates all {@link JobConfiguration}s that are not {@link JobConfiguration#isEnabled()} to
* state {@link JobStatus#DISABLED} in case they are in state {@link JobStatus#SCHEDULED}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public interface JobConfigurationStore extends GenericDimensionalObjectStore<Job
*/
boolean tryRevertNow(@Nonnull String jobId);

boolean executeNow(@Nonnull String jobId);

/**
* A successful update means the DB state flipped from {@link JobStatus#SCHEDULED} to {@link
* JobStatus#RUNNING}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@
*/
package org.hisp.dhis.scheduling;

import java.io.InputStream;
import java.util.List;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.hisp.dhis.common.NonTransactional;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.feedback.ConflictException;
import org.hisp.dhis.feedback.ForbiddenException;
import org.hisp.dhis.feedback.NotFoundException;
import org.hisp.dhis.scheduling.JobProgress.Progress;
import org.springframework.util.MimeType;

/**
* This is the external API (called by users via controller API) for the scheduling.
Expand All @@ -60,6 +63,22 @@ public interface JobSchedulerService {
*/
void executeNow(@Nonnull String jobId) throws ConflictException, NotFoundException;

/**
* Executes a job configuration in a separate transaction.
*
* @param jobId the job id to execute
* @throws NotFoundException
* @throws ConflictException
*/
void runInTransaction(String jobId) throws NotFoundException, ConflictException;

@NonTransactional
void createThenExecute(JobConfiguration config, MimeType contentType, InputStream content)
throws ConflictException, NotFoundException;

@NonTransactional
void createThenExecute(JobConfiguration config) throws ConflictException, NotFoundException;

/**
* Reverts the {@link JobStatus} of the job from {@link JobStatus#RUNNING} to the appropriate
* status after a failed execution. For an ad-hoc job this is {@link JobStatus#DISABLED}, for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
package org.hisp.dhis.security;

import javax.xml.bind.DatatypeConverter;
import jakarta.xml.bind.DatatypeConverter;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.security.core.Authentication;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
package org.hisp.dhis.sms.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
package org.hisp.dhis.user;

import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.hisp.dhis.common.auth.RegistrationParams;
import org.hisp.dhis.common.auth.UserInviteParams;
import org.hisp.dhis.common.auth.UserRegistrationParams;
Expand Down
4 changes: 2 additions & 2 deletions dhis-2/dhis-services/dhis-service-administration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import static java.util.stream.Collectors.toUnmodifiableList;

import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.dataintegrity.DataIntegrityCheck;
import org.hisp.dhis.dataintegrity.DataIntegrityDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
package org.hisp.dhis.merge.dataelement;

import com.google.common.collect.ImmutableList;
import jakarta.persistence.EntityManager;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.common.UID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package org.hisp.dhis.merge.dataelement.handler;

import jakarta.persistence.EntityManager;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -35,7 +36,6 @@
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.dataelement.DataElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers;

import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.dataapproval.DataApprovalAuditService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
package org.hisp.dhis.merge.orgunit.handler;

import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest;
Expand Down
Loading

0 comments on commit 2097f7e

Please sign in to comment.