Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
- export TWITTERWALL_INFO_IMPRINT_SCREEN_NAME=port80guru
- export TWITTERWALL_GOOGLE_ANALYTICS_ID=TWITTERWALL_GOOGLE_ANALYTICS_ID
- export TWITTERWALL_SCHEDULER_USER_LIST_NAME=test-typo3-hibernate-java
- export TWITTERWALL_LOGIN_USERNAME=admin
- export TWITTERWALL_LOGIN_PASSWORD=password

- run with: mvn clean spring-boot:run

Expand Down
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.woehlke.twitterwall</groupId>
<artifactId>twitterwall2</artifactId>
<version>1.0.17-SNAPSHOT</version>
<version>1.0.18-SNAPSHOT</version>
<name>twitterwall2</name>

<description>Twitterwall with spring:boot for heroku</description>
Expand Down Expand Up @@ -80,12 +80,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mobile</artifactId>
Expand Down Expand Up @@ -113,6 +111,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/woehlke/twitterwall/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.web.config.EnableSpringDataWebSupport;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.woehlke.twitterwall.conf.TwitterProperties;
import org.woehlke.twitterwall.conf.TwitterwallBackendProperties;
import org.woehlke.twitterwall.conf.TwitterwallFrontendProperties;
import org.woehlke.twitterwall.conf.TwitterwallSchedulerProperties;
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
import org.woehlke.twitterwall.conf.properties.BackendProperties;
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;


