3535import io .spring .projectapi .github .ProjectDocumentation .Status ;
3636import org .apache .maven .artifact .versioning .ComparableVersion ;
3737import org .jetbrains .annotations .NotNull ;
38+ import org .slf4j .Logger ;
39+ import org .slf4j .LoggerFactory ;
3840
3941import org .springframework .boot .web .client .RestTemplateBuilder ;
4042import org .springframework .cache .annotation .Cacheable ;
@@ -78,6 +80,8 @@ public class GithubOperations {
7880
7981 private final String branch ;
8082
83+ private static final Logger logger = LoggerFactory .getLogger (GithubOperations .class );
84+
8185 public GithubOperations (RestTemplateBuilder restTemplateBuilder , ObjectMapper objectMapper , String token ,
8286 String branch ) {
8387 this .restTemplate = restTemplateBuilder .rootUri (GITHUB_URI )
@@ -95,13 +99,6 @@ private static int compare(ProjectDocumentation o1, ProjectDocumentation o2) {
9599 return -version1 .compareTo (version2 );
96100 }
97101
98- @ Cacheable (value = "documentation" , key = "#projectSlug" )
99- public List <ProjectDocumentation > getProjectDocumentations (String projectSlug ) {
100- ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "documentation.json" );
101- String content = getFileContents (response );
102- return convertToProjectDocumentation (content );
103- }
104-
105102 public void addProjectDocumentation (String projectSlug , ProjectDocumentation documentation ) {
106103 ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "documentation.json" );
107104 List <ProjectDocumentation > documentations = new ArrayList <>();
@@ -212,13 +209,15 @@ public void deleteDocumentation(String projectSlug, String version) {
212209 }
213210
214211 private ResponseEntity <Map <String , Object >> getFile (String projectSlug , String fileName ) {
212+ logger .info ("****In private getFile for project " + projectSlug );
215213 RequestEntity <Void > request = RequestEntity
216214 .get ("/project/{projectSlug}/{fileName}?ref=" + this .branch , projectSlug , fileName )
217215 .build ();
218216 try {
219217 return this .restTemplate .exchange (request , STRING_OBJECT_MAP );
220218 }
221219 catch (HttpClientErrorException ex ) {
220+ logger .info ("****In private getFile for project with exception " + projectSlug );
222221 HttpStatusCode statusCode = ex .getStatusCode ();
223222 if (statusCode .value () == 404 ) {
224223 throwIfProjectDoesNotExist (projectSlug );
@@ -256,6 +255,7 @@ private String getFileSha(ResponseEntity<Map<String, Object>> exchange) {
256255 public List <Project > getProjects () {
257256 List <Project > projects = new ArrayList <>();
258257 try {
258+ logger .info ("****In getProjects" );
259259 RequestEntity <Void > request = RequestEntity .get ("/project?ref=" + this .branch ).build ();
260260 ResponseEntity <List <Map <String , Object >>> exchange = this .restTemplate .exchange (request ,
261261 STRING_OBJECT_MAP_LIST );
@@ -279,6 +279,7 @@ public List<Project> getProjects() {
279279
280280 @ Cacheable (value = "project" , key = "#projectSlug" )
281281 public Project getProject (String projectSlug ) {
282+ logger .info ("****In getProject with project " + projectSlug );
282283 ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "index.md" );
283284 String contents = getFileContents (response );
284285 Map <String , String > frontMatter = MarkdownUtils .getFrontMatter (contents );
@@ -287,8 +288,17 @@ public Project getProject(String projectSlug) {
287288 return this .objectMapper .convertValue (frontMatter , Project .class );
288289 }
289290
291+ @ Cacheable (value = "documentation" , key = "#projectSlug" )
292+ public List <ProjectDocumentation > getProjectDocumentations (String projectSlug ) {
293+ logger .info ("****In getProjectDocumentations with project " + projectSlug );
294+ ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "documentation.json" );
295+ String content = getFileContents (response );
296+ return convertToProjectDocumentation (content );
297+ }
298+
290299 @ Cacheable (value = "support" , key = "#projectSlug" )
291300 public List <ProjectSupport > getProjectSupports (String projectSlug ) {
301+ logger .info ("****In getProjectSupports with project " + projectSlug );
292302 ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "support.json" );
293303 if (response == null ) {
294304 return Collections .emptyList ();
@@ -306,6 +316,7 @@ public List<ProjectSupport> getProjectSupports(String projectSlug) {
306316
307317 @ Cacheable (value = "support_policy" , key = "#projectSlug" )
308318 public String getProjectSupportPolicy (String projectSlug ) {
319+ logger .info ("****In getProjectSupportPolicy with project " + projectSlug );
309320 ResponseEntity <Map <String , Object >> indexResponse = getFile (projectSlug , "index.md" );
310321 String indexContents = getFileContents (indexResponse );
311322 Map <String , String > frontMatter = MarkdownUtils .getFrontMatter (indexContents );
0 commit comments