Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/hocs 6851 springboot upgrade #1021

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
af149c0
Initial check-in for springboot3 upgrade
vinothon84 Feb 20, 2024
efa3dae
Resolving compilation error involving TypeDef, TypeDefs and Type inte…
vinothon84 Feb 22, 2024
06490ae
Remove commente code
vinothon84 Feb 22, 2024
b7584da
Next update to resolve compilation errors on tests
vinothon84 Feb 22, 2024
30dca8d
Add latest jars to avoid compilation error
vinothon84 Feb 22, 2024
d9e5516
Organize imports and remove unwanted code
vinothon84 Feb 28, 2024
65067f7
Code changes to include correct alias name
vinothon84 Feb 28, 2024
883b9a8
Comment SQS email sent code to debug the number of junit failures
vinothon84 Feb 29, 2024
e83ba78
Add httpclient5 related jar
vinothon84 Feb 29, 2024
d15da92
Build changes to accomodate sdk2 and sqs/sns3.0
vinothon84 Mar 12, 2024
815ab1f
Sqs, sns MessageAttributeValue changes
vinothon84 Mar 12, 2024
a92ebe7
Updated test cases with latest api changes for SQS and SNS 3.0
vinothon84 Mar 12, 2024
ba47d1c
Merge branch 'main' into feature/hocs_6851_springboot_upgrade
vinothon84 Mar 12, 2024
2cf9158
Added codec 1.6 version to gradle file
vinothon84 Mar 12, 2024
b9b63c3
Add httpcore5 jar dependency
vinothon84 Mar 12, 2024
0bb6312
Test class changes to accomodate sqs3.0 and sns3.0 upgrade
vinothon84 Mar 14, 2024
d0ddc1a
Typecast any() to PublishRequest class
vinothon84 Mar 14, 2024
4ce049a
Merge branch 'main' into feature/hocs_6851_springboot_upgrade
vinothon84 Apr 2, 2024
74fe45e
Update package to use hypersistence-utils-hibernate-63:3.7.3. Code is…
vinothon84 Apr 8, 2024
34cfddc
Add httpClient5 jar to incline with springboot3.2.2
vinothon84 Apr 8, 2024
3d3a041
Fix SNS headers
vinothon84 Apr 10, 2024
50d1bb4
Avoid SnsClient already defined bean error
vinothon84 Apr 10, 2024
6d81595
Format ContributionsProcessorImpl
vinothon84 Apr 11, 2024
f9008fe
Merge branch 'main' into feature/hocs_6851_springboot_upgrade
vinothon84 Apr 11, 2024
a056835
Chnage sql query to remove varchar return type. Make extraction metho…
vinothon84 Apr 11, 2024
0c5ea3b
Build changes to correct headers
vinothon84 Apr 11, 2024
26c581c
remove unused class files
vinothon84 Apr 11, 2024
4ddfd50
Remove unused imports
vinothon84 Apr 11, 2024
7084fa0
Correct headers as part of the reqeust
vinothon84 Apr 12, 2024
c8a37e5
Fix for Queue Headers
vinothon84 Apr 12, 2024
5cc3e5a
Adding request as part of message
vinothon84 Apr 12, 2024
287b231
Fix for queue heards and junits
vinothon84 Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.15'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.3'
}

Expand All @@ -24,28 +24,37 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-json'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.amazonaws:aws-java-sdk-sns:1.12.149'
implementation group: 'software.amazon.awssdk', name: 'sqs'
implementation group: 'io.awspring.cloud', name: 'spring-cloud-aws-starter-sqs', version: '3.1.0'
implementation group: 'io.awspring.cloud', name: 'spring-cloud-aws-starter-sns', version: '3.1.0'

implementation 'com.vladmihalcea:hibernate-types-55:2.21.1'
// implementation 'com.vladmihalcea:hibernate-types-60:2.21.1'
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.7.3'
implementation 'javax.annotation:javax.annotation-api:1.3.2'

implementation group: 'commons-codec', name: 'commons-codec', version: '1.6'
implementation group: 'org.apache.httpcomponents.core5', name: 'httpcore5', version: '5.2.4'
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.3.1'

implementation 'net.logstash.logback:logstash-logback-encoder:7.3'
implementation 'org.springdoc:springdoc-openapi-ui:1.7.0'

implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
implementation 'org.json:json:20230618'
implementation 'org.json:json:20231013'

implementation 'org.flywaydb:flyway-core:8.5.13'
implementation 'org.flywaydb:flyway-core:9.16.0'
runtimeOnly 'org.postgresql:postgresql:42.6.0'

compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor 'org.springframework:spring-context-indexer:5.3.24'
annotationProcessor 'org.springframework:spring-context-indexer:6.0.6'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

testImplementation 'com.google.guava:guava:32.1.2-jre'
testImplementation 'com.google.guava:guava:33.0.0-jre'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.assertj:assertj-core'
testImplementation 'junit:junit:4.13.2'

}

dependencyManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

import javax.annotation.PreDestroy;
import jakarta.annotation.PreDestroy;

