-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit also breaks out Github operations for fetch into a new class. Exceptions that are encountered when loading the cache are ignored so that cache creation does not fail. Exceptions encountered on writes to Github are bubbled up and handled using a ControllerAdvice.
- Loading branch information
Showing
14 changed files
with
831 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/io/spring/projectapi/github/GithubProjectRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2022-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.spring.projectapi.github; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import io.spring.projectapi.ProjectRepository; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* {@link ProjectRepository} backed by Github. | ||
* | ||
* @author Madhura Bhave | ||
* @author Phillip Webb | ||
*/ | ||
@Component | ||
class GithubProjectRepository implements ProjectRepository { | ||
|
||
private final GithubQueries githubQueries; | ||
|
||
private transient ProjectData projectData; | ||
|
||
GithubProjectRepository(GithubQueries githubQueries) { | ||
this.githubQueries = githubQueries; | ||
this.projectData = ProjectData.load(githubQueries); | ||
} | ||
|
||
@Override | ||
public void update() { | ||
this.projectData = ProjectData.load(this.githubQueries); | ||
} | ||
|
||
@Override | ||
public Collection<Project> getProjects() { | ||
return this.projectData.project().values(); | ||
} | ||
|
||
@Override | ||
public Project getProject(String projectSlug) { | ||
Project project = this.projectData.project().get(projectSlug); | ||
NoSuchGithubProjectException.throwIfNotFound(project, projectSlug); | ||
return project; | ||
} | ||
|
||
@Override | ||
public List<ProjectDocumentation> getProjectDocumentations(String projectSlug) { | ||
List<ProjectDocumentation> documentations = this.projectData.documentation().get(projectSlug); | ||
NoSuchGithubProjectException.throwIfNotFound(documentations, projectSlug); | ||
return documentations; | ||
} | ||
|
||
@Override | ||
public List<ProjectSupport> getProjectSupports(String projectSlug) { | ||
List<ProjectSupport> projectSupports = this.projectData.support().get(projectSlug); | ||
NoSuchGithubProjectException.throwIfNotFound(projectSupports, projectSlug); | ||
return projectSupports; | ||
} | ||
|
||
@Override | ||
public String getProjectSupportPolicy(String projectSlug) { | ||
String policy = this.projectData.supportPolicy().get(projectSlug); | ||
NoSuchGithubProjectException.throwIfNotFound(policy, projectSlug); | ||
return policy; | ||
} | ||
|
||
} |
Oops, something went wrong.