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

feat: Updated error handling with problem-json RFC specs #5

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ hs_err_pid*
# Helm
/helm/charts/*
**/.terraform/

.DS_Store
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package it.gov.pagopa.wispconverter.config;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -26,13 +24,6 @@ public class RedisConfig {
@Value("${spring.redis.password}")
private String password;

@Bean
public ObjectMapper registerObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
return objectMapper;
}

@Bean
public LettuceConnectionFactory registerRedisConnectionFactory() {
RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration(host, port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

@Configuration
public class UnmarshallerConfig {

@Bean
@Scope("prototype")
public DocumentBuilderFactory documentBuilderFactory() throws ParserConfigurationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import it.gov.pagopa.wispconverter.config.model.AppCors;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;


@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

List<Locale> locales = Arrays.asList(Locale.ENGLISH, Locale.ITALIAN);
Expand All @@ -32,13 +34,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
@SneakyThrows
@Override
public void addCorsMappings(CorsRegistry registry) {
AppCors appCors = new ObjectMapper().readValue(corsConfiguration,
AppCors.class);
AppCors appCors = new ObjectMapper().readValue(corsConfiguration, AppCors.class);
registry.addMapping("/**")
.allowedOrigins(appCors.getOrigins())
.allowedMethods(appCors.getMethods());
}


@Bean
public LocaleResolver localeResolver() {
AcceptHeaderLocaleResolver acceptHeaderLocaleResolver = new AcceptHeaderLocaleResolver();
Expand All @@ -47,14 +49,15 @@ public LocaleResolver localeResolver() {
return acceptHeaderLocaleResolver;
}


@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setUseCodeAsDefaultMessage(true);
return messageSource;
public ResourceBundleMessageSource messageSource() {
var resourceBundleMessageSource=new ResourceBundleMessageSource();
resourceBundleMessageSource.setBasename("i18n/messages"); // directory with messages_XX.properties
resourceBundleMessageSource.setDefaultLocale(Locale.ENGLISH);
resourceBundleMessageSource.setDefaultEncoding(StandardCharsets.UTF_8.name());
resourceBundleMessageSource.setAlwaysUseMessageFormat(true);
return resourceBundleMessageSource;
}

@Primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -36,7 +37,8 @@ public class RedirectController {
})
@GetMapping
public void redirect(@Parameter(description = "", example = "identificativoIntermediarioPA_sessionId")
@NotBlank(message = "{redirect.session-id.not-blank}") @RequestParam("sessionId") String sessionId,
@NotBlank(message = "{redirect.session-id.not-blank}")
@RequestParam("sessionId") String sessionId,
HttpServletResponse response) throws IOException {
ConversionResultDTO conversionResultDTO = converterService.convert(sessionId);
response.sendRedirect(conversionResultDTO.getUri());
Expand Down

This file was deleted.

Loading
Loading