Skip to content

Commit 5aaabff

Browse files
working on #157
1 parent 7a3dc66 commit 5aaabff

File tree

72 files changed

+1733
-911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1733
-911
lines changed

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
<artifactId>spring-boot-configuration-processor</artifactId>
112112
<optional>true</optional>
113113
</dependency>
114+
<dependency>
115+
<groupId>org.thymeleaf.extras</groupId>
116+
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
117+
</dependency>
114118
<dependency>
115119
<groupId>org.yaml</groupId>
116120
<artifactId>snakeyaml</artifactId>

src/main/java/org/woehlke/twitterwall/conf/WebSecurityConfig.java

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,30 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
1717
@Override
1818
protected void configure(HttpSecurity http) throws Exception {
1919
http
20-
.authorizeRequests()
21-
.antMatchers("/", "/tweet/all","/user/tweets","/hashtag/overview","/imprint","/user/*","/hashtag/*","/css/**","/favicon/**","/js","/map-icons","/webjars/**").permitAll()
22-
.anyRequest().authenticated()
23-
.and()
24-
.formLogin()
25-
.loginPage("/login")
26-
.permitAll()
27-
.and()
28-
.logout()
29-
.permitAll();
20+
.authorizeRequests()
21+
.antMatchers(
22+
"/",
23+
"/tweet/all",
24+
"/user/tweets",
25+
"/hashtag/overview",
26+
"/imprint",
27+
"/user/*",
28+
"/hashtag/*",
29+
"/css/*","/css/**",
30+
"/favicon/*","/favicon/**",
31+
"/js/*","/js/**",
32+
"/map-icons/*","/map-icons/**",
33+
"/webjars/*","/webjars/**"
34+
).permitAll()
35+
.anyRequest().authenticated()
36+
.and()
37+
.formLogin()
38+
.loginPage("/login")
39+
.permitAll()
40+
.and()
41+
.logout()
42+
.logoutSuccessUrl("/")
43+
.permitAll();
3044
}
3145

3246
@Autowired

src/main/java/org/woehlke/twitterwall/frontend/controller/ApplicationController.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ public String managementPage(Model model) {
3939
return "application/management";
4040
}
4141

42-
@Autowired
43-
public ApplicationController(CountedEntitiesService countedEntitiesService, ControllerHelper controllerHelper, TwitterProperties twitterProperties) {
44-
this.countedEntitiesService = countedEntitiesService;
45-
this.controllerHelper = controllerHelper;
46-
this.twitterProperties = twitterProperties;
47-
}
48-
4942
private final CountedEntitiesService countedEntitiesService;
5043

5144
private final ControllerHelper controllerHelper;
5245

5346
private final TwitterProperties twitterProperties;
5447

48+
@Autowired
49+
public ApplicationController(
50+
CountedEntitiesService countedEntitiesService,
51+
ControllerHelper controllerHelper,
52+
TwitterProperties twitterProperties) {
53+
this.countedEntitiesService = countedEntitiesService;
54+
this.controllerHelper = controllerHelper;
55+
this.twitterProperties = twitterProperties;
56+
}
57+
5558
}