/**
Expand All @@ -19,9 +19,9 @@
@EnableScheduling
@SpringBootApplication
@EnableConfigurationProperties({
TwitterwallBackendProperties.class,
TwitterwallFrontendProperties.class,
TwitterwallSchedulerProperties.class,
BackendProperties.class,
FrontendProperties.class,
SchedulerProperties.class,
TwitterProperties.class
})
@EnableSpringDataWebSupport
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/woehlke/twitterwall/ScheduledTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.woehlke.twitterwall.conf.TwitterwallSchedulerProperties;
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;
import org.woehlke.twitterwall.scheduled.mq.endoint.StartTask;

/**
Expand All @@ -20,46 +20,46 @@ public class ScheduledTasks {
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS)
public void fetchTweetsFromTwitterSearch() {
String msg = "fetch Tweets From TwitterSearch ";
if(twitterwallSchedulerProperties.getAllowUpdateTweets() && !twitterwallSchedulerProperties.getSkipFortesting()) {
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()) {
startTask.fetchTweetsFromTwitterSearch();
}
}

@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS)
public void updateTweets() {
String msg = "update Tweets ";
if(twitterwallSchedulerProperties.getAllowUpdateTweets() && !twitterwallSchedulerProperties.getSkipFortesting()){
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()){
startTask.updateTweets();
}
}

@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER)
public void updateUserProfiles() {
String msg = "update User Profiles ";
if(twitterwallSchedulerProperties.getAllowUpdateUserProfiles() && !twitterwallSchedulerProperties.getSkipFortesting()) {
if(schedulerProperties.getAllowUpdateUserProfiles() && !schedulerProperties.getSkipFortesting()) {
startTask.updateUserProfiles();
}
}

@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION)
public void updateUserProfilesFromMentions(){
String msg = "update User Profiles From Mentions";
if(twitterwallSchedulerProperties.getAllowUpdateUserProfilesFromMention() && !twitterwallSchedulerProperties.getSkipFortesting()) {
if(schedulerProperties.getAllowUpdateUserProfilesFromMention() && !schedulerProperties.getSkipFortesting()) {
startTask.updateUserProfilesFromMentions();
}
}

@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST)
public void fetchUsersFromDefinedUserList(){
String msg = "fetch Users from Defined User List ";
if(twitterwallSchedulerProperties.getFetchUserList().getAllow() && !twitterwallSchedulerProperties.getSkipFortesting()) {
if(schedulerProperties.getFetchUserList().getAllow() && !schedulerProperties.getSkipFortesting()) {
startTask.fetchUsersFromDefinedUserList();
}
}

@Autowired
public ScheduledTasks(TwitterwallSchedulerProperties twitterwallSchedulerProperties, StartTask startTask) {
this.twitterwallSchedulerProperties = twitterwallSchedulerProperties;
public ScheduledTasks(SchedulerProperties schedulerProperties, StartTask startTask) {
this.schedulerProperties = schedulerProperties;
this.startTask = startTask;
}

Expand All @@ -83,7 +83,7 @@ public ScheduledTasks(TwitterwallSchedulerProperties twitterwallSchedulerPropert

private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);

private final TwitterwallSchedulerProperties twitterwallSchedulerProperties;
private final SchedulerProperties schedulerProperties;

private final StartTask startTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
@Configuration
@EnableJpaRepositories("org.woehlke.twitterwall.oodm.repositories")
public class DataSourceConf {
public class DataSourceConfig {

@Bean
@Primary
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/woehlke/twitterwall/conf/WebMvcConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.woehlke.twitterwall.conf;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/adm").setViewName("redirect:/application/management");
registry.addViewController("/").setViewName("redirect:/tweet/all");
}

}

63 changes: 63 additions & 0 deletions src/main/java/org/woehlke/twitterwall/conf/WebSecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.woehlke.twitterwall.conf;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.woehlke.twitterwall.conf.properties.FrontendProperties;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(
"/",
"/tweet/all",
"/user/*",
"/user/screenName/*",
"/user/list/tweets",
"/hashtag/overview",
"/hashtag/*",
"/hashtag/text/*",
"/imprint",
"/css/*","/css/**",
"/favicon/*","/favicon/**",
"/js/*","/js/**",
"/map-icons/*","/map-icons/**",
"/webjars/*","/webjars/**"
).permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/")
.permitAll();
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
String user = frontendProperties.getLoginUsername();
String pwd = frontendProperties.getLoginPassword();
String role = "USER";
auth
.inMemoryAuthentication()
.withUser(user).password(pwd).roles(role);
}

@Autowired
public WebSecurityConfig(FrontendProperties frontendProperties) {
this.frontendProperties = frontendProperties;
}

private final FrontendProperties frontendProperties;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.woehlke.twitterwall.conf;
package org.woehlke.twitterwall.conf.properties;


import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -12,7 +12,7 @@
@Component
@Validated
@ConfigurationProperties(prefix="twitterwall.backend")
public class TwitterwallBackendProperties {
public class BackendProperties {

@Valid
public Twitter twitter = new Twitter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.woehlke.twitterwall.conf;
package org.woehlke.twitterwall.conf.properties;


import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -11,7 +11,7 @@
@Component
@Validated
@ConfigurationProperties(prefix="twitterwall.frontend")
public class TwitterwallFrontendProperties {
public class FrontendProperties {

@NotNull
private String idGoogleAnalytics;
Expand All @@ -37,6 +37,12 @@ public class TwitterwallFrontendProperties {
@NotNull
private Integer pageSize;

@NotNull
private String loginUsername;

@NotNull
private String loginPassword;

@Valid
private Controller controller = new Controller();

Expand Down Expand Up @@ -125,4 +131,20 @@ public Integer getPageSize() {
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}

public String getLoginUsername() {
return loginUsername;
}

public void setLoginUsername(String loginUsername) {
this.loginUsername = loginUsername;
}

public String getLoginPassword() {
return loginPassword;
}

public void setLoginPassword(String loginPassword) {
this.loginPassword = loginPassword;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.woehlke.twitterwall.conf;
package org.woehlke.twitterwall.conf.properties;


import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -13,7 +13,7 @@
@Component
@Validated
@ConfigurationProperties(prefix="twitterwall.scheduler")
public class TwitterwallSchedulerProperties {
public class SchedulerProperties {

@NotNull
private Boolean allowFetchTweetsFromTwitterSearch;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.woehlke.twitterwall.conf;
package org.woehlke.twitterwall.conf.properties;


import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.woehlke.twitterwall.conf.TwitterProperties;
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
import org.woehlke.twitterwall.frontend.controller.common.Symbols;
import org.woehlke.twitterwall.frontend.controller.common.ControllerHelper;
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
Expand All @@ -30,26 +30,29 @@ public String domainCount(Model model) {
}

@RequestMapping(path="/management")
public String dmanagementPage(Model model) {
public String managementPage(Model model) {
String msg = "/application/domain/count: ";
String title = "Application Management";
String subtitle = twitterProperties.getSearchQuery();
String symbol = Symbols.DATABASE.toString();
model = controllerHelper.setupPage(model,title,subtitle,symbol);
return "application/management";
}

@Autowired
public ApplicationController(CountedEntitiesService countedEntitiesService, ControllerHelper controllerHelper, TwitterProperties twitterProperties) {
this.countedEntitiesService = countedEntitiesService;
this.controllerHelper = controllerHelper;
this.twitterProperties = twitterProperties;
}

private final CountedEntitiesService countedEntitiesService;

private final ControllerHelper controllerHelper;

private final TwitterProperties twitterProperties;

@Autowired
public ApplicationController(
CountedEntitiesService countedEntitiesService,
ControllerHelper controllerHelper,
TwitterProperties twitterProperties) {
this.countedEntitiesService = countedEntitiesService;
this.controllerHelper = controllerHelper;
this.twitterProperties = twitterProperties;
}

}
Loading