Skip to content

Commit

Permalink
Merge pull request #4 from nkevins/develop
Browse files Browse the repository at this point in the history
Increment 2 Development Code
  • Loading branch information
nkevins authored Feb 10, 2018
2 parents a65df05 + 01b8d88 commit 173f5e9
Show file tree
Hide file tree
Showing 269 changed files with 17,648 additions and 712 deletions.
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,38 @@
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.0.2</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
<version>1.2</version>
</dependency>

</dependencies>

<repositories>
<repository>
<id>itext</id>
<name>iText Repository - releases</name>
<url>https://repo.itextsupport.com/releases</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/chlorocode/tendertracker/AWSConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* This class is used for AWS configuration.
*/
@Configuration
public class AWSConfiguration {
@Value("${cloud.aws.credentials.accessKey}")
Expand All @@ -20,11 +23,24 @@ public class AWSConfiguration {
@Value("${cloud.aws.region}")
private String region;

/**
* This method is used for basic AWS credentials.
*
* @return BasicAWSCredentials
* @see BasicAWSCredentials
*/
@Bean
public BasicAWSCredentials basicAWSCredentials() {
return new BasicAWSCredentials(accessKey, secretKey);
}

/**
* This method is used for amazon S3 client.
*
* @param awsCredentials AWSCredentials
* @return AmazonS3Client
* @see AmazonS3Client
*/
@Bean
public AmazonS3Client amazonS3Client(AWSCredentials awsCredentials) {
AmazonS3Client amazonS3Client = new AmazonS3Client(awsCredentials);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.chlorocode.tendertracker;

import com.chlorocode.tendertracker.api.LongProcess;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
* Created by Kyaw Min Thu on 5/1/2017.
* This class is used to control the long background process of the application.
*/
@Configuration
@EnableAsync
public class LongProcessConfiguration implements AsyncConfigurer {

/**
* This method is used to generate the LongProcess bean.
*
* @return LongProcess
* @see LongProcess
*/
@Bean
public LongProcess longProcessBean() {
return new LongProcess();
}

/**
* This method is used to get the executor of async tasks.
*
* @return Executor
*/
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setMaxPoolSize(10);
taskExecutor.setThreadNamePrefix("LULExecutor-");
taskExecutor.initialize();
return taskExecutor;
}

/**
* This method is used to create the AsyncUncaughtExceptionHandler.
*
* @return AsyncUncaughtExceptionHandler
*/
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new SimpleAsyncUncaughtExceptionHandler();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
import org.springframework.data.jpa.datatables.repository.DataTablesRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import javax.annotation.PostConstruct;
import java.util.TimeZone;
import java.util.concurrent.Executor;

/**
* The base class of the application. Application will be started from this class.
*/
@SpringBootApplication
@EnableAsync
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class)
@EnableScheduling
public class TendertrackerApplication {

@Value("${application.timezone}")
Expand All @@ -32,6 +37,11 @@ public static void main(String[] args) {
SpringApplication.run(TendertrackerApplication.class, args);
}

/**
* This method used to create the admin filter.
*
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean adminFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
Expand All @@ -40,6 +50,11 @@ public FilterRegistrationBean adminFilter() {
return registration;
}

/**
* This method used to create the executor for async threads.
*
* @return Executor
*/
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
Expand Down
38 changes: 29 additions & 9 deletions src/main/java/com/chlorocode/tendertracker/WebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
* This class is used to control the security of the application by using spring security.
*/
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {


// @Autowired
// private AuthenticationSuccessHandler myAuthenticationSuccessHandler;

@Autowired
private AuthenticationFailureHandler authenticationFailureHandler;

Expand All @@ -32,20 +30,31 @@ public PasswordEncoder passwordEncoder() {

private AuthService authService;

/**
* Constructor.
*
* @param authService AuthService
*/
@Autowired
public WebSecurityConfig(AuthService authService) {
this.authService = authService;
}

/**
* This method is used to configure the HttpSecurity control of the application.
*
* @param http HttpSecurity
* @throws Exception Exception
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/registerCompany").authenticated()
.antMatchers("/tenderNotification").authenticated()
.antMatchers("/user/profile").authenticated()
.antMatchers("/admin").access("hasAnyRole('ADMIN','SYS_ADMIN','PREPARER')")
.antMatchers("/admin/**").access("hasAnyRole('ADMIN','PREPARER')")
.antMatchers("/admin").access("hasAnyRole('ADMIN','SYS_ADMIN','PREPARER','SUBMITTER')")
.antMatchers("/admin/**").access("hasAnyRole('ADMIN','PREPARER','SUBMITTER')")
.antMatchers("/sysadm/**").access("hasRole('SYS_ADMIN')")
.antMatchers("/**").permitAll()
.and()
Expand All @@ -55,7 +64,6 @@ protected void configure(HttpSecurity http) throws Exception {
.failureUrl("/login?error")
.usernameParameter("email")
.defaultSuccessUrl("/")
// .successHandler(myAuthenticationSuccessHandler)
.failureHandler(authenticationFailureHandler)
.permitAll()
.and()
Expand All @@ -64,16 +72,28 @@ protected void configure(HttpSecurity http) throws Exception {
.logoutSuccessUrl("/")
.permitAll()
.and()
.csrf();
.csrf().ignoringAntMatchers("/restapi/**");
}

/**
* This method is used to configure the WebSecurity control of the application.
*
* @param web WebSecurity
* @throws Exception exception
*/
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/images/**", "/data/**");
}

/**
* This method is used to configure the AuthenticationManagerBuilder for login of the application.
*
* @param auth AuthenticationManagerBuilder
* @throws Exception exception
*/
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/chlorocode/tendertracker/api/LongProcess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.chlorocode.tendertracker.api;

import com.chlorocode.tendertracker.dao.entity.ExternalTender;
import com.chlorocode.tendertracker.service.ExternalTenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;

import java.util.List;
import java.util.concurrent.Future;

/**
* This class is used to handle long process threading during external tender saving process.
*/
public class LongProcess {

@Autowired
private ExternalTenderService tenderWCService;

/**
* This method is used to save external tender asynchronously.
*
* @param tenders list of external tender to be saved
* @return String
*/
@Async
public Future<String> createExternalTenderList(List<ExternalTender> tenders) {
tenderWCService.createTenderWCList(tenders);
return new AsyncResult<>("success");
}

}
Loading

0 comments on commit 173f5e9

Please sign in to comment.