Skip to content

Commit d202951

Browse files
committed
Replace contentful backend with github
Closes gh-21
1 parent 653d6d7 commit d202951

File tree

61 files changed

+10237
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+10237
-134
lines changed

README.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Spring projects are listed and documented on the spring.io website.
44
We can find there information about releases, samples, support and more.
5-
These projects are managed in Contentful.
5+
These projects are managed in Github.
66

7-
This project provides a RESTful web layer on top of Contentful's API for fetching and updating Spring Project Metadata.
7+
This project provides a RESTful web layer on top of Github's API for fetching and updating Spring Project Metadata.
88
It uses hypermedia to describe the relationships between resources and to allow navigation between them.
99

1010
## Running the app locally
@@ -14,14 +14,11 @@ Configure the application with the following properties:
1414
[source,yaml]
1515
----
1616
projects:
17-
contentful:
18-
access-token:
19-
content-management-token:
20-
space-id:
21-
environment-id:
2217
github:
2318
org:
2419
team:
20+
accessToken:
21+
branch:
2522
----
2623

2724
Build the application with `./gradlew build`.

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ dependencies {
4242
implementation 'org.springframework.boot:spring-boot-starter-graphql'
4343
implementation 'com.azure.spring:spring-cloud-azure-starter-keyvault-secrets'
4444
implementation 'com.contentful.java:cma-sdk:3.4.12'
45+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
46+
implementation 'com.vladsch.flexmark:flexmark-all:0.64.8'
47+
implementation 'org.apache.maven:maven-artifact:3.6.3'
4548
testImplementation 'com.squareup.okhttp3:mockwebserver'
4649
testImplementation 'org.springframework.boot:spring-boot-starter-test'
4750
testImplementation 'org.springframework.graphql:spring-graphql-test'

src/main/java/io/spring/projectapi/Application.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020
import io.spring.projectapi.ApplicationProperties.Contentful;
21+
import io.spring.projectapi.ApplicationProperties.Github;
2122
import io.spring.projectapi.contentful.ContentfulService;
23+
import io.spring.projectapi.github.GithubOperations;
2224

2325
import org.springframework.boot.SpringApplication;
2426
import org.springframework.boot.autoconfigure.SpringBootApplication;
2527
import org.springframework.boot.context.properties.EnableConfigurationProperties;
28+
import org.springframework.boot.web.client.RestTemplateBuilder;
2629
import org.springframework.context.annotation.Bean;
2730
import org.springframework.web.reactive.function.client.WebClient;
2831

@@ -46,6 +49,15 @@ public ContentfulService contentfulService(ObjectMapper objectMapper, WebClient.
4649
environmentId);
4750
}
4851

52+
@Bean
53+
public GithubOperations githubOperations(RestTemplateBuilder builder, ObjectMapper objectMapper,
54+
ApplicationProperties properties) {
55+
Github github = properties.getGithub();
56+
String accessToken = github.getAccesstoken();
57+
String branch = github.getBranch();
58+
return new GithubOperations(builder, objectMapper, accessToken, branch);
59+
}
60+
4961
public static void main(String[] args) {
5062
SpringApplication.run(Application.class, args);
5163
}

src/main/java/io/spring/projectapi/ApplicationProperties.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,22 @@ public static class Github {
124124
*/
125125
private String team;
126126

127+
/**
128+
* Github access token for accessing the API.
129+
*/
130+
private String accesstoken;
131+
132+
/**
133+
* Github branch to use for fetching and updating content.
134+
*/
135+
private String branch;
136+
127137
@ConstructorBinding
128-
Github(String org, String team) {
138+
Github(String org, String team, String accesstoken, @DefaultValue("main") String branch) {
129139
this.org = org;
130140
this.team = team;
141+
this.accesstoken = accesstoken;
142+
this.branch = branch;
131143
}
132144

133145
public String getOrg() {
@@ -138,6 +150,14 @@ public String getTeam() {
138150
return this.team;
139151
}
140152

153+
public String getBranch() {
154+
return this.branch;
155+
}
156+
157+
public String getAccesstoken() {
158+
return this.accesstoken;
159+
}
160+
141161
}
142162

143163
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2022-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.spring.projectapi.github;
18+
19+
/**
20+
* {@link RuntimeException} indicating a problem with Github.
21+
*
22+
* @author Madhura Bhave
23+
*/
24+
public class GithubException extends RuntimeException {
25+
26+
GithubException(String message) {
27+
super(message);
28+
}
29+
30+
GithubException(Throwable cause) {
31+
super(cause);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)