@Slf4j
@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import uk.gov.digital.ho.hocs.casework.security.AccessLevel;
import uk.gov.digital.ho.hocs.casework.security.Authorised;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.util.Set;
import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import uk.gov.digital.ho.hocs.casework.domain.model.CaseDataTag;
import uk.gov.digital.ho.hocs.casework.domain.repository.CaseTagRepository;

import javax.transaction.Transactional;
import jakarta.transaction.Transactional;
import java.util.UUID;

import static uk.gov.digital.ho.hocs.casework.application.LogEvent.CASE_TAG_CONFLICT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import uk.gov.digital.ho.hocs.casework.security.AllocationLevel;
import uk.gov.digital.ho.hocs.casework.security.Authorised;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.util.Set;
import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.time.LocalDate;
import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import uk.gov.digital.ho.hocs.casework.security.AllocationLevel;
import uk.gov.digital.ho.hocs.casework.security.Authorised;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import uk.gov.digital.ho.hocs.casework.security.AllocationLevel;
import uk.gov.digital.ho.hocs.casework.security.Authorised;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.util.Set;
import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;

@AllArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import org.springframework.lang.NonNull;

import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;

@AllArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
import java.util.UUID;

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import org.springframework.lang.NonNull;

import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;

@AllArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.apache.hc.core5.http.ContentType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.digital.ho.hocs.casework.application;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.sql.Date;
import java.time.LocalDate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.digital.ho.hocs.casework.application;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.sql.Timestamp;
import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.UUID;

@Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
package uk.gov.digital.ho.hocs.casework.application.aws;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSAsync;
import com.amazonaws.services.sns.AmazonSNSAsyncClientBuilder;
import com.amazonaws.services.sns.AmazonSNSClientBuilder;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsAsyncClient;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;

import java.net.URI;

@Configuration
@Profile({ "local" })
public class LocalStackConfiguration {
private final AwsCredentialsProvider awsCredentialsProvider;

private final AWSCredentialsProvider awsCredentialsProvider;

private final AwsClientBuilder.EndpointConfiguration endpoint;

public LocalStackConfiguration(@Value("${localstack.base-url}") String baseUrl,
@Value("${localstack.config.region}") String region) {
this.awsCredentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials("test", "test"));
this.endpoint = new AwsClientBuilder.EndpointConfiguration(baseUrl, region);
public LocalStackConfiguration() {
this.awsCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create("test", "test"));
}

@Primary
@Bean
public AmazonSQSAsync sqsClient() {
return AmazonSQSAsyncClientBuilder.standard().withCredentials(awsCredentialsProvider).withEndpointConfiguration(
endpoint).build();
public SqsAsyncClient sqsAsyncClient(@Value("${localstack.base-url}") String baseUrl, @Value("${localstack.config.region}") String region) {
return SqsAsyncClient.builder()
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider)
.endpointOverride(URI.create(baseUrl))
.build();
}

@Primary
@Bean
public AmazonSNSAsync snsClient() {
return AmazonSNSAsyncClientBuilder.standard().withCredentials(awsCredentialsProvider).withEndpointConfiguration(
endpoint).build();
public SnsAsyncClient snsAsyncClient(@Value("${localstack.base-url}") String baseUrl, @Value("${localstack.config.region}") String region) {
return SnsAsyncClient.builder()
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider)
.endpointOverride(URI.create(baseUrl))
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package uk.gov.digital.ho.hocs.casework.application.aws;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.sns.AmazonSNSAsync;
import com.amazonaws.services.sns.AmazonSNSAsyncClientBuilder;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsAsyncClient;

@Configuration
@Profile({ "sns" })
public class SnsConfiguration {

@Primary
@Bean
public AmazonSNSAsync snsClient(@Value("${aws.sns.audit-search.account.access-key}") String accessKey,
@Value("${aws.sns.audit-search.account.secret-key}") String secretKey,
@Value("${aws.sns.config.region}") String region) {
return AmazonSNSAsyncClientBuilder.standard().withRegion(region).withCredentials(
new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))).withClientConfiguration(
new ClientConfiguration()).build();
public SnsAsyncClient snsClient(@Value("${aws.sns.audit-search.account.access-key}") String accessKey,
@Value("${aws.sns.audit-search.account.secret-key}") String secretKey,
@Value("${aws.sns.config.region}") String region) {
return SnsAsyncClient.builder().region(Region.of(region))
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)))
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package uk.gov.digital.ho.hocs.casework.application.aws;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;

@Configuration
@Profile({ "sqs" })
public class SqsConfiguration {

@Primary
@Bean
public AmazonSQSAsync sqsClient(@Value("${aws.sqs.notify.account.access-key}") String accessKey,
@Value("${aws.sqs.notify.account.secret-key}") String secretKey,
@Value("${aws.sqs.config.region}") String region) {
return AmazonSQSAsyncClientBuilder.standard().withRegion(region).withCredentials(
new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))).withClientConfiguration(
new ClientConfiguration()).build();
public SqsAsyncClient sqsAsyncClient(@Value("${aws.sqs.notify.account.access-key}") String accessKey,
@Value("${aws.sqs.notify.account.secret-key}") String secretKey,
@Value("${aws.sqs.config.region}") String region) {
return SqsAsyncClient.builder()
.region(Region.of(region))
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey))).build();
}

}
Loading
Loading