Skip to content

Commit 41bf4e7

Browse files
author
Rajeev Kumar Singh
committed
Corrected Typo
1 parent 34b7c71 commit 41bf4e7

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

jpa-one-to-many-demo/src/main/java/com/example/jpa/controller/CommentController.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
package com.example.jpa.controller;
22

3-
import com.example.jpa.exception.ResourceNotFoundExcption;
3+
import com.example.jpa.exception.ResourceNotFoundException;
44
import com.example.jpa.model.Comment;
55
import com.example.jpa.repository.CommentRepository;
66
import com.example.jpa.repository.PostRepository;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.data.domain.Page;
9-
import org.springframework.data.domain.PageRequest;
109
import org.springframework.data.domain.Pageable;
11-
import org.springframework.data.domain.Sort;
1210
import org.springframework.http.ResponseEntity;
1311
import org.springframework.web.bind.annotation.*;
1412

1513
import javax.validation.Valid;
16-
import java.util.List;
1714

1815
@RestController
1916
public class CommentController {
@@ -36,33 +33,33 @@ public Comment createComment(@PathVariable (value = "postId") Long postId,
3633
return postRepository.findById(postId).map(post -> {
3734
comment.setPost(post);
3835
return commentRepository.save(comment);
39-
}).orElseThrow(() -> new ResourceNotFoundExcption("PostId " + postId + " not found"));
36+
}).orElseThrow(() -> new ResourceNotFoundException("PostId " + postId + " not found"));
4037
}
4138

4239
@PutMapping("/posts/{postId}/comments/{commentId}")
4340
public Comment updateComment(@PathVariable (value = "postId") Long postId,
4441
@PathVariable (value = "commentId") Long commentId,
4542
@Valid @RequestBody Comment commentRequest) {
4643
if(!postRepository.existsById(postId)) {
47-
throw new ResourceNotFoundExcption("PostId " + postId + " not found");
44+
throw new ResourceNotFoundException("PostId " + postId + " not found");
4845
}
4946

5047
return commentRepository.findById(commentId).map(comment -> {
5148
comment.setText(commentRequest.getText());
5249
return commentRepository.save(comment);
53-
}).orElseThrow(() -> new ResourceNotFoundExcption("CommentId " + commentId + "not found"));
50+
}).orElseThrow(() -> new ResourceNotFoundException("CommentId " + commentId + "not found"));
5451
}
5552

5653
@DeleteMapping("/posts/{postId}/comments/{commentId}")
5754
public ResponseEntity<?> deleteComment(@PathVariable (value = "postId") Long postId,
5855
@PathVariable (value = "commentId") Long commentId) {
5956
if(!postRepository.existsById(postId)) {
60-
throw new ResourceNotFoundExcption("PostId " + postId + " not found");
57+
throw new ResourceNotFoundException("PostId " + postId + " not found");
6158
}
6259

6360
return commentRepository.findById(commentId).map(comment -> {
6461
commentRepository.delete(comment);
6562
return ResponseEntity.ok().build();
66-
}).orElseThrow(() -> new ResourceNotFoundExcption("CommentId " + commentId + " not found"));
63+
}).orElseThrow(() -> new ResourceNotFoundException("CommentId " + commentId + " not found"));
6764
}
6865
}

jpa-one-to-many-demo/src/main/java/com/example/jpa/controller/PostController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.jpa.controller;
22

3-
import com.example.jpa.exception.ResourceNotFoundExcption;
3+
import com.example.jpa.exception.ResourceNotFoundException;
44
import com.example.jpa.model.Post;
55
import com.example.jpa.repository.PostRepository;
66
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,7 +34,7 @@ public Post updatePost(@PathVariable Long postId, @Valid @RequestBody Post postR
3434
post.setDescription(postRequest.getDescription());
3535
post.setContent(postRequest.getContent());
3636
return postRepository.save(post);
37-
}).orElseThrow(() -> new ResourceNotFoundExcption("PostId " + postId + " not found"));
37+
}).orElseThrow(() -> new ResourceNotFoundException("PostId " + postId + " not found"));
3838
}
3939

4040

@@ -43,7 +43,7 @@ public ResponseEntity<?> deletePost(@PathVariable Long postId) {
4343
return postRepository.findById(postId).map(post -> {
4444
postRepository.delete(post);
4545
return ResponseEntity.ok().build();
46-
}).orElseThrow(() -> new ResourceNotFoundExcption("PostId " + postId + " not found"));
46+
}).orElseThrow(() -> new ResourceNotFoundException("PostId " + postId + " not found"));
4747
}
4848

4949
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import org.springframework.web.bind.annotation.ResponseStatus;
55

66
@ResponseStatus(HttpStatus.NOT_FOUND)
7-
public class ResourceNotFoundExcption extends RuntimeException {
8-
public ResourceNotFoundExcption() {
7+
public class ResourceNotFoundException extends RuntimeException {
8+
public ResourceNotFoundException() {
99
super();
1010
}
1111

12-
public ResourceNotFoundExcption(String message) {
12+
public ResourceNotFoundException(String message) {
1313
super(message);
1414
}
1515

16-
public ResourceNotFoundExcption(String message, Throwable cause) {
16+
public ResourceNotFoundException(String message, Throwable cause) {
1717
super(message, cause);
1818
}
1919
}

0 commit comments

Comments
 (0)