-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE #339] Add a skeleton for separated openschema registry service…
… and implement most APIs that doesn't need compatibility check. (#525) * [ISSUE #339] a skeleton of independent openschema registry service * add license for build.gradle add license for ```incubator-eventmesh/eventmesh-openschema/build.gradle``` * modify license modify license of ```incubator-eventmesh/eventmesh-openschema/build.gradle``` * update license update license of ```build.gradle``` in ```incubator-eventmesh/eventmesh-openschema/eventmesh-openschema-registry``` * Update application.yml update license of ```application.yml``` in ```incubator-eventmesh/eventmesh-openschema/eventmesh-openschema-registry``` * [ISSUE #339] add FLIP-like progress * [ISSUE #339] fix allowed-licenses.txt and remove unused dependencies * [ISSUE #339] remove null in allowed-licenses.txt and move dependency version in root-build.gradle
- Loading branch information
Showing
34 changed files
with
1,754 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
plugins { | ||
} | ||
|
||
group 'org.apache.eventmesh' | ||
version '1.2.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
44 changes: 44 additions & 0 deletions
44
eventmesh-openschema/eventmesh-openschema-registry/build.gradle
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,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
group 'org.apache.eventmesh' | ||
version '1.2.0-SNAPSHOT' | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
implementation 'org.springframework.boot:spring-boot-starter-jdbc' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework:spring-beans' | ||
compileOnly 'org.projectlombok:lombok' | ||
runtimeOnly 'com.h2database:h2' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
29 changes: 29 additions & 0 deletions
29
.../src/main/java/org/apache/eventmesh/openschemaregistry/OpenSchemaRegistryApplication.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,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 org.apache.eventmesh.openschemaregistry; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class OpenSchemaRegistryApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(OpenSchemaRegistryApplication.class, args); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...main/java/org/apache/eventmesh/openschemaregistry/controller/CompatibilityController.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,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 org.apache.eventmesh.openschemaregistry.controller; | ||
|
||
import org.apache.eventmesh.openschemaregistry.domain.Compatibility; | ||
import org.apache.eventmesh.openschemaregistry.domain.Schema; | ||
import org.apache.eventmesh.openschemaregistry.response.CompatibilityResultResponse; | ||
import org.apache.eventmesh.openschemaregistry.service.CompatibilityService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/compatibility") | ||
public class CompatibilityController { | ||
|
||
@Autowired | ||
CompatibilityService compatibilityService; | ||
|
||
@PostMapping("/subjects/{subject}/versions/{version}") | ||
public ResponseEntity<CompatibilityResultResponse> checkWhetherCompatible(@PathVariable("subject") String subject, | ||
@PathVariable("version") Integer version, | ||
@RequestBody Schema schema){ | ||
CompatibilityResultResponse resultResponse = compatibilityService.checkWhetherCompatible(subject, version, schema); | ||
return ResponseEntity.ok(resultResponse); | ||
} | ||
|
||
@GetMapping("/{subject}") | ||
public ResponseEntity<Compatibility> getCompatibilityBySubject(@PathVariable("subject") String subject){ | ||
Compatibility compatibility = compatibilityService.getCompatibilityBySubject(subject); | ||
return ResponseEntity.ok(compatibility); | ||
} | ||
|
||
@PutMapping("/{subject}") | ||
public ResponseEntity<Compatibility> updateCompatibilityBySubject(@PathVariable("subject") String subject, | ||
@RequestBody Compatibility compatibility){ | ||
Compatibility updatedCompatibility = compatibilityService.updateCompatibilityBySubject(subject, compatibility); | ||
return ResponseEntity.ok(updatedCompatibility); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SchemaController.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,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 org.apache.eventmesh.openschemaregistry.controller; | ||
|
||
import org.apache.eventmesh.openschemaregistry.domain.Schema; | ||
import org.apache.eventmesh.openschemaregistry.response.SubjectAndVersionResponse; | ||
import org.apache.eventmesh.openschemaregistry.service.SchemaService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/schemas") | ||
public class SchemaController { | ||
@Autowired | ||
SchemaService schemaService; | ||
|
||
@GetMapping("/ids/{id}") | ||
public ResponseEntity<Schema> fetchSchemaById(@PathVariable("id") long id){ | ||
Schema schema = schemaService.getSchemaById(id); | ||
return ResponseEntity.ok(schema); | ||
} | ||
|
||
@GetMapping("/ids/{id}/subjects") | ||
public ResponseEntity<SubjectAndVersionResponse> fetchSubjectAndVersionById(@PathVariable("id") long id){ | ||
SubjectAndVersionResponse subjectAndVersionResponse = schemaService.getSubjectAndVersionById(id); | ||
return ResponseEntity.ok(subjectAndVersionResponse); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...y/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SubjectController.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,85 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://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 org.apache.eventmesh.openschemaregistry.controller; | ||
|
||
import org.apache.eventmesh.openschemaregistry.domain.Schema; | ||
import org.apache.eventmesh.openschemaregistry.domain.Subject; | ||
import org.apache.eventmesh.openschemaregistry.domain.SubjectWithSchema; | ||
import org.apache.eventmesh.openschemaregistry.response.SchemaIdResponse; | ||
import org.apache.eventmesh.openschemaregistry.service.SubjectService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/subjects") | ||
public class SubjectController { | ||
|
||
@Autowired | ||
SubjectService subjectService; | ||
|
||
@GetMapping({"","/"}) | ||
public ResponseEntity<List<String>> getAllSubjects(){ | ||
List<String> subjects = subjectService.getAllSubjects(); | ||
return ResponseEntity.ok(subjects); | ||
} | ||
|
||
@GetMapping("/{subject}/versions") | ||
public ResponseEntity<List<Integer>> getAllVersionBySubject(@PathVariable("subject") String subject){ | ||
List<Integer> versions = subjectService.getAllVersionsBySubject(subject); | ||
return ResponseEntity.ok(versions); | ||
} | ||
|
||
@DeleteMapping("/subjects/{subject}") | ||
public ResponseEntity<List<Integer>> deleteSubjectAndAllSchemaBySubject(@PathVariable("subject") String subject){ | ||
List<Integer> versions = subjectService.deleteSubjectAndAllSchemaBySubject(subject); | ||
return ResponseEntity.ok(versions); | ||
} | ||
|
||
@GetMapping("/{subject}") | ||
public ResponseEntity<Subject> getSubjectByName(@PathVariable("subject") String subject){ | ||
Subject getSubject = subjectService.getSubjectByName(subject); | ||
return ResponseEntity.ok(getSubject); | ||
} | ||
|
||
@GetMapping("/{subject}/versions/{version}/schema") | ||
public ResponseEntity<SubjectWithSchema> getSchemaBySubjectAndVersion(@PathVariable("subject")String subject, @PathVariable("version")int version){ | ||
SubjectWithSchema subjectWithSchema = subjectService.getSchemaBySubjectAndVersion(subject, version); | ||
return ResponseEntity.ok(subjectWithSchema); | ||
} | ||
|
||
@PostMapping("/subjects/{subject}/versions") | ||
public ResponseEntity<SchemaIdResponse> checkOrRegisterSchema(@PathVariable("subject") String subject, @RequestBody Schema schema){ | ||
SchemaIdResponse schemaIdResponse = subjectService.checkOrRegisterSchema(subject, schema); | ||
return ResponseEntity.ok(schemaIdResponse); | ||
} | ||
|
||
@PostMapping("/subjects/{subject}") | ||
public ResponseEntity<Subject> updateSubjectIfDifferent(@PathVariable("subject") String subjectName, @RequestBody Subject subject){ | ||
Subject updatedSubject = subjectService.updateSubjectIfDifferent(subjectName, subject); | ||
return ResponseEntity.ok(updatedSubject); | ||
} | ||
|
||
@DeleteMapping("/subjects/{subject}/versions/{version}") | ||
public ResponseEntity<Integer> deleteSchemaBySubjectAndVersion(@PathVariable("subject")String subject, @PathVariable("version") int version){ | ||
Integer deletedId = subjectService.deleteSchemaBySubjectAndVersion(subject, version); | ||
return ResponseEntity.ok(deletedId); | ||
} | ||
} |
Oops, something went wrong.