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

Fix #1683: Provide default lang.json for external resources #1684

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import io.getlime.security.powerauth.rest.api.spring.annotation.support.PowerAuthEncryptionArgumentResolver;
import io.getlime.security.powerauth.rest.api.spring.annotation.support.PowerAuthWebArgumentResolver;
import io.getlime.security.powerauth.rest.api.spring.filter.PowerAuthRequestFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.UrlResource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
Expand All @@ -52,6 +54,7 @@
* @author Petr Dvorak, petr@wultra.com
*/
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {

@Autowired
Expand Down Expand Up @@ -140,7 +143,12 @@ public ReloadableResourceBundleMessageSourceWithListing messageSource() {

@Bean
public Resource languageSettingSource() throws MalformedURLException {
return resourceLoader.getResource(configuration.getResourcesLocation() + "lang.json");
Resource resource = resourceLoader.getResource(configuration.getResourcesLocation() + "lang.json");
if (!resource.exists()) {
logger.info("The lang.json file was not found in {}, using default location", configuration.getResourcesLocation());
resource = new UrlResource("classpath:/static/resources/lang.json");
banterCZ marked this conversation as resolved.
Show resolved Hide resolved
}
return resource;
}

@Override
Expand Down