src/main/java/org/woehlke/twitterwall/frontend/controller/CountedEntitiesController.java

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ public class CountedEntitiesController {
2929

3030
@RequestMapping(path="/tweet/hashtag")
3131
public String domainCountTweet2hashtag(
32-
@RequestParam(
33-
name= "page",
34-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
35-
) int page, Model model
32+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
33+
Model model
3634
) {
3735
String title = "Tweet -&gt; HashTag";
3836
setUpThisPage(title,model);
@@ -55,10 +53,8 @@ public String domainCountTweet2hashtag(
5553

5654
@RequestMapping(path="/tweet/media")
5755
public String domainCountTweet2media(
58-
@RequestParam(
59-
name= "page",
60-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
61-
) int page, Model model
56+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
57+
Model model
6258
) {
6359
String title = "Tweet -&gt; Media";
6460
setUpThisPage(title,model);
@@ -80,7 +76,10 @@ public String domainCountTweet2media(
8076
}
8177

8278
@RequestMapping(path="/tweet/mention")
83-
public String domainCountTweet2mention(@RequestParam(name= "page" ,defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page, Model model) {
79+
public String domainCountTweet2mention(
80+
@RequestParam(name= "page" ,defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
81+
Model model
82+
) {
8483
String title = "Tweet -&gt; Mention";
8584
setUpThisPage(title,model);
8685
Pageable pageRequest = new PageRequest(page, frontendProperties.getPageSize());
@@ -102,10 +101,8 @@ public String domainCountTweet2mention(@RequestParam(name= "page" ,defaultValue=
102101

103102
@RequestMapping(path="/tweet/tickersymbol")
104103
public String domainCountTweet2tickersymbol(
105-
@RequestParam(
106-
name= "page",
107-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
108-
) int page, Model model
104+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
105+
Model model
109106
) {
110107
String title = "Tweet -&gt; TickerSymbol";
111108
setUpThisPage(title,model);
@@ -128,10 +125,8 @@ public String domainCountTweet2tickersymbol(
128125

129126
@RequestMapping(path="/tweet/url")
130127
public String domainCountTweet2url(
131-
@RequestParam(
132-
name= "page",
133-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
134-
) int page, Model model
128+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
129+
Model model
135130
) {
136131
String title = "Tweet -&gt; Url";
137132
setUpThisPage(title,model);
@@ -154,10 +149,8 @@ public String domainCountTweet2url(
154149

155150
@RequestMapping(path="/user/hashtag")
156151
public String domainCountUserprofile2hashtag(
157-
@RequestParam(
158-
name= "page" ,
159-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
160-
) int page, Model model
152+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
153+
Model model
161154
) {
162155
String title = "UserProfile -&gt; HashTag";
163156
setUpThisPage(title,model);
@@ -180,10 +173,8 @@ public String domainCountUserprofile2hashtag(
180173

181174
@RequestMapping(path="/user/media")
182175
public String domainCountUserprofile2media(
183-
@RequestParam(
184-
name= "page" ,
185-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
186-
) int page, Model model
176+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
177+
Model model
187178
) {
188179
String title = "UserProfile -&gt; Media";
189180
setUpThisPage(title,model);
@@ -206,10 +197,8 @@ public String domainCountUserprofile2media(
206197

207198
@RequestMapping(path="/user/mention")
208199
public String domainCountUserprofile2mention(
209-
@RequestParam(
210-
name= "page",
211-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
212-
) int page, Model model
200+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
201+
Model model
213202
) {
214203
String title = "UserProfile -&gt; Mention";
215204
setUpThisPage(title,model);
@@ -232,10 +221,8 @@ public String domainCountUserprofile2mention(
232221

233222
@RequestMapping(path="/user/tickersymbol")
234223
public String domainCountUserprofile2Tickersymbol(
235-
@RequestParam(
236-
name= "page",
237-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
238-
) int page, Model model
224+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
225+
Model model
239226
) {
240227
String title = "UserProfile -&gt; TickerSymbol";
241228
setUpThisPage(title,model);
@@ -258,10 +245,8 @@ public String domainCountUserprofile2Tickersymbol(
258245

259246
@RequestMapping(path="/user/url")
260247
public String domainCountUserprofile2Url(
261-
@RequestParam(
262-
name= "page",
263-
defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER
264-
) int page, Model model
248+
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
249+
Model model
265250
) {
266251
String title = "UserProfile -&gt; Url";
267252
setUpThisPage(title,model);
@@ -289,21 +274,6 @@ private void setUpThisPage(String title,Model model){
289274
}
290275

291276

292-
@Autowired
293-
public CountedEntitiesController(FrontendProperties frontendProperties, ControllerHelper controllerHelper, TweetService tweetService, UserService userService, HashTagService hashTagService, MediaService mediaService, MentionService mentionService, TickerSymbolService tickerSymbolService, UrlService urlService) {
294-
this.frontendProperties = frontendProperties;
295-
this.controllerHelper = controllerHelper;
296-
this.tweetService = tweetService;
297-
this.userService = userService;
298-
this.hashTagService = hashTagService;
299-
this.mediaService = mediaService;
300-
this.mentionService = mentionService;
301-
this.tickerSymbolService = tickerSymbolService;
302-
this.urlService = urlService;
303-
}
304-
305-
306-
307277
private final FrontendProperties frontendProperties;
308278

309279
private final ControllerHelper controllerHelper;
@@ -321,4 +291,27 @@ public CountedEntitiesController(FrontendProperties frontendProperties, Controll
321291
private final TickerSymbolService tickerSymbolService;
322292

323293
private final UrlService urlService;
294+
295+
@Autowired
296+
public CountedEntitiesController(
297+
FrontendProperties frontendProperties,
298+
ControllerHelper controllerHelper,
299+
TweetService tweetService,
300+
UserService userService,
301+
HashTagService hashTagService,
302+
MediaService mediaService,
303+
MentionService mentionService,
304+
TickerSymbolService tickerSymbolService,
305+
UrlService urlService
306+
) {
307+
this.frontendProperties = frontendProperties;
308+
this.controllerHelper = controllerHelper;
309+
this.tweetService = tweetService;
310+
this.userService = userService;
311+
this.hashTagService = hashTagService;
312+
this.mediaService = mediaService;
313+
this.mentionService = mentionService;
314+
this.tickerSymbolService = tickerSymbolService;
315+
this.urlService = urlService;
316+
}
324317
}

src/main/java/org/woehlke/twitterwall/frontend/controller/HashTagController.java

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,59 @@
3939
public class HashTagController {
4040

4141
@RequestMapping(path="/all")
42-
public String getAll(@RequestParam(name= "page" ,defaultValue=""+ FIRST_PAGE_NUMBER) int page, Model model){
42+
public String getAll(
43+
@RequestParam(name= "page" ,defaultValue=""+ FIRST_PAGE_NUMBER) int page,
44+
Model model
45+
) {
4346
String subtitle = "all";
4447
String title = "HashTag";
4548
String symbol = Symbols.HASHTAG.toString();
4649
model = controllerHelper.setupPage(model,title,subtitle,symbol);
47-
Pageable pageRequest = new PageRequest(page, frontendProperties.getPageSize(), Sort.Direction.ASC,"text");
50+
Pageable pageRequest = new PageRequest(
51+
page,
52+
frontendProperties.getPageSize(),
53+
Sort.Direction.ASC,
54+
"text"
55+
);
4856
Page<HashTag> myPageContent = hashTagService.getAll(pageRequest);
4957
model.addAttribute("myPageContent",myPageContent);
5058
return "hashtag/all";
5159
}
5260

61+
@RequestMapping(path="/id/{id}")
62+
public String findById(
63+
@PathVariable("id") HashTag hashTag,
64+
@RequestParam(name= "pageTweet" ,defaultValue=""+ FIRST_PAGE_NUMBER) int pageTweet,
65+
@RequestParam(name= "pageUser" ,defaultValue=""+ FIRST_PAGE_NUMBER) int pageUser,
66+
Model model
67+
) {
68+
String msg = "/hashtag/" + hashTag.getId()+ " ";
69+
String msg2 = msg + " parameter IS valid - START ";
70+
log.debug(msg2);
71+
Pageable pageRequestTweet = new PageRequest(pageTweet, frontendProperties.getPageSize());
72+
Pageable pageRequestUser = new PageRequest(pageUser, frontendProperties.getPageSize());
73+
String subtitle = "Tweets und User für HashTag";
74+
String title = hashTag.getText();
75+
String symbol = Symbols.HASHTAG.toString();
76+
model = controllerHelper.setupPage(model, title, subtitle, symbol);
77+
model.addAttribute("hashTag",hashTag);
78+
log.debug(msg+" try to: tweetService.findTweetsForHashTag: ");
79+
Page<Tweet> tweets = tweetService.findTweetsForHashTag(hashTag,pageRequestTweet);
80+
model.addAttribute("latestTweets", tweets);
81+
log.debug(msg+" try to: userService.getUsersForHashTag: ");
82+
Page<User> users = userService.getUsersForHashTag(hashTag,pageRequestUser);
83+
model.addAttribute("users", users);
84+
log.debug(msg + " READY - DONE");
85+
return "hashtag/id";
86+
}
87+
5388
@RequestMapping(path="/{text}")
5489
public String hashTagFromTweetsAndUsers(
5590
@PathVariable("text") String text,
5691
@RequestParam(name= "pageTweet" ,defaultValue=""+ FIRST_PAGE_NUMBER) int pageTweet,
5792
@RequestParam(name= "pageUser" ,defaultValue=""+ FIRST_PAGE_NUMBER) int pageUser,
58-
Model model)
59-
{
93+
Model model
94+
) {
6095
String msg = "/hashtag/" + text + " ";
6196
Pattern p = Pattern.compile(HASHTAG_TEXT_PATTERN);
6297
Matcher m = p.matcher(text);
@@ -73,21 +108,18 @@ public String hashTagFromTweetsAndUsers(
73108
HashTag hashTag = hashTagService.findByText(text);
74109
model.addAttribute("hashTag",hashTag);
75110
log.debug(msg + " found: " + text);
76-
//
77111
log.debug(msg+" try to: tweetService.findTweetsForHashTag: ");
78112
Page<Tweet> tweets = tweetService.findTweetsForHashTag(hashTag,pageRequestTweet);
79113
model.addAttribute("latestTweets", tweets);
80-
//
81114
log.debug(msg+" try to: userService.getUsersForHashTag: ");
82115
Page<User> users = userService.getUsersForHashTag(hashTag,pageRequestUser);
83116
model.addAttribute("users", users);
84-
//
85117
log.debug(msg + " READY - DONE");
86-
return "hashtag/hashtagText";
118+
return "hashtag/id";
87119
} else {
88120
String msg2 = msg + " parameter ist NOT valid";
89121
log.warn(msg2);
90-
return "hashtag/hashtagText";
122+
return "hashtag/id";
91123
}
92124
}
93125

@@ -121,7 +153,15 @@ public String hashTagsOverview(Model model) {
121153
private final HashTagsOverviewHelper hashTagsOverviewHelper;
122154

123155
@Autowired
124-
public HashTagController(FrontendProperties frontendProperties, TwitterProperties twitterProperties, HashTagService hashTagService, TweetService tweetService, UserService userService, ControllerHelper controllerHelper, HashTagsOverviewHelper hashTagsOverviewHelper) {
156+
public HashTagController(
157+
FrontendProperties frontendProperties,
158+
TwitterProperties twitterProperties,
159+
HashTagService hashTagService,
160+
TweetService tweetService,
161+
UserService userService,
162+
ControllerHelper controllerHelper,
163+
HashTagsOverviewHelper hashTagsOverviewHelper
164+
) {
125165
this.frontendProperties = frontendProperties;
126166
this.twitterProperties = twitterProperties;
127167
this.hashTagService = hashTagService;
@@ -130,4 +170,5 @@ public HashTagController(FrontendProperties frontendProperties, TwitterPropertie
130170
this.controllerHelper = controllerHelper;
131171
this.hashTagsOverviewHelper = hashTagsOverviewHelper;
132172
}
173+
133174
}

0 commit comments

Comments
 (0)