Enable creating an API using Spring Web #5

Merged
niat8586 merged 39 commits from spring into develop 2024-11-06 11:23:29 +01:00
Owner

SciPro will have to provide information to the upcoming student portal. Wicket does not have the ability to serve JSON in the usual REST way and is only able to serve HTML. The most common way to write JSON over HTTP API:s in Java is using Spring Web, but currently SciPro uses Guice for dependency injection rather than Spring which makes adding Spring Web a bit more tricky.

This pull request attempts to solve this by doing the following;

  • Replacing Guice with Spring
  • Adding a new API module that uses Spring Web
  • Turning the entire system into a standard Spring Boot web application

The hope is that these changes will bring the following benefits;

  • Harmonize our web stack (Daisy uses Spring and the new lecture hall system is full Spring Boot)
  • Enable easy development of a traditional JSON over HTTP API
  • Ease future recruitment by using the most common Java web frameworks
SciPro will have to provide information to the upcoming student portal. Wicket does not have the ability to serve JSON in the usual REST way and is only able to serve HTML. The most common way to write JSON over HTTP API:s in Java is using Spring Web, but currently SciPro uses Guice for dependency injection rather than Spring which makes adding Spring Web a bit more tricky. This pull request attempts to solve this by doing the following; * Replacing Guice with Spring * Adding a new API module that uses Spring Web * Turning the entire system into a standard Spring Boot web application The hope is that these changes will bring the following benefits; * Harmonize our web stack (Daisy uses Spring and the new lecture hall system is full Spring Boot) * Enable easy development of a traditional JSON over HTTP API * Ease future recruitment by using the most common Java web frameworks
ansv7779 added 17 commits 2024-06-04 10:03:07 +02:00
tozh4728 reviewed 2024-06-04 10:14:08 +02:00
@ -0,0 +1,29 @@
package se.su.dsv.scipro.api;
Owner

Serves as placeholder, will be cleaned up later.

Serves as placeholder, will be cleaned up later.
tozh4728 marked this conversation as resolved
tozh4728 reviewed 2024-06-04 10:37:03 +02:00
@ -43,6 +43,7 @@ public class UserProfileServiceImpl extends AbstractServiceImpl<UserProfile, Lon
}
@Override
@jakarta.transaction.Transactional
Owner

@Transactional should be enough? Why need full qualified annotation name?

@Transactional should be enough? Why need full qualified annotation name?
ansv7779 marked this conversation as resolved
tozh4728 reviewed 2024-06-04 10:46:35 +02:00
@ -0,0 +1,4 @@
package se.su.dsv.scipro.war;
Owner

What's the purpose of this marker interface?

