Skip to content

Commit c123f7a

Browse files
committed
Cambios varios
1 parent e4a8651 commit c123f7a

27 files changed

Lines changed: 257 additions & 105 deletions

pom.xml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>2.1.8.RELEASE</version>
18+
<!--<version>2.1.8.RELEASE</version>-->
19+
<version>2.5.6</version>
1920
<relativePath/> <!-- lookup parent from repository -->
2021
</parent>
2122

@@ -49,26 +50,41 @@
4950
<artifactId>spring-boot-starter-web</artifactId>
5051
</dependency>
5152

53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-starter-validation</artifactId>
56+
</dependency>
57+
5258
<dependency>
5359
<groupId>org.springframework.boot</groupId>
5460
<artifactId>spring-boot-starter-aop</artifactId>
5561
</dependency>
5662

5763
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
58-
<dependency>
64+
<!--<dependency>
5965
<groupId>org.springframework.boot</groupId>
6066
<artifactId>spring-boot-starter-test</artifactId>
6167
<scope>test</scope>
62-
</dependency>
68+
</dependency>-->
69+
6370

6471
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
65-
<dependency>
72+
<!--<dependency>
6673
<groupId>org.mockito</groupId>
6774
<artifactId>mockito-all</artifactId>
6875
<version>2.0.2-beta</version>
6976
<scope>test</scope>
77+
</dependency>-->
78+
79+
<dependency>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-starter-test</artifactId>
82+
<scope>test</scope>
83+
7084
</dependency>
7185

86+
87+
7288
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-test -->
7389
<dependency>
7490
<groupId>org.springframework.security</groupId>
@@ -139,6 +155,12 @@
139155
<artifactId>commons-lang3</artifactId>
140156
</dependency>
141157

158+
<dependency>
159+
<groupId>com.h2database</groupId>
160+
<artifactId>h2</artifactId>
161+
<scope>runtime</scope>
162+
</dependency>
163+
142164
</dependencies>
143165

144166
<build>

src/main/java/com/sopromadze/blogapi/BlogApiApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ void init() {
2525
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
2626
}
2727

28-
@Bean
28+
/*@Bean
2929
public JwtAuthenticationFilter jwtAuthenticationFilter() {
3030
return new JwtAuthenticationFilter();
31-
}
31+
}*/
3232

