This is an automated email from the ASF dual-hosted git repository. duhengforever pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/rocketmq-schema-registry.git
commit aca43ac69f885a319ffa956d35a98275fa6b8d35 Author: duhenglucky <[email protected]> AuthorDate: Sat Jul 30 13:33:26 2022 +0800 feat refactor code --- README.md | 22 ++- .../client/NormalSchemaRegistryClient.java | 33 ++-- .../registry/client/SchemaRegistryClient.java | 30 ++-- .../client/exceptions/RestClientException.java | 26 ++-- .../schema/registry/client/rest/JacksonMapper.java | 2 +- .../schema/registry/client/rest/RestService.java | 46 +++--- .../schema/registry/client/rest/UrlBuilder.java | 25 +-- .../schema/registry/client/util/HttpUtil.java | 21 +-- .../schema/registry/common/QualifiedName.java | 18 +-- .../registry/common/auth/AccessControlService.java | 2 +- .../auth/DefaultAccessControlServiceImpl.java | 2 +- .../registry/common/context/RequestContext.java | 3 +- .../common/context/RequestContextManager.java | 8 +- .../common/context/StoragePluginContext.java | 5 - .../common/context/StorageServiceContext.java | 1 - .../schema/registry/common/dto/AuditDto.java | 3 +- .../schema/registry/common/dto/BaseDto.java | 5 - .../schema/registry/common/dto/FieldDto.java | 2 +- .../registry/common/dto/SchemaDetailDto.java | 2 - .../schema/registry/common/dto/SchemaMetaDto.java | 5 +- .../registry/common/dto/SchemaStorageDto.java | 3 +- .../schema/registry/common/dto/SubjectDto.java | 1 - .../registry/common/exception/SchemaException.java | 6 +- .../common/exception/SchemaExistException.java | 22 +-- .../registry/common/filter/RequestFilter.java | 10 +- .../schema/registry/common/json/JsonConverter.java | 3 +- .../registry/common/json/JsonConverterImpl.java | 6 +- .../schema/registry/common/model/AuditInfo.java | 1 - .../schema/registry/common/model/Dependency.java | 2 +- .../schema/registry/common/model/FieldInfo.java | 1 - .../registry/common/model/SchemaDetailInfo.java | 4 - .../registry/common/model/SchemaMetaInfo.java | 1 - .../registry/common/model/SchemaStorageInfo.java | 1 - .../schema/registry/common/model/SchemaType.java | 2 +- .../registry/common/properties/AclProperties.java | 6 +- .../common/properties/ServiceProperties.java | 1 - .../registry/common/storage/StorageManager.java | 4 +- .../registry/common/storage/StoragePlugin.java | 2 +- .../common/storage/StoragePluginManager.java | 2 +- .../registry/common/storage/StorageService.java | 9 +- .../common/storage/StorageServiceProxy.java | 17 +-- .../schema/registry/common/utils/CommonUtil.java | 29 +++- .../schema/registry/common/utils/IdGenerator.java | 1 - .../common/utils/MemoryJavaFileManager.java | 9 +- .../schema/registry/common/utils/StorageUtil.java | 8 +- core/mvnw | 0 core/pom.xml | 2 +- .../schema/registry/core/CoreApplication.java | 27 +++- .../schema/registry/core/api/RequestProcessor.java | 40 ++--- .../registry/core/api/v1/SchemaController.java | 85 ++++++----- .../registry/core/config/SchemaManagerConfig.java | 2 +- .../registry/core/config/SchemaServiceConfig.java | 10 +- .../schema/registry/core/config/SwaggerConfig.java | 16 +- .../ArtifactoryDependencyServiceImpl.java | 2 - .../registry/core/dependency/DependencyHelper.java | 2 +- .../core/dependency/DynamicCompileProvider.java | 7 +- .../core/dependency/DynamicJarsProvider.java | 23 --- .../core/expection/RequestExceptionHandler.java | 7 +- .../schema/registry/core/package-info.java | 33 ++-- .../registry/core/service/SchemaService.java | 7 +- .../registry/core/service/SchemaServiceImpl.java | 4 +- .../schema/registry/core/service/Service.java | 1 - core/src/main/resources/application.properties | 38 ++--- core/src/main/resources/template.pom | 10 +- .../schema/registry/core/CoreApplicationTests.java | 5 +- .../core/controller/HelloControllerTest.java | 17 +-- pom.xml | 168 +++++++++++++++++++++ storage-rocketmq/pom.xml | 14 +- .../registry/storage/rocketmq/RocketmqClient.java | 1 - .../storage/rocketmq/RocketmqStorageClient.java | 1 - .../rocketmq/RocketmqStorageClientImpl.java | 2 - .../storage/rocketmq/RocketmqStorageService.java | 3 +- .../rocketmq/configs/RocketmqConfigConstants.java | 1 - .../storage/rocketmq/configs/ServiceConfig.java | 1 - .../registry/storage/rocketmq/package-info.java | 31 ++-- .../src/main/resources/rocketmq.properties | 1 - style/copyright/Apache.xml | 24 +++ style/copyright/profiles_settings.xml | 64 ++++++++ style/rmq_checkstyle.xml | 135 +++++++++++++++++ style/rmq_codeStyle.xml | 157 +++++++++++++++++++ war/pom.xml | 1 - 81 files changed, 935 insertions(+), 419 deletions(-) diff --git a/README.md b/README.md index a8a515f..e1fc625 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ rocketmq-schema-registry ================ -RocketMQ schema registry is a management platform for Avro schema of RocketMQ Topic, which provides a restful interface for store, delete, update and query schema. Schema register will generate new schema version in every update request. Therefore, during schema evolution, the platform supports formatting and verification based on specified compatibility configurations. By default, seven compatibility policies are supported. Schemas can evolve based on a unique subject, and each Schema v [...] +RocketMQ schema registry is a management platform for Avro schema of RocketMQ Topic, which provides a restful interface +for store, delete, update and query schema. Schema register will generate new schema version in every update request. +Therefore, during schema evolution, the platform supports formatting and verification based on specified compatibility +configurations. By default, seven compatibility policies are supported. Schemas can evolve based on a unique subject, +and each Schema version in the evolution can be individually referenced to other subjects. By binding subject to the +Schema, the New RocketMQ client can send data based on a user-specified structure without requiring the user to care +about the details of serialization and deserialization It offers a variety of features: + * Handle basic schema management operation including store, query, update, delete * Encoding / Decoding capacity by user specified serializer / deserializer in client * Compatibility validate in duration of schema evolution or send/receive message @@ -22,7 +29,10 @@ cd rocketmq-schema-registry ``` #### Prepare storage layer -Currently, only RocketMQ is supported as the storage layer. And relies on the Compact Topic feature of RocketMQ 5.0, although previous versions can also be worked, but there is a risk of data loss if the machine disk fails. Similarly, DB-type storage layers will be extended in the future. + +Currently, only RocketMQ is supported as the storage layer. And relies on the Compact Topic feature of RocketMQ 5.0, +although previous versions can also be worked, but there is a risk of data loss if the machine disk fails. Similarly, +DB-type storage layers will be extended in the future. On rocketmq storage type, we need to start a RocketMQ namesrv and broker service first. @@ -44,6 +54,7 @@ $ nohup sh bin/mqbroker -n localhost:9876 & #### Edit configuration * Config storage local cache path + ```shell $ storage.local.cache.path="" >> schema-storage-rocketmq/src/main/resources ``` @@ -59,7 +70,8 @@ Swagger API documentation can be accessed from http://localhost:8080/swagger-ui/ Package management -------------- -If you want to upload binary resources to your package repository like artifactory, schema-registry support `schema.dependency.upload-enabled = true` to enable package management. +If you want to upload binary resources to your package repository like artifactory, schema-registry +support `schema.dependency.upload-enabled = true` to enable package management. Properties details: @@ -110,7 +122,9 @@ $ curl -X GET http://localhost:8081/schema-registry/v1/cluster/{cluster-name}/te Contribute -------------- -We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). +We always welcome new contributions, whether for trivial +cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material +rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). License ---------- diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/NormalSchemaRegistryClient.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/NormalSchemaRegistryClient.java index 21cf9d2..074dc76 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/NormalSchemaRegistryClient.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/NormalSchemaRegistryClient.java @@ -17,16 +17,14 @@ package org.apache.rocketmq.schema.registry.client; +import java.io.IOException; +import java.util.List; import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; import org.apache.rocketmq.schema.registry.client.rest.RestService; import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -public class NormalSchemaRegistryClient implements SchemaRegistryClient{ +public class NormalSchemaRegistryClient implements SchemaRegistryClient { private final RestService restService; @@ -35,34 +33,38 @@ public class NormalSchemaRegistryClient implements SchemaRegistryClient{ } @Override - public SchemaDto registerSchema(String subject, String schemaName, SchemaDto schemaDto) throws RestClientException, IOException { + public SchemaDto registerSchema(String subject, String schemaName, + SchemaDto schemaDto) throws RestClientException, IOException { return restService.registerSchema(subject, schemaName, schemaDto); } @Override public SchemaDto registerSchema(String clusterName, String tenant, String subjectName, - String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { return restService.registerSchema(clusterName, tenant, subjectName, schemaName, schemaDto); } @Override - public SchemaDto deleteSchema(String cluster, String tenant, String subject) throws IOException, RestClientException { + public SchemaDto deleteSchema(String cluster, String tenant, + String subject) throws IOException, RestClientException { return restService.deleteSchema(cluster, tenant, subject); } @Override - public SchemaDto deleteSchema(String cluster, String tenant, String subject, long version) throws IOException, RestClientException { + public SchemaDto deleteSchema(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException { return restService.deleteSchema(cluster, tenant, subject, version); } @Override - public SchemaDto updateSchema(String subject, String schemaName, SchemaDto schemaDto) throws RestClientException, IOException { + public SchemaDto updateSchema(String subject, String schemaName, + SchemaDto schemaDto) throws RestClientException, IOException { return restService.updateSchema(subject, schemaName, schemaDto); } @Override public SchemaDto updateSchema(String cluster, String tenant, String subjectName, - String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { return restService.updateSchema(cluster, tenant, subjectName, schemaName, schemaDto); } @@ -71,17 +73,20 @@ public class NormalSchemaRegistryClient implements SchemaRegistryClient{ return restService.getSchemaBySubject(subject); } - public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject) throws RestClientException, IOException { + public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, + String subject) throws RestClientException, IOException { return restService.getSchemaBySubject(cluster, tenant, subject); } @Override - public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, long version) throws IOException, RestClientException { + public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException { return restService.getSchemaBySubject(cluster, tenant, subject, version); } @Override - public List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, String subject) throws RestClientException, IOException { + public List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, + String subject) throws RestClientException, IOException { return restService.getSchemaListBySubject(cluster, tenant, subject); } diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/SchemaRegistryClient.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/SchemaRegistryClient.java index 851fcf9..becd945 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/SchemaRegistryClient.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/SchemaRegistryClient.java @@ -17,35 +17,41 @@ package org.apache.rocketmq.schema.registry.client; +import java.io.IOException; +import java.util.List; import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; -import java.io.IOException; -import java.util.List; - public interface SchemaRegistryClient { - SchemaDto registerSchema(String subject, String schemaName, SchemaDto schemaDto) throws RestClientException, IOException; - - SchemaDto registerSchema(String clusterName, String tenant, String subjectName, String schemaName, SchemaDto schemaDto) throws IOException, RestClientException; + SchemaDto registerSchema(String subject, String schemaName, + SchemaDto schemaDto) throws RestClientException, IOException; + SchemaDto registerSchema(String clusterName, String tenant, String subjectName, String schemaName, + SchemaDto schemaDto) throws IOException, RestClientException; SchemaDto deleteSchema(String cluster, String tenant, String subject) throws IOException, RestClientException; - SchemaDto deleteSchema(String cluster, String tenant, String subject, long version) throws IOException, RestClientException; + SchemaDto deleteSchema(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException; - SchemaDto updateSchema(String subject, String schemaName, SchemaDto schemaDto) throws RestClientException, IOException; + SchemaDto updateSchema(String subject, String schemaName, + SchemaDto schemaDto) throws RestClientException, IOException; - SchemaDto updateSchema(String cluster, String tenant, String subjectName, String schemaName, SchemaDto schemaDto) throws IOException, RestClientException; + SchemaDto updateSchema(String cluster, String tenant, String subjectName, String schemaName, + SchemaDto schemaDto) throws IOException, RestClientException; SchemaRecordDto getSchemaBySubject(String subject) throws RestClientException, IOException; - SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject) throws IOException, RestClientException; + SchemaRecordDto getSchemaBySubject(String cluster, String tenant, + String subject) throws IOException, RestClientException; - SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, long version) throws IOException, RestClientException; + SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException; - List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, String subject) throws RestClientException, IOException; + List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, + String subject) throws RestClientException, IOException; SchemaRecordDto getSchemaById(long schemaId); diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/exceptions/RestClientException.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/exceptions/RestClientException.java index 1d40703..a5061fe 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/exceptions/RestClientException.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/exceptions/RestClientException.java @@ -19,20 +19,20 @@ package org.apache.rocketmq.schema.registry.client.exceptions; public class RestClientException extends Exception { - private final int status; - private final int errorCode; + private final int status; + private final int errorCode; - public RestClientException(final String message, final int status, final int errorCode) { - super(message + "; error code: " + errorCode); - this.status = status; - this.errorCode = errorCode; - } + public RestClientException(final String message, final int status, final int errorCode) { + super(message + "; error code: " + errorCode); + this.status = status; + this.errorCode = errorCode; + } - public int getStatus() { - return status; - } + public int getStatus() { + return status; + } - public int getErrorCode() { - return errorCode; - } + public int getErrorCode() { + return errorCode; + } } \ No newline at end of file diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/JacksonMapper.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/JacksonMapper.java index 40accdf..de0791f 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/JacksonMapper.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/JacksonMapper.java @@ -23,5 +23,5 @@ import com.fasterxml.jackson.databind.json.JsonMapper; public class JacksonMapper { public static final ObjectMapper INSTANCE = JsonMapper.builder(). - enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS).build(); + enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS).build(); } diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/RestService.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/RestService.java index f45b3c7..df49076 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/RestService.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/RestService.java @@ -19,26 +19,25 @@ package org.apache.rocketmq.schema.registry.client.rest; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; -import org.apache.rocketmq.schema.registry.client.util.HttpUtil; -import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; -import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; - import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; +import org.apache.rocketmq.schema.registry.client.util.HttpUtil; +import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; +import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; public class RestService { private static final TypeReference<SchemaDto> SCHEMA_DTO_TYPE_REFERENCE = - new TypeReference<SchemaDto>() { - }; + new TypeReference<SchemaDto>() { + }; private static final TypeReference<SchemaRecordDto> SCHEMA_RECORD_DTO_TYPE_REFERENCE = - new TypeReference<SchemaRecordDto>() { - }; + new TypeReference<SchemaRecordDto>() { + }; private static final TypeReference<List<SchemaRecordDto>> SCHEMA_RECORD_DTO_TYPE_LIST_REFERENCE = - new TypeReference<List<SchemaRecordDto>>() { - }; + new TypeReference<List<SchemaRecordDto>>() { + }; public static ObjectMapper jsonParser = JacksonMapper.INSTANCE; @@ -61,7 +60,8 @@ public class RestService { this.httpHeaders = httpHeaders; } - public SchemaDto registerSchema(String subject, String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + public SchemaDto registerSchema(String subject, String schemaName, + SchemaDto schemaDto) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/subject/{subject-name}/schema/{schema-name}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(subject, schemaName).toString()); String data = jsonParser.writeValueAsString(schemaDto); @@ -69,26 +69,29 @@ public class RestService { } public SchemaDto registerSchema(String clusterName, String tenant, String subjectName, - String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/{schema-name}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(clusterName, tenant, subjectName, schemaName).toString()); String data = jsonParser.writeValueAsString(schemaDto); return HttpUtil.sendHttpRequest(path, HTTP_POST, data, httpHeaders, SCHEMA_DTO_TYPE_REFERENCE); } - public SchemaDto deleteSchema(String cluster, String tenant, String subject) throws RestClientException, IOException { + public SchemaDto deleteSchema(String cluster, String tenant, + String subject) throws RestClientException, IOException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject).toString()); return HttpUtil.sendHttpRequest(path, HTTP_DELETE, null, httpHeaders, SCHEMA_DTO_TYPE_REFERENCE); } - public SchemaDto deleteSchema(String cluster, String tenant, String subject, long version) throws IOException, RestClientException { + public SchemaDto deleteSchema(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions/{version}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject, version).toString()); return HttpUtil.sendHttpRequest(path, HTTP_DELETE, null, httpHeaders, SCHEMA_DTO_TYPE_REFERENCE); } - public SchemaDto updateSchema(String subject, String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + public SchemaDto updateSchema(String subject, String schemaName, + SchemaDto schemaDto) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/subject/{subject-name}/schema/{schema-name}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(subject, schemaName).toString()); String data = jsonParser.writeValueAsString(schemaDto); @@ -96,7 +99,7 @@ public class RestService { } public SchemaDto updateSchema(String cluster, String tenant, String subject, - String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { + String schemaName, SchemaDto schemaDto) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/{schema-name}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject, schemaName).toString()); String data = jsonParser.writeValueAsString(schemaDto); @@ -109,19 +112,22 @@ public class RestService { return HttpUtil.sendHttpRequest(path, HTTP_GET, null, httpHeaders, SCHEMA_RECORD_DTO_TYPE_REFERENCE); } - public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject) throws IOException, RestClientException { + public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, + String subject) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject).toString()); return HttpUtil.sendHttpRequest(path, HTTP_GET, null, httpHeaders, SCHEMA_RECORD_DTO_TYPE_REFERENCE); } - public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, long version) throws IOException, RestClientException { + public SchemaRecordDto getSchemaBySubject(String cluster, String tenant, String subject, + long version) throws IOException, RestClientException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions/{version}"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject, version).toString()); return HttpUtil.sendHttpRequest(path, HTTP_GET, null, httpHeaders, SCHEMA_RECORD_DTO_TYPE_REFERENCE); } - public List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, String subject) throws RestClientException, IOException { + public List<SchemaRecordDto> getSchemaListBySubject(String cluster, String tenant, + String subject) throws RestClientException, IOException { UrlBuilder urlBuilder = UrlBuilder.fromPath("/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions"); String path = HttpUtil.buildRequestUrl(baseUri, urlBuilder.build(cluster, tenant, subject).toString()); return HttpUtil.sendHttpRequest(path, HTTP_GET, null, httpHeaders, SCHEMA_RECORD_DTO_TYPE_LIST_REFERENCE); diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/UrlBuilder.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/UrlBuilder.java index dd22f3e..0870146 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/UrlBuilder.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/rest/UrlBuilder.java @@ -22,7 +22,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import java.nio.charset.Charset; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.Collections; +import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public class UrlBuilder { @@ -85,11 +90,11 @@ public class UrlBuilder { public URI build(Object... templatePathValues) { List<String> templateValues = Arrays.stream(templatePathValues) - .map(o -> UriPercentEncoder.encode(String.valueOf(o), Charset.defaultCharset())) - .collect(Collectors.toList()); + .map(o -> UriPercentEncoder.encode(String.valueOf(o), Charset.defaultCharset())) + .collect(Collectors.toList()); if (templateValues.size() != this.templateNames.size()) { throw new IllegalArgumentException("Mismatched number of template variable names: expected " - + this.templateNames.size() + ", got " + templateValues.size()); + + this.templateNames.size() + ", got " + templateValues.size()); } String encodedPath = templatePath; @@ -117,7 +122,7 @@ public class UrlBuilder { } try { queryParamString.append(encodeQueryParameter(paramName)).append('=') - .append(encodeQueryParameter(paramValue)); + .append(encodeQueryParameter(paramValue)); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } @@ -141,11 +146,11 @@ public class UrlBuilder { static String encodeQueryParameter(String paramValue) throws UnsupportedEncodingException { return URLEncoder.encode(paramValue, "UTF-8") - /* - * use percent-encoding which is supported everywhere as per RFC-3986, not - * legacy RFC-1866 - */ - .replace("+", "%20"); + /* + * use percent-encoding which is supported everywhere as per RFC-3986, not + * legacy RFC-1866 + */ + .replace("+", "%20"); } static final List<String> findNamesInTemplate(String path) { diff --git a/client/src/main/java/org/apache/rocketmq/schema/registry/client/util/HttpUtil.java b/client/src/main/java/org/apache/rocketmq/schema/registry/client/util/HttpUtil.java index 54afc0b..2a452c2 100644 --- a/client/src/main/java/org/apache/rocketmq/schema/registry/client/util/HttpUtil.java +++ b/client/src/main/java/org/apache/rocketmq/schema/registry/client/util/HttpUtil.java @@ -19,13 +19,14 @@ package org.apache.rocketmq.schema.registry.client.util; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; -import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper; - -import java.io.*; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; +import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; +import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper; public class HttpUtil { public static ObjectMapper jsonParser = JacksonMapper.INSTANCE; @@ -34,9 +35,9 @@ public class HttpUtil { private static final int ERROR_CODE = 5001; public static <T> T sendHttpRequest(String requestUrl, String method, String requestBodyData, - Map<String, String> requestProperties, - TypeReference<T> responseFormat) - throws IOException, RestClientException { + Map<String, String> requestProperties, + TypeReference<T> responseFormat) + throws IOException, RestClientException { HttpURLConnection connection = null; try { @@ -64,7 +65,7 @@ public class HttpUtil { return null; } else { throw new RestClientException("send request failed", responseCode, - ERROR_CODE); + ERROR_CODE); } } finally { @@ -75,8 +76,8 @@ public class HttpUtil { } private static HttpURLConnection buildConnection(URL url, String method, Map<String, - String> requestProperties) - throws IOException { + String> requestProperties) + throws IOException { HttpURLConnection connection = null; connection = (HttpURLConnection) url.openConnection(); diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/QualifiedName.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/QualifiedName.java index 06b5059..f9d48a0 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/QualifiedName.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/QualifiedName.java @@ -17,12 +17,8 @@ package org.apache.rocketmq.schema.registry.common; -import java.beans.Transient; -import javax.annotation.Nullable; import java.io.Serializable; - -import javax.security.auth.Subject; -import lombok.AllArgsConstructor; +import javax.annotation.Nullable; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -46,9 +42,9 @@ public class QualifiedName implements Serializable { @Nullable final String subject, @Nullable final String schema ) { - this.cluster= cluster; - this.tenant= tenant; - this.subject= subject; + this.cluster = cluster; + this.tenant = tenant; + this.subject = subject; this.schema = schema; } @@ -59,9 +55,9 @@ public class QualifiedName implements Serializable { @Nullable final String schema, @Nullable final Long version ) { - this.cluster= cluster; - this.tenant= tenant; - this.subject= subject; + this.cluster = cluster; + this.tenant = tenant; + this.subject = subject; this.schema = schema; this.version = version; } diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/AccessControlService.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/AccessControlService.java index 086b1d9..bc355e2 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/AccessControlService.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/AccessControlService.java @@ -17,8 +17,8 @@ package org.apache.rocketmq.schema.registry.common.auth; -import org.apache.rocketmq.schema.registry.common.model.SchemaOperation; import org.apache.rocketmq.schema.registry.common.exception.SchemaAuthorizedException; +import org.apache.rocketmq.schema.registry.common.model.SchemaOperation; public interface AccessControlService { diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/DefaultAccessControlServiceImpl.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/DefaultAccessControlServiceImpl.java index 14f9df5..630956f 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/DefaultAccessControlServiceImpl.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/auth/DefaultAccessControlServiceImpl.java @@ -19,9 +19,9 @@ package org.apache.rocketmq.schema.registry.common.auth; import java.util.Map; import java.util.Set; -import org.apache.rocketmq.schema.registry.common.model.SchemaOperation; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.exception.SchemaAuthorizedException; +import org.apache.rocketmq.schema.registry.common.model.SchemaOperation; import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; public class DefaultAccessControlServiceImpl implements AccessControlService { diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContext.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContext.java index 88df328..1dd5cf5 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContext.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContext.java @@ -17,10 +17,9 @@ package org.apache.rocketmq.schema.registry.common.context; -import javax.annotation.Nullable; import java.io.Serializable; import java.util.UUID; - +import javax.annotation.Nullable; import lombok.Builder; import lombok.Data; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContextManager.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContextManager.java index 76dafbb..e065533 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContextManager.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/RequestContextManager.java @@ -19,17 +19,17 @@ package org.apache.rocketmq.schema.registry.common.context; public class RequestContextManager { - private static final ThreadLocal<RequestContext> contexts = new ThreadLocal<>(); + private static final ThreadLocal<RequestContext> CONTEXTS = new ThreadLocal<>(); private RequestContextManager() { } public static void removeContext() { - contexts.remove(); + CONTEXTS.remove(); } public static RequestContext getContext() { - RequestContext result = contexts.get(); + RequestContext result = CONTEXTS.get(); if (result == null) { result = new RequestContext(); putContext(result); @@ -38,6 +38,6 @@ public class RequestContextManager { } public static void putContext(final RequestContext context) { - contexts.set(context); + CONTEXTS.set(context); } } diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StoragePluginContext.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StoragePluginContext.java index 28b0679..e314857 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StoragePluginContext.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StoragePluginContext.java @@ -17,14 +17,9 @@ package org.apache.rocketmq.schema.registry.common.context; -import java.util.Properties; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.rocketmq.schema.registry.common.exception.SchemaException; -import org.apache.rocketmq.schema.registry.common.model.StorageType; import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; -import org.springframework.context.ApplicationContext; @Data @AllArgsConstructor diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StorageServiceContext.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StorageServiceContext.java index c417e0d..364c8af 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StorageServiceContext.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/context/StorageServiceContext.java @@ -20,7 +20,6 @@ package org.apache.rocketmq.schema.registry.common.context; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.apache.rocketmq.schema.registry.common.model.StorageType; @Data @AllArgsConstructor diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/AuditDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/AuditDto.java index 0f558ae..f80c8e3 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/AuditDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/AuditDto.java @@ -17,9 +17,8 @@ package org.apache.rocketmq.schema.registry.common.dto; -import java.util.Date; - import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/BaseDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/BaseDto.java index e7445ac..a6df701 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/BaseDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/BaseDto.java @@ -17,14 +17,9 @@ package org.apache.rocketmq.schema.registry.common.dto; import java.io.Serializable; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; import org.apache.rocketmq.schema.registry.common.json.JsonConverter; import org.apache.rocketmq.schema.registry.common.json.JsonConverterImpl; - /** * Base class for all DTOs, and all DTOs should be READ-ONLY. */ diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/FieldDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/FieldDto.java index dd4be4c..e2f6daf 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/FieldDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/FieldDto.java @@ -59,7 +59,7 @@ public class FieldDto extends BaseDto { @ApiModelProperty(value = "Is a sorted field, default is false") private Boolean isSortable = false; - @ApiModelProperty(value = "This filed sorted type, likeļ¼ascending, descending, ignore") + @ApiModelProperty(value = "This filed sorted type, like: ascending, descending, ignore") private String sortType; @ApiModelProperty(value = "Extra info of the field") diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaDetailDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaDetailDto.java index 914e6cf..dbc3bca 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaDetailDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaDetailDto.java @@ -19,13 +19,11 @@ package org.apache.rocketmq.schema.registry.common.dto; import io.swagger.annotations.ApiModelProperty; import java.util.List; -import java.util.Optional; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.apache.rocketmq.schema.registry.common.exception.SchemaException; @Data @EqualsAndHashCode(callSuper = false) diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaMetaDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaMetaDto.java index 4c4a5b4..164731c 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaMetaDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaMetaDto.java @@ -17,15 +17,14 @@ package org.apache.rocketmq.schema.registry.common.dto; -import org.apache.rocketmq.schema.registry.common.model.Compatibility; -import org.apache.rocketmq.schema.registry.common.model.SchemaType; - import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import org.apache.rocketmq.schema.registry.common.model.Compatibility; +import org.apache.rocketmq.schema.registry.common.model.SchemaType; @Data @EqualsAndHashCode(callSuper = false) diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaStorageDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaStorageDto.java index 5db3cac..e31e96f 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaStorageDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SchemaStorageDto.java @@ -17,9 +17,8 @@ package org.apache.rocketmq.schema.registry.common.dto; -import java.util.Map; - import io.swagger.annotations.ApiModelProperty; +import java.util.Map; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SubjectDto.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SubjectDto.java index 4d19d5f..dbf27af 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SubjectDto.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/dto/SubjectDto.java @@ -18,7 +18,6 @@ package org.apache.rocketmq.schema.registry.common.dto; import io.swagger.annotations.ApiModelProperty; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaException.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaException.java index a95fb90..8b2bc70 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaException.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaException.java @@ -24,7 +24,9 @@ public class SchemaException extends RuntimeException { private final int errorCode = 50001; - /** Constructor. */ + /** + * Constructor. + */ public SchemaException() { super(); } @@ -41,7 +43,7 @@ public class SchemaException extends RuntimeException { /** * Constructor. * - * @param msg The error message + * @param msg The error message * @param cause The cause of the error */ public SchemaException(final String msg, final Throwable cause) { diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaExistException.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaExistException.java index f8a9071..ced6680 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaExistException.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/exception/SchemaExistException.java @@ -22,19 +22,19 @@ import org.apache.rocketmq.schema.registry.common.QualifiedName; @Getter public class SchemaExistException extends SchemaException { - private static final long serialVersionUID = -9177284523006645052L; + private static final long serialVersionUID = -9177284523006645052L; - private final int errorCode = 40401; + private final int errorCode = 40401; - public SchemaExistException(final QualifiedName qualifiedName) { - this(String.format("Schema: %s is exist, please check your configuration.", qualifiedName.schemaFullName())); - } + public SchemaExistException(final QualifiedName qualifiedName) { + this(String.format("Schema: %s is exist, please check your configuration.", qualifiedName.schemaFullName())); + } - public SchemaExistException(final String msg) { - super(msg); - } + public SchemaExistException(final String msg) { + super(msg); + } - public SchemaExistException(final String msg, final Throwable cause) { - super(msg, cause); - } + public SchemaExistException(final String msg, final Throwable cause) { + super(msg, cause); + } } diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/filter/RequestFilter.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/filter/RequestFilter.java index 05b566a..658ec50 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/filter/RequestFilter.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/filter/RequestFilter.java @@ -17,7 +17,7 @@ package org.apache.rocketmq.schema.registry.common.filter; - +import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -25,17 +25,13 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import java.io.IOException; - -import org.apache.rocketmq.schema.registry.common.context.RequestContextManager; -import org.apache.rocketmq.schema.registry.common.context.RequestContext; - import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.schema.registry.common.context.RequestContext; +import org.apache.rocketmq.schema.registry.common.context.RequestContextManager; @Slf4j public class RequestFilter implements Filter { - public RequestFilter() { } diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverter.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverter.java index 4094c3f..72cedea 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverter.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverter.java @@ -17,9 +17,8 @@ package org.apache.rocketmq.schema.registry.common.json; -import org.apache.rocketmq.schema.registry.common.exception.SchemaException; - import com.fasterxml.jackson.databind.node.ObjectNode; +import org.apache.rocketmq.schema.registry.common.exception.SchemaException; /** * Json <-> Object diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverterImpl.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverterImpl.java index 03b1f1f..0a4b9fe 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverterImpl.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/json/JsonConverterImpl.java @@ -18,16 +18,14 @@ package org.apache.rocketmq.schema.registry.common.json; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.Gson; import java.nio.charset.StandardCharsets; +import lombok.Getter; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.exception.SchemaException; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.AllArgsConstructor; -import lombok.Getter; - @NoArgsConstructor @Getter @Slf4j diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/AuditInfo.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/AuditInfo.java index 66cbd5e..f100d70 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/AuditInfo.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/AuditInfo.java @@ -17,7 +17,6 @@ package org.apache.rocketmq.schema.registry.common.model; -import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.Date; import lombok.AllArgsConstructor; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/Dependency.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/Dependency.java index 3484e48..bcc1a85 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/Dependency.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/Dependency.java @@ -29,7 +29,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class Dependency implements Serializable { private static final long serialVersionUID = -5947555406026133852L; - + private String groupId; private String artifactId; private String version; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/FieldInfo.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/FieldInfo.java index 3d11a7d..cd45b9f 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/FieldInfo.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/FieldInfo.java @@ -17,7 +17,6 @@ package org.apache.rocketmq.schema.registry.common.model; -import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaDetailInfo.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaDetailInfo.java index aa93dbf..20f9532 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaDetailInfo.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaDetailInfo.java @@ -17,15 +17,11 @@ package org.apache.rocketmq.schema.registry.common.model; -import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.List; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; import org.apache.rocketmq.schema.registry.common.exception.SchemaException; @Data diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaMetaInfo.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaMetaInfo.java index 135e636..0d657a3 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaMetaInfo.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaMetaInfo.java @@ -17,7 +17,6 @@ package org.apache.rocketmq.schema.registry.common.model; -import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaStorageInfo.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaStorageInfo.java index 491924e..308e4ba 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaStorageInfo.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaStorageInfo.java @@ -17,7 +17,6 @@ package org.apache.rocketmq.schema.registry.common.model; -import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.Map; import lombok.AllArgsConstructor; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaType.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaType.java index 785a05a..610f685 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaType.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/model/SchemaType.java @@ -42,7 +42,7 @@ public enum SchemaType { /** * Binlog type for reserved */ - BINLOG(6); + BINLOG(6); private final int value; diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/AclProperties.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/AclProperties.java index 8a427ad..66a8b07 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/AclProperties.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/AclProperties.java @@ -40,10 +40,8 @@ public class AclProperties { } /** - * Parse the configuration to get operation control. The control is at userName level - * and the controlled operations include create, delete, and rename for table. - * The format is below. - * db1:user1,user2|db2:user1,user2 + * Parse the configuration to get operation control. The control is at userName level and the controlled operations + * include create, delete, and rename for table. The format is below. db1:user1,user2|db2:user1,user2 * * @param aclStr the config strings for dbs * @return acl config diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/ServiceProperties.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/ServiceProperties.java index bd84177..1dfd464 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/ServiceProperties.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/properties/ServiceProperties.java @@ -18,7 +18,6 @@ package org.apache.rocketmq.schema.registry.common.properties; import lombok.Data; -import org.apache.rocketmq.schema.registry.common.model.StorageType; @Data public class ServiceProperties { diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageManager.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageManager.java index 3b15524..c1acd68 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageManager.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageManager.java @@ -22,10 +22,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.schema.registry.common.context.StoragePluginContext; import org.apache.rocketmq.schema.registry.common.model.PluginLoadState; -import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; -import org.apache.rocketmq.schema.registry.common.context.StoragePluginContext; +import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; import org.springframework.context.ApplicationContext; @Slf4j diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePlugin.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePlugin.java index 507cbbf..130fa93 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePlugin.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePlugin.java @@ -32,7 +32,7 @@ public interface StoragePlugin { /** * Returns the storage service implementation for the type. * - * @param storageContext registry for spectator + * @param storageContext registry for spectator * @return connector factory */ StorageFactory load(StoragePluginContext storageContext); diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePluginManager.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePluginManager.java index f3f3646..41b29f9 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePluginManager.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StoragePluginManager.java @@ -28,7 +28,7 @@ public class StoragePluginManager { private final GlobalConfig config; private final StorageManager storageManager; - private static final AtomicReference<PluginLoadState> state = new AtomicReference<>(); + private static final AtomicReference<PluginLoadState> STATE = new AtomicReference<>(); /** * Constructor. diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageService.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageService.java index 7e57d1f..54de019 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageService.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageService.java @@ -18,7 +18,6 @@ package org.apache.rocketmq.schema.registry.common.storage; import java.util.List; - import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; import org.apache.rocketmq.schema.registry.common.model.BaseInfo; @@ -35,7 +34,7 @@ public interface StorageService<T extends BaseInfo> { /** * Register a brand new schema. * - * @param context The storage service needed context + * @param context The storage service needed context * @param schemaInfo The schema information * @throws UnsupportedOperationException If the storage type doesn't implement this method */ @@ -47,7 +46,7 @@ public interface StorageService<T extends BaseInfo> { * Delete schema with all version * * @param context The storage service needed context - * @param name Qualified name with tenant / name of schema + * @param name Qualified name with tenant / name of schema * @throws UnsupportedOperationException If the storage type doesn't implement this method */ default void delete(final StorageServiceContext context, final QualifiedName name) { @@ -57,7 +56,7 @@ public interface StorageService<T extends BaseInfo> { /** * Update schema and generate a new version with the given information. * - * @param context The request context + * @param context The request context * @param schemaInfo schema information * @throws UnsupportedOperationException If the connector doesn't implement this method */ @@ -69,7 +68,7 @@ public interface StorageService<T extends BaseInfo> { * Query a resource with the given tenant and name. * * @param context The storage service needed context - * @param name Qualified name with tenant / name of schema + * @param name Qualified name with tenant / name of schema * @return The resource metadata. * @throws UnsupportedOperationException If the storage type doesn't implement this method */ diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageServiceProxy.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageServiceProxy.java index 181739d..eacb566 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageServiceProxy.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/storage/StorageServiceProxy.java @@ -18,13 +18,12 @@ package org.apache.rocketmq.schema.registry.common.storage; import java.util.List; - import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.context.RequestContext; +import org.apache.rocketmq.schema.registry.common.context.RequestContextManager; import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; -import org.apache.rocketmq.schema.registry.common.context.RequestContextManager; import org.apache.rocketmq.schema.registry.common.model.SchemaRecordInfo; import org.apache.rocketmq.schema.registry.common.utils.StorageUtil; import org.springframework.cache.annotation.CacheConfig; @@ -41,8 +40,8 @@ public class StorageServiceProxy { /** * Constructor for storage service proxy. * - * @param storageManager storage manager - * @param storageUtil convert from Dto to storage instance or vice versa + * @param storageManager storage manager + * @param storageUtil convert from Dto to storage instance or vice versa */ public StorageServiceProxy(final StorageManager storageManager, final StorageUtil storageUtil) { this.storageManager = storageManager; @@ -51,8 +50,9 @@ public class StorageServiceProxy { /** * Proxy calls the StorageService's register method. + * * @param qualifiedName Qualified name with tenant / name of schema - * @param schemaInfo schema object + * @param schemaInfo schema object */ public SchemaInfo register( final QualifiedName qualifiedName, @@ -82,7 +82,7 @@ public class StorageServiceProxy { /** * Proxy calls the StorageService's update method. * - * @param name schema qualified name + * @param name schema qualified name * @param schemaInfo schema information instance * @return true if errors after this should be ignored. */ @@ -96,10 +96,9 @@ public class StorageServiceProxy { } /** - * Proxy calls the StorageService's get method. Returns schema from store - * if <code>useCache</code> is false. + * Proxy calls the StorageService's get method. Returns schema from store if <code>useCache</code> is false. * - * @param name Qualified name with tenant / name of schema + * @param name Qualified name with tenant / name of schema * @param useCache if schema can be retrieved from cache * @return schema information instance */ diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/CommonUtil.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/CommonUtil.java index a29d6e6..5673f67 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/CommonUtil.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/CommonUtil.java @@ -52,8 +52,8 @@ import org.apache.avro.SchemaValidator; import org.apache.avro.SchemaValidatorBuilder; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; -import org.apache.rocketmq.schema.registry.common.exception.SchemaException; import org.apache.rocketmq.schema.registry.common.exception.SchemaCompatibilityException; +import org.apache.rocketmq.schema.registry.common.exception.SchemaException; import org.apache.rocketmq.schema.registry.common.model.Compatibility; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; @@ -201,10 +201,10 @@ public class CommonUtil { @Override public void run() { - try ( - InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - BufferedReader br = new BufferedReader(inputStreamReader); - ) { + + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader br = new BufferedReader(inputStreamReader); + try { String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { @@ -212,7 +212,24 @@ public class CommonUtil { } output = sb.toString(); } catch (Throwable e) { - log.error("", e); + log.error("Read from file error", e); + } finally { + if (br != null) { + try { + br.close(); + + } catch (IOException ioException) { + log.error("", ioException); + } + } + if (inputStreamReader != null) { + try { + inputStreamReader.close(); + + } catch (IOException ioException) { + log.error("", ioException); + } + } } } } diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/IdGenerator.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/IdGenerator.java index 8a4c5f6..8cbbd8b 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/IdGenerator.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/IdGenerator.java @@ -20,7 +20,6 @@ package org.apache.rocketmq.schema.registry.common.utils; public interface IdGenerator { /** - * * @return unique id */ public long nextId(); diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/MemoryJavaFileManager.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/MemoryJavaFileManager.java index ae6c2df..5ade460 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/MemoryJavaFileManager.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/MemoryJavaFileManager.java @@ -35,7 +35,9 @@ import javax.tools.SimpleJavaFileObject; public class MemoryJavaFileManager extends ForwardingJavaFileManager { - /** Java source file extension. */ + /** + * Java source file extension. + */ private final static String EXT = ".java"; private Map<String, ByteBuffer> classBytes; @@ -87,7 +89,7 @@ public class MemoryJavaFileManager extends ForwardingJavaFileManager { return new FilterOutputStream(new ByteArrayOutputStream()) { public void close() throws IOException { out.close(); - ByteArrayOutputStream bos = (ByteArrayOutputStream)out; + ByteArrayOutputStream bos = (ByteArrayOutputStream) out; classBytes.put(name, ByteBuffer.wrap(bos.toByteArray())); } }; @@ -116,7 +118,8 @@ public class MemoryJavaFileManager extends ForwardingJavaFileManager { final StringBuilder newUri = new StringBuilder(); newUri.append("mfm:///"); newUri.append(name.replace('.', '/')); - if(name.endsWith(EXT)) newUri.replace(newUri.length() - EXT.length(), newUri.length(), EXT); + if (name.endsWith(EXT)) + newUri.replace(newUri.length() - EXT.length(), newUri.length(), EXT); return URI.create(newUri.toString()); } catch (Exception exp) { return URI.create("mfm:///com/sun/script/java/java_source"); diff --git a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/StorageUtil.java b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/StorageUtil.java index 268458b..706f977 100644 --- a/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/StorageUtil.java +++ b/common/src/main/java/org/apache/rocketmq/schema/registry/common/utils/StorageUtil.java @@ -17,20 +17,20 @@ package org.apache.rocketmq.schema.registry.common.utils; -import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; -import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; -import org.apache.rocketmq.schema.registry.common.dto.SubjectDto; -import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; import org.apache.rocketmq.schema.registry.common.context.RequestContext; +import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; import org.apache.rocketmq.schema.registry.common.dto.AuditDto; import org.apache.rocketmq.schema.registry.common.dto.FieldDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaDetailDto; +import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaMetaDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaStorageDto; +import org.apache.rocketmq.schema.registry.common.dto.SubjectDto; import org.apache.rocketmq.schema.registry.common.model.AuditInfo; import org.apache.rocketmq.schema.registry.common.model.FieldInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaDetailInfo; +import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaMetaInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaRecordInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaStorageInfo; diff --git a/core/mvnw b/core/mvnw old mode 100644 new mode 100755 diff --git a/core/pom.xml b/core/pom.xml index 0b6ae01..94e436d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -22,7 +22,7 @@ <dependency> <groupId>org.apache.rocketmq</groupId> - <artifactId>schema-storage-rocketmq</artifactId> + <artifactId>storage-rocketmq</artifactId> <version>${project.version}</version> </dependency> </dependencies> diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/CoreApplication.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/CoreApplication.java index 133695a..f4e47e7 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/CoreApplication.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/CoreApplication.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.schema.registry.core; import org.springframework.boot.SpringApplication; @@ -6,7 +22,6 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; import org.springframework.scheduling.annotation.EnableScheduling; - import springfox.documentation.oas.annotations.EnableOpenApi; @SpringBootApplication @@ -15,11 +30,11 @@ import springfox.documentation.oas.annotations.EnableOpenApi; @ComponentScan(excludeFilters = @Filter(type = FilterType.ASPECTJ, pattern = "org.apache.rocketmq.schema.registry.storage..*")) public class CoreApplication { - public CoreApplication() { - } + public CoreApplication() { + } - public static void main(String[] args) { - SpringApplication.run(CoreApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(CoreApplication.class, args); + } } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/RequestProcessor.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/RequestProcessor.java index 4b2e828..8a9ada6 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/RequestProcessor.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/RequestProcessor.java @@ -1,20 +1,29 @@ -/** - * Copyright 2022, Xiaomi. - * All rights reserved. - * Author: [email protected] +/* + * 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.rocketmq.schema.registry.core.api; import java.util.function.Supplier; - +import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.exception.SchemaException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import lombok.extern.slf4j.Slf4j; - @Slf4j @Component public class RequestProcessor { @@ -29,8 +38,8 @@ public class RequestProcessor { * * @param qualifiedName qualifiedName * @param requestName request name - * @param supplier supplier - * @param <R> response + * @param supplier supplier + * @param <R> response * @return response of supplier */ public <R> R processRequest( @@ -50,17 +59,16 @@ public class RequestProcessor { throw e; } catch (Throwable e) { throw new SchemaException(String.format("%s request failed due to: %s %s", requestName, e.getMessage(), e.getCause()), e); - } finally { - log.info("Handle request: {} cost {}", requestName, (System.currentTimeMillis() - time)); } + } /** * Request processor to handle request. * - * @param requestName request name - * @param supplier supplier - * @param <R> response + * @param requestName request name + * @param supplier supplier + * @param <R> response * @return response of supplier */ public <R> R processRequest( @@ -72,10 +80,8 @@ public class RequestProcessor { return supplier.get(); } catch (SchemaException e) { throw e; - } catch (Throwable e) { + } catch (Throwable e) { throw new SchemaException(String.format("Request: %s failed due to %s %s", requestName, e.getMessage(), e.getCause()), e); - } finally { - log.info("Handle request: {} cost {}", requestName, (System.currentTimeMillis() - time)); } } } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/v1/SchemaController.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/v1/SchemaController.java index 97fe8bb..def77e0 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/v1/SchemaController.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/api/v1/SchemaController.java @@ -1,19 +1,29 @@ -/** - * Copyright 2022, Xiaomi. - * All rights reserved. - * Author: [email protected] +/* + * 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.rocketmq.schema.registry.core.api.v1; -import java.net.HttpURLConnection; -import java.util.List; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import java.net.HttpURLConnection; +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; @@ -37,12 +47,12 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping( path = "/schema-registry/v1", produces = MediaType.APPLICATION_JSON_VALUE -) + ) @Api( value = "SchemaRegistryV1", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE -) + ) @Slf4j public class SchemaController { @@ -57,7 +67,7 @@ public class SchemaController { * Constructor. * * @param requestProcessor request processor - * @param schemaService schema service + * @param schemaService schema service */ @Autowired public SchemaController( @@ -72,12 +82,12 @@ public class SchemaController { method = RequestMethod.POST, path = "/subject/{subject-name}/schema/{schema-name}", consumes = MediaType.APPLICATION_JSON_VALUE - ) + ) @ResponseStatus(HttpStatus.CREATED) @ApiOperation( value = "Register a new schema", notes = "Return success if there were no errors registering the schema" - ) + ) @ApiResponses( { @ApiResponse( @@ -89,7 +99,7 @@ public class SchemaController { message = "The requested schema cannot be registered" ) } - ) + ) public SchemaDto registerSchema( @ApiParam(value = "The subject of the schema", required = true) @PathVariable(value = "subject-name") final String subject, @@ -105,12 +115,12 @@ public class SchemaController { method = RequestMethod.POST, path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/{schema-name}", consumes = MediaType.APPLICATION_JSON_VALUE - ) + ) @ResponseStatus(HttpStatus.CREATED) @ApiOperation( value = "Register a new schema", notes = "Return success if there were no errors registering the schema" - ) + ) @ApiResponses( { @ApiResponse( @@ -122,7 +132,7 @@ public class SchemaController { message = "The requested schema cannot be registered" ) } - ) + ) public SchemaDto registerSchema( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -151,12 +161,12 @@ public class SchemaController { @RequestMapping( path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema", method = RequestMethod.DELETE - ) + ) @ResponseStatus(HttpStatus.OK) @ApiOperation( value = "Delete schema", notes = "Delete the schema under the given subject" - ) + ) @ApiResponses( { @ApiResponse( @@ -167,8 +177,7 @@ public class SchemaController { code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested schema cannot be found or it's still been used" ) - } - ) + }) public SchemaDto deleteSchema( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -188,12 +197,12 @@ public class SchemaController { @RequestMapping( path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions/{version}", method = RequestMethod.DELETE - ) + ) @ResponseStatus(HttpStatus.OK) @ApiOperation( value = "Delete schema", notes = "Delete the schema under the given subject and version" - ) + ) @ApiResponses( { @ApiResponse( @@ -205,7 +214,7 @@ public class SchemaController { message = "The requested schema cannot be found or it's still been used" ) } - ) + ) public SchemaDto deleteSchema( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -224,16 +233,15 @@ public class SchemaController { ); } - @RequestMapping( path = "/subject/{subject-name}/schema/{schema-name}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE - ) + ) @ApiOperation( value = "Update schema and generate new schema version", notes = "Update the given schema" - ) + ) @ApiResponses( { @ApiResponse( @@ -245,7 +253,7 @@ public class SchemaController { message = "The requested schema cannot be found" ) } - ) + ) public SchemaDto updateSchema( @ApiParam(value = "The subject of the schema", required = true) @PathVariable(value = "subject-name") final String subject, @@ -261,11 +269,11 @@ public class SchemaController { path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/{schema-name}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE - ) + ) @ApiOperation( value = "Update schema and generate new schema version", notes = "Update the given schema" - ) + ) @ApiResponses( { @ApiResponse( @@ -277,7 +285,7 @@ public class SchemaController { message = "The requested schema cannot be found" ) } - ) + ) public SchemaDto updateSchema( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -298,11 +306,10 @@ public class SchemaController { ); } - @RequestMapping( method = RequestMethod.GET, path = "/subject/{subject-name}/schema" - ) + ) @ApiOperation( value = "Schema information", notes = "Schema information with the latest version under the subject") @@ -317,7 +324,7 @@ public class SchemaController { message = "The requested tenant or schema cannot be found" ) } - ) + ) public SchemaRecordDto getSchemaBySubject( @ApiParam(value = "The name of the subject", required = true) @PathVariable(value = "subject-name") String subject @@ -328,7 +335,7 @@ public class SchemaController { @RequestMapping( method = RequestMethod.GET, path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema" - ) + ) @ApiOperation( value = "Schema information", notes = "Schema information with the latest version under the subject") @@ -343,7 +350,7 @@ public class SchemaController { message = "The requested tenant or schema cannot be found" ) } - ) + ) public SchemaRecordDto getSchemaBySubject( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -364,7 +371,7 @@ public class SchemaController { @RequestMapping( method = RequestMethod.GET, path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions/{version}" - ) + ) @ApiOperation( value = "Schema information", notes = "Schema information with the given version under the subject") @@ -379,7 +386,7 @@ public class SchemaController { message = "The requested tenant or schema cannot be found" ) } - ) + ) public SchemaRecordDto getSchemaBySubject( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, @@ -401,7 +408,7 @@ public class SchemaController { @RequestMapping( method = RequestMethod.GET, path = "/cluster/{cluster-name}/tenant/{tenant-name}/subject/{subject-name}/schema/versions" - ) + ) @ApiOperation( value = "Schema information", notes = "Schema information with a list of versions under the subject") @@ -416,7 +423,7 @@ public class SchemaController { message = "The requested tenant or schema cannot be found" ) } - ) + ) public List<SchemaRecordDto> getSchemaListBySubject( @ApiParam(value = "The cluster of the subject", required = true) @PathVariable(value = "cluster-name") final String cluster, diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaManagerConfig.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaManagerConfig.java index eee526d..9340a59 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaManagerConfig.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaManagerConfig.java @@ -18,9 +18,9 @@ package org.apache.rocketmq.schema.registry.core.config; import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; +import org.apache.rocketmq.schema.registry.common.storage.StorageManager; import org.apache.rocketmq.schema.registry.core.dependency.ArtifactoryDependencyServiceImpl; import org.apache.rocketmq.schema.registry.core.dependency.DependencyService; -import org.apache.rocketmq.schema.registry.common.storage.StorageManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaServiceConfig.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaServiceConfig.java index 6dadcde..af8a6e4 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaServiceConfig.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SchemaServiceConfig.java @@ -21,15 +21,15 @@ import org.apache.rocketmq.schema.registry.common.auth.AccessControlService; import org.apache.rocketmq.schema.registry.common.auth.DefaultAccessControlServiceImpl; import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; import org.apache.rocketmq.schema.registry.common.properties.GlobalConfig; +import org.apache.rocketmq.schema.registry.common.storage.StorageManager; +import org.apache.rocketmq.schema.registry.common.storage.StorageServiceProxy; import org.apache.rocketmq.schema.registry.common.utils.IdGenerator; import org.apache.rocketmq.schema.registry.common.utils.SnowFlakeIdGenerator; +import org.apache.rocketmq.schema.registry.common.utils.StorageUtil; import org.apache.rocketmq.schema.registry.core.dependency.DependencyService; -import org.apache.rocketmq.schema.registry.common.storage.StorageManager; import org.apache.rocketmq.schema.registry.core.service.SchemaInitializationService; import org.apache.rocketmq.schema.registry.core.service.SchemaService; import org.apache.rocketmq.schema.registry.core.service.SchemaServiceImpl; -import org.apache.rocketmq.schema.registry.common.storage.StorageServiceProxy; -import org.apache.rocketmq.schema.registry.common.utils.StorageUtil; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -59,8 +59,7 @@ public class SchemaServiceConfig { /** * Handle startup and shutdown of schema service. * - * @param storageManager Plugin manager to use - * + * @param storageManager Plugin manager to use * @return The initialization service bean */ @Bean @@ -106,5 +105,4 @@ public class SchemaServiceConfig { return new SnowFlakeIdGenerator(config); } - } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SwaggerConfig.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SwaggerConfig.java index b5aeed4..313b03c 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SwaggerConfig.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/config/SwaggerConfig.java @@ -18,7 +18,6 @@ package org.apache.rocketmq.schema.registry.core.config; import java.util.ArrayList; - import java.util.Collection; import java.util.List; import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties; @@ -37,7 +36,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; - import org.springframework.util.StringUtils; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.oas.annotations.EnableOpenApi; @@ -58,14 +56,14 @@ public class SwaggerConfig { boolean isEnable = environment.acceptsProfiles(profiles); return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .enable(isEnable) - .select() - .apis(RequestHandlerSelectors.basePackage("org.apache.rocketmq.schema.registry.core")) - .build(); + .apiInfo(apiInfo()) + .enable(isEnable) + .select() + .apis(RequestHandlerSelectors.basePackage("org.apache.rocketmq.schema.registry.core")) + .build(); } - private ApiInfo apiInfo(){ + private ApiInfo apiInfo() { Contact contact = new Contact( "Apache rocketmq-schema-registry", @@ -105,7 +103,7 @@ public class SwaggerConfig { return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsEndpointProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegister, null); } - private boolean should (WebEndpointProperties webEndpointProperties, Environment environment, String basePath) { + private boolean should(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) { return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT)); } } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/ArtifactoryDependencyServiceImpl.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/ArtifactoryDependencyServiceImpl.java index 684c7ea..f2d08bf 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/ArtifactoryDependencyServiceImpl.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/ArtifactoryDependencyServiceImpl.java @@ -37,7 +37,6 @@ public class ArtifactoryDependencyServiceImpl implements DependencyService { private final String jdkPath; private String dependencyTemplate; - public ArtifactoryDependencyServiceImpl(final GlobalConfig config) { this.config = config; this.parent = config.getDependencyCompilePath(); @@ -75,5 +74,4 @@ public class ArtifactoryDependencyServiceImpl implements DependencyService { return dependencyHelper.getDependency(); } - } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DependencyHelper.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DependencyHelper.java index f095476..aa90514 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DependencyHelper.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DependencyHelper.java @@ -104,7 +104,7 @@ public class DependencyHelper { .collect(Collectors.toList()); log.info("Success flush java files: " + javaFileList); return CommonUtil.compileJavaFile(javaFileList); - } catch (Throwable e){ + } catch (Throwable e) { throw new SchemaException("Compile schema failed", e); } } diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicCompileProvider.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicCompileProvider.java index 555127c..a9e863c 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicCompileProvider.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicCompileProvider.java @@ -26,7 +26,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.rocketmq.schema.registry.common.exception.SchemaException; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; -import org.apache.rocketmq.schema.registry.common.properties.GlobalConfigImpl; import org.apache.rocketmq.schema.registry.common.utils.CommonUtil; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; @@ -51,7 +50,7 @@ import org.eclipse.aether.util.repository.AuthenticationBuilder; @Data @Slf4j public class DynamicCompileProvider { - private final static RepositorySystem system = newRepositorySystem(); + private final static RepositorySystem SYSTEM = newRepositorySystem(); public static DependencyHelper compile(final String jdkPath, final String parentDir, final SchemaInfo schemaInfo, final String dependencyTemplate) { @@ -125,12 +124,12 @@ public class DynamicCompileProvider { try { String versionCache = CommonUtil.mkdir(String.format("%s/version_cache/%d_resources", localRepo, System.currentTimeMillis())).getCanonicalPath(); - RepositorySystemSession session = newSession(system, versionCache); + RepositorySystemSession session = newSession(SYSTEM, versionCache); DeployRequest deployRequest = new DeployRequest() .setRepository(remoteRepo) .addArtifact(jarArtifact) .addArtifact(pomArtifact); - DeployResult result = system.deploy(session, deployRequest); + DeployResult result = SYSTEM.deploy(session, deployRequest); log.info("transfer artifact " + groupId + ":" + artifactId + ":" + version + " to central success."); } catch (DeploymentException | IOException e) { throw new SchemaException("Deploy jar file: " + jarFile + " failed", e); diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicJarsProvider.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicJarsProvider.java index 104060f..c2bfaa8 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicJarsProvider.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/dependency/DynamicJarsProvider.java @@ -17,30 +17,7 @@ package org.apache.rocketmq.schema.registry.core.dependency; -import java.io.File; -import java.io.IOException; import lombok.extern.slf4j.Slf4j; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.apache.rocketmq.schema.registry.common.exception.SchemaException; -import org.apache.rocketmq.schema.registry.common.utils.CommonUtil; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; -import org.eclipse.aether.deployment.DeployRequest; -import org.eclipse.aether.deployment.DeploymentException; -import org.eclipse.aether.impl.DefaultServiceLocator; -import org.eclipse.aether.repository.Authentication; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.transport.file.FileTransporterFactory; -import org.eclipse.aether.transport.http.HttpTransporterFactory; -import org.eclipse.aether.util.artifact.SubArtifact; -import org.eclipse.aether.util.repository.AuthenticationBuilder; @Slf4j public class DynamicJarsProvider { diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/expection/RequestExceptionHandler.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/expection/RequestExceptionHandler.java index 04a74f3..9a59830 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/expection/RequestExceptionHandler.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/expection/RequestExceptionHandler.java @@ -17,16 +17,13 @@ package org.apache.rocketmq.schema.registry.core.expection; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; - +import javax.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.exception.SchemaException; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import lombok.extern.slf4j.Slf4j; - @RestControllerAdvice @Slf4j public class RequestExceptionHandler { diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/package-info.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/package-info.java index cd10ac9..f52cae4 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/package-info.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/package-info.java @@ -1,26 +1,21 @@ /* - * Copyright 2017 Netflix, Inc. + * 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 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. - */ - -/** - * talos connector. - * - * @author wangfan8 - * @since 1.3.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. */ @ParametersAreNonnullByDefault package org.apache.rocketmq.schema.registry.core; -import javax.annotation.ParametersAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaService.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaService.java index 84c70cc..571f678 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaService.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaService.java @@ -18,12 +18,9 @@ package org.apache.rocketmq.schema.registry.core.service; import java.util.List; -import java.util.Optional; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.dto.BaseDto; -import org.apache.rocketmq.schema.registry.common.dto.SchemaDto; import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; -import org.apache.rocketmq.schema.registry.common.model.SchemaRecordInfo; public interface SchemaService<T extends BaseDto> { @@ -31,7 +28,7 @@ public interface SchemaService<T extends BaseDto> { * Register the given schema. * * @param qualifiedName tenant / name of the schema - * @param dto register resource information + * @param dto register resource information * @return registered schema object */ T register(QualifiedName qualifiedName, T dto); @@ -40,7 +37,7 @@ public interface SchemaService<T extends BaseDto> { * Register the schema. * * @param qualifiedName tenant / name of the schema - * @param dto update information + * @param dto update information * @return updated schema object */ T update(QualifiedName qualifiedName, T dto); diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaServiceImpl.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaServiceImpl.java index 9d368b9..3b291d1 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaServiceImpl.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/SchemaServiceImpl.java @@ -17,11 +17,10 @@ package org.apache.rocketmq.schema.registry.core.service; +import com.google.common.base.Strings; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; - -import com.google.common.base.Strings; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.auth.AccessControlService; @@ -195,6 +194,7 @@ public class SchemaServiceImpl implements SchemaService<SchemaDto> { } // TODO add get last record query + /** * {@inheritDoc} */ diff --git a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/Service.java b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/Service.java index 4e8227e..a9fc589 100644 --- a/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/Service.java +++ b/core/src/main/java/org/apache/rocketmq/schema/registry/core/service/Service.java @@ -21,5 +21,4 @@ import org.apache.rocketmq.schema.registry.common.dto.BaseDto; public interface Service<T extends BaseDto> { - } diff --git a/core/src/main/resources/application.properties b/core/src/main/resources/application.properties index 022e3dc..ff31443 100644 --- a/core/src/main/resources/application.properties +++ b/core/src/main/resources/application.properties @@ -1,29 +1,23 @@ - -spring.profiles.active = dev -spring.application.name = rocketmq-schema-registry +spring.profiles.active=dev +spring.application.name=rocketmq-schema-registry server.port=8080 -logging.file.name = log/app.log - -schema.dependency.upload-enabled = false +logging.file.name=log/app.log +schema.dependency.upload-enabled=false #schema.dependency.jdk-path #schema.dependency.compile-path #schema.dependency.local-repository-path #schema.dependency.repository-url #schema.dependency.username #schema.dependency.password -schema.storage.type = rocketmq -schema.storage.config-path = storage-rocketmq/src/main/resources/rocketmq.properties - -springfox.documentation.swagger-ui.enabled = true -management.health.db.enabled = true - -server.error.include-stacktrace = on_param -server.error.include-message = always - -spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER - -spring.main.allow-bean-definition-overriding = true -management.health.elasticsearch.enabled = false -management.endpoints.enabled-by-default = true -management.endpoints.web.exposure.include = health,info -management.endpoints.web.exposure.exclude = httptrace,shutdown \ No newline at end of file +schema.storage.type=rocketmq +schema.storage.config-path=storage-rocketmq/src/main/resources/rocketmq.properties +springfox.documentation.swagger-ui.enabled=true +management.health.db.enabled=true +server.error.include-stacktrace=on_param +server.error.include-message=always +spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER +spring.main.allow-bean-definition-overriding=true +management.health.elasticsearch.enabled=false +management.endpoints.enabled-by-default=true +management.endpoints.web.exposure.include=health,info +management.endpoints.web.exposure.exclude=httptrace,shutdown \ No newline at end of file diff --git a/core/src/main/resources/template.pom b/core/src/main/resources/template.pom index 2bef620..1216cfc 100644 --- a/core/src/main/resources/template.pom +++ b/core/src/main/resources/template.pom @@ -2,10 +2,10 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>$groupId</groupId> - <artifactId>$artifactId</artifactId> - <version>$version</version> - <description>schema service auto generated POM</description> + <modelVersion>4.0.0</modelVersion> + <groupId>$groupId</groupId> + <artifactId>$artifactId</artifactId> + <version>$version</version> + <description>schema service auto generated POM</description> </project> diff --git a/core/src/test/java/org/apache/rocketmq/schema/registry/core/CoreApplicationTests.java b/core/src/test/java/org/apache/rocketmq/schema/registry/core/CoreApplicationTests.java index a49fd05..cb2017f 100644 --- a/core/src/test/java/org/apache/rocketmq/schema/registry/core/CoreApplicationTests.java +++ b/core/src/test/java/org/apache/rocketmq/schema/registry/core/CoreApplicationTests.java @@ -6,6 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class CoreApplicationTests { - @Test - void contextLoads() {} + @Test + void contextLoads() { + } } diff --git a/core/src/test/java/org/apache/rocketmq/schema/registry/core/controller/HelloControllerTest.java b/core/src/test/java/org/apache/rocketmq/schema/registry/core/controller/HelloControllerTest.java index 4ed7622..9f4dea5 100644 --- a/core/src/test/java/org/apache/rocketmq/schema/registry/core/controller/HelloControllerTest.java +++ b/core/src/test/java/org/apache/rocketmq/schema/registry/core/controller/HelloControllerTest.java @@ -1,17 +1,10 @@ /** - * Copyright 2022, Xiaomi. - * All rights reserved. - * Author: [email protected] + * Copyright 2022, Xiaomi. All rights reserved. Author: [email protected] */ package org.apache.rocketmq.schema.registry.core.controller; -import static org.hamcrest.Matchers.equalTo; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.jupiter.api.Test; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -19,6 +12,10 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import static org.hamcrest.Matchers.equalTo; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @SpringBootTest @AutoConfigureMockMvc public class HelloControllerTest { @@ -28,7 +25,7 @@ public class HelloControllerTest { @Test public void getHello() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(equalTo("Greetings from Spring Boot!"))); + .andExpect(status().isOk()) + .andExpect(content().string(equalTo("Greetings from Spring Boot!"))); } } diff --git a/pom.xml b/pom.xml index f854f7d..9f38fb3 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,174 @@ <avro.version>1.11.0</avro.version> </properties> + <mailingLists> + <mailingList> + <name>Development List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + </mailingList> + <mailingList> + <name>User List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + </mailingList> + <mailingList> + <name>Commits List</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + </mailingList> + </mailingLists> + + + <organization> + <name>Apache Software Foundation</name> + <url>http://www.apache.org</url> + </organization> + + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + <comments>A business-friendly OSS license</comments> + </license> + </licenses> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.17</version> + <executions> + <execution> + <id>validate</id> + <phase>validate</phase> + <configuration> + <excludes>src/main/resources</excludes> + <configLocation>style/rmq_checkstyle.xml</configLocation> + <encoding>UTF-8</encoding> + <consoleOutput>true</consoleOutput> + <failsOnError>true</failsOnError> + </configuration> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.8.6</version> + <executions> + <execution> + <id>default-prepare-agent</id> + <goals> + <goal>prepare-agent</goal> + </goals> + <configuration> + <destFile>${project.build.directory}/jacoco.exec</destFile> + </configuration> + </execution> + <execution> + <id>default-prepare-agent-integration</id> + <phase>pre-integration-test</phase> + <goals> + <goal>prepare-agent-integration</goal> + </goals> + <configuration> + <destFile>${project.build.directory}/jacoco-it.exec</destFile> + <propertyName>failsafeArgLine</propertyName> + </configuration> + </execution> + <execution> + <id>default-report</id> + <goals> + <goal>report</goal> + </goals> + </execution> + <execution> + <id>default-report-integration</id> + <goals> + <goal>report-integration</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <skipAfterFailureCount>1</skipAfterFailureCount> + <forkCount>1</forkCount> + <reuseForks>true</reuseForks> + <excludes> + <exclude>**/IT*.java</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <version>3.0.4</version> + </plugin> + <plugin> + <groupId>org.sonarsource.scanner.maven</groupId> + <artifactId>sonar-maven-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <version>0.12</version> + <configuration> + <excludes> + <exclude>.gitignore</exclude> + <exclude>.travis.yml</exclude> + <exclude>CONTRIBUTING.md</exclude> + <exclude>**/README.md</exclude> + <exclude>**/README_zh_CN.md</exclude> + <exclude>.github/**</exclude> + <exclude>src/test/resources/certs/*</exclude> + <exclude>src/test/**/*.log</exclude> + <exclude>src/test/resources/META-INF/service/*</exclude> + <exclude>**/target/**</exclude> + <exclude>*/*.iml</exclude> + <exclude>**/application.properties</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <groupId>org.eluder.coveralls</groupId> + <artifactId>coveralls-maven-plugin</artifactId> + <version>4.3.0</version> + </plugin> + </plugins> + + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.0.0</version> + </plugin> + </plugins> + </pluginManagement> + </build> + + <profiles> + <profile> + <id>sonar-apache</id> + <properties> + <!-- URL of the ASF SonarQube server --> + <sonar.host.url>https://builds.apache.org/analysis</sonar.host.url> + </properties> + </profile> + </profiles> + <dependencies> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/storage-rocketmq/pom.xml b/storage-rocketmq/pom.xml index b933223..bd8601f 100644 --- a/storage-rocketmq/pom.xml +++ b/storage-rocketmq/pom.xml @@ -29,7 +29,7 @@ <artifactId>storage-rocketmq</artifactId> <name>rocketmq-schema-registry-storage-rocketmq-${project.version}</name> <packaging>jar</packaging> - + <properties> <rocketmq.client.version>5.0.0-ALPHA</rocketmq.client.version> </properties> @@ -54,17 +54,5 @@ </dependency> </dependencies> - <distributionManagement> - <repository> - <id>central</id> - <name>maven-release-virtual</name> - <url></url> - </repository> - <snapshotRepository> - <id>snapshots</id> - <name>maven-snapshot-virtual</name> - <url></url> - </snapshotRepository> - </distributionManagement> </project> \ No newline at end of file diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqClient.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqClient.java index f671a7b..8fa04aa 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqClient.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqClient.java @@ -28,7 +28,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; - import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer; diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClient.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClient.java index ecb3fb6..848258d 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClient.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClient.java @@ -18,7 +18,6 @@ package org.apache.rocketmq.schema.registry.storage.rocketmq; import java.util.List; - import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaRecordInfo; diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClientImpl.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClientImpl.java index 2b0987e..9d3cdba 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClientImpl.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageClientImpl.java @@ -23,9 +23,7 @@ import java.util.Map; import java.util.Properties; import java.util.function.Function; import java.util.stream.Collectors; - import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.schema.registry.common.QualifiedName; import org.apache.rocketmq.schema.registry.common.context.StoragePluginContext; import org.apache.rocketmq.schema.registry.common.json.JsonConverter; diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageService.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageService.java index ac0b2e9..f0c66f6 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageService.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/RocketmqStorageService.java @@ -18,13 +18,12 @@ package org.apache.rocketmq.schema.registry.storage.rocketmq; import java.util.List; - import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.schema.registry.common.QualifiedName; +import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; import org.apache.rocketmq.schema.registry.common.model.SchemaInfo; import org.apache.rocketmq.schema.registry.common.model.SchemaRecordInfo; import org.apache.rocketmq.schema.registry.common.storage.StorageService; -import org.apache.rocketmq.schema.registry.common.context.StorageServiceContext; @Slf4j public class RocketmqStorageService implements StorageService<SchemaInfo> { diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/RocketmqConfigConstants.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/RocketmqConfigConstants.java index 4ec11b2..0157e9c 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/RocketmqConfigConstants.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/RocketmqConfigConstants.java @@ -46,5 +46,4 @@ public class RocketmqConfigConstants { public static final String DELETE_KEYS = "%DEL%"; - } diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/ServiceConfig.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/ServiceConfig.java index b8905ea..de0aa90 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/ServiceConfig.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/configs/ServiceConfig.java @@ -29,7 +29,6 @@ public class ServiceConfig { * create rocketmq storage service. * * @param storageClient rocketmq storage Client - * * @return talos connector table Service */ @Bean diff --git a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/package-info.java b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/package-info.java index fcd541a..4803b83 100644 --- a/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/package-info.java +++ b/storage-rocketmq/src/main/java/org/apache/rocketmq/schema/registry/storage/rocketmq/package-info.java @@ -1,26 +1,21 @@ /* - * Copyright 2017 Netflix, Inc. + * 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 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. - */ - -/** - * talos connector. - * - * @author wangfan8 - * @since 1.3.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. */ @ParametersAreNonnullByDefault package org.apache.rocketmq.schema.registry.storage.rocketmq; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/storage-rocketmq/src/main/resources/rocketmq.properties b/storage-rocketmq/src/main/resources/rocketmq.properties index 5070713..01bbedd 100644 --- a/storage-rocketmq/src/main/resources/rocketmq.properties +++ b/storage-rocketmq/src/main/resources/rocketmq.properties @@ -14,6 +14,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # - storage.type=rocketmq #storage.local.cache.path \ No newline at end of file diff --git a/style/copyright/Apache.xml b/style/copyright/Apache.xml new file mode 100644 index 0000000..7ca71b5 --- /dev/null +++ b/style/copyright/Apache.xml @@ -0,0 +1,24 @@ +<!-- + 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. + --> + +<component name="CopyrightManager"> + <copyright> + <option name="myName" value="Apache"/> + <option name="notice" + value="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/lice [...] + </copyright> +</component> \ No newline at end of file diff --git a/style/copyright/profiles_settings.xml b/style/copyright/profiles_settings.xml new file mode 100644 index 0000000..d326b8c --- /dev/null +++ b/style/copyright/profiles_settings.xml @@ -0,0 +1,64 @@ +<!-- + 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. + --> + +<component name="CopyrightManager"> + <settings default="Apache"> + <module2copyright> + <element module="All" copyright="Apache"/> + </module2copyright> + <LanguageOptions name="GSP"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="HTML"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="JAVA"> + <option name="fileTypeOverride" value="3"/> + <option name="addBlankAfter" value="false"/> + </LanguageOptions> + <LanguageOptions name="JSP"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="JSPX"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="MXML"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="Properties"> + <option name="fileTypeOverride" value="3"/> + <option name="block" value="false"/> + </LanguageOptions> + <LanguageOptions name="SPI"> + <option name="fileTypeOverride" value="3"/> + <option name="block" value="false"/> + </LanguageOptions> + <LanguageOptions name="XML"> + <option name="fileTypeOverride" value="3"/> + <option name="prefixLines" value="false"/> + </LanguageOptions> + <LanguageOptions name="__TEMPLATE__"> + <option name="separateBefore" value="true"/> + <option name="lenBefore" value="1"/> + </LanguageOptions> + </settings> +</component> \ No newline at end of file diff --git a/style/rmq_checkstyle.xml b/style/rmq_checkstyle.xml new file mode 100644 index 0000000..52b3caf --- /dev/null +++ b/style/rmq_checkstyle.xml @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + --> + +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> +<!--Refer http://checkstyle.sourceforge.net/reports/google-java-style.html#s2.2-file-encoding --> +<module name="Checker"> + + <property name="localeLanguage" value="en"/> + + <!--To configure the check to report on the first instance in each file--> + <module name="FileTabCharacter"/> + + <!-- header --> + <module name="RegexpHeader"> + <property name="header" value="/\*\nLicensed to the Apache Software Foundation*"/> + <property name="fileExtensions" value="java"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="System\.out\.println"/> + <property name="message" value="Prohibit invoking System.out.println in source code !"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="//FIXME"/> + <property name="message" value="Recommended fix FIXME task !"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="//TODO"/> + <property name="message" value="Recommended fix TODO task !"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="@alibaba"/> + <property name="message" value="Recommended remove @alibaba keyword!"/> + </module> + <module name="RegexpSingleline"> + <property name="format" value="@taobao"/> + <property name="message" value="Recommended remove @taobao keyword!"/> + </module> + <module name="RegexpSingleline"> + <property name="format" value="@author"/> + <property name="message" value="Recommended remove @author tag in javadoc!"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" + value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/> + <property name="message" value="Not allow chinese character !"/> + </module> + + <module name="FileLength"> + <property name="max" value="3000"/> + </module> + + <module name="TreeWalker"> + + <module name="UnusedImports"> + <property name="processJavadoc" value="true"/> + </module> + <module name="RedundantImport"/> + + <!--<module name="IllegalImport" />--> + + <!--Checks that classes that override equals() also override hashCode()--> + <module name="EqualsHashCode"/> + <!--Checks for over-complicated boolean expressions. Currently finds code like if (topic == true), topic || true, !false, etc.--> + <module name="SimplifyBooleanExpression"/> + <module name="OneStatementPerLine"/> + <module name="UnnecessaryParentheses"/> + <!--Checks for over-complicated boolean return statements. For example the following code--> + <module name="SimplifyBooleanReturn"/> + + <!--Check that the default is after all the cases in producerGroup switch statement--> + <module name="DefaultComesLast"/> + <!--Detects empty statements (standalone ";" semicolon)--> + <module name="EmptyStatement"/> + <!--Checks that long constants are defined with an upper ell--> + <module name="UpperEll"/> + <module name="ConstantName"> + <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/> + </module> + <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property--> + <module name="LocalVariableName"/> + <!--Validates identifiers for local, final variables, including catch parameters--> + <module name="LocalFinalVariableName"/> + <!--Validates identifiers for non-static fields--> + <module name="MemberName"/> + <!--Validates identifiers for class type parameters--> + <module name="ClassTypeParameterName"> + <property name="format" value="^[A-Z0-9]*$"/> + </module> + <!--Validates identifiers for method type parameters--> + <module name="MethodTypeParameterName"> + <property name="format" value="^[A-Z0-9]*$"/> + </module> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> + <!--Checks that there are no import statements that use the * notation--> + <module name="AvoidStarImport"/> + + <!--whitespace--> + <module name="GenericWhitespace"/> + <module name="NoWhitespaceBefore"/> + <module name="NoWhitespaceAfter"/> + <module name="WhitespaceAround"> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyMethods" value="true"/> + </module> + <module name="Indentation"/> + <module name="MethodParamPad"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + </module> +</module> diff --git a/style/rmq_codeStyle.xml b/style/rmq_codeStyle.xml new file mode 100644 index 0000000..9db075e --- /dev/null +++ b/style/rmq_codeStyle.xml @@ -0,0 +1,157 @@ +<!-- + 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. + --> + +<code_scheme name="rocketmq"> + <option name="USE_SAME_INDENTS" value="true"/> + <option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true"/> + <option name="OTHER_INDENT_OPTIONS"> + <value> + <option name="INDENT_SIZE" value="4"/> + <option name="CONTINUATION_INDENT_SIZE" value="4"/> + <option name="TAB_SIZE" value="4"/> + <option name="USE_TAB_CHARACTER" value="false"/> + <option name="SMART_TABS" value="false"/> + <option name="LABEL_INDENT_SIZE" value="0"/> + <option name="LABEL_INDENT_ABSOLUTE" value="false"/> + <option name="USE_RELATIVE_INDENTS" value="false"/> + </value> + </option> + <option name="PREFER_LONGER_NAMES" value="false"/> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000"/> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000"/> + <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> + <value/> + </option> + <option name="IMPORT_LAYOUT_TABLE"> + <value> + <package name="" withSubpackages="true" static="false"/> + <emptyLine/> + <package name="" withSubpackages="true" static="true"/> + </value> + </option> + <option name="JD_ALIGN_PARAM_COMMENTS" value="false"/> + <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false"/> + <option name="JD_P_AT_EMPTY_LINES" value="false"/> + <option name="JD_KEEP_INVALID_TAGS" value="false"/> + <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true"/> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/> + <option name="ELSE_ON_NEW_LINE" value="true"/> + <option name="WHILE_ON_NEW_LINE" value="true"/> + <option name="CATCH_ON_NEW_LINE" value="true"/> + <option name="FINALLY_ON_NEW_LINE" value="true"/> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/> + <option name="ALIGN_MULTILINE_FOR" value="false"/> + <option name="SPACE_AFTER_TYPE_CAST" value="false"/> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true"/> + <option name="METHOD_PARAMETERS_WRAP" value="1"/> + <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true"/> + <option name="LABELED_STATEMENT_WRAP" value="1"/> + <option name="WRAP_COMMENTS" value="true"/> + <option name="METHOD_ANNOTATION_WRAP" value="1"/> + <option name="CLASS_ANNOTATION_WRAP" value="1"/> + <option name="FIELD_ANNOTATION_WRAP" value="1"/> + <JavaCodeStyleSettings> + <option name="CLASS_NAMES_IN_JAVADOC" value="3"/> + </JavaCodeStyleSettings> + <XML> + <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true"/> + </XML> + <ADDITIONAL_INDENT_OPTIONS fileType="haml"> + <option name="INDENT_SIZE" value="2"/> + </ADDITIONAL_INDENT_OPTIONS> + <codeStyleSettings language="Groovy"> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/> + <option name="ELSE_ON_NEW_LINE" value="true"/> + <option name="CATCH_ON_NEW_LINE" value="true"/> + <option name="FINALLY_ON_NEW_LINE" value="true"/> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/> + <option name="ALIGN_MULTILINE_FOR" value="false"/> + <option name="SPACE_AFTER_TYPE_CAST" value="false"/> + <option name="METHOD_PARAMETERS_WRAP" value="1"/> + <option name="METHOD_ANNOTATION_WRAP" value="1"/> + <option name="CLASS_ANNOTATION_WRAP" value="1"/> + <option name="FIELD_ANNOTATION_WRAP" value="1"/> + <option name="PARENT_SETTINGS_INSTALLED" value="true"/> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4"/> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="HOCON"> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/> + <option name="PARENT_SETTINGS_INSTALLED" value="true"/> + </codeStyleSettings> + <codeStyleSettings language="JAVA"> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/> + <option name="ELSE_ON_NEW_LINE" value="true"/> + <option name="WHILE_ON_NEW_LINE" value="true"/> + <option name="CATCH_ON_NEW_LINE" value="true"/> + <option name="FINALLY_ON_NEW_LINE" value="true"/> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/> + <option name="ALIGN_MULTILINE_FOR" value="false"/> + <option name="SPACE_AFTER_TYPE_CAST" value="false"/> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true"/> + <option name="METHOD_PARAMETERS_WRAP" value="1"/> + <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true"/> + <option name="LABELED_STATEMENT_WRAP" value="1"/> + <option name="METHOD_ANNOTATION_WRAP" value="1"/> + <option name="CLASS_ANNOTATION_WRAP" value="1"/> + <option name="FIELD_ANNOTATION_WRAP" value="1"/> + <option name="PARENT_SETTINGS_INSTALLED" value="true"/> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4"/> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="JSON"> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/> + <option name="PARENT_SETTINGS_INSTALLED" value="true"/> + </codeStyleSettings> + <codeStyleSettings language="Scala"> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/> + <option name="ELSE_ON_NEW_LINE" value="true"/> + <option name="WHILE_ON_NEW_LINE" value="true"/> + <option name="CATCH_ON_NEW_LINE" value="true"/> + <option name="FINALLY_ON_NEW_LINE" value="true"/> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/> + <option name="ALIGN_MULTILINE_FOR" value="false"/> + <option name="METHOD_PARAMETERS_WRAP" value="1"/> + <option name="METHOD_ANNOTATION_WRAP" value="1"/> + <option name="CLASS_ANNOTATION_WRAP" value="1"/> + <option name="FIELD_ANNOTATION_WRAP" value="1"/> + <option name="PARENT_SETTINGS_INSTALLED" value="true"/> + <indentOptions> + <option name="INDENT_SIZE" value="4"/> + <option name="CONTINUATION_INDENT_SIZE" value="4"/> + <option name="TAB_SIZE" value="4"/> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="XML"> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4"/> + </indentOptions> + </codeStyleSettings> +</code_scheme> \ No newline at end of file diff --git a/war/pom.xml b/war/pom.xml index cb7b4cb..9c1a261 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -54,5 +54,4 @@ </build> - </project> \ No newline at end of file
