You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2021/09/23 06:46:39 UTC
[incubator-eventmesh] branch develop updated: [ISSUE #339] Add a
skeleton for separated openschema registry service and implement most APIs
that doesn't need compatibility check. (#525)
This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/develop by this push:
new 3510c83 [ISSUE #339] Add a skeleton for separated openschema registry service and implement most APIs that doesn't need compatibility check. (#525)
3510c83 is described below
commit 3510c83fa636a3c0323d93127f23a5ac9abe419c
Author: JunjieZhou <11...@qq.com>
AuthorDate: Thu Sep 23 14:46:31 2021 +0800
[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
---
build.gradle | 7 +
.../en/features/eventmesh-schemaregistry-design.md | 60 ++++
.../eventmesh-schemaregistry-projectstructure.png | Bin 0 -> 45279 bytes
.../build.gradle | 31 +-
.../eventmesh-openschema-registry/build.gradle | 42 +--
.../OpenSchemaRegistryApplication.java | 27 +-
.../controller/CompatibilityController.java | 54 ++++
.../controller/SchemaController.java | 43 +++
.../controller/SubjectController.java | 85 ++++++
.../openschemaregistry/domain/Compatibility.java | 26 +-
.../openschemaregistry/domain/Schema.java | 41 +--
.../domain/SchemaWithSubjectName.java | 59 ++++
.../openschemaregistry/domain/Subject.java | 60 ++++
.../domain/SubjectWithSchema.java | 57 ++++
.../enumerate/CompatibilityEnum.java | 33 +++
.../exception/ErrorResponse.java | 27 +-
.../exception/ExceptionEnum.java | 42 +++
.../exception/OpenSchemaException.java | 35 +--
.../exception/OpenSchemaExceptionHandler.java | 28 +-
.../repository/SchemaRepository.java | 42 +++
.../repository/SubjectRepository.java | 39 +++
.../request/SchemaCreateRequest.java | 23 +-
.../request/SubjectCreateRequest.java | 23 +-
.../response/CompatibilityResultResponse.java | 26 +-
.../response/SchemaIdResponse.java | 26 +-
.../response/SubjectAndVersionResponse.java | 26 +-
.../service/CompatibilityChecker.java | 22 +-
.../service/CompatibilityService.java | 101 +++++++
.../openschemaregistry/service/SchemaService.java | 68 +++++
.../openschemaregistry/service/SubjectService.java | 221 +++++++++++++++
.../src/main/resources/application.yml | 35 +++
.../src/main/resources/h2/db.mv.db | Bin 0 -> 24576 bytes
settings.gradle | 2 +
tool/license/allowed-licenses.txt | 315 +++++++++++++++++++++
34 files changed, 1502 insertions(+), 224 deletions(-)
diff --git a/build.gradle b/build.gradle
index c24692a..d42d81d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -386,6 +386,13 @@ subprojects {
dependency "org.mockito:mockito-core:2.23.0"
dependency "org.powermock:powermock-module-junit4:2.0.2"
dependency "org.powermock:powermock-api-mockito2:2.0.2"
+
+ dependency 'org.springframework.boot:spring-boot-starter-data-jdbc:2.5.4'
+ dependency 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.4'
+ dependency 'org.springframework.boot:spring-boot-starter-jdbc:2.5.4'
+ dependency 'org.springframework:spring-beans:5.1.8.RELEASE'
+ dependency 'org.projectlombok:lombok:1.18.20'
+ dependency 'com.h2database:h2:1.4.200'
}
}
}
\ No newline at end of file
diff --git a/docs/en/features/eventmesh-schemaregistry-design.md b/docs/en/features/eventmesh-schemaregistry-design.md
index c244662..f541cf6 100644
--- a/docs/en/features/eventmesh-schemaregistry-design.md
+++ b/docs/en/features/eventmesh-schemaregistry-design.md
@@ -63,6 +63,66 @@ The highlevel process of messages transmission undergoes 10 steps as follows:
- step9: Schema Registry returns schema and EventMesh caches it.
- step10: EventMesh patches schema in front of messages and push it to consumer.
+## Current Progress
+### Status
+**Current state** : Developing
+
+**Discussion thread** : ISSUE #339
+
+### Proposed Changes
+The proposal has two aspects.
+
+First is a separated Open Schema Registry, which includes storage and compatibility check for schema.
+This proposal is under developing.
+
+Second is the integration of Open Schema in Eventmesh, which includes validation for schema. This proposal is to be developed.
+
+As for the first proposal, some developing statuses are as follows.
+
+**Status Code and Exception Code**
+
+No. | Status Code | Exception Code | Description | status
+--- | :---: | :---: | :---: | :---:
+1 | 401 | 40101 | Unauthorized Exception | ✔
+2 | 404 | 40401 | Schema Non- Exception | ✔
+3 | ^ | 40402 | Subject Non-exist Exception | ✔
+4 | ^ | 40403 | Version Non-exist Exception | ✔
+5 | 409 | 40901 | Compatibility Exception | ✔
+6 | 422 | 42201 | Schema Format Exception | ✔
+7 | ^ | 42202 | Subject Format Exception | ✔
+8 | ^ | 42203 | Version Format Exception | ✔
+9 | ^ | 42204 | Compatibility Format Exception | ✔
+10 | 500 | 50001 | Storage Service Exception | ✔
+11 | ^ | 50002 | Timeout Exception | ✔
+
+**API developing status** :
+
+No. | Type | URL | response | exception | code | test
+--- | --- | --- | --- | --- | --- | ---
+1 | GET | /schemas/ids/{string: id} | Schema.class | 40101\40401\50001 | ✔ | ❌
+2 | GET | /schemas/ids/{string: id}/subjects | SubjectAndVersion.class | 40101\40401\50001 | ✔ | ❌
+3 | GET | /subjects | List\<String> | 40101\50001 | ✔ | ❌
+4 | GET | /subjects/{string: subject}/versions | List\<Integer> | 40101\40402\50001 | ✔ | ❌
+5 | DELETE | /subjects/(string: subject) | List\<Integer> | 40101\40402\50001 | ✔ | ❌
+6 | GET | /subjects/(string: subject) | Subject.class | 40101\40402\50001 | ✔ | ❌
+7 | GET | /subjects/(string: subject)/versions/(version: version)/schema | SubjectWithSchema.class | 40101\40402\40403\50001 | ✔ | ❌
+8 | POST | /subjects/(string: subject)/versions | SchemaIdResponse.class | 40101\40901\42201\50001\50002 | - | ❌
+9 | POST | /subjects/(string: subject)/ | Subject.class | 40101\40901\42202\50001\50002 | ✔ | ❌
+10 | DELETE | /subjects/(string: subject)/versions/(version: version) | int | 40101\40402\40403\40901\50001| - | ❌
+11 | POST | /compatibility/subjects/(string: subject)/versions/(version: version) | CompatibilityResultResponse.class | 40101\40402\40403\42201\42203\50001| - | ❌
+12 | GET | /compatibility/(string: subject) | Compatibility.class | 40101\40402\50001 | ✔ | ❌
+13 | PUT | /compatibility/(string: subject) | Compatibility.class | 40101\40402\40901\42204\50001 | - | ❌
+
+**Overall Project Structure**
+
+```SchemaController.java```+```SchemaService.java``` : ```OpenSchema 7.1.1~7.1.2 (API 1~2)```
+
+```SubjectController.java```+```SubjectService.java``` : ```OpenSchema 7.2.1~7.2.8 (API 3~10)```
+
+```CompatibilityController.java```+```CompatibilityService.java``` : ```OpenSchema 7.3.1~7.3.3 (API 11~13)``` + ```Check for Compatibility```
+
+
+
## References
[1] [schema validator (github.com)](https://github.com/search?q=schema+validator)
diff --git a/docs/images/features/eventmesh-schemaregistry-projectstructure.png b/docs/images/features/eventmesh-schemaregistry-projectstructure.png
new file mode 100644
index 0000000..c12ac2b
Binary files /dev/null and b/docs/images/features/eventmesh-schemaregistry-projectstructure.png differ
diff --git a/settings.gradle b/eventmesh-openschema/build.gradle
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/build.gradle
index f893360..96a33a1 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/build.gradle
@@ -15,20 +15,19 @@
* limitations under the License.
*/
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+plugins {
+}
+group 'org.apache.eventmesh'
+version '1.2.0-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+}
+
+test {
+ useJUnitPlatform()
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/build.gradle
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/build.gradle
index f893360..d97e5d8 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/build.gradle
@@ -15,20 +15,30 @@
* limitations under the License.
*/
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+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()
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/OpenSchemaRegistryApplication.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/OpenSchemaRegistryApplication.java
index f893360..a329288 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/OpenSchemaRegistryApplication.java
@@ -14,21 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+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);
+ }
+
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/CompatibilityController.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/CompatibilityController.java
new file mode 100644
index 0000000..1769b9a
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/CompatibilityController.java
@@ -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);
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SchemaController.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SchemaController.java
new file mode 100644
index 0000000..ee7ac99
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SchemaController.java
@@ -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);
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SubjectController.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SubjectController.java
new file mode 100644
index 0000000..f92c0e3
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/controller/SubjectController.java
@@ -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);
+ }
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Compatibility.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Compatibility.java
index f893360..5f2e947 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Compatibility.java
@@ -14,21 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.domain;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Compatibility {
+ private String compatibility;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Schema.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Schema.java
index f893360..4ec1757 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Schema.java
@@ -14,21 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.domain;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Schema {
+
+ private String id;
+
+ private String name;
+
+ private String comment;
+
+ private String serialization;
+
+ private String schemaType;
+
+ private String schemaDefinition;
+
+ private String validator;
+
+ private int version;
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SchemaWithSubjectName.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SchemaWithSubjectName.java
new file mode 100644
index 0000000..10d388f
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SchemaWithSubjectName.java
@@ -0,0 +1,59 @@
+/*
+ * 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.domain;
+
+import lombok.*;
+
+import javax.persistence.*;
+
+@Entity
+@Setter
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@Table(name = "SCHEMA")
+public class SchemaWithSubjectName {
+ @Id
+ @Column(name = "ID")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long id;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "COMMENT")
+ private String comment;
+
+ @Column(name = "SERIALIZATION")
+ private String serialization;
+
+ @Column(name = "SCHEMATYPE")
+ private String schemaType;
+
+ @Column(name = "SCHEMADEFINITION", length = 10240)
+ private String schemaDefinition;
+
+ @Column(name = "VALIDATOR")
+ private String validator;
+
+ @Column(name = "VERSION")
+ private int version;
+
+ @Column(name = "SUBJECT")
+ private String subject;
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Subject.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Subject.java
new file mode 100644
index 0000000..13b05aa
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/Subject.java
@@ -0,0 +1,60 @@
+/*
+ * 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.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Data
+@DynamicUpdate
+@AllArgsConstructor
+@NoArgsConstructor
+@Table(name = "SUBJECT")
+public class Subject {
+ @Id
+ @Column(name = "SUBJECT")
+ private String subject;
+
+ @Column(name = "TENANT")
+ private String tenant;
+
+ @Column(name = "NAMESPACE")
+ private String namespace;
+
+ @Column(name = "APP")
+ private String app;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "STATUS")
+ private String status;
+
+ @Column(name = "COMPATIBILITY")
+ private String compatibility;
+
+ @Column(name = "COORDINATE")
+ private String coordinate;
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SubjectWithSchema.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SubjectWithSchema.java
new file mode 100644
index 0000000..d07f666
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/domain/SubjectWithSchema.java
@@ -0,0 +1,57 @@
+/*
+ * 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.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SubjectWithSchema {
+
+ public SubjectWithSchema(Subject subject, Schema schema){
+ this.subject = subject.getSubject();
+ this.tenant = subject.getTenant();
+ this.namespace = subject.getNamespace();
+ this.app = subject.getApp();
+ this.description = subject.getDescription();
+ this.status = subject.getStatus();
+ this.compatibility = subject.getCompatibility();
+ this.coordinate = subject.getCoordinate();
+ this.schema = schema;
+ }
+
+ private String subject;
+
+ private String tenant;
+
+ private String namespace;
+
+ private String app;
+
+ private String description;
+
+ private String status;
+
+ private String compatibility;
+
+ private String coordinate;
+
+ private Schema schema;
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/enumerate/CompatibilityEnum.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/enumerate/CompatibilityEnum.java
new file mode 100644
index 0000000..3b0c5a2
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/enumerate/CompatibilityEnum.java
@@ -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.
+ */
+package org.apache.eventmesh.openschemaregistry.enumerate;
+
+import lombok.AllArgsConstructor;
+
+@AllArgsConstructor
+public enum CompatibilityEnum {
+ BACKWARD("BACKWARD", "Consumers using the new schema can read data produced with the last schema."),
+ BACKWARD_TRANSITIVE("BACKWARD_TRANSITIVE", "Consumers using the new schema can read data sent by the producer using all previously registered schemas."),
+ FORWARD("FORWARD", "Data produced with a new schema can be read by consumers using the last schema."),
+ FORWARD_TRANSITIVE("FORWARD_TRANSITIVE", "Data produced with a new schema can be read by consumers using all registered schemas."),
+ FULL("FULL", "The new schema is backward and forward compatible with the newly registered schema."),
+ FULL_TRANSITIVE("FULL_TRANSITIVE", "The newly registered schema is backward and forward compatible with all previously registered schemas."),
+ NONE("NONE", "Schema compatibility checks are disabled.");
+
+ private String name;
+ private String description;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ErrorResponse.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ErrorResponse.java
index f893360..3d05015 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ErrorResponse.java
@@ -14,21 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.exception;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
+@AllArgsConstructor
+public class ErrorResponse {
+ private String err_code;
+ private String err_message;
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ExceptionEnum.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ExceptionEnum.java
new file mode 100644
index 0000000..79f92d6
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/ExceptionEnum.java
@@ -0,0 +1,42 @@
+/*
+ * 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.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+@Getter
+@AllArgsConstructor
+public enum ExceptionEnum {
+
+ UnAuthorizedException(HttpStatus.UNAUTHORIZED, "40101", "Unauthorized Exception"),
+ SchemaNonExist(HttpStatus.NOT_FOUND,"40401", "Schema Non-exist Exception"),
+ SubjectNonExist(HttpStatus.NOT_FOUND, "40402", "Subject Non-exist Exception"),
+ VersionNonExist(HttpStatus.NOT_FOUND, "40403", "Version Non-exist Exception"),
+ CompatibilityException(HttpStatus.CONFLICT, "40901", "Compatibility Exception"),
+ SchemaFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42201", "Schema Format Exception"),
+ SubjectFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42202", "Subject Format Exception"),
+ VersionFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42203", "Version Format Exception"),
+ CompatibilityFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42204", "Compatibility Format Exception"),
+ StorageServiceException(HttpStatus.INTERNAL_SERVER_ERROR, "50001", "Storage Service Exception"),
+ TimeoutException(HttpStatus.INTERNAL_SERVER_ERROR, "50002", "Timeout Exception");
+
+ private HttpStatus status;
+ private String exceptionCode;
+ private String description;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaException.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaException.java
index f893360..f65b1e9 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaException.java
@@ -14,21 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.exception;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.http.HttpStatus;
+@Getter
+@Setter
+@AllArgsConstructor
+public class OpenSchemaException extends RuntimeException{
+ protected HttpStatus err_status;
+ protected String err_code;
+ protected String err_message;
+
+ public OpenSchemaException(ExceptionEnum e){
+ this.err_status = e.getStatus();
+ this.err_code = e.getExceptionCode();
+ this.err_message = e.getDescription();
+ }
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaExceptionHandler.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaExceptionHandler.java
index f893360..574320f 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/exception/OpenSchemaExceptionHandler.java
@@ -14,21 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.exception;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+@ControllerAdvice
+public class OpenSchemaExceptionHandler {
+
+ @ExceptionHandler(value = OpenSchemaException.class)
+ public ResponseEntity<ErrorResponse> ExceptionHandler(OpenSchemaException e){
+ return ResponseEntity.status(e.getErr_status().value()).body(new ErrorResponse(e.getErr_code(), e.getErr_message()));
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SchemaRepository.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SchemaRepository.java
new file mode 100644
index 0000000..e1cf0b2
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SchemaRepository.java
@@ -0,0 +1,42 @@
+/*
+ * 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.repository;
+
+import org.apache.eventmesh.openschemaregistry.domain.Schema;
+import org.apache.eventmesh.openschemaregistry.domain.SchemaWithSubjectName;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface SchemaRepository extends JpaRepository<SchemaWithSubjectName, Long> {
+
+ SchemaWithSubjectName getSchemaById(long id);
+
+ @Query(value = "select VERSION from SCHEMA", nativeQuery = true)
+ List<Integer> getVersionsBySubject(String subject);
+
+ List<Integer> deleteSchemasBySubject(String subject);
+
+ Integer deleteSchemaBySubjectAndVersion(String subject, int version);
+
+ Schema getSchemaBySubjectAndVersion(String subject, int version);
+
+ List<SchemaWithSubjectName> getSchemaWithSubjectNamesBySubjectOrderByVersionDesc(String subject);
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SubjectRepository.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SubjectRepository.java
new file mode 100644
index 0000000..ad7f843
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/repository/SubjectRepository.java
@@ -0,0 +1,39 @@
+/*
+ * 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.repository;
+
+import org.apache.eventmesh.openschemaregistry.domain.Subject;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface SubjectRepository extends JpaRepository<Subject,String> {
+
+ @Query(value = "select SUBJECT from SUBJECT", nativeQuery = true)
+ List<String> getAllSubject();
+
+ @Query(value = "select VERSION from SCHEMA v where v.SUBJECT=:subject",nativeQuery = true)
+ List<Integer> getAllVersionsBySubject(@Param("subject") String subject);
+
+ Subject deleteSubjectBySubject(String subject);
+
+ Subject getSubjectBySubject(String subject);
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SchemaCreateRequest.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SchemaCreateRequest.java
index f893360..3c7c58a 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SchemaCreateRequest.java
@@ -14,21 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.request;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+@Data
+@AllArgsConstructor
+public class SchemaCreateRequest {
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SubjectCreateRequest.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SubjectCreateRequest.java
index f893360..0b19d8a 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/request/SubjectCreateRequest.java
@@ -14,21 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.request;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+@Data
+@AllArgsConstructor
+public class SubjectCreateRequest {
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/CompatibilityResultResponse.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/CompatibilityResultResponse.java
index f893360..0888d06 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/CompatibilityResultResponse.java
@@ -14,21 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.response;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CompatibilityResultResponse {
+ boolean is_compatibility;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SchemaIdResponse.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SchemaIdResponse.java
index f893360..bb78ee4 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SchemaIdResponse.java
@@ -14,21 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.response;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SchemaIdResponse {
+ String id;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SubjectAndVersionResponse.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SubjectAndVersionResponse.java
index f893360..198f189 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/response/SubjectAndVersionResponse.java
@@ -14,21 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.response;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import lombok.AllArgsConstructor;
+import lombok.Data;
+@Data
+@AllArgsConstructor
+public class SubjectAndVersionResponse {
+ public String subject;
+
+ public int version;
+}
diff --git a/settings.gradle b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityChecker.java
similarity index 53%
copy from settings.gradle
copy to eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityChecker.java
index f893360..46be7d0 100644
--- a/settings.gradle
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityChecker.java
@@ -14,21 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.eventmesh.openschemaregistry.service;
-rootProject.name = 'EventMesh'
-String jdkVersion = "${jdk}"
-include 'eventmesh-runtime'
-include 'eventmesh-sdk-java'
-include 'eventmesh-common'
-include 'eventmesh-starter'
-include 'eventmesh-examples'
-include 'eventmesh-spi'
-include 'eventmesh-connector-plugin:eventmesh-connector-api'
-include 'eventmesh-connector-plugin:eventmesh-connector-rocketmq'
-include 'eventmesh-connector-plugin:eventmesh-connector-standalone'
-include 'eventmesh-security-plugin:eventmesh-security-api'
-include 'eventmesh-security-plugin:eventmesh-security-acl'
-include 'eventmesh-registry-plugin:eventmesh-registry-api'
-include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
-include 'eventmesh-admin'
+import org.apache.eventmesh.openschemaregistry.domain.Schema;
+public interface CompatibilityChecker {
+
+ boolean isCompatible(Schema schemaA, Schema schemaB);
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityService.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityService.java
new file mode 100644
index 0000000..8a001a3
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/CompatibilityService.java
@@ -0,0 +1,101 @@
+/*
+ * 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.service;
+
+import org.apache.eventmesh.openschemaregistry.domain.Compatibility;
+import org.apache.eventmesh.openschemaregistry.domain.Schema;
+import org.apache.eventmesh.openschemaregistry.domain.Subject;
+import org.apache.eventmesh.openschemaregistry.exception.ExceptionEnum;
+import org.apache.eventmesh.openschemaregistry.exception.OpenSchemaException;
+import org.apache.eventmesh.openschemaregistry.repository.SchemaRepository;
+import org.apache.eventmesh.openschemaregistry.repository.SubjectRepository;
+import org.apache.eventmesh.openschemaregistry.response.CompatibilityResultResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CompatibilityService {
+
+ @Autowired
+ SubjectRepository subjectRepository;
+
+ @Autowired
+ SchemaRepository schemaRepository;
+
+
+ public CompatibilityResultResponse checkWhetherCompatible(String subject, Integer version, Schema schema){
+ Subject getSubject = null;
+ Schema getSchema = null;
+ CompatibilityResultResponse response = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if(getSubject == null){
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ try {
+ getSchema = schemaRepository.getSchemaBySubjectAndVersion(subject, version);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if(getSchema == null){
+ throw new OpenSchemaException(ExceptionEnum.SchemaNonExist);
+ }
+ // todo check the compatibility
+
+ return response;
+ }
+
+
+ public Compatibility getCompatibilityBySubject(String subject){
+ Subject getSubject = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ if(getSubject==null){
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ return new Compatibility(getSubject.getCompatibility());
+ }
+
+ public Compatibility updateCompatibilityBySubject(String subject, Compatibility compatibility){
+ Subject getSubject = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if(getSubject == null){
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+ getSubject.setCompatibility(compatibility.getCompatibility());
+ try {
+ // todo check the compatibility among schemas of newly set compatibility
+ subjectRepository.save(getSubject);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ return compatibility;
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SchemaService.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SchemaService.java
new file mode 100644
index 0000000..b792262
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SchemaService.java
@@ -0,0 +1,68 @@
+/*
+ * 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.service;
+
+import org.apache.eventmesh.openschemaregistry.domain.Schema;
+import org.apache.eventmesh.openschemaregistry.domain.SchemaWithSubjectName;
+import org.apache.eventmesh.openschemaregistry.exception.ExceptionEnum;
+import org.apache.eventmesh.openschemaregistry.exception.OpenSchemaException;
+import org.apache.eventmesh.openschemaregistry.repository.SchemaRepository;
+import org.apache.eventmesh.openschemaregistry.response.SubjectAndVersionResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SchemaService {
+
+ @Autowired
+ SchemaRepository schemaRepository;
+
+ public Schema getSchemaById(long id){
+ SchemaWithSubjectName schemaWithSubjectName = null;
+ try {
+ schemaWithSubjectName = schemaRepository.getSchemaById(id);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if(schemaWithSubjectName==null){
+ throw new OpenSchemaException(ExceptionEnum.SchemaNonExist);
+ }
+ Schema schema = new Schema();
+ schema.setId(String.valueOf(schemaWithSubjectName.getId()));
+ schema.setName(schemaWithSubjectName.getName());
+ schema.setComment(schemaWithSubjectName.getComment());
+ schema.setSerialization(schemaWithSubjectName.getSerialization());
+ schema.setSchemaType(schemaWithSubjectName.getSchemaType());
+ schema.setSchemaDefinition(schemaWithSubjectName.getSchemaDefinition());
+ schema.setValidator(schemaWithSubjectName.getValidator());
+ schema.setVersion(schemaWithSubjectName.getVersion());
+ return schema;
+ }
+
+ public SubjectAndVersionResponse getSubjectAndVersionById(long id){
+ SchemaWithSubjectName schemaWithSubjectName = null;
+ try {
+ schemaWithSubjectName = schemaRepository.getSchemaById(id);
+ }catch (Exception e){
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if(schemaWithSubjectName==null){
+ throw new OpenSchemaException(ExceptionEnum.SchemaNonExist);
+ }
+ return new SubjectAndVersionResponse(schemaWithSubjectName.getSubject(), schemaWithSubjectName.getVersion());
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SubjectService.java b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SubjectService.java
new file mode 100644
index 0000000..6b246c5
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/java/org/apache/eventmesh/openschemaregistry/service/SubjectService.java
@@ -0,0 +1,221 @@
+/*
+ * 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.service;
+
+import org.apache.eventmesh.openschemaregistry.domain.*;
+import org.apache.eventmesh.openschemaregistry.exception.ExceptionEnum;
+import org.apache.eventmesh.openschemaregistry.exception.OpenSchemaException;
+import org.apache.eventmesh.openschemaregistry.repository.SchemaRepository;
+import org.apache.eventmesh.openschemaregistry.repository.SubjectRepository;
+import org.apache.eventmesh.openschemaregistry.response.SchemaIdResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class SubjectService {
+
+ @Autowired
+ SubjectRepository subjectRepository;
+
+ @Autowired
+ SchemaRepository schemaRepository;
+
+ public List<String> getAllSubjects() {
+ List<String> subjects;
+ try {
+ subjects = subjectRepository.getAllSubject();
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ return subjects;
+ }
+
+ public List<Integer> getAllVersionsBySubject(String subject) {
+ List<Integer> versions;
+ try {
+ versions = subjectRepository.getAllVersionsBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if (versions == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+ return versions;
+ }
+
+ public List<Integer> deleteSubjectAndAllSchemaBySubject(String subject) {
+ List<Integer> versions;
+ Subject deletedSubject;
+ try {
+ deletedSubject = subjectRepository.deleteSubjectBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if (deletedSubject == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ try {
+ versions = schemaRepository.deleteSchemasBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ return versions;
+ }
+
+ public Subject getSubjectByName(String subject) {
+ Subject getSubject;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ if (getSubject == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ return getSubject;
+ }
+
+ public SubjectWithSchema getSchemaBySubjectAndVersion(String subject, int version) {
+ Schema schema = null;
+ Subject getSubject = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ schema = schemaRepository.getSchemaBySubjectAndVersion(subject, version);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ if (getSubject == null) {
+ throw new OpenSchemaException(ExceptionEnum.VersionNonExist);
+ }
+
+ if (schema == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ return new SubjectWithSchema(getSubject, schema);
+ }
+
+
+ public SchemaIdResponse checkOrRegisterSchema(String subject, Schema schema) {
+ Subject subjectBySubject = null;
+ try {
+ subjectBySubject = subjectRepository.getSubjectBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ if (subjectBySubject == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ List<SchemaWithSubjectName> schemaWithNames = null;
+ try {
+ schemaWithNames = schemaRepository.getSchemaWithSubjectNamesBySubjectOrderByVersionDesc(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ SchemaIdResponse schemaIdResponse = schemaWithNames
+ .stream()
+ .filter(schemaWithSubjectName
+ -> schema.getSerialization().equals(schemaWithSubjectName.getSerialization())
+ && schema.getSchemaType().equals(schemaWithSubjectName.getSchemaType())
+ && schema.getSchemaDefinition().equals(schemaWithSubjectName.getSchemaType()))
+ .findFirst()
+ .map(schemaWithSubjectName
+ -> new SchemaIdResponse(String.valueOf(schemaWithSubjectName.getId())))
+ .orElse(null);
+
+ if (schemaIdResponse == null) {
+ SchemaWithSubjectName schemaWithSubjectName = SchemaWithSubjectName
+ .builder()
+ .name(schema.getName())
+ .comment(schema.getComment())
+ .serialization(schema.getSerialization())
+ .schemaType(schema.getSchemaType())
+ .schemaDefinition(schema.getSchemaDefinition())
+ .validator(schema.getValidator())
+ .version(schemaWithNames.get(0).getVersion() + 1)
+ .subject(subject)
+ .build();
+ try {
+ SchemaWithSubjectName save = schemaRepository.save(schemaWithSubjectName);
+ schemaIdResponse = new SchemaIdResponse(String.valueOf(save.getId()));
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ }
+ return schemaIdResponse;
+ }
+
+ public Subject updateSubjectIfDifferent(String subjectName, Subject subject) {
+ Subject getSubject = null;
+ Subject returnSubject = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subjectName);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if (getSubject == null) {
+ returnSubject = subjectRepository.save(subject);
+ } else {
+ if (getSubject.equals(subject)) {
+ returnSubject = subject;
+ } else {
+ //todo
+ // if compatibility is changed, the left schemas should satisfy compatibility
+ }
+ }
+ return returnSubject;
+ }
+
+ public Integer deleteSchemaBySubjectAndVersion(String subject, int version) {
+ Integer deletedVersion = null;
+ // todo complete the logic here for compatibility check
+ try {
+ deletedVersion = schemaRepository.deleteSchemaBySubjectAndVersion(subject, version);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+ if (deletedVersion == null) {
+ throw new OpenSchemaException(ExceptionEnum.SchemaNonExist);
+ }
+ return deletedVersion;
+ }
+
+ public Compatibility getCompatibilityBySubject(String subject) {
+ Subject getSubject = null;
+ try {
+ getSubject = subjectRepository.getSubjectBySubject(subject);
+ } catch (Exception e) {
+ throw new OpenSchemaException(ExceptionEnum.StorageServiceException);
+ }
+
+ if (getSubject == null) {
+ throw new OpenSchemaException(ExceptionEnum.SubjectNonExist);
+ }
+
+ return new Compatibility(getSubject.getCompatibility());
+ }
+}
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/application.yml b/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/application.yml
new file mode 100644
index 0000000..fae35c4
--- /dev/null
+++ b/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/application.yml
@@ -0,0 +1,35 @@
+#
+# 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.
+#
+
+spring:
+ h2:
+ console:
+ path: /h2-console
+ enabled: true
+ datasource:
+ driver-class-name: org.h2.Driver
+ url: jdbc:h2:./eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/h2/db
+ username: root
+ password: test
+ jpa:
+ database: h2
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+
+server:
+ port: 13579
diff --git a/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/h2/db.mv.db b/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/h2/db.mv.db
new file mode 100644
index 0000000..7a7a400
Binary files /dev/null and b/eventmesh-openschema/eventmesh-openschema-registry/src/main/resources/h2/db.mv.db differ
diff --git a/settings.gradle b/settings.gradle
index f893360..71f5c13 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -31,4 +31,6 @@ include 'eventmesh-security-plugin:eventmesh-security-acl'
include 'eventmesh-registry-plugin:eventmesh-registry-api'
include 'eventmesh-registry-plugin:eventmesh-registry-rocketmq-namesrv'
include 'eventmesh-admin'
+include 'eventmesh-openschema'
+include 'eventmesh-openschema:eventmesh-openschema-registry'
diff --git a/tool/license/allowed-licenses.txt b/tool/license/allowed-licenses.txt
index f1ce3d3..aeb2980 100644
--- a/tool/license/allowed-licenses.txt
+++ b/tool/license/allowed-licenses.txt
@@ -564,6 +564,321 @@
"moduleLicense": "The Apache Software License, Version 2.0",
"moduleVersion": "0.8.1",
"moduleName": "io.prometheus:simpleclient_httpserver"
+ },
+ {
+ "moduleLicense": "BSD License",
+ "moduleVersion": "2.7.7",
+ "moduleName": "antlr:antlr"
+ },
+ {
+ "moduleLicense": "Eclipse Public License - v 1.0",
+ "moduleVersion": "1.2.5",
+ "moduleName": "ch.qos.logback:logback-classic"
+ },
+ {
+ "moduleLicense": "GNU Lesser General Public License",
+ "moduleVersion": "1.2.5",
+ "moduleName": "ch.qos.logback:logback-classic"
+ },
+ {
+ "moduleLicense": "Eclipse Public License - v 1.0",
+ "moduleVersion": "1.2.5",
+ "moduleName": "ch.qos.logback:logback-core"
+ },
+ {
+ "moduleLicense": "GNU Lesser General Public License",
+ "moduleVersion": "1.2.5",
+ "moduleName": "ch.qos.logback:logback-core"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "1.5.1",
+ "moduleName": "com.fasterxml:classmate"
+ },
+ {
+ "moduleLicense": "The Apache Software License, Version 2.0",
+ "moduleVersion": "1.5.1",
+ "moduleName": "com.fasterxml:classmate"
+ },
+ {
+ "moduleLicense": "MPL 2.0 or EPL 1.0",
+ "moduleVersion": "1.4.200",
+ "moduleName": "com.h2database:h2"
+ },
+ {
+ "moduleLicense": "CDDL 1.1",
+ "moduleVersion": "3.0.7",
+ "moduleName": "com.sun.istack:istack-commons-runtime"
+ },
+ {
+ "moduleLicense": "GPL2 w/ CPE",
+ "moduleVersion": "3.0.7",
+ "moduleName": "com.sun.istack:istack-commons-runtime"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "1.2.15",
+ "moduleName": "com.sun.xml.fastinfoset:FastInfoset"
+ },
+ {
+ "moduleLicense": "The Apache Software License, Version 2.0",
+ "moduleVersion": "4.0.3",
+ "moduleName": "com.zaxxer:HikariCP"
+ },
+ {
+ "moduleLicense": "EPL 2.0",
+ "moduleVersion": "1.3.5",
+ "moduleName": "jakarta.annotation:jakarta.annotation-api"
+ },
+ {
+ "moduleLicense": "Eclipse Public License v. 2.0",
+ "moduleVersion": "1.3.5",
+ "moduleName": "jakarta.annotation:jakarta.annotation-api"
+ },
+ {
+ "moduleLicense": "GNU General Public License, version 2 with the GNU Classpath Exception",
+ "moduleVersion": "1.3.5",
+ "moduleName": "jakarta.annotation:jakarta.annotation-api"
+ },
+ {
+ "moduleLicense": "GPL2 w/ CPE",
+ "moduleVersion": "1.3.5",
+ "moduleName": "jakarta.annotation:jakarta.annotation-api"
+ },
+ {
+ "moduleLicense": "Eclipse Distribution License v. 1.0",
+ "moduleVersion": "2.2.3",
+ "moduleName": "jakarta.persistence:jakarta.persistence-api"
+ },
+ {
+ "moduleLicense": "Eclipse Public License v. 2.0",
+ "moduleVersion": "2.2.3",
+ "moduleName": "jakarta.persistence:jakarta.persistence-api"
+ },
+ {
+ "moduleLicense": "GNU General Public License, version 2 with the GNU Classpath Exception",
+ "moduleVersion": "2.2.3",
+ "moduleName": "jakarta.persistence:jakarta.persistence-api"
+ },
+ {
+ "moduleLicense": "EPL 2.0",
+ "moduleVersion": "1.3.3",
+ "moduleName": "jakarta.transaction:jakarta.transaction-api"
+ },
+ {
+ "moduleLicense": "Eclipse Public License v. 2.0",
+ "moduleVersion": "1.3.3",
+ "moduleName": "jakarta.transaction:jakarta.transaction-api"
+ },
+ {
+ "moduleLicense": "GNU General Public License, version 2 with the GNU Classpath Exception",
+ "moduleVersion": "1.3.3",
+ "moduleName": "jakarta.transaction:jakarta.transaction-api"
+ },
+ {
+ "moduleLicense": "GPL2 w/ CPE",
+ "moduleVersion": "1.3.3",
+ "moduleName": "jakarta.transaction:jakarta.transaction-api"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "1.10.22",
+ "moduleName": "net.bytebuddy:byte-buddy"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.14.1",
+ "moduleName": "org.apache.logging.log4j:log4j-to-slf4j"
+ },
+ {
+ "moduleLicense": "Eclipse Public License - v 2.0",
+ "moduleVersion": "1.9.7",
+ "moduleName": "org.aspectj:aspectjweaver"
+ },
+ {
+ "moduleLicense": "BSD 3-clause New License",
+ "moduleVersion": "2.1.3",
+ "moduleName": "org.dom4j:dom4j"
+ },
+ {
+ "moduleLicense": "CDDL+GPL License",
+ "moduleVersion": "2.3.1",
+ "moduleName": "org.glassfish.jaxb:jaxb-runtime"
+ },
+ {
+ "moduleLicense": "CDDL+GPL License",
+ "moduleVersion": "2.3.1",
+ "moduleName": "org.glassfish.jaxb:txw2"
+ },
+ {
+ "moduleLicense": "GNU Library General Public License v2.1 or later",
+ "moduleVersion": "5.1.2.Final",
+ "moduleName": "org.hibernate.common:hibernate-commons-annotations"
+ },
+ {
+ "moduleLicense": "GNU Library General Public License v2.1 or later",
+ "moduleVersion": "5.4.32.Final",
+ "moduleName": "org.hibernate:hibernate-core"
+ },
+ {
+ "moduleLicense": "Apache License 2.0",
+ "moduleVersion": "3.27.0-GA",
+ "moduleName": "org.javassist:javassist"
+ },
+ {
+ "moduleLicense": "LGPL 2.1",
+ "moduleVersion": "3.27.0-GA",
+ "moduleName": "org.javassist:javassist"
+ },
+ {
+ "moduleLicense": "MPL 1.1",
+ "moduleVersion": "3.27.0-GA",
+ "moduleName": "org.javassist:javassist"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "3.4.1.Final",
+ "moduleName": "org.jboss.logging:jboss-logging"
+ },
+ {
+ "moduleLicense": "Apache License, version 2.0",
+ "moduleVersion": "3.4.1.Final",
+ "moduleName": "org.jboss.logging:jboss-logging"
+ },
+ {
+ "moduleLicense": "Public Domain",
+ "moduleVersion": "3.4.1.Final",
+ "moduleName": "org.jboss.logging:jboss-logging"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.2.3.Final",
+ "moduleName": "org.jboss:jandex"
+ },
+ {
+ "moduleLicense": "Public Domain",
+ "moduleVersion": "2.2.3.Final",
+ "moduleName": "org.jboss:jandex"
+ },
+ {
+ "moduleLicense": "\n Dual license consisting of the CDDL v1.1 and GPL v2\n ",
+ "moduleVersion": "1.8",
+ "moduleName": "org.jvnet.staxex:stax-ex"
+ },
+ {
+ "moduleLicense": "MIT License",
+ "moduleVersion": "1.7.32",
+ "moduleName": "org.slf4j:jul-to-slf4j"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-autoconfigure"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter-aop"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter-data-jdbc"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter-data-jpa"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter-jdbc"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.boot:spring-boot-starter-logging"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.data:spring-data-commons"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.2.4",
+ "moduleName": "org.springframework.data:spring-data-jdbc"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.5.4",
+ "moduleName": "org.springframework.data:spring-data-jpa"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "2.2.4",
+ "moduleName": "org.springframework.data:spring-data-relational"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-aop"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-aspects"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-context"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-core"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-expression"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-jcl"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-jdbc"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-orm"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "5.3.9",
+ "moduleName": "org.springframework:spring-tx"
+ },
+ {
+ "moduleLicense": "Apache License, Version 2.0",
+ "moduleVersion": "1.28",
+ "moduleName": "org.yaml:snakeyaml"
}
]
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org