TSK-754 Use custom spring boot mvn initializer
This commit is contained in:
parent
3be2a01553
commit
53451cd61b
|
@ -0,0 +1,55 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
|
||||
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||
"classpath:/static/", "classpath:/public/"};
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
if (!registry.hasMappingForPattern("/webjars/**")) {
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations(
|
||||
"classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
if (!registry.hasMappingForPattern("/**")) {
|
||||
registry.addResourceHandler("/**").addResourceLocations(
|
||||
CLASSPATH_RESOURCE_LOCATIONS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
for (HttpMessageConverter<?> converter : converters) {
|
||||
if (converter instanceof MappingJackson2HttpMessageConverter) {
|
||||
MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
|
||||
jacksonConverter.setPrettyPrint(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void enableObjectIndent() {
|
||||
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
@Controller
|
||||
public class ViewController {
|
||||
|
||||
@RequestMapping({"/administration*/**", "/workplace*/**", "/monitor*/**", "/no-role*/**"})
|
||||
@RequestMapping({"", "/administration*/**", "/workplace*/**", "/monitor*/**", "/no-role*/**"})
|
||||
public String index() {
|
||||
return "forward:/index.html";
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
.anyRequest().fullyAuthenticated()
|
||||
.and()
|
||||
.formLogin().loginPage("/login").failureUrl("/login?error")
|
||||
.defaultSuccessUrl("/")
|
||||
.permitAll()
|
||||
.and()
|
||||
.logout()
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 755 B |
|
@ -1,6 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<link rel="icon"
|
||||
type="image/x-icon"
|
||||
th:href="@{/img/favicon.png}">
|
||||
<title>Taskana login</title>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap/4.1.3/bootstrap.min.css}"/>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}"/>
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
|
@ -299,6 +300,7 @@ public class TaskControllerIntTest {
|
|||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||
assertEquals(200, con.getResponseCode());
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
|
@ -310,11 +312,11 @@ public class TaskControllerIntTest {
|
|||
in.close();
|
||||
con.disconnect();
|
||||
String response = content.toString();
|
||||
JsonNode jsonNode = objectMapper.readTree(response);
|
||||
String created = jsonNode.get("created").asText();
|
||||
assertFalse(response.contains("\"attachments\":[]"));
|
||||
int start = response.indexOf("created", response.indexOf("created") + 1);
|
||||
String createdString = response.substring(start + 10, start + 30);
|
||||
assertTrue(
|
||||
createdString.matches("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)"));
|
||||
created.matches("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
@ -12,11 +11,8 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
|
||||
|
||||
|
@ -35,7 +31,7 @@ import pro.taskana.ldap.LdapClient;
|
|||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableTransactionManagement
|
||||
public class RestConfiguration extends WebMvcConfigurationSupport {
|
||||
public class RestConfiguration{
|
||||
|
||||
@Value("${taskana.schemaName:TASKANA}")
|
||||
private String schemaName;
|
||||
|
@ -83,13 +79,4 @@ public class RestConfiguration extends WebMvcConfigurationSupport {
|
|||
return new SpringHandlerInstantiator(context.getAutowireCapableBeanFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
for (HttpMessageConverter<?> converter : converters) {
|
||||
if (converter instanceof MappingJackson2HttpMessageConverter) {
|
||||
MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
|
||||
jacksonConverter.setPrettyPrint(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue