Skip to content

Commit 3de0a14

Browse files
fixed #283
1 parent 2c40310 commit 3de0a14

File tree

14 files changed

+418
-55
lines changed

14 files changed

+418
-55
lines changed

pom.xml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@
124124
<groupId>org.thymeleaf.extras</groupId>
125125
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
126126
</dependency>
127+
128+
<dependency>
129+
<groupId>org.springframework.session</groupId>
130+
<artifactId>spring-session-jdbc</artifactId>
131+
</dependency>
132+
<dependency>
133+
<groupId>org.springframework.boot</groupId>
134+
<artifactId>spring-boot-starter-jdbc</artifactId>
135+
</dependency>
136+
127137
<dependency>
128138
<groupId>org.yaml</groupId>
129139
<artifactId>snakeyaml</artifactId>
@@ -169,11 +179,6 @@
169179
<artifactId>spring-boot-starter-test</artifactId>
170180
<scope>test</scope>
171181
</dependency>
172-
<dependency>
173-
<groupId>com.h2database</groupId>
174-
<artifactId>h2</artifactId>
175-
<scope>test</scope>
176-
</dependency>
177182
<dependency>
178183
<groupId>net.sourceforge.htmlunit</groupId>
179184
<artifactId>htmlunit</artifactId>
@@ -190,6 +195,26 @@
190195
<build>
191196
<plugins>
192197

198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-enforcer-plugin</artifactId>
201+
<executions>
202+
<execution>
203+
<id>enforce-maven</id>
204+
<goals>
205+
<goal>enforce</goal>
206+
</goals>
207+
<configuration>
208+
<rules>
209+
<requireMavenVersion>
210+
<version>3.3.9</version>
211+
</requireMavenVersion>
212+
</rules>
213+
</configuration>
214+
</execution>
215+
</executions>
216+
</plugin>
217+
193218
<plugin>
194219
<groupId>org.springframework.boot</groupId>
195220
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -202,6 +227,9 @@
202227
<source>${java.version}</source>
203228
<target>${java.version}</target>
204229
<encoding>${project.build.sourceEncoding}</encoding>
230+
<compilerArgs>
231+
<arg>-Xlint:all,-options,-path</arg>
232+
</compilerArgs>
205233
</configuration>
206234
</plugin>
207235

@@ -389,20 +417,6 @@
389417
<outputEncoding>${project.build.sourceEncoding}</outputEncoding>
390418
<generateReports>true</generateReports>
391419
</configuration>
392-
<dependencies>
393-
<!-- http://andriusvelykis.github.io/reflow-maven-skin/skin/ -->
394-
<dependency>
395-
<groupId>lt.velykis.maven.skins</groupId>
396-
<artifactId>reflow-velocity-tools</artifactId>
397-
<version>1.1.1</version>
398-
</dependency>
399-
<!-- Reflow skin requires Velocity >= 1.7 -->
400-
<dependency>
401-
<groupId>org.apache.velocity</groupId>
402-
<artifactId>velocity</artifactId>
403-
<version>1.7</version>
404-
</dependency>
405-
</dependencies>
406420
</plugin>
407421

408422
<plugin>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.woehlke.twitterwall.configuration.properties;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.stereotype.Component;
5+
import org.springframework.validation.annotation.Validated;
6+
7+
import javax.validation.Valid;
8+
import javax.validation.constraints.NotNull;
9+
10+
@Component
11+
@Validated
12+
@ConfigurationProperties
13+
public class OtherProperties {
14+
15+
@Valid
16+
private Server server = new Server();
17+
18+
@Validated
19+
public static class Server {
20+
21+
@Valid
22+
private Error error = new Error();
23+
24+
@Validated
25+
public static class Error {
26+
27+
@NotNull
28+
private String path;
29+
30+
public String getPath() {
31+
return path;
32+
}
33+
34+
public void setPath(String path) {
35+
this.path = path;
36+
}
37+
38+
}
39+
40+
public Error getError() {
41+
return error;
42+
}
43+
44+
public void setError(Error error) {
45+
this.error = error;
46+
}
47+
}
48+
49+
public Server getServer() {
50+
return server;
51+
}
52+
53+
public void setServer(Server server) {
54+
this.server = server;
55+
}
56+
}

src/main/java/org/woehlke/twitterwall/configuration/DataSourceConfig.java renamed to src/main/java/org/woehlke/twitterwall/configuration/spring/DataSourceConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.configuration;
1+
package org.woehlke.twitterwall.configuration.spring;
22

33
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
44
import org.springframework.boot.context.properties.ConfigurationProperties;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.woehlke.twitterwall.configuration.spring;
2+
3+
import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
4+
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
8+
9+
@Configuration
10+
@EnableJdbcHttpSession
11+
public class HttpSessionConfig {
12+
13+
@Bean
14+
public ErrorAttributes errorAttributes(){
15+
return new DefaultErrorAttributes();
16+
}
17+
18+
}

src/main/java/org/woehlke/twitterwall/configuration/WebMvcConfig.java renamed to src/main/java/org/woehlke/twitterwall/configuration/spring/WebMvcConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.configuration;
1+
package org.woehlke.twitterwall.configuration.spring;
22

33

44
import org.springframework.context.annotation.Configuration;

src/main/java/org/woehlke/twitterwall/configuration/WebSecurityConfig.java renamed to src/main/java/org/woehlke/twitterwall/configuration/spring/WebSecurityConfig.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.configuration;
1+
package org.woehlke.twitterwall.configuration.spring;
22

33

44
import org.springframework.beans.factory.annotation.Autowired;
@@ -7,6 +7,7 @@
77
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
88
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
99
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10+
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
1011
import org.woehlke.twitterwall.configuration.properties.FrontendProperties;
1112

1213
@Configuration
@@ -19,15 +20,19 @@ protected void configure(HttpSecurity http) throws Exception {
1920
.authorizeRequests()
2021
.antMatchers(
2122
frontendProperties.getWebSecurityConfigPublicPathsAsArray()
22-
).permitAll()
23+
)
24+
.permitAll()
2325
.anyRequest().authenticated()
2426
.and()
2527
.formLogin()
2628
.loginPage("/login")
29+
.failureForwardUrl("/login")
30+
.defaultSuccessUrl("/adm")
2731
.permitAll()
2832
.and()
2933
.logout()
30-
.logoutSuccessUrl("/")
34+
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
35+
.logoutSuccessUrl("/logout_success")
3136
.permitAll();
3237
}
3338

src/main/java/org/woehlke/twitterwall/frontend/content/ContentFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.springframework.ui.Model;
44
import org.springframework.web.servlet.ModelAndView;
55

6+
import java.util.Map;
7+
68
/**
79
* Created by tw on 18.07.17.
810
*/
@@ -13,4 +15,6 @@ public interface ContentFactory {
1315
ModelAndView setupPage(ModelAndView mav, String title, String subtitle, String symbol);
1416

1517
Model setupPage(Model model, String title, String subtitle, String symbol);
18+
19+
Map<String,Object> setupPage(Map<String, Object> model, String title, String subtitle, String symbol);
1620
}

src/main/java/org/woehlke/twitterwall/frontend/content/impl/ContentFactoryImpl.java

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1212
import org.woehlke.twitterwall.frontend.content.Page;
1313

14+
import java.util.Map;
15+
1416
/**
1517
* Created by tw on 18.07.17.
1618
*/
@@ -43,19 +45,73 @@ private Page setupPage(Page page, String title, String subtitle, String symbol)
4345
public ModelAndView setupPage(ModelAndView mav, String title, String subtitle, String symbol) {
4446
Page page = new Page();
4547
page = setupPage(page, title, subtitle, symbol);
46-
log.debug("page: "+page.toString());
48+
page.setMenuAppName(frontendProperties.getMenuAppName());
49+
page.setTwitterSearchTerm(twitterProperties.getSearchQuery());
50+
page.setInfoWebpage(frontendProperties.getInfoWebpage());
51+
page.setTheme(frontendProperties.getTheme());
52+
page.setContextTest(frontendProperties.getContextTest());
53+
page.setHistoryBack(true);
54+
if(!frontendProperties.getIdGoogleAnalytics().isEmpty()){
55+
String html = GOOGLE_ANALYTICS_SCRIPT_HTML;
56+
html = html.replace("###GOOGLE_ANALYTICS_ID###", frontendProperties.getIdGoogleAnalytics());
57+
page.setGoogleAnalyticScriptHtml(html);
58+
} else {
59+
page.setGoogleAnalyticScriptHtml("");
60+
}
61+
log.debug("--------------------------------------------------------------------");
62+
log.debug("setupPage = "+page.toString());
63+
log.debug("--------------------------------------------------------------------");
4764
mav.addObject("page", page);
4865
return mav;
4966
}
5067

5168
public Model setupPage(Model model, String title, String subtitle, String symbol) {
5269
Page page = new Page();
5370
page = setupPage(page, title, subtitle, symbol);
54-
log.debug("page: "+page.toString());
71+
page.setMenuAppName(frontendProperties.getMenuAppName());
72+
page.setTwitterSearchTerm(twitterProperties.getSearchQuery());
73+
page.setInfoWebpage(frontendProperties.getInfoWebpage());
74+
page.setTheme(frontendProperties.getTheme());
75+
page.setContextTest(frontendProperties.getContextTest());
76+
page.setHistoryBack(true);
77+
if(!frontendProperties.getIdGoogleAnalytics().isEmpty()){
78+
String html = GOOGLE_ANALYTICS_SCRIPT_HTML;
79+
html = html.replace("###GOOGLE_ANALYTICS_ID###", frontendProperties.getIdGoogleAnalytics());
80+
page.setGoogleAnalyticScriptHtml(html);
81+
} else {
82+
page.setGoogleAnalyticScriptHtml("");
83+
}
84+
log.debug("--------------------------------------------------------------------");
85+
log.debug("setupPage = "+page.toString());
86+
log.debug("--------------------------------------------------------------------");
5587
model.addAttribute("page", page);
5688
return model;
5789
}
5890

91+
@Override
92+
public Map<String, Object> setupPage(Map<String, Object> model, String title, String subtitle, String symbol) {
93+
Page page = new Page();
94+
page = setupPage(page, title, subtitle, symbol);
95+
page.setMenuAppName(frontendProperties.getMenuAppName());
96+
page.setTwitterSearchTerm(twitterProperties.getSearchQuery());
97+
page.setInfoWebpage(frontendProperties.getInfoWebpage());
98+
page.setTheme(frontendProperties.getTheme());
99+
page.setContextTest(frontendProperties.getContextTest());
100+
page.setHistoryBack(true);
101+
if(!frontendProperties.getIdGoogleAnalytics().isEmpty()){
102+
String html = GOOGLE_ANALYTICS_SCRIPT_HTML;
103+
html = html.replace("###GOOGLE_ANALYTICS_ID###", frontendProperties.getIdGoogleAnalytics());
104+
page.setGoogleAnalyticScriptHtml(html);
105+
} else {
106+
page.setGoogleAnalyticScriptHtml("");
107+
}
108+
log.debug("--------------------------------------------------------------------");
109+
log.debug("setupPage = "+page.toString());
110+
log.debug("--------------------------------------------------------------------");
111+
model.put("page", page);
112+
return model;
113+
}
114+
59115
private static final Logger log = LoggerFactory.getLogger(ContentFactoryImpl.class);
60116

61117
private final FrontendProperties frontendProperties;

0 commit comments

Comments
 (0)