What's the purpose of this marker interface?
tozh4728 marked this conversation as resolved
tozh4728 reviewed 2024-06-04 11:33:49 +02:00
@ -18,2 +30,4 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public abstract class GuiceTest {
Owner

Are we going to change all Guice tests to Spring tests later? Or what is the plan?

Are we going to change all Guice tests to Spring tests later? Or what is the plan?
tozh4728 marked this conversation as resolved
tozh4728 approved these changes 2024-06-04 12:11:49 +02:00
ansv7779 added 3 commits 2024-06-04 16:46:21 +02:00
ansv7779 added 1 commit 2024-06-04 16:48:10 +02:00
ansv7779 requested review from tozh4728 2024-06-11 12:00:12 +02:00
ansv7779 changed title from WIP: Enable creating an API using Spring Web to Enable creating an API using Spring Web 2024-06-11 12:01:10 +02:00
Author
Owner

For some reason new commits are not shown here in the conversation but can be found in the "Commits" tab.

For some reason new commits are not shown here in the conversation but can be found in the "Commits" tab.
ansv7779 added 1 commit 2024-06-11 13:45:12 +02:00
ansv7779 added 1 commit 2024-06-12 13:34:01 +02:00
ansv7779 added 1 commit 2024-07-10 15:13:43 +02:00
# Conflicts:
#	core/src/main/java/modules/CoreModule.java
ansv7779 added 1 commit 2024-09-09 09:56:24 +02:00
ansv7779 reviewed 2024-10-28 13:25:19 +01:00
@ -0,0 +2,4 @@
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.servlet.FilterChain;
Author
Owner

Clean up unused imports

Clean up unused imports
ansv7779 marked this conversation as resolved
ansv7779 reviewed 2024-10-28 13:32:28 +01:00
@ -0,0 +7,4 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
public class UrkundSettingsRepositoryTest extends SpringTest {
Author
Owner

Should extend IntegrationTest instead of SpringTest

Should extend IntegrationTest instead of SpringTest
ansv7779 reviewed 2024-10-28 13:32:58 +01:00
@ -0,0 +16,4 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class UrkundSubmissionRepositoryTest extends SpringTest {
Author
Owner

Should extend IntegrationTest instead of SpringTest

Should extend IntegrationTest instead of SpringTest
ansv7779 added 3 commits 2024-10-28 14:19:54 +01:00
These classes were copied from Spring Data a long time ago. Their existence on the class path confuses Spring Boot into thinking we use Spring Data JPA which we do not.
# Conflicts:
#	core/src/main/java/se/su/dsv/scipro/checklist/ChecklistCategoryRepo.java
#	core/src/main/java/se/su/dsv/scipro/checklist/ChecklistQuestionRepo.java
#	core/src/main/java/se/su/dsv/scipro/file/FileDescriptionRepo.java
#	core/src/main/java/se/su/dsv/scipro/file/ProjectFileServiceImpl.java
#	core/src/main/java/se/su/dsv/scipro/finalseminar/FinalSeminarOppositionRepo.java
#	core/src/main/java/se/su/dsv/scipro/forum/ForumPostReadStateRepository.java
#	core/src/main/java/se/su/dsv/scipro/forum/ForumPostRepository.java
#	core/src/main/java/se/su/dsv/scipro/forum/GroupThreadRepository.java
#	core/src/main/java/se/su/dsv/scipro/forum/ProjectThreadRepository.java
#	core/src/main/java/se/su/dsv/scipro/integration/activityfinalseminar/ActivityFinalSeminarRepository.java
#	core/src/main/java/se/su/dsv/scipro/match/FirstMeetingRepository.java
#	core/src/main/java/se/su/dsv/scipro/milestones/MilestoneActivityTemplateRepository.java
#	core/src/main/java/se/su/dsv/scipro/milestones/service/impl/MilestonePhaseTemplateServiceImpl.java
#	core/src/main/java/se/su/dsv/scipro/peer/CommentThreadRepo.java
#	core/src/main/java/se/su/dsv/scipro/peer/PeerRequestRepository.java
#	core/src/main/java/se/su/dsv/scipro/project/ProjectRepo.java
#	core/src/main/java/se/su/dsv/scipro/system/FooterAddressRepo.java
#	core/src/main/java/se/su/dsv/scipro/system/FooterLinkRepo.java
#	core/src/main/java/se/su/dsv/scipro/system/PasswordRepo.java
#	core/src/main/java/se/su/dsv/scipro/system/UserRepo.java
ansv7779 added 1 commit 2024-10-28 14:55:32 +01:00
ansv7779 added 1 commit 2024-10-28 15:37:02 +01:00
Add the spring-context dependency in core to keep the Spring @Configuration classes in the module as well.

Spring is still well isolated to only those @Configuration classes and the SpringTest base class which is "hidden" via the IntegrationTest subclass.

Some minor @Bean definition juggling had to take place to keep Spring Boot out of core as well as some classes residing in the view module.
ansv7779 added 1 commit 2024-11-04 09:53:08 +01:00
Merge branch 'develop' into spring
All checks were successful
Build and test / build-and-test (push) Successful in 6m51s
a7530fa85c
# Conflicts:
#	core/src/main/java/modules/RepositoryModule.java
#	core/src/main/java/se/su/dsv/scipro/grading/GradingModule.java
#	core/src/main/java/se/su/dsv/scipro/report/GradingReportServiceImpl.java
niat8586 reviewed 2024-11-06 08:56:04 +01:00
@ -0,0 +13,4 @@
public class ApiController {
private final UserService userService;
@Inject
Owner

Is @Inject needed because the UserService is in the core module?

Because normally we don't need to @Inject when doing constructor based injection in Spring

Is @Inject needed because the UserService is in the core module? Because normally we don't need to @Inject when doing constructor based injection in Spring
niat8586 marked this conversation as resolved
niat8586 approved these changes 2024-11-06 11:12:42 +01:00
niat8586 merged commit ccac2c1cf8 into develop 2024-11-06 11:23:29 +01:00
niat8586 deleted branch spring 2024-11-06 11:23:29 +01:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: DMC/scipro#5
No description provided.