diff --git a/src/main/java/io/spring/projectapi/github/GithubOperations.java b/src/main/java/io/spring/projectapi/github/GithubOperations.java index f3a6390..dd1577b 100644 --- a/src/main/java/io/spring/projectapi/github/GithubOperations.java +++ b/src/main/java/io/spring/projectapi/github/GithubOperations.java @@ -35,6 +35,8 @@ import io.spring.projectapi.github.ProjectDocumentation.Status; import org.apache.maven.artifact.versioning.ComparableVersion; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.cache.annotation.Cacheable; @@ -78,6 +80,8 @@ public class GithubOperations { private final String branch; + private static final Logger logger = LoggerFactory.getLogger(GithubOperations.class); + public GithubOperations(RestTemplateBuilder restTemplateBuilder, ObjectMapper objectMapper, String token, String branch) { this.restTemplate = restTemplateBuilder.rootUri(GITHUB_URI) @@ -95,13 +99,6 @@ private static int compare(ProjectDocumentation o1, ProjectDocumentation o2) { return -version1.compareTo(version2); } - @Cacheable(value = "documentation", key = "#projectSlug") - public List getProjectDocumentations(String projectSlug) { - ResponseEntity> response = getFile(projectSlug, "documentation.json"); - String content = getFileContents(response); - return convertToProjectDocumentation(content); - } - public void addProjectDocumentation(String projectSlug, ProjectDocumentation documentation) { ResponseEntity> response = getFile(projectSlug, "documentation.json"); List documentations = new ArrayList<>(); @@ -212,6 +209,7 @@ public void deleteDocumentation(String projectSlug, String version) { } private ResponseEntity> getFile(String projectSlug, String fileName) { + logger.info("****In private getFile for project " + projectSlug); RequestEntity request = RequestEntity .get("/project/{projectSlug}/{fileName}?ref=" + this.branch, projectSlug, fileName) .build(); @@ -219,6 +217,7 @@ private ResponseEntity> getFile(String projectSlug, String f return this.restTemplate.exchange(request, STRING_OBJECT_MAP); } catch (HttpClientErrorException ex) { + logger.info("****In private getFile for project with exception " + projectSlug); HttpStatusCode statusCode = ex.getStatusCode(); if (statusCode.value() == 404) { throwIfProjectDoesNotExist(projectSlug); @@ -256,6 +255,7 @@ private String getFileSha(ResponseEntity> exchange) { public List getProjects() { List projects = new ArrayList<>(); try { + logger.info("****In getProjects"); RequestEntity request = RequestEntity.get("/project?ref=" + this.branch).build(); ResponseEntity>> exchange = this.restTemplate.exchange(request, STRING_OBJECT_MAP_LIST); @@ -279,6 +279,7 @@ public List getProjects() { @Cacheable(value = "project", key = "#projectSlug") public Project getProject(String projectSlug) { + logger.info("****In getProject with project " + projectSlug); ResponseEntity> response = getFile(projectSlug, "index.md"); String contents = getFileContents(response); Map frontMatter = MarkdownUtils.getFrontMatter(contents); @@ -287,8 +288,17 @@ public Project getProject(String projectSlug) { return this.objectMapper.convertValue(frontMatter, Project.class); } + @Cacheable(value = "documentation", key = "#projectSlug") + public List getProjectDocumentations(String projectSlug) { + logger.info("****In getProjectDocumentations with project " + projectSlug); + ResponseEntity> response = getFile(projectSlug, "documentation.json"); + String content = getFileContents(response); + return convertToProjectDocumentation(content); + } + @Cacheable(value = "support", key = "#projectSlug") public List getProjectSupports(String projectSlug) { + logger.info("****In getProjectSupports with project " + projectSlug); ResponseEntity> response = getFile(projectSlug, "support.json"); if (response == null) { return Collections.emptyList(); @@ -306,6 +316,7 @@ public List getProjectSupports(String projectSlug) { @Cacheable(value = "support_policy", key = "#projectSlug") public String getProjectSupportPolicy(String projectSlug) { + logger.info("****In getProjectSupportPolicy with project " + projectSlug); ResponseEntity> indexResponse = getFile(projectSlug, "index.md"); String indexContents = getFileContents(indexResponse); Map frontMatter = MarkdownUtils.getFrontMatter(indexContents);