From 1ca4c4ce8d8da50a79dfdd21793b30080ab6cb98 Mon Sep 17 00:00:00 2001 From: Janek1010 Date: Thu, 15 Feb 2024 15:30:16 +0100 Subject: [PATCH] CHORE: Removing comments --- .../controller/GithubController.java | 17 ----------------- .../githubservice/model/dtos/BranchDTO.java | 10 ---------- .../githubservice/model/dtos/CommitDTO.java | 6 ------ .../githubservice/model/dtos/OwnerDTO.java | 3 --- .../model/dtos/RepositoryDTO.java | 18 ------------------ .../dtos/UserNotFoundErrorResponseDTO.java | 10 +--------- .../service/api/GithubService.java | 18 ------------------ .../service/impl/GithubServiceImpl.java | 7 ------- 8 files changed, 1 insertion(+), 88 deletions(-) diff --git a/src/main/java/org/example/githubservice/controller/GithubController.java b/src/main/java/org/example/githubservice/controller/GithubController.java index f3288b0..eeeb21e 100644 --- a/src/main/java/org/example/githubservice/controller/GithubController.java +++ b/src/main/java/org/example/githubservice/controller/GithubController.java @@ -10,26 +10,12 @@ import org.springframework.web.server.ResponseStatusException; import reactor.core.publisher.Flux; -/** - * Class that handles the requests to the Github API. - */ @RestController @RequiredArgsConstructor public class GithubController { private final String REPOS_OF_USER = "/api/v1/users/{username}/repos"; private final GithubService githubService; - /** - * Retrieves a list of all repositories owned by the specified GitHub user. - * This version of the API does not require authorization, allowing up to 60 requests per hour. - * - * @param username GitHub username. - * @param page Page number to be returned. - * @param perPage Number of records per page; GitHub handles a maximum of 100. - * @return A stream of repositories in JSON format, including owner login, repository name, and branches. - * Returns 404 if the user is not found, 200 OK if the user is found. - * @see documentation of endpoint - */ @GetMapping(value = REPOS_OF_USER, produces = MediaType.APPLICATION_JSON_VALUE) public Flux listAllRepositoriesOfUser(@PathVariable String username, @RequestParam(defaultValue = "0") int page, @@ -37,9 +23,6 @@ public Flux listAllRepositoriesOfUser(@PathVariable String userna return githubService.listAllRepositoriesOfUser(username, page, perPage); } - /** - * The method is responsible for returning the error message in a different format. - */ @ExceptionHandler(ResponseStatusException.class) public ResponseEntity handleResponseStatusException(ResponseStatusException ex) { return ResponseEntity.status(ex.getStatusCode()).body(UserNotFoundErrorResponseDTO diff --git a/src/main/java/org/example/githubservice/model/dtos/BranchDTO.java b/src/main/java/org/example/githubservice/model/dtos/BranchDTO.java index 6fbdb20..44a0c3a 100644 --- a/src/main/java/org/example/githubservice/model/dtos/BranchDTO.java +++ b/src/main/java/org/example/githubservice/model/dtos/BranchDTO.java @@ -5,23 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; -/** - * Represents a branch of a repository. - */ @Data @Builder @AllArgsConstructor @NoArgsConstructor public class BranchDTO { - /** - * Name of the branch. - */ private String name; - - /** - * Last commit associated with the branch. - */ private CommitDTO commit; } diff --git a/src/main/java/org/example/githubservice/model/dtos/CommitDTO.java b/src/main/java/org/example/githubservice/model/dtos/CommitDTO.java index 9ec7ad5..1648516 100644 --- a/src/main/java/org/example/githubservice/model/dtos/CommitDTO.java +++ b/src/main/java/org/example/githubservice/model/dtos/CommitDTO.java @@ -7,18 +7,12 @@ import lombok.Data; import lombok.NoArgsConstructor; -/** - * Represents a commit in a repository. - */ @Data @Builder @AllArgsConstructor @NoArgsConstructor public class CommitDTO { - /** - * SHA of the LAST commit. - */ @JsonValue @JsonProperty("sha") private String sha; diff --git a/src/main/java/org/example/githubservice/model/dtos/OwnerDTO.java b/src/main/java/org/example/githubservice/model/dtos/OwnerDTO.java index 71a8da4..e9ef993 100644 --- a/src/main/java/org/example/githubservice/model/dtos/OwnerDTO.java +++ b/src/main/java/org/example/githubservice/model/dtos/OwnerDTO.java @@ -7,9 +7,6 @@ import lombok.Data; import lombok.NoArgsConstructor; -/** - * Represents the owner of a repository. - */ @Data @Builder @AllArgsConstructor diff --git a/src/main/java/org/example/githubservice/model/dtos/RepositoryDTO.java b/src/main/java/org/example/githubservice/model/dtos/RepositoryDTO.java index bbf2a57..6b5a705 100644 --- a/src/main/java/org/example/githubservice/model/dtos/RepositoryDTO.java +++ b/src/main/java/org/example/githubservice/model/dtos/RepositoryDTO.java @@ -6,37 +6,19 @@ import java.util.List; -/** - * Represents a repository on GitHub. - */ @Data @Builder public class RepositoryDTO { - /** - * Name of the repository. - */ private String name; - /** - * Owner of the repository. In the response there will be presented value 'login' from OwnerDTO as ownerLogin - */ @JsonProperty("ownerLogin") private OwnerDTO owner; - /** - * Indicates if the repository is a fork. Invisible in a response - */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private boolean fork; - /** - * URL to list branches of the repository. Invisible in a response - */ @JsonProperty(value = "branches_url", access = JsonProperty.Access.WRITE_ONLY) private String branchesUrl; - /** - * List of branches of the repository. - */ private List branches; } diff --git a/src/main/java/org/example/githubservice/model/dtos/UserNotFoundErrorResponseDTO.java b/src/main/java/org/example/githubservice/model/dtos/UserNotFoundErrorResponseDTO.java index cf85d75..6ed8aac 100644 --- a/src/main/java/org/example/githubservice/model/dtos/UserNotFoundErrorResponseDTO.java +++ b/src/main/java/org/example/githubservice/model/dtos/UserNotFoundErrorResponseDTO.java @@ -4,19 +4,11 @@ import lombok.Data; import org.springframework.http.HttpStatusCode; -/** - * Represents a customized error response for user not found. - */ @Data @Builder public class UserNotFoundErrorResponseDTO { - /** - * HTTP status code of the error response. - */ + private HttpStatusCode status; - /** - * Error message for user not found. - */ private String message; } diff --git a/src/main/java/org/example/githubservice/service/api/GithubService.java b/src/main/java/org/example/githubservice/service/api/GithubService.java index 8ba73f9..c1706ed 100644 --- a/src/main/java/org/example/githubservice/service/api/GithubService.java +++ b/src/main/java/org/example/githubservice/service/api/GithubService.java @@ -4,25 +4,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** - * Service interface for interacting with the GitHub API. - */ public interface GithubService { - /** - * Retrieves a list of all repositories owned by the specified user. - * - * @param username GitHub username of the user. - * @param page Page number to be returned. - * @param perPage Number of records per page. - * @return A flux of RepositoryDTO representing the repositories. - */ Flux listAllRepositoriesOfUser(String username, int page, int perPage); - - /** - * Retrieves a list of all branches for the specified repository. - * - * @param repositoryDTO The RepositoryDTO for which to retrieve branches. - * @return A mono of RepositoryDTO representing the repository with branches. - */ Mono listAllBranches(RepositoryDTO repositoryDTO); } diff --git a/src/main/java/org/example/githubservice/service/impl/GithubServiceImpl.java b/src/main/java/org/example/githubservice/service/impl/GithubServiceImpl.java index d9d82ca..bf4f047 100644 --- a/src/main/java/org/example/githubservice/service/impl/GithubServiceImpl.java +++ b/src/main/java/org/example/githubservice/service/impl/GithubServiceImpl.java @@ -12,9 +12,6 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** - * Implementation of the GithubService interface for interacting with the GitHub API. - */ @Service @Primary public class GithubServiceImpl implements GithubService { @@ -34,13 +31,10 @@ public Flux listAllRepositoriesOfUser(String username, int page, .build(username)) .accept(MediaType.APPLICATION_JSON) .retrieve() - // Handles response statuses, in this case 404 (NOT_FOUND). .onStatus(status -> status.value() == HttpStatus.NOT_FOUND.value(), clientResponse -> Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND, "User not found"))) - // Maps the response body to a Flux stream. .bodyToFlux(RepositoryDTO.class) .filter(repositoryDTO -> !repositoryDTO.isFork()) - // For each repository, calls the listAllBranches method to retrieve a list of branches. .flatMap(this::listAllBranches); } @@ -53,7 +47,6 @@ public Mono listAllBranches(RepositoryDTO repositoryDTO) { .retrieve() .bodyToFlux(BranchDTO.class) .collectList() - // Collected branches are mapped to a list and assigned to the repository. .map(branches -> { repositoryDTO.setBranches(branches); return repositoryDTO;