3333
@Bean
3434
public ModelMapper modelMapper() {

src/main/java/com/sopromadze/blogapi/config/SecutiryConfig.java renamed to src/main/java/com/sopromadze/blogapi/config/SecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
securedEnabled = true,
2727
jsr250Enabled = true,
2828
prePostEnabled = true)
29-
public class SecutiryConfig extends WebSecurityConfigurerAdapter {
29+
public class SecurityConfig extends WebSecurityConfigurerAdapter {
3030
private final CustomUserDetailsServiceImpl customUserDetailsService;
3131
private final JwtAuthenticationEntryPoint unauthorizedHandler;
3232
private final JwtAuthenticationFilter jwtAuthenticationFilter;
3333

3434
@Autowired
35-
public SecutiryConfig(UserRepository userRepository, CustomUserDetailsServiceImpl customUserDetailsService,
36-
JwtAuthenticationEntryPoint unauthorizedHandler, JwtAuthenticationFilter jwtAuthenticationFilter) {
35+
public SecurityConfig(UserRepository userRepository, CustomUserDetailsServiceImpl customUserDetailsService,
36+
JwtAuthenticationEntryPoint unauthorizedHandler, JwtAuthenticationFilter jwtAuthenticationFilter) {
3737
this.customUserDetailsService = customUserDetailsService;
3838
this.unauthorizedHandler = unauthorizedHandler;
3939
this.jwtAuthenticationFilter = jwtAuthenticationFilter;

src/main/java/com/sopromadze/blogapi/controller/AlbumController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.sopromadze.blogapi.service.PhotoService;
1414
import com.sopromadze.blogapi.utils.AppConstants;
1515
import com.sopromadze.blogapi.utils.AppUtils;
16+
import lombok.RequiredArgsConstructor;
1617
import org.springframework.beans.factory.annotation.Autowired;
1718
import org.springframework.http.HttpStatus;
1819
import org.springframework.http.ResponseEntity;
@@ -32,12 +33,12 @@
3233

3334
@RestController
3435
@RequestMapping("/api/albums")
36+
@RequiredArgsConstructor
3537
public class AlbumController {
36-
@Autowired
37-
private AlbumService albumService;
3838

39-
@Autowired
40-
private PhotoService photoService;
39+
private final AlbumService albumService;
40+
41+
private final PhotoService photoService;
4142

4243
@ExceptionHandler(ResponseEntityErrorException.class)
4344
public ResponseEntity<ApiResponse> handleExceptions(ResponseEntityErrorException exception) {

src/main/java/com/sopromadze/blogapi/controller/AuthController.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.sopromadze.blogapi.repository.RoleRepository;
1313
import com.sopromadze.blogapi.repository.UserRepository;
1414
import com.sopromadze.blogapi.security.JwtTokenProvider;
15+
import lombok.RequiredArgsConstructor;
1516
import org.springframework.beans.factory.annotation.Autowired;
1617
import org.springframework.http.HttpStatus;
1718
import org.springframework.http.ResponseEntity;
@@ -33,23 +34,20 @@
3334

3435
@RestController
3536
@RequestMapping("/api/auth")
37+
@RequiredArgsConstructor
3638
public class AuthController {
3739
private static final String USER_ROLE_NOT_SET = "User role not set";
3840

39-
@Autowired
40-
private AuthenticationManager authenticationManager;
4141

42-
@Autowired
43-
private UserRepository userRepository;
42+
private final AuthenticationManager authenticationManager;
4443

45-
@Autowired
46-
private RoleRepository roleRepository;
44+
private final UserRepository userRepository;
4745

48-
@Autowired
49-
private PasswordEncoder passwordEncoder;
46+
private final RoleRepository roleRepository;
5047

51-
@Autowired
52-
private JwtTokenProvider jwtTokenProvider;
48+
private final PasswordEncoder passwordEncoder;
49+
50+
private final JwtTokenProvider jwtTokenProvider;
5351

5452
@PostMapping("/signin")
5553
public ResponseEntity<JwtAuthenticationResponse> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {

src/main/java/com/sopromadze/blogapi/controller/CategoryController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.sopromadze.blogapi.security.UserPrincipal;
99
import com.sopromadze.blogapi.service.CategoryService;
1010
import com.sopromadze.blogapi.utils.AppConstants;
11+
import lombok.RequiredArgsConstructor;
1112
import org.springframework.beans.factory.annotation.Autowired;
1213
import org.springframework.http.ResponseEntity;
1314
import org.springframework.security.access.prepost.PreAuthorize;
@@ -25,9 +26,10 @@
2526

2627
@RestController
2728
@RequestMapping("/api/categories")
29+
@RequiredArgsConstructor
2830
public class CategoryController {
29-
@Autowired
30-
private CategoryService categoryService;
31+
32+
private final CategoryService categoryService;
3133

3234
@GetMapping
3335
public PagedResponse<Category> getAllCategories(

src/main/java/com/sopromadze/blogapi/controller/CommentController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import com.sopromadze.blogapi.security.UserPrincipal;
99
import com.sopromadze.blogapi.service.CommentService;
1010
import com.sopromadze.blogapi.utils.AppConstants;
11+
import lombok.RequiredArgsConstructor;
1112
import org.springframework.beans.factory.annotation.Autowired;
13+
import org.springframework.beans.factory.annotation.Required;
1214
import org.springframework.http.HttpStatus;
1315
import org.springframework.http.ResponseEntity;
1416
import org.springframework.security.access.prepost.PreAuthorize;
@@ -26,9 +28,10 @@
2628

2729
@RestController
2830
@RequestMapping("/api/posts/{postId}/comments")
31+
@RequiredArgsConstructor
2932
public class CommentController {
30-
@Autowired
31-
private CommentService commentService;
33+
34+
private final CommentService commentService;
3235

3336
@GetMapping
3437
public ResponseEntity<PagedResponse<Comment>> getAllComments(@PathVariable(name = "postId") Long postId,

src/main/java/com/sopromadze/blogapi/controller/PhotoController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.sopromadze.blogapi.security.UserPrincipal;
99
import com.sopromadze.blogapi.service.PhotoService;
1010
import com.sopromadze.blogapi.utils.AppConstants;
11+
import lombok.RequiredArgsConstructor;
1112
import org.springframework.beans.factory.annotation.Autowired;
1213
import org.springframework.http.HttpStatus;
1314
import org.springframework.http.ResponseEntity;
@@ -26,9 +27,11 @@
2627

2728
@RestController
2829
@RequestMapping("/api/photos")
30+
@RequiredArgsConstructor
2931
public class PhotoController {
30-
@Autowired
31-
private PhotoService photoService;
32+
33+
34+
private final PhotoService photoService;
3235

3336
@GetMapping
3437
public PagedResponse<PhotoResponse> getAllPhotos(

src/main/java/com/sopromadze/blogapi/controller/PostController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.sopromadze.blogapi.security.UserPrincipal;
1010
import com.sopromadze.blogapi.service.PostService;
1111
import com.sopromadze.blogapi.utils.AppConstants;
12+
import lombok.RequiredArgsConstructor;
1213
import org.springframework.beans.factory.annotation.Autowired;
1314
import org.springframework.http.HttpStatus;
1415
import org.springframework.http.ResponseEntity;
@@ -27,9 +28,11 @@
2728

2829
@RestController
2930
@RequestMapping("/api/posts")
31+
@RequiredArgsConstructor
3032
public class PostController {
31-
@Autowired
32-
private PostService postService;
33+
34+
35+
private final PostService postService;
3336

3437
@GetMapping
3538
public ResponseEntity<PagedResponse<Post>> getAllPosts(

src/main/java/com/sopromadze/blogapi/controller/TagController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.sopromadze.blogapi.security.UserPrincipal;
88
import com.sopromadze.blogapi.service.TagService;
99
import com.sopromadze.blogapi.utils.AppConstants;
10+
import lombok.RequiredArgsConstructor;
1011
import org.springframework.beans.factory.annotation.Autowired;
1112
import org.springframework.http.HttpStatus;
1213
import org.springframework.http.ResponseEntity;
@@ -25,9 +26,11 @@
2526

2627
@RestController
2728
@RequestMapping("/api/tags")
29+
@RequiredArgsConstructor
2830
public class TagController {
29-
@Autowired
30-
private TagService tagService;
31+
32+
33+
private final TagService tagService;
3134

3235
@GetMapping
3336
public ResponseEntity<PagedResponse<Tag>> getAllTags(

0 commit comments

Comments
